xref: /petsc/src/dm/tests/ex45.c (revision 061e922f3926be00487707c73b78dd3d40309129)
1 /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
2 
3   Detected bug in DMCreateMatrix() for skinny domains with periodic boundary conditions in overestimating nonzero preallocation
4 
5   Creation Date : 08-12-2016
6 
7   Last Modified : Thu 08 Dec 2016 10:46:02 AM CET
8 
9   Created By : Davide Monsorno
10 
11 _._._._._._._._._._._._._._._._._._._._._.*/
12 
13 #include <petscdmda.h>
14 
main(int argc,char * argv[])15 int main(int argc, char *argv[])
16 {
17   PetscInt nx = 2;
18   PetscInt ny = 2;
19   PetscInt nz = 128;
20   DM       da;
21   Mat      A;
22 
23   PetscFunctionBeginUser;
24   PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
25   PetscCall(DMDACreate3d(PETSC_COMM_WORLD, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_GHOSTED, DMDA_STENCIL_BOX, nx, ny, nz, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE, 1, 2, NULL, NULL, NULL, &da));
26   PetscCall(DMSetFromOptions(da));
27   PetscCall(DMSetUp(da));
28   PetscCall(DMView(da, PETSC_VIEWER_STDOUT_WORLD));
29   PetscCall(DMCreateMatrix(da, &A));
30 
31   PetscCall(MatDestroy(&A));
32   PetscCall(DMDestroy(&da));
33   PetscCall(PetscFinalize());
34   return 0;
35 }
36 
37 /*TEST
38 
39    test:
40       nsize: 5
41 
42 TEST*/
43