static char help[] = "Tests DMDAGlobalToNaturalAllCreate() using contour plotting for 2d DMDAs.\n\n"; #include #include #include int main(int argc,char **argv) { PetscInt i,j,M = 10,N = 8,m = PETSC_DECIDE,n = PETSC_DECIDE; PetscMPIInt rank; PetscBool flg = PETSC_FALSE; DM da; PetscViewer viewer; Vec localall,global; PetscScalar value,*vlocal; DMBoundaryType bx = DM_BOUNDARY_NONE,by = DM_BOUNDARY_NONE; DMDAStencilType stype = DMDA_STENCIL_BOX; VecScatter tolocalall,fromlocalall; PetscInt start,end; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCall(PetscViewerDrawOpen(PETSC_COMM_WORLD,0,"",300,0,300,300,&viewer)); /* Read options */ PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL)); PetscCall(PetscOptionsGetBool(NULL,NULL,"-star_stencil",&flg,NULL)); if (flg) stype = DMDA_STENCIL_STAR; /* Create distributed array and get vectors */ PetscCall(DMDACreate2d(PETSC_COMM_WORLD,bx,by,stype,M,N,m,n,1,1,NULL,NULL,&da)); PetscCall(DMSetFromOptions(da)); PetscCall(DMSetUp(da)); PetscCall(DMCreateGlobalVector(da,&global)); PetscCall(VecCreateSeq(PETSC_COMM_SELF,M*N,&localall)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCall(VecGetOwnershipRange(global,&start,&end)); for (i=start; i