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; ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRMPI(ierr); ierr = 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(ierr); ierr = DMSetUp(da);CHKERRQ(ierr); ierr = DMCreateMatrix(da,&A);CHKERRQ(ierr); /* 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 */ ierr = DMCreateColoring(da,IS_COLORING_LOCAL,&iscoloring);CHKERRQ(ierr); ierr = ISColoringGetColors(iscoloring,&n,&nc,&icolors);CHKERRQ(ierr); ierr = DMGetLocalToGlobalMapping(da,<og);CHKERRQ(ierr); ierr = PetscMalloc1(n,&map);CHKERRQ(ierr); for (i=0; i PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix is not identical, problem with MatFDColoringSetValues()\n");CHKERRQ(ierr); } ierr = PetscFree(colors);CHKERRQ(ierr); ierr = PetscFree(cm);CHKERRQ(ierr); ierr = ISColoringDestroy(&iscoloring);CHKERRQ(ierr); ierr = MatFDColoringDestroy(&fdcoloring);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = MatDestroy(&B);CHKERRQ(ierr); ierr = DMDestroy(&da);CHKERRQ(ierr); 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*/