The most important example where mesh connectivity is needed is the
nearest-projection mapping, where the mesh we project into needs mesh connectivity. For a consistent mapping, this is the mesh from which you map. For a conservative mapping, the mesh to which you map. More information is given on the mapping configuration page.
In 2D, mesh connectivity simply means to define edges between vertices. In 3D, you need to define triangles and / or quads. Both, we can either build up from edges or directly from vertices.
int setMeshEdge (int meshID, int firstVertexID, int secondVertexID); void setMeshTriangle (int meshID, int firstEdgeID, int secondEdgeID, int thirdEdgeID); void setMeshTriangleWithEdges (int meshID, int firstVertexID, int secondVertexID, int thirdVertexID); void setMeshQuad(int meshID, int firstEdgeID, int secondEdgeID, int thirdEdgeID, int fourthEdgeID); void setMeshQuadWithEdges(int meshID, int firstVertexID, int secondVertexID, int thirdVertexID, int fourthVertexID);
setMeshEdgedefines a mesh edge between two vertices and returns an edge ID.
setMeshTriangledefines a mesh triangle by three edges.
setMeshTriangleWithEdgesdefines a mesh triangle by three vertices and also creates the edges in preCICE on the fly. Of course, preCICE takes care that no edge is defined twice. Please note that this function is computationally more expensive than
setMeshQuaddefines a mesh quad by four edges.
setMeshQuadWithEdgesdefines a mesh quad by four vertices and also creates the edges in preCICE on the fly. Again, preCICE takes care that no edge is defined twice. This function is computationally more expensive than
If you do not configure any features in the preCICE configuration that require mesh connectivity, all these API functions are no-ops. Thus, don’t worry about performance. If you need a significant workload to already create this connectivity information in your adapter in the first place, you can also explicitly ask preCICE whether it is required:
bool isMeshConnectivityRequired(int meshID);
isMeshConnectivityRequiredis only supported since v2.3.
Maybe interesting to know: preCICE actually does internally not compute with quads, but creates two triangles. Read more.
The following code shows how mesh connectivity can be defined in our example. For sake of simplification, let’s only define one triangle and let’s assume that it consists of the first three vertices.
[...] int* vertexIDs = new int[vertexSize]; precice.setMeshVertices(meshID, vertexSize, coords, vertexIDs); delete coords; int edgeIDs; edgeIDs = precice.setMeshEdge(meshID, vertexIDs, vertexIDs); edgeIDs = precice.setMeshEdge(meshID, vertexIDs, vertexIDs); edgeIDs = precice.setMeshEdge(meshID, vertexIDs, vertexIDs); if(dim==3) precice.setMeshTriangle(meshID, edgeIDs, edgeIDs, edgeIDs); [...]