Loic Gouarin <[email protected]> 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.

Attachment: signature.asc
Description: PGP signature

Reply via email to