[petsc-users] Using same DMPlex for solving two different problems

Abhyankar, Shrirang G. abhyshr at anl.gov
Thu Apr 6 13:04:54 CDT 2017


I am solving a time-dependent problem using DMNetwork (uses DMPlex
internally) to manage the network. To find the initial conditions, I need
to solve a nonlinear problem on the same network but with different number
of dofs on the nodes and edges.

Question: Can I reuse the same DMNetwork (DMPlex) for solving the two
problems. The way I am trying to approach this currently is by creating
two PetscSections to be used with Plex. The first one is used for the
initial conditions and the second one is for the time-stepping. Here¹s the
code I have

  for(i=vStart; i < vEnd; i++) {
    /* Two variables at each vertex for the initial condition problem */
    ierr = PetscSectionSetDof(dyn->initpflowpsection,i,2);CHKERRQ(ierr);
  }
  ierr = PetscSectionSetUp(dyn->initpflowpsection);CHKERRQ(ierr);

  /* Get the plex dm */
  ierr = DMNetworkGetPlex(networkdm,&plexdm);CHKERRQ(ierr);

  /* Get default sections associated with this plex set for time-stepping
*/
  ierr = DMGetDefaultSection(plexdm,&dyn->defaultsection);CHKERRQ(ierr);
ierr = 
DMGetDefaultGlobalSection(plexdm,&dyn->defaultglobalsection);CHKERRQ(ierr);

/* Increase the reference count so that the section does not get destroyed
when a new one is set with DMSetDefaultSection */
ierr = 
PetscObjectReference((PetscObject)dyn->defaultsection);CHKERRQ(ierr);
ierr = 
PetscObjectReference((PetscObject)dyn->defaultglobalsection);CHKERRQ(ierr);


  /* Set the new section created for initial conditions */
  ierr = DMSetDefaultSection(plexdm,dyn->initpflowpsection);CHKERRQ(ierr);
  ierr = 
DMGetDefaultGlobalSection(plexdm,&dyn->initpflowpglobsection);CHKERRQ(ierr)
;



Would this work or should I rather use DMPlexCreateSection to create the
PetscSection used for initial conditions (dyn->initpflowpsection)? Any
other problems that I should be aware of? Has anyone else attempted using
the same plex for solving two different problems?

Thanks,
Shri




More information about the petsc-users mailing list