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