xref: /petsc/src/dm/tests/ex20.c (revision ffa8c5705e8ab2cf85ee1d14dbe507a6e2eb5283)
1 static char help[] = "Tests DMDACreate3d() memory usage\n\n";
2 
3 #include <petscdmda.h>
4 
5 int main(int argc,char **argv)
6 {
7   DM             dm;
8   Vec            X,Y;
9   PetscInt       dof = 10;
10 
11   PetscCall(PetscInitialize(&argc,&argv,(char*)0,help));
12   PetscCall(PetscOptionsGetInt(NULL,NULL,"-dof",&dof,NULL));
13   PetscCall(DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,-128,-128,-128,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,dof,1,NULL,NULL,NULL,&dm));
14   PetscCall(DMSetFromOptions(dm));
15   PetscCall(DMSetUp(dm));
16   PetscCall(PetscMemoryTrace("DMDACreate3d        "));
17 
18   PetscCall(DMCreateGlobalVector(dm,&X));
19   PetscCall(PetscMemoryTrace("DMCreateGlobalVector"));
20   PetscCall(DMCreateGlobalVector(dm,&Y));
21   PetscCall(PetscMemoryTrace("DMCreateGlobalVector"));
22 
23   PetscCall(VecDestroy(&X));
24   PetscCall(VecDestroy(&Y));
25   PetscCall(DMDestroy(&dm));
26   PetscCall(PetscFinalize());
27   return 0;
28 }
29