[petsc-users] how to get the vertices belongs to a control volume in 2D?
Lawrence Mitchell
lawrence.mitchell at imperial.ac.uk
Fri May 12 03:48:37 CDT 2017
> On 12 May 2017, at 04:57, 李季 <leejearl at 126.com> wrote:
>
> Hi developers:
> I have such a question that I want to get the vertices of a cell. I know I can get the points by
> 1. Getting the faces of a cell such as "DMPlexGetCone(dm, c, &faces";
> 2. Getting the vertices of every face of the cell such as "DMPlexGetCone(dm, f, &vertices)".
>
> Then I can obtain the vertices belongs to a cell. Is there any concise routine which I can choose to get the
> vertices of a cell directly?
You should use the interface for the transitive closure.
Find bounds of points that are vertices:
DMPlexGetDepthStratum(dm, &vStart, &vEnd);
...
DMPlexGetTransitiveClosure(dm, c, PETSC_TRUE, &nclosure, &closure);
for (PetscInt i = 0; i < nclosure; i++) {
const PetscInt p = closure[2*i];
if (p >= vStart && p < vEnd) {
p is a vertex
}
}
This works regardless of the topological dimension of the "cell" point you are using (the same code is good to find the vertices in the closure of a facet, say).
Matt's course notes (http://www.caam.rice.edu/~caam519/CSBook.pdf) have nice pictures that help understand this language in section 7.1.
Cheers,
Lawrence
More information about the petsc-users
mailing list