core
core copied to clipboard
Access faces of a cell: to then get vertices of the face
Hi,
In 3D I’ve managed to write loops that give me: 1)Vertices of an edge 2)Vertices of a face
I can’t work out how to get faces of a cell. I need that to subsequently then use 2) to get the vertices of the face. This should give me the vertices of the cell.
Secondly, I’d like to be able to also request the vertices of the cell directly rather than via the vertices of the cell-faces.
I’d really appreciated learning the various ways to do this so I can navigate the mesh. Any help appreciated. Cheers Andy
Are you using the pumi
or apf
interface?
Hi Andy,
Take a look at the PUMI user's guide (https://scorec.rpi.edu/~seol/PUMI.pdf) example on page 77. Specifically, this API call:
pumi_ment_getAdj(e, mesh_dim-1, adj_ents);
I’m using the apf interface at the moment. I’ve used that API so far for the loops I’ve got working.
Whoops. OK. I thought this was related to the code with ghosting.
Using the apf APIs, the necessary call is here:
https://github.com/SCOREC/core/blob/b384d6cef49cda83b8176d2ba860e3a8923ff572/apf/apfMesh.h#L184-L193
edit: getDownward(...)
should be used, not getAdjacent(...)
Ok brill thanks I’ll give that a go. Currently working on CGNS reader so all apf at the moment.
I know the following is a bit contrived but just so I'm understanding things correctly, in 3D are the following both identical in terms of accessing the vertices of a cell?
{
apf::MeshIterator *cellIter = m->begin(3);
apf::MeshEntity *cell = nullptr;
apf::Downward verts;
cellIter = m->begin(3);
while ((cell = m->iterate(cellIter)))
{
const auto numVerts = m->getDownward(cell, 0, verts);
for (int i = 0; i < numVerts; i++)
{
}
}
}
and:
{
apf::MeshIterator *cellIter = m->begin(3);
apf::MeshEntity *cell = nullptr;
apf::Downward faces;
apf::Downward edges;
apf::Downward verts;
cellIter = m->begin(3);
while ((cell = m->iterate(cellIter)))
{
const auto numFaces = m->getDownward(cell, 2, faces);
for (int f = 0; f < numFaces; f++)
{
const auto numEdges = m->getDownward(faces[f], 1, edges);
for (int e = 0; e < numEdges; e++)
{
const auto numVerts = m->getDownward(edges[e], 0, verts);
for (int i = 0; i < numVerts; i++)
{
}
}
}
}
}
Thanks, Andy
The number of operations will be identical since pumi/apf is storing a one-level adjacency structure (section 2.4 of https://www.scorec.rpi.edu/REPORTS/2015-4.pdf). The iteration order of vertices should also be the same.