static char help[] = "Tests various 2-dimensional DMDA routines.\n\n"; #include #include int main(int argc,char **argv) { PetscInt M = 10,N = 8,dof=1,s=1,bx=0,by=0,i,n,j,k,m,wrap,xs,ys; DM da,dac; PetscViewer viewer; Vec local,global,coors; PetscScalar ***xy,***aglobal; PetscDraw draw; char fname[32]; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); /* Create viewers */ PetscCall(PetscViewerDrawOpen(PETSC_COMM_WORLD,0,"",PETSC_DECIDE,PETSC_DECIDE,600,200,&viewer)); PetscCall(PetscViewerDrawGetDraw(viewer,0,&draw)); PetscCall(PetscDrawSetDoubleBuffer(draw)); /* Read options */ PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-dof",&dof,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-s",&s,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-periodic_x",&wrap,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-periodic_y",&wrap,NULL)); /* Create distributed array and get vectors */ PetscCall(DMDACreate2d(PETSC_COMM_WORLD,(DMBoundaryType)bx,(DMBoundaryType)by,DMDA_STENCIL_BOX,M,N,PETSC_DECIDE,PETSC_DECIDE,dof,s,NULL,NULL,&da)); PetscCall(DMSetFromOptions(da)); PetscCall(DMSetUp(da)); PetscCall(DMDASetUniformCoordinates(da,0.0,1.0,0.0,1.0,0.0,0.0)); for (i=0; i