[petsc-dev] DMSetUseNatural() and DMPlexConstructGhostCells()

Matthew Knepley knepley at gmail.com
Mon Jul 20 05:51:19 CDT 2015

On Sun, Jul 19, 2015 at 11:46 PM, Adrian Croucher <a.croucher at auckland.ac.nz
> wrote:

> hi
> I am testing out the new DMSetUseNatural(), DMPlexNaturalToGlobalBegin()
> etc. functions- along the lines of src/dm/impls/plex/examples/tests/ex15.c,
> but kinda the other way around.
> What I want to do is set initial conditions in vector on a distributed DM
> representing a finite volume mesh. If I just do this using VecSetValues()
> they all end up in the wrong places on the mesh- in the global order rather
> than the natural order, with results dependent on number of processors.
> So I'm trying:
> - calling DMSetUseNatural(dm, PETSC_TRUE) before distributing the DM
> - creating a separate 'natural' vector, and using VecSetValues() to set
> its values from the program input
> - using DMPlexNaturalToGlobalBegin() / DMPlexNaturalToGlobalEnd() to fill
> my 'global' vector from the natural one
> - viewing the final global vector with a VTK viewer to make sure the
> values are ending up in the right physical locations on the mesh.
> It is all working ok until I also put in a DMPlexConstructGhostCells()
> (just after distributing) to fill the 'ghost' label on the DM. If I do
> that, when it gets to the DMPlexNaturalToGlobalBegin() call, it errors out
> with the following:
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Object is in wrong state
> [0]PETSC ERROR: DM global to natural SF was not created.
> You must call DMPlexSetUseNaturalSF() before DMPlexDistribute().
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [0]PETSC ERROR: Petsc Development GIT revision: v3.6-512-g8d76ee9  GIT
> Date: 2015-07-19 12:15:50 -0400
> [0]PETSC ERROR: supermodel on a linux-gnu-c-opt named des108 by acro018
> Mon Jul 20 16:32:22 2015
> [0]PETSC ERROR: Configure options --download-netcdf --download-exodusii
> --with-hdf5-dir=/usr --download-triangle --download-ptscotch
> --download-chaco --download-ctetgen
> [0]PETSC ERROR: #1 DMPlexNaturalToGlobalBegin() line 203 in
> /home/acro018/software/PETSc/code/src/dm/impls/plex/plexnatural.c
> --------------------------------------------------------------------------
> So it thinks I haven't called DMSetUseNatural(), but I have. (There is
> also a typo in the error message- it's saying I should call
> 'DMPlexSetUseNaturalSF()', but I think it means DMSetUseNatural()).
> It looks a bit like DMPlexConstructGhostCells() might be messing with the
> DM's sfNatural property? or does this not work the way I think it should?

Thats a bug. CreateGhostCells() makes an entirely new DM, and the
SetNatural is a piece of state which did not get carried over. I will
fix it.

I have a question about this strategy. The design philosophy for the PETSc
discretization stuff is to make as much
mesh-independent as possible. I usually think of boundary and initial
conditions as analytic functions that are
applied to a given geometric region on the mesh, and then projected into a
function space once I choose my
discretization. Why doesn't that work in this case?



> - Adrian
> --
> Dr Adrian Croucher
> Senior Research Fellow
> Department of Engineering Science
> University of Auckland, New Zealand
> email: a.croucher at auckland.ac.nz
> tel: +64 (0)9 923 84611

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-dev/attachments/20150720/f00af39c/attachment.html>

More information about the petsc-dev mailing list