Пример #1
0
void ImportSTL:: doImport
(
    const std::string& name,
    mesh::Mesh&        mesh )
{
    preciceTrace1("doImport()", name);
    assertion1(mesh.getDimensions() == 3, mesh.getDimensions());
    // TODO
}
Пример #2
0
void DriftRatchet:: createBodyWall
(
   mesh::Mesh&              mesh,
   mesh::PropertyContainer* propertyContainer,
   mesh::Vertex*            cutVertices[],
   mesh::Edge*              cutEdges[] )
{
   int sectionCount = getCutsAlongXAxis ( _discretizationWidth );
   double currentXInImage = 0.0;
   double currentXInPreImage = 0.0;
   double xStepInImage = _length / (double)sectionCount;
   double xStepInPreImage = (_pores * getCharacteristicLength(_maxRadius)) / (double)sectionCount;
   int dimensions = mesh.getDimensions();
   utils::DynVector currentCenter ( dimensions, 0.0 );
   currentXInImage    += xStepInImage;
   currentXInPreImage += xStepInPreImage;
   for ( int i=0; i < sectionCount; i++ ) {
      currentCenter(0) = currentXInImage;
      double radius = getRadius ( currentXInPreImage );
      createBodyWallSection ( mesh, propertyContainer, cutVertices, cutEdges,
                              currentCenter, radius );
      currentXInImage    += xStepInImage;
      currentXInPreImage += xStepInPreImage;
   }
}
Пример #3
0
void DriftRatchet:: createRightWall
(
  mesh::Mesh&              mesh,
  mesh::PropertyContainer* propertyContainer,
  mesh::Vertex*            cutVertices[],
  mesh::Edge*              cutEdges[]  )
{
  int dimensions = mesh.getDimensions();
  if ( dimensions == 2 ){
    utils::Vector2D center ( 0.0 );
    center(0) += _length;
    mesh::Vertex& centerVertex = mesh.createVertex ( center );
    if ( propertyContainer != NULL ) {
      centerVertex.addParent ( *propertyContainer );
    }
    mesh::Edge& e0 = mesh.createEdge ( centerVertex, *cutVertices[0] );
    mesh::Edge& e1 = mesh.createEdge ( *cutVertices[1], centerVertex );
    if ( propertyContainer != NULL ) {
      e0.addParent ( *propertyContainer );
      e1.addParent ( *propertyContainer );
    }
  }
  else {
    assertion1 ( dimensions == 3, dimensions );
    utils::Vector3D center ( 0.0 );
    center(0) += _length;
    mesh::Vertex& centerVertex = mesh.createVertex ( center );
    if ( propertyContainer != NULL ) {
      centerVertex.addParent ( *propertyContainer );
    }
    int vertexCount = getNumberOfVerticesPerCut ( _discretizationWidth );

    // Create edges and triangles
    mesh::Edge& firstCenterEdge = mesh.createEdge ( centerVertex, *cutVertices[0] );
    if ( propertyContainer != NULL ) {
      firstCenterEdge.addParent ( *propertyContainer );
    }
    mesh::Edge* oldCenterEdge = & firstCenterEdge;
    mesh::Edge* newCenterEdge = NULL;
    for ( int i=0; i < vertexCount - 1; i++ ) {
      newCenterEdge = & mesh.createEdge ( centerVertex, *cutVertices[i+1] );
      mesh::Triangle& t = mesh.createTriangle (
          *cutEdges[i], *oldCenterEdge, *newCenterEdge );
      if ( propertyContainer != NULL ) {
        newCenterEdge->addParent ( *propertyContainer );
        t.addParent ( *propertyContainer );
      }
      oldCenterEdge = newCenterEdge;
    }
    mesh::Triangle& t = mesh.createTriangle ( *cutEdges[vertexCount-1],
                                              *oldCenterEdge, firstCenterEdge );
    if ( propertyContainer != NULL ) {
      t.addParent ( *propertyContainer );
    }
  }
}
Пример #4
0
void CommunicateMesh:: receiveMesh
(
  mesh::Mesh& mesh,
  int         rankSender )
{
  preciceTrace2 ( "receiveMesh()", mesh.getName(), rankSender );
  using tarch::la::raw;
  int dim = mesh.getDimensions();
  std::map<int, mesh::Vertex*> vertexMap;
  int vertexCount;
  _communication->startReceivePackage ( rankSender );
  _communication->receive ( vertexCount, rankSender);
  utils::DynVector coords(dim);
  for ( int i=0; i < vertexCount; i++ ){
    _communication->receive ( raw(coords), dim, rankSender );
    mesh::Vertex& v = mesh.createVertex ( coords );
    assertion1 ( v.getID() >= 0, v.getID() );
    vertexMap[v.getID()] = &v;
  }
  std::map<int,mesh::Edge*> edgeMap; // only used in 3D
  int edgeCount;
  _communication->receive ( edgeCount, rankSender );
  for ( int i=0; i < edgeCount; i++ ){
    int vertexIndex1 = -1;
    int vertexIndex2 = -1;
    _communication->receive ( vertexIndex1, rankSender );
    _communication->receive ( vertexIndex2, rankSender );

    assertion ( vertexMap.find(vertexIndex1) != vertexMap.end() );
    assertion ( vertexMap.find(vertexIndex2) != vertexMap.end() );
    assertion1 ( vertexIndex1 != vertexIndex2, vertexIndex1 );

    if ( dim == 2 ){
      mesh.createEdge ( *vertexMap[vertexIndex1], *vertexMap[vertexIndex2] );
    }
    else {
      assertion1 ( dim == 3, dim );
      mesh::Edge & e = mesh.createEdge (
          *vertexMap[vertexIndex1], *vertexMap[vertexIndex2] );
      assertion1 ( e.getID() >= 0, e.getID() );
      edgeMap[e.getID()] = &e;
    }
  }
  if ( dim == 3 ){
    int triangleCount = 0;
    assertion ( (edgeMap.size() > 0) || (triangleCount == 0) );
    _communication->receive ( triangleCount, rankSender );
    for ( int i=0; i < triangleCount; i++ ) {
      int index1 = -1;
      int index2 = -1;
      int index3 = -1;
      _communication->receive ( index1, rankSender );
      _communication->receive ( index2, rankSender );
      _communication->receive ( index3, rankSender );

      assertion ( edgeMap.find(index1) != edgeMap.end() );
      assertion ( edgeMap.find(index2) != edgeMap.end() );
      assertion ( edgeMap.find(index3) != edgeMap.end() );
      assertion ( index1 != index2 );
      assertion ( index2 != index3 );
      assertion ( index3 != index1 );

      mesh.createTriangle ( *edgeMap[index1], *edgeMap[index2], *edgeMap[index3] );
    }
  }
  _communication->finishReceivePackage ();
}
Пример #5
0
void DriftRatchet:: createBodyWallSection
(
   mesh::Mesh&              mesh,
   mesh::PropertyContainer* propertyContainer,
   mesh::Vertex*            cutVertices[],
   mesh::Edge*              cutEdges[],
   const utils::DynVector&  center,
   double                   radius )
{
  int dimensions = mesh.getDimensions();
  if ( dimensions == 2 ){
    utils::Vector2D upperPoint ( center[0], center[1] + radius );
    utils::Vector2D lowerPoint ( center[0], center[1] - radius );
    mesh::Vertex& upperVertex = mesh.createVertex ( upperPoint );
    mesh::Vertex& lowerVertex = mesh.createVertex ( lowerPoint );
    mesh::Edge& e0 = mesh.createEdge ( upperVertex, *cutVertices[0] );
    mesh::Edge& e1 = mesh.createEdge ( *cutVertices[1], lowerVertex );
    cutVertices[0] = & upperVertex;
    cutVertices[1] = & lowerVertex;
    if ( propertyContainer != NULL ) {
      e0.addParent ( *propertyContainer );
      e1.addParent ( *propertyContainer );
      cutVertices[0]->addParent ( *propertyContainer );
      cutVertices[1]->addParent ( *propertyContainer );
    }
  }
  else {
    assertion1 ( dimensions == 3, dimensions );
    double currentAngle = 0.0;
    int vertexCount = getNumberOfVerticesPerCut ( _discretizationWidth );
    double angle = 2.0 * tarch::la::PI / static_cast<double>(vertexCount);

    // Create vertices
    mesh::Vertex ** newCutVertices = new mesh::Vertex * [vertexCount];
    for ( int i=0; i < vertexCount; i++ ) {
      utils::Vector3D currentCenter ( center );
      double y = std::cos(currentAngle) * radius;
      currentCenter(1) += y;
      double z = std::sin(currentAngle) * radius;
      currentCenter(2) += z;
      currentAngle += angle;
      newCutVertices[i] = & mesh.createVertex ( currentCenter );
      if ( propertyContainer != NULL ) {
        newCutVertices[i]->addParent ( *propertyContainer );
      }
    }

    // Create edges and triangles
    mesh::Edge** newCutEdges = new mesh::Edge * [vertexCount];
    mesh::Edge* initialEdge = & mesh.createEdge ( *cutVertices[0],
                                                  *newCutVertices[0] );
    if ( propertyContainer != NULL ) {
      initialEdge->addParent ( *propertyContainer );
    }
    mesh::Edge* firstEdge = initialEdge;
    mesh::Edge* crossingEdge = NULL;
    mesh::Edge* secondEdge = NULL;
    for ( int i=0; i < vertexCount - 1; i++ ) {
      crossingEdge = & mesh.createEdge ( *cutVertices[i],
                                         *newCutVertices[i+1] );
      newCutEdges[i] = & mesh.createEdge ( *newCutVertices[i],
                                           *newCutVertices[i+1] );
      secondEdge = & mesh.createEdge ( *cutVertices[i+1],
                                       *newCutVertices[i+1] );
      mesh::Triangle& t0 = mesh.createTriangle ( *firstEdge, *newCutEdges[i], *crossingEdge );
      mesh::Triangle& t1 = mesh.createTriangle ( *crossingEdge, *secondEdge, *cutEdges[i] );
      if ( propertyContainer != NULL ) {
        t0.addParent ( *propertyContainer );
        t1.addParent ( *propertyContainer );
        crossingEdge->addParent ( *propertyContainer );
        secondEdge->addParent ( *propertyContainer );
      }
      firstEdge = secondEdge;
    }
    crossingEdge = & mesh.createEdge ( *cutVertices[vertexCount - 1],
                                       *newCutVertices[0] );
    newCutEdges[vertexCount - 1] =
      & mesh.createEdge ( *newCutVertices[vertexCount - 1], *newCutVertices[0] );
    secondEdge = initialEdge;
    mesh::Triangle & t0 =
      mesh.createTriangle ( *firstEdge, *newCutEdges[vertexCount -1], *crossingEdge );
    mesh::Triangle & t1 =
      mesh.createTriangle ( *crossingEdge, *secondEdge, *cutEdges[vertexCount - 1] );
    if ( propertyContainer != NULL ) {
      crossingEdge->addParent ( *propertyContainer );
      newCutEdges[vertexCount - 1]->addParent ( *propertyContainer );
      t0.addParent ( *propertyContainer );
      t1.addParent ( *propertyContainer );
    }

    // Transfer cutting vertices and edges
    for ( int i=0; i < vertexCount; i++ ) {
      cutVertices[i] = newCutVertices[i];
      cutEdges[i] = newCutEdges[i];
    }
    delete[] newCutVertices;
    delete[] newCutEdges;
  }
}
Пример #6
0
void DriftRatchet:: createLeftWall
(
  mesh::Mesh&              mesh,
  mesh::PropertyContainer* propertyContainer,
  mesh::Vertex*            cutVertices[],
  mesh::Edge*              cutEdges[]  )
{
  int dimensions = mesh.getDimensions();
  if ( dimensions == 2 ){
    using utils::Vector2D;
    double radius = getRadius ( 0.0 );
    Vector2D center ( 0.0 );
    mesh::Vertex& centerVertex = mesh.createVertex ( center );
    if ( propertyContainer != NULL ) {
       centerVertex.addParent ( *propertyContainer );
    }
    Vector2D upperPoint ( center(0), center(1) + radius );
    cutVertices[0] = & mesh.createVertex ( upperPoint );
    Vector2D lowerPoint ( center(0), center(1) - radius);
    cutVertices[1] = & mesh.createVertex ( lowerPoint );
    mesh::Edge& e0 = mesh.createEdge ( *cutVertices[0], centerVertex);
    mesh::Edge& e1 = mesh.createEdge ( centerVertex, *cutVertices[1] );
    if ( propertyContainer != NULL ) {
      e0.addParent ( *propertyContainer );
      e1.addParent ( *propertyContainer );
    }
  }
  else {
    assertion1 ( dimensions == 3, dimensions );
    using utils::Vector3D;
    double currentAngle = 0.0;
    int vertexCount = getNumberOfVerticesPerCut ( _discretizationWidth );
    double angle = 2.0 * tarch::la::PI / static_cast<double>(vertexCount);
    double radius = getRadius ( 0.0 );
    Vector3D center(0.0);
    mesh::Vertex& centerVertex = mesh.createVertex ( center );
    if ( propertyContainer != NULL ) {
       centerVertex.addParent ( *propertyContainer );
    }

    // Create vertices
    for ( int i=0; i < vertexCount; i++ ) {
      Vector3D currentPoint ( center );
      double y = std::cos(currentAngle) * radius;
      currentPoint(1) += y;
      double z = std::sin(currentAngle) * radius;
      currentPoint(2) += z;
      currentAngle += angle;
      cutVertices[i] = & mesh.createVertex ( currentPoint );
      if ( propertyContainer != NULL ) {
        cutVertices[i]->addParent ( *propertyContainer );
      }
    }

    // Create edges and triangles
    mesh::Edge & firstCenterEdge = mesh.createEdge ( centerVertex,
                                                     *cutVertices[0] );
    mesh::Edge * oldCenterEdge = & firstCenterEdge;
    mesh::Edge * newCenterEdge = NULL;
    for ( int i=0; i < vertexCount - 1; i++ ) {
      newCenterEdge = & mesh.createEdge ( centerVertex, *cutVertices[i+1] );
      cutEdges[i] = & mesh.createEdge ( *cutVertices[i], *cutVertices[i+1] );
      mesh::Triangle & t = mesh.createTriangle ( *oldCenterEdge, *cutEdges[i], *newCenterEdge );
      if ( propertyContainer != NULL ) {
        cutEdges[i]->addParent ( *propertyContainer );
        oldCenterEdge->addParent ( *propertyContainer );
        t.addParent ( *propertyContainer );
      }
      oldCenterEdge = newCenterEdge;
    }
    cutEdges[vertexCount-1] = & mesh.createEdge ( *cutVertices[vertexCount-1],
                                                  *cutVertices[0] );
    mesh::Triangle & t = mesh.createTriangle (
      *oldCenterEdge, *cutEdges[vertexCount-1], firstCenterEdge );
    if ( propertyContainer != NULL ) {
      cutEdges[vertexCount-1]->addParent ( *propertyContainer );
      t.addParent ( *propertyContainer );
    }
  }
}