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;

 15:   PetscInitialize(&argc,&argv,(char*)0,help);
 16:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17:      Create distributed array (DMDA) to manage parallel grid and vectors
 18:   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 19:   DMDACreate2d(PETSC_COMM_WORLD,DM_BOUNDARY_PERIODIC, DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,-5,-5,PETSC_DECIDE,PETSC_DECIDE,1,2,0,0,&da);
 20:   DMSetFromOptions(da);
 21:   DMSetUp(da);
 22:   DMSetMatType(da,MATAIJ);
 23:   DMCreateMatrix(da,&J);
 24:   DMCreateColoring(da,IS_COLORING_LOCAL,&iscoloring);
 25:   MatFDColoringCreate(J,iscoloring,&matfdcoloring);
 26:   MatFDColoringSetUp(J,iscoloring,matfdcoloring);
 27:   ISColoringDestroy(&iscoloring);

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