static char help[] ="Tests MatFDColoringSetValues()\n\n"; #include #include int main(int argc,char **argv) { DM da; PetscErrorCode ierr; PetscInt N, mx = 5,my = 4,i,j,nc,nrow,n,ncols,rstart,*colors,*map; const PetscInt *cols; const PetscScalar *vals; Mat A,B; PetscReal norm; MatFDColoring fdcoloring; ISColoring iscoloring; PetscScalar *cm; const ISColoringValue *icolors; PetscMPIInt rank; ISLocalToGlobalMapping ltog; PetscBool single,two; ierr = PetscInitialize(&argc,&argv,NULL,help);if (ierr) return ierr; CHKERRMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); CHKERRQ(DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,mx,my,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&da)); CHKERRQ(DMSetUp(da)); CHKERRQ(DMCreateMatrix(da,&A)); /* as a test copy the matrices from the standard format to the compressed format; this is not scalable but is ok because just for testing */ /* first put the coloring in the global ordering */ CHKERRQ(DMCreateColoring(da,IS_COLORING_LOCAL,&iscoloring)); CHKERRQ(ISColoringGetColors(iscoloring,&n,&nc,&icolors)); CHKERRQ(DMGetLocalToGlobalMapping(da,<og)); CHKERRQ(PetscMalloc1(n,&map)); for (i=0; i PETSC_MACHINE_EPSILON) { CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"Matrix is not identical, problem with MatFDColoringSetValues()\n")); } CHKERRQ(PetscFree(colors)); CHKERRQ(PetscFree(cm)); CHKERRQ(ISColoringDestroy(&iscoloring)); CHKERRQ(MatFDColoringDestroy(&fdcoloring)); CHKERRQ(MatDestroy(&A)); CHKERRQ(MatDestroy(&B)); CHKERRQ(DMDestroy(&da)); ierr = PetscFinalize(); return ierr; } /*TEST test: nsize: 2 requires: !complex test: suffix: single requires: !complex nsize: 2 args: -single_block output_file: output/ex240_1.out test: suffix: two requires: !complex nsize: 2 args: -two_block output_file: output/ex240_1.out test: suffix: 2 requires: !complex nsize: 5 TEST*/