Re: [petsc-dev] No LocalToGlobalMapping in DMPlex
On Fri, Oct 5, 2018 at 2:58 PM Tristan Konolige < [email protected]> wrote:
Hello PETSc Developers,
I’d like to get an ISLocalToGlobalMapping from a DMPlex. But, currently, DMGetLocalToGlobalMapping returns an empty ISLocalToGlobalMapping. I can see that ISLocalToGlobalMappings are created in DMPlexDistribute, but they are never assigned to the DM. Is DMGetLocalToGlobalMapping supported with DMPlex or is this a bug?
LocalToGlobal mappings are only meaningful for function spaces, not topology. DMPlex itself only deals with topology. You have to give it a PetscSection if you want to say something about the function space, using DMSetSection(). DMDA only has one function space (values at vertices), so it just uses this by default, and GetLocalToGlobal() works automatically. Thanks, Matt
I’ve included a simple example below.
``` #include <petsc.h>
int main(int argc, char** argv) { PetscErrorCode ierr; PetscInt size; ISLocalToGlobalMapping l2g; DM dm, dm_dist; PetscInt num_points[2] = {2, 2}; PetscInt cone_size[4] = {1, 1, 0, 0}; PetscInt cones[2] = {2,3}; PetscInt orientations[2] = {0, 0}; PetscInt local_points[2] = {0, 1}; PetscInt global_points[2];
PetscInitialize(&argc, &argv, NULL, NULL);
DMPlexCreate(PETSC_COMM_WORLD, &dm); DMPlexCreateFromDAG(dm, 1, num_points, cone_size, cones, orientations, NULL); DMPlexDistribute(dm, 0, NULL, &dm_dist);
DMGetLocalToGlobalMapping(dm_dist, &l2g); ISLocalToGlobalMappingApply(l2g, 2, local_points, global_points);
PetscFinalize(); } ```
Thank you, Tristan Konolige
-- 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/>
participants (1)
-
Matthew Knepley