Actual source code: ex199.c
petsc-3.13.6 2020-09-29
2: static char help[] = "Tests the different MatColoring implementatons.\n\n";
4: #include <petscmat.h>
6: int main(int argc,char **args)
7: {
8: Mat C;
10: PetscViewer viewer;
11: char file[128];
12: PetscBool flg;
13: MatColoring ctx;
14: ISColoring coloring;
15: PetscMPIInt size;
17: PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
18: MPI_Comm_size(PETSC_COMM_WORLD,&size);
20: PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg);
21: if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must use -f filename to load sparse matrix");
22: PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer);
23: MatCreate(PETSC_COMM_WORLD,&C);
24: MatLoad(C,viewer);
25: PetscViewerDestroy(&viewer);
27: MatColoringCreate(C,&ctx);
28: MatColoringSetFromOptions(ctx);
29: MatColoringApply(ctx,&coloring);
30: MatColoringTest(ctx,coloring);
31: if (size == 1) {
32: /* jp, power and greedy have bug -- need to be fixed */
33: MatISColoringTest(C,coloring);
34: }
36: /* Free data structures */
37: ISColoringDestroy(&coloring);
38: MatColoringDestroy(&ctx);
39: MatDestroy(&C);
40: PetscFinalize();
41: return ierr;
42: }
44: /*TEST
46: test:
47: nsize: {{3}}
48: requires: datafilespath !complex double !define(PETSC_USE_64BIT_INDICES)
49: args: -f ${DATAFILESPATH}/matrices/arco1 -mat_coloring_type {{ jp power natural greedy}} -mat_coloring_distance {{ 1 2}}
51: test:
52: suffix: 2
53: nsize: {{1 2}}
54: requires: datafilespath !complex double !define(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
58: TEST*/