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

Matthew Knepley knepley at gmail.com
Fri Apr 7 06:25:25 CDT 2017


On Thu, Apr 6, 2017 at 1:04 PM, Abhyankar, Shrirang G. <abhyshr at anl.gov>
wrote:

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

This is the right way to do it, but its easier if you call DMClone() first
to get a new
DM with the same Plex, and then change its default Section and solve your
problem
with it.

  Matt


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


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170407/293a0a4c/attachment.html>


More information about the petsc-users mailing list