On Sat, Jul 25, 2020 at 4:10 AM Swarnava Ghosh <swarnav...@gmail.com> wrote:
> Dear Petsc users, > > I had a trivial question about DMPlex. Suppose I have a 3D mesh of > tetrahedrons. I want to find out the 3D coordinates of the vertices of a > particular cell. What would be the function to do this? > Lots of good responses. You can see that it is taking some time for canonical patterns to emerge as the "right way" to do something. The reason we provide multiple layers of interface is that user codes rely on different abstractions and would like to interact with PETSc using different assumptions. If you just want the coordinates of each vertex in some cell with the vertices in a canonical ordering, you can do as Mark suggested, with a slight modification: DM plex, cdm; Vec coordinates; ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr); ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr); ierr = DMConvert(cdm, DMPLEX, &plex);CHKERRQ(ierr); ierr = DMPlexVecGetClosure(plex, NULL, coordinates, cell, NULL, &coef);CHKERRQ(ierr); .... ierr = DMPlexVecRestoreClosure(plex, NULL, coordinates, cell, NULL, &coef);CHKERRQ(ierr); We get a local coordinate vector, because local vectors are guaranteed to store everything in the closure of anything in the Plex. Global vectors are non-overlapping partitions, suitable for solvers, and might not have some of the values. Thanks, Matt > Thank you, > SG > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>