core icon indicating copy to clipboard operation
core copied to clipboard

Access faces of a cell: to then get vertices of the face

Open a-jp opened this issue 4 years ago • 7 comments

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

a-jp avatar Oct 16 '19 19:10 a-jp

Are you using the pumi or apf interface?

jacobmerson avatar Oct 16 '19 20:10 jacobmerson

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);

cwsmith avatar Oct 16 '19 20:10 cwsmith

I’m using the apf interface at the moment. I’ve used that API so far for the loops I’ve got working.

a-jp avatar Oct 16 '19 20:10 a-jp

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(...)

cwsmith avatar Oct 16 '19 20:10 cwsmith

Ok brill thanks I’ll give that a go. Currently working on CGNS reader so all apf at the moment.

a-jp avatar Oct 16 '19 20:10 a-jp

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

a-jp avatar Oct 17 '19 10:10 a-jp

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.

cwsmith avatar Oct 17 '19 11:10 cwsmith