Actual source code: ex26.c

petsc-3.13.6 2020-09-29
Report Typos and Errors

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


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

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

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

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