static char help[] = "Tests DMGetGlobalVector() and DMRestoreGlobalVector().\n\n"; /* Use the options -da_grid_x - number of grid points in x direction, if M < 0 -da_grid_y - number of grid points in y direction, if N < 0 -da_processors_x number of processors in x directio -da_processors_y number of processors in x direction */ #include #include int main(int argc,char **argv) { PetscInt M = 10,N = 8; PetscErrorCode ierr; PetscBool flg = PETSC_FALSE; DM da; Vec global1,global2,global3; DMBoundaryType bx = DM_BOUNDARY_NONE,by = DM_BOUNDARY_NONE; DMDAStencilType stype = DMDA_STENCIL_BOX; ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr; CHKERRQ(PetscOptionsGetBool(NULL,NULL,"-star_stencil",&flg,NULL)); if (flg) stype = DMDA_STENCIL_STAR; /* Create distributed array and get vectors */ CHKERRQ(DMDACreate2d(PETSC_COMM_WORLD,bx,by,stype,M,N,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&da)); CHKERRQ(DMSetFromOptions(da)); CHKERRQ(DMSetUp(da)); CHKERRQ(DMGetGlobalVector(da,&global1)); CHKERRQ(DMGetGlobalVector(da,&global2)); CHKERRQ(DMRestoreGlobalVector(da,&global1)); CHKERRQ(DMRestoreGlobalVector(da,&global2)); CHKERRQ(DMGetGlobalVector(da,&global1)); CHKERRQ(DMGetGlobalVector(da,&global3)); CHKERRQ(DMGetGlobalVector(da,&global2)); CHKERRQ(DMRestoreGlobalVector(da,&global1)); CHKERRQ(DMRestoreGlobalVector(da,&global3)); CHKERRQ(DMRestoreGlobalVector(da,&global2)); CHKERRQ(DMGetGlobalVector(da,&global1)); CHKERRQ(DMGetGlobalVector(da,&global3)); CHKERRQ(DMGetGlobalVector(da,&global2)); CHKERRQ(DMRestoreGlobalVector(da,&global1)); CHKERRQ(DMRestoreGlobalVector(da,&global3)); CHKERRQ(DMRestoreGlobalVector(da,&global2)); CHKERRQ(DMDestroy(&da)); ierr = PetscFinalize(); return ierr; } /*TEST test: TEST*/