1 2 static char help[] = "Tests the different MatColoring implementatons.\n\n"; 3 4 #include <petscmat.h> 5 6 int main(int argc,char **args) 7 { 8 Mat C; 9 PetscViewer viewer; 10 char file[128]; 11 PetscBool flg; 12 MatColoring ctx; 13 ISColoring coloring; 14 PetscMPIInt size; 15 16 PetscFunctionBeginUser; 17 PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); 18 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); 19 20 PetscCall(PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg)); 21 PetscCheck(flg,PETSC_COMM_WORLD,PETSC_ERR_USER,"Must use -f filename to load sparse matrix"); 22 PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer)); 23 PetscCall(MatCreate(PETSC_COMM_WORLD,&C)); 24 PetscCall(MatLoad(C,viewer)); 25 PetscCall(PetscViewerDestroy(&viewer)); 26 27 PetscCall(MatColoringCreate(C,&ctx)); 28 PetscCall(MatColoringSetFromOptions(ctx)); 29 PetscCall(MatColoringApply(ctx,&coloring)); 30 PetscCall(MatColoringTest(ctx,coloring)); 31 if (size == 1) { 32 /* jp, power and greedy have bug -- need to be fixed */ 33 PetscCall(MatISColoringTest(C,coloring)); 34 } 35 36 /* Free data structures */ 37 PetscCall(ISColoringDestroy(&coloring)); 38 PetscCall(MatColoringDestroy(&ctx)); 39 PetscCall(MatDestroy(&C)); 40 PetscCall(PetscFinalize()); 41 return 0; 42 } 43 44 /*TEST 45 46 test: 47 nsize: {{3}} 48 requires: datafilespath !complex double !defined(PETSC_USE_64BIT_INDICES) 49 args: -f ${DATAFILESPATH}/matrices/arco1 -mat_coloring_type {{ jp power natural greedy}} -mat_coloring_distance {{ 1 2}} 50 51 test: 52 suffix: 2 53 nsize: {{1 2}} 54 requires: datafilespath !complex double !defined(PETSC_USE_64BIT_INDICES) 55 args: -f ${DATAFILESPATH}/matrices/arco1 -mat_coloring_type {{ sl lf id }} -mat_coloring_distance 2 56 output_file: output/ex199_1.out 57 58 TEST*/ 59