Actual source code: ex26.c


  2: static char help[] = "Tests error message in DMCreateColoring() with periodic boundary conditions. \n\n";

  4: #include <petscdm.h>
  5: #include <petscdmda.h>
  6: #include <petscmat.h>

  8: int main(int argc, char **argv)
  9: {
 10:   Mat           J;
 11:   DM            da;
 12:   MatFDColoring matfdcoloring = 0;
 13:   ISColoring    iscoloring;

 16:   PetscInitialize(&argc, &argv, (char *)0, help);
 17:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:      Create distributed array (DMDA) to manage parallel grid and vectors
 19:   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 20:   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:   DMSetFromOptions(da);
 22:   DMSetUp(da);
 23:   DMSetMatType(da, MATAIJ);
 24:   DMCreateMatrix(da, &J);
 25:   DMCreateColoring(da, IS_COLORING_LOCAL, &iscoloring);
 26:   MatFDColoringCreate(J, iscoloring, &matfdcoloring);
 27:   MatFDColoringSetUp(J, iscoloring, matfdcoloring);
 28:   ISColoringDestroy(&iscoloring);

 30:   /* free spaces */
 31:   MatDestroy(&J);
 32:   MatFDColoringDestroy(&matfdcoloring);
 33:   DMDestroy(&da);
 34:   PetscFinalize();
 35:   return 0;
 36: }