static char help[] = "Tests DMGlobalToLocal() for 3d DA with stencil width of 2.\n\n"; #include #include int main(int argc,char **argv) { PetscInt N = 3,M=2,P=4,dof=1,rstart,rend,i; PetscInt stencil_width = 2; PetscMPIInt rank; DMBoundaryType bx = DM_BOUNDARY_NONE,by = DM_BOUNDARY_NONE,bz = DM_BOUNDARY_NONE; DMDAStencilType stencil_type = DMDA_STENCIL_STAR; DM da; Vec global,local; CHKERRQ(PetscInitialize(&argc,&argv,(char*)0,help)); CHKERRMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-P",&P,NULL)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-dof",&dof,NULL)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-stencil_width",&stencil_width,NULL)); CHKERRQ(PetscOptionsGetInt(NULL,NULL,"-stencil_type",(PetscInt*)&stencil_type,NULL)); CHKERRQ(DMDACreate3d(PETSC_COMM_WORLD,bx,by,bz,stencil_type,M,N,P,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,dof,stencil_width,0,0,0,&da)); CHKERRQ(DMSetFromOptions(da)); CHKERRQ(DMSetUp(da)); CHKERRQ(DMCreateGlobalVector(da,&global)); CHKERRQ(VecGetOwnershipRange(global,&rstart,&rend)); for (i=rstart; i