xref: /petsc/src/dm/tests/ex26.c (revision df4cd43f92eaa320656440c40edb1046daee8f75)
1 
2 static char help[] = "Tests error message in DMCreateColoring() with periodic boundary conditions. \n\n";
3 
4 #include <petscdm.h>
5 #include <petscdmda.h>
6 #include <petscmat.h>
7 
8 int main(int argc, char **argv)
9 {
10   Mat           J;
11   DM            da;
12   MatFDColoring matfdcoloring = 0;
13   ISColoring    iscoloring;
14 
15   PetscFunctionBeginUser;
16   PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
17   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18      Create distributed array (DMDA) to manage parallel grid and vectors
19   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
20   PetscCall(DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_NONE, DMDA_STENCIL_BOX, -5, -5, PETSC_DECIDE, PETSC_DECIDE, 1, 2, 0, 0, &da));
21   PetscCall(DMSetFromOptions(da));
22   PetscCall(DMSetUp(da));
23   PetscCall(DMSetMatType(da, MATAIJ));
24   PetscCall(DMCreateMatrix(da, &J));
25   PetscCall(DMCreateColoring(da, IS_COLORING_LOCAL, &iscoloring));
26   PetscCall(MatFDColoringCreate(J, iscoloring, &matfdcoloring));
27   PetscCall(MatFDColoringSetUp(J, iscoloring, matfdcoloring));
28   PetscCall(ISColoringDestroy(&iscoloring));
29 
30   /* free spaces */
31   PetscCall(MatDestroy(&J));
32   PetscCall(MatFDColoringDestroy(&matfdcoloring));
33   PetscCall(DMDestroy(&da));
34   PetscCall(PetscFinalize());
35   return 0;
36 }
37