[petsc-users] DMDA set dof

Jed Brown jed at jedbrown.org
Wed Nov 2 07:28:13 CDT 2016


Loic Gouarin <loic.gouarin at math.u-psud.fr> writes:

> Hi,
>
> I try to run this code
>
> #include <petsc.h>
>
> int main(int argc, char **argv)
> {
>      PetscErrorCode ierr;
>      DM DApressure, DAvel;
>
>      ierr = PetscInitialize(&argc, &argv,  (char *)0, (char 
> *)0);CHKERRQ(ierr);
>
>      ierr = DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, 
> DM_BOUNDARY_NONE, DMDA_STENCIL_BOX,
>                          5, 5, PETSC_DECIDE, PETSC_DECIDE,
>                          1, 1, 0, 0, &DApressure);CHKERRQ(ierr);
>
>      ierr = DMRefine(DApressure, PETSC_COMM_WORLD, &DAvel);
>      ierr = DMSetFromOptions(DAvel);CHKERRQ(ierr);
>      ierr = DMSetUp(DAvel);CHKERRQ(ierr);
>      ierr = DMDASetDof(DAvel, 2);CHKERRQ(ierr);

  "This function must be called before DMSetUp()"

>      ierr = PetscFinalize();CHKERRQ(ierr);
>
>      return 0;
> }
>
> and I get the error that DAvel is in wrong state whereas I call SetUp as 
> mentioned in the error message. It seems that it is not possible to 
> redefine the dof number if it is already set. Could you confirm ?

Correct.  Create a new DM.

When asking questions, *always* send the entire error message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161102/383bbac2/attachment-0001.pgp>


More information about the petsc-users mailing list