void DriftRatchet:: specializedCreate ( mesh::Mesh& seed ) { using namespace mesh; std::string nameSubID ( seed.getName() + "-side-" ); PropertyContainer* leftWall = NULL; PropertyContainer* rightWall = NULL; if ( seed.getNameIDPairs().count(nameSubID + "0") ) { leftWall = & seed.getPropertyContainer ( nameSubID + "0" ); } if ( seed.getNameIDPairs().count(nameSubID + "1") ) { rightWall = & seed.getPropertyContainer ( nameSubID + "1" ); } int count = getNumberOfVerticesPerCut ( _discretizationWidth ); mesh::Vertex** cutVertices = new mesh::Vertex* [count]; count = getOffset().size() == 3 ? count : 0; // Only used in 3D mesh::Edge ** cutEdges = new mesh::Edge * [count]; createLeftWall ( seed, leftWall, cutVertices, cutEdges ); createBodyWall ( seed, NULL, cutVertices, cutEdges ); createRightWall ( seed, rightWall, cutVertices, cutEdges ); delete[] cutVertices; delete[] cutEdges; }
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 (); }