Actual source code: spoolesOptions.c
2: /*
3: Default and runtime options used by seq and MPI Spooles' interface for both aij and sbaij mat objects
4: */
6: #include <../src/mat/impls/aij/seq/spooles/spooles.h>
8: /* Set Spooles' default and runtime options */
11: PetscErrorCode SetSpoolesOptions(Mat A, Spooles_options *options)
12: {
14: int indx;
15: const char *ordertype[]={"BestOfNDandMS","MMD","MS","ND"};
16: PetscBool flg;
19: /* set default input parameters */
20: #if defined(PETSC_USE_COMPLEX)
21: options->typeflag = SPOOLES_COMPLEX;
22: #else
23: options->typeflag = SPOOLES_REAL;
24: #endif
25: options->msglvl = 0;
26: options->msgFile = 0;
27: options->tau = 100.;
28: options->seed = 10101;
29: options->ordering = 1; /* MMD */
30: options->maxdomainsize = 500;
31: options->maxzeros = 1000;
32: options->maxsize = 96;
33: options->FrontMtxInfo = PETSC_FALSE;
34: if ( options->symflag == SPOOLES_SYMMETRIC ) { /* || SPOOLES_HERMITIAN */
35: options->patchAndGoFlag = 0; /* no patch */
36: options->storeids = 1;
37: options->storevalues = 1;
38: options->toosmall = 1.e-9;
39: options->fudge = 1.e-9;
40:
41: }
43: /* get runtime input parameters */
44: PetscOptionsBegin(((PetscObject)A)->comm,((PetscObject)A)->prefix,"Spooles Options","Mat");
46: PetscOptionsReal("-mat_spooles_tau","tau (used for pivoting; \n\
47: all entries in L and U have magnitude no more than tau)","None",
48: options->tau,&options->tau,PETSC_NULL);
50: PetscOptionsInt("-mat_spooles_seed","random number seed, used for ordering","None",
51: options->seed,&options->seed,PETSC_NULL);
53: if (PetscLogPrintInfo) options->msglvl = 1;
54: PetscOptionsInt("-mat_spooles_msglvl","msglvl","None",
55: options->msglvl,&options->msglvl,0);
56: if (options->msglvl > 0) {
57: options->msgFile = fopen("spooles.msgFile", "a");
58: PetscPrintf(PETSC_COMM_SELF,"\n Spooles' output is written into the file 'spooles.msgFile' \n\n");
59: }
61: PetscOptionsEList("-mat_spooles_ordering","ordering type","None",ordertype,4,ordertype[1],&indx,&flg);
62: if (flg) options->ordering = indx;
63:
64: PetscOptionsInt("-mat_spooles_maxdomainsize","maxdomainsize","None",\
65: options->maxdomainsize,&options->maxdomainsize,PETSC_NULL);
66: PetscOptionsInt("-mat_spooles_maxzeros ","maxzeros","None",\
67: options->maxzeros,&options->maxzeros,PETSC_NULL);
68: PetscOptionsInt("-mat_spooles_maxsize","maxsize","None",\
69: options->maxsize,&options->maxsize,PETSC_NULL);
70: PetscOptionsBool("-mat_spooles_FrontMtxInfo","FrontMtxInfo","None",PETSC_FALSE,&flg,0);
71: if (flg) options->FrontMtxInfo = PETSC_TRUE;
73: if ( options->symflag == SPOOLES_SYMMETRIC ) {
74: PetscOptionsInt("-mat_spooles_symmetryflag","matrix type","None", \
75: options->symflag,&options->symflag,PETSC_NULL);
77: PetscOptionsInt("-mat_spooles_patchAndGoFlag","patchAndGoFlag","None", \
78: options->patchAndGoFlag,&options->patchAndGoFlag,PETSC_NULL);
79:
80: PetscOptionsReal("-mat_spooles_fudge","fudge","None", \
81: options->fudge,&options->fudge,PETSC_NULL);
82: PetscOptionsReal("-mat_spooles_toosmall","toosmall","None", \
83: options->toosmall,&options->toosmall,PETSC_NULL);
84: PetscOptionsInt("-mat_spooles_storeids","storeids","None", \
85: options->storeids,&options->storeids,PETSC_NULL);
86: PetscOptionsInt("-mat_spooles_storevalues","storevalues","None", \
87: options->storevalues,&options->storevalues,PETSC_NULL);
88: }
89: PetscOptionsEnd();
91: return(0);
92: }
94: /* used by -ksp_view */
97: PetscErrorCode MatFactorInfo_Spooles(Mat A,PetscViewer viewer)
98: {
99: Mat_Spooles *lu = (Mat_Spooles*)A->spptr;
101: int size;
104: MPI_Comm_size(((PetscObject)A)->comm,&size);
105: /* check if matrix is spooles type */
106: if (size == 1){
107: if (A->ops->solve != MatSolve_SeqSpooles) return(0);
108: } else {
109: if (A->ops->solve != MatSolve_MPISpooles) return(0);
110: }
112: PetscViewerASCIIPrintf(viewer,"Spooles run parameters:\n");
113: switch (lu->options.symflag) {
114: case 0:
115: PetscViewerASCIIPrintf(viewer," symmetryflag: SPOOLES_SYMMETRIC");
116: break;
117: case 1:
118: PetscViewerASCIIPrintf(viewer," symmetryflag: SPOOLES_HERMITIAN\n");
119: break;
120: case 2:
121: PetscViewerASCIIPrintf(viewer," symmetryflag: SPOOLES_NONSYMMETRIC\n");
122: break;
123: }
125: switch (lu->options.pivotingflag) {
126: case 0:
127: PetscViewerASCIIPrintf(viewer," pivotingflag: SPOOLES_NO_PIVOTING\n");
128: break;
129: case 1:
130: PetscViewerASCIIPrintf(viewer," pivotingflag: SPOOLES_PIVOTING\n");
131: break;
132: }
133: PetscViewerASCIIPrintf(viewer," tau: %g \n",lu->options.tau);
134: PetscViewerASCIIPrintf(viewer," seed: %D \n",lu->options.seed);
135: PetscViewerASCIIPrintf(viewer," msglvl: %D \n",lu->options.msglvl);
137: switch (lu->options.ordering) {
138: case 0:
139: PetscViewerASCIIPrintf(viewer," ordering: BestOfNDandMS\n");
140: break;
141: case 1:
142: PetscViewerASCIIPrintf(viewer," ordering: MMD\n");
143: break;
144: case 2:
145: PetscViewerASCIIPrintf(viewer," ordering: MS\n");
146: break;
147: case 3:
148: PetscViewerASCIIPrintf(viewer," ordering: ND\n");
149: break;
150: }
151: PetscViewerASCIIPrintf(viewer," maxdomainsize: %D \n",lu->options.maxdomainsize);
152: PetscViewerASCIIPrintf(viewer," maxzeros: %D \n",lu->options.maxzeros);
153: PetscViewerASCIIPrintf(viewer," maxsize: %D \n",lu->options.maxsize);
154: PetscViewerASCIIPrintf(viewer," FrontMtxInfo: %D \n",lu->options.FrontMtxInfo);
156: if ( lu->options.symflag == SPOOLES_SYMMETRIC ) {
157: PetscViewerASCIIPrintf(viewer," patchAndGoFlag: %D \n",lu->options.patchAndGoFlag);
158: if ( lu->options.patchAndGoFlag > 0 ) {
159: PetscViewerASCIIPrintf(viewer," fudge: %g \n",lu->options.fudge);
160: PetscViewerASCIIPrintf(viewer," toosmall: %g \n",lu->options.toosmall);
161: PetscViewerASCIIPrintf(viewer," storeids: %D \n",lu->options.storeids);
162: PetscViewerASCIIPrintf(viewer," storevalues: %D \n",lu->options.storevalues);
163: }
164: }
165: return(0);
166: }