Actual source code: spoolesOptions.c

  1: #define PETSCMAT_DLL

  3: /* 
  4:    Default and runtime options used by seq and MPI Spooles' interface for both aij and sbaij mat objects
  5: */

 7:  #include ../src/mat/impls/aij/seq/spooles/spooles.h

  9: /* Set Spooles' default and runtime options */
 12: PetscErrorCode SetSpoolesOptions(Mat A, Spooles_options *options)
 13: {
 15:   int          indx;
 16:   const char   *ordertype[]={"BestOfNDandMS","MMD","MS","ND"};
 17:   PetscTruth   flg;

 20:   /* set default input parameters */
 21: #if defined(PETSC_USE_COMPLEX)
 22:   options->typeflag       = SPOOLES_COMPLEX;
 23: #else
 24:   options->typeflag       = SPOOLES_REAL;
 25: #endif
 26:   options->msglvl         = 0;
 27:   options->msgFile        = 0;
 28:   options->tau            = 100.;
 29:   options->seed           = 10101;
 30:   options->ordering       = 1;     /* MMD */
 31:   options->maxdomainsize  = 500;
 32:   options->maxzeros       = 1000;
 33:   options->maxsize        = 96;
 34:   options->FrontMtxInfo   = PETSC_FALSE;
 35:   if ( options->symflag == SPOOLES_SYMMETRIC ) { /* || SPOOLES_HERMITIAN */
 36:     options->patchAndGoFlag = 0;  /* no patch */
 37:     options->storeids       = 1;
 38:     options->storevalues    = 1;
 39:     options->toosmall       = 1.e-9;
 40:     options->fudge          = 1.e-9;
 41: 
 42:   }

 44:   /* get runtime input parameters */
 45:   PetscOptionsBegin(((PetscObject)A)->comm,((PetscObject)A)->prefix,"Spooles Options","Mat");

 47:     PetscOptionsReal("-mat_spooles_tau","tau (used for pivoting; \n\
 48:            all entries in L and U have magnitude no more than tau)","None",
 49:                             options->tau,&options->tau,PETSC_NULL);

 51:     PetscOptionsInt("-mat_spooles_seed","random number seed, used for ordering","None",
 52:                            options->seed,&options->seed,PETSC_NULL);

 54:     if (PetscLogPrintInfo) options->msglvl = 1;
 55:     PetscOptionsInt("-mat_spooles_msglvl","msglvl","None",
 56:                            options->msglvl,&options->msglvl,0);
 57:     if (options->msglvl > 0) {
 58:         options->msgFile = fopen("spooles.msgFile", "a");
 59:         PetscPrintf(PETSC_COMM_SELF,"\n Spooles' output is written into the file 'spooles.msgFile' \n\n");
 60:     }

 62:     PetscOptionsEList("-mat_spooles_ordering","ordering type","None",ordertype,4,ordertype[1],&indx,&flg);
 63:     if (flg) options->ordering = indx;
 64: 
 65:     PetscOptionsInt("-mat_spooles_maxdomainsize","maxdomainsize","None",\
 66:                            options->maxdomainsize,&options->maxdomainsize,PETSC_NULL);
 67:     PetscOptionsInt("-mat_spooles_maxzeros ","maxzeros","None",\
 68:                            options->maxzeros,&options->maxzeros,PETSC_NULL);
 69:     PetscOptionsInt("-mat_spooles_maxsize","maxsize","None",\
 70:                            options->maxsize,&options->maxsize,PETSC_NULL);
 71:     PetscOptionsTruth("-mat_spooles_FrontMtxInfo","FrontMtxInfo","None",PETSC_FALSE,&flg,0);
 72:     if (flg) options->FrontMtxInfo = PETSC_TRUE;

 74:     if ( options->symflag == SPOOLES_SYMMETRIC ) {
 75:       PetscOptionsInt("-mat_spooles_symmetryflag","matrix type","None", \
 76:                            options->symflag,&options->symflag,PETSC_NULL);

 78:       PetscOptionsInt("-mat_spooles_patchAndGoFlag","patchAndGoFlag","None", \
 79:                            options->patchAndGoFlag,&options->patchAndGoFlag,PETSC_NULL);
 80: 
 81:       PetscOptionsReal("-mat_spooles_fudge","fudge","None", \
 82:                            options->fudge,&options->fudge,PETSC_NULL);
 83:       PetscOptionsReal("-mat_spooles_toosmall","toosmall","None", \
 84:                            options->toosmall,&options->toosmall,PETSC_NULL);
 85:       PetscOptionsInt("-mat_spooles_storeids","storeids","None", \
 86:                            options->storeids,&options->storeids,PETSC_NULL);
 87:       PetscOptionsInt("-mat_spooles_storevalues","storevalues","None", \
 88:                            options->storevalues,&options->storevalues,PETSC_NULL);
 89:     }
 90:   PetscOptionsEnd();

 92:   return(0);
 93: }

 95: /* used by -ksp_view */
 98: PetscErrorCode MatFactorInfo_Spooles(Mat A,PetscViewer viewer)
 99: {
100:   Mat_Spooles    *lu = (Mat_Spooles*)A->spptr;
102:   int            size;

105:   MPI_Comm_size(((PetscObject)A)->comm,&size);
106:   /* check if matrix is spooles type */
107:   if (size == 1){
108:     if (A->ops->solve != MatSolve_SeqSpooles) return(0);
109:   } else {
110:     if (A->ops->solve != MatSolve_MPISpooles) return(0);
111:   }

113:   PetscViewerASCIIPrintf(viewer,"Spooles run parameters:\n");
114:   switch (lu->options.symflag) {
115:   case 0:
116:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:   SPOOLES_SYMMETRIC");
117:     break;
118:   case 1:
119:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:    SPOOLES_HERMITIAN\n");
120:     break;
121:   case 2:
122:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:    SPOOLES_NONSYMMETRIC\n");
123:     break;
124:   }

126:   switch (lu->options.pivotingflag) {
127:   case 0:
128:     PetscViewerASCIIPrintf(viewer,"  pivotingflag:   SPOOLES_NO_PIVOTING\n");
129:     break;
130:   case 1:
131:     PetscViewerASCIIPrintf(viewer,"  pivotingflag:   SPOOLES_PIVOTING\n");
132:     break;
133:   }
134:   PetscViewerASCIIPrintf(viewer,"  tau:            %g \n",lu->options.tau);
135:   PetscViewerASCIIPrintf(viewer,"  seed:           %D \n",lu->options.seed);
136:   PetscViewerASCIIPrintf(viewer,"  msglvl:         %D \n",lu->options.msglvl);

138:   switch (lu->options.ordering) {
139:   case 0:
140:     PetscViewerASCIIPrintf(viewer,"  ordering:       BestOfNDandMS\n");
141:     break;
142:   case 1:
143:     PetscViewerASCIIPrintf(viewer,"  ordering:       MMD\n");
144:     break;
145:   case 2:
146:     PetscViewerASCIIPrintf(viewer,"  ordering:       MS\n");
147:     break;
148:   case 3:
149:     PetscViewerASCIIPrintf(viewer,"  ordering:       ND\n");
150:     break;
151:   }
152:   PetscViewerASCIIPrintf(viewer,"  maxdomainsize:  %D \n",lu->options.maxdomainsize);
153:   PetscViewerASCIIPrintf(viewer,"  maxzeros:       %D \n",lu->options.maxzeros);
154:   PetscViewerASCIIPrintf(viewer,"  maxsize:        %D \n",lu->options.maxsize);
155:   PetscViewerASCIIPrintf(viewer,"  FrontMtxInfo:   %D \n",lu->options.FrontMtxInfo);

157:   if ( lu->options.symflag == SPOOLES_SYMMETRIC ) {
158:     PetscViewerASCIIPrintf(viewer,"  patchAndGoFlag: %D \n",lu->options.patchAndGoFlag);
159:     if ( lu->options.patchAndGoFlag > 0 ) {
160:       PetscViewerASCIIPrintf(viewer,"  fudge:          %g \n",lu->options.fudge);
161:       PetscViewerASCIIPrintf(viewer,"  toosmall:       %g \n",lu->options.toosmall);
162:       PetscViewerASCIIPrintf(viewer,"  storeids:       %D \n",lu->options.storeids);
163:       PetscViewerASCIIPrintf(viewer,"  storevalues:    %D \n",lu->options.storevalues);
164:     }
165:   }
166:   return(0);
167: }