Actual source code: spoolesOptions.c

  1: /*$Id: spoolesOptions.c,v 1.10 2001/08/15 15:56:50 bsmith Exp $*/
  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/aij.h
 7:  #include src/mat/impls/sbaij/seq/sbaij.h

  9: #if defined(PETSC_HAVE_SPOOLES) && !defined(PETSC_USE_SINGLE) && !defined(PETSC_USE_COMPLEX)
 10:  #include src/mat/impls/aij/seq/spooles.h

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

 20:   /* set default input parameters */
 21:   options->msglvl         = 0;
 22:   options->msgFile        = 0;
 23:   options->tau            = 100.;
 24:   options->seed           = 10101;
 25:   options->ordering       = 0;     /* BestOfNDandMS */
 26:   options->maxdomainsize  = 500;
 27:   options->maxzeros       = 1000;
 28:   options->maxsize        = 96;
 29:   options->FrontMtxInfo   = PETSC_FALSE;
 30:   if ( options->symflag == SPOOLES_SYMMETRIC ) {
 31:     options->patchAndGoFlag = 0;  /* no patch */
 32:     options->storeids       = 1;
 33:     options->storevalues    = 1;
 34:     options->toosmall       = 1.e-9;
 35:     options->fudge          = 1.e-9;
 36:   }

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

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

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

 48:     if (PetscLogPrintInfo) options->msglvl = 1;
 49:     PetscOptionsInt("-mat_spooles_msglvl","msglvl","None",
 50:                            options->msglvl,&options->msglvl,0);
 51:     if (options->msglvl > 0) {
 52:         options->msgFile = fopen("spooles.msgFile", "a");
 53:         PetscPrintf(PETSC_COMM_SELF,"n Spooles' output is written into the file 'spooles.msgFile' nn");
 54:     }

 56:     PetscOptionsEList("-mat_spooles_ordering","ordering type","None",
 57:              ordertype,4,ordertype[0],buff,32,&flg);
 58:     while (flg) {
 59:       PetscStrcmp(buff,"BestOfNDandMS",&flg);
 60:       if (flg) {
 61:         options->ordering = 0;
 62:         break;
 63:       }
 64:       PetscStrcmp(buff,"MMD",&flg);
 65:       if (flg) {
 66:         options->ordering = 1;
 67:         break;
 68:       }
 69:       PetscStrcmp(buff,"MS",&flg);
 70:       if (flg) {
 71:         options->ordering = 2;
 72:         break;
 73:       }
 74:       PetscStrcmp(buff,"ND",&flg);
 75:       if (flg) {
 76:         options->ordering = 3;
 77:         break;
 78:       }
 79:       SETERRQ1(1,"Unknown Spooles's ordering %s",buff);
 80:     }
 81: 
 82:     PetscOptionsInt("-mat_spooles_maxdomainsize","maxdomainsize","None", 83:                            options->maxdomainsize,&options->maxdomainsize,PETSC_NULL);
 84:     PetscOptionsInt("-mat_spooles_maxzeros ","maxzeros","None", 85:                            options->maxzeros,&options->maxzeros,PETSC_NULL);
 86:     PetscOptionsInt("-mat_spooles_maxsize","maxsize","None", 87:                            options->maxsize,&options->maxsize,PETSC_NULL);
 88:     PetscOptionsLogical("-mat_spooles_FrontMtxInfo","FrontMtxInfo","None",PETSC_FALSE,&flg,0);
 89:     if (flg) options->FrontMtxInfo = PETSC_TRUE;

 91:     if ( options->symflag == SPOOLES_SYMMETRIC ) {
 92:       PetscOptionsInt("-mat_spooles_patchAndGoFlag","patchAndGoFlag","None",  93:                            options->patchAndGoFlag,&options->patchAndGoFlag,PETSC_NULL);
 94: 
 95:       PetscOptionsReal("-mat_spooles_fudge","fudge","None",  96:                            options->fudge,&options->fudge,PETSC_NULL);
 97:       PetscOptionsReal("-mat_spooles_toosmall","toosmall","None",  98:                            options->toosmall,&options->toosmall,PETSC_NULL);
 99:       PetscOptionsInt("-mat_spooles_storeids","storeids","None", 100:                            options->storeids,&options->storeids,PETSC_NULL);
101:       PetscOptionsInt("-mat_spooles_storevalues","storevalues","None", 102:                            options->storevalues,&options->storevalues,PETSC_NULL);
103: 
104:     }
105:   PetscOptionsEnd();

107:   return(0);
108: }

110: /* used by -sles_view */
111: extern int MatSolve_SeqAIJ_Spooles(Mat,Vec,Vec);
112: extern int MatSolve_MPIAIJ_Spooles(Mat,Vec,Vec);
113: int MatFactorInfo_Spooles(Mat A,PetscViewer viewer)
114: {
115:   Mat_Spooles    *lu = (Mat_Spooles*)A->spptr;
116:   int            ierr,size;
117:   char           *s;

120:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
121: 
122:   /* check if matrix is spooles type */
123:   if (size == 1){
124:     if (A->ops->solve != MatSolve_SeqAIJ_Spooles) return(0);
125:   } else {
126:     if (A->ops->solve != MatSolve_MPIAIJ_Spooles) return(0);
127:   }

129:   switch (lu->options.symflag) {
130:   case 0: s = "SPOOLES_SYMMETRIC"; break;
131:   case 2: s = "SPOOLES_NONSYMMETRIC"; break; }
132:   PetscViewerASCIIPrintf(viewer,"  symmetryflag:   %s n",s);

134:   switch (lu->options.pivotingflag) {
135:   case 0: s = "SPOOLES_NO_PIVOTING"; break;
136:   case 1: s = "SPOOLES_PIVOTING"; break; }
137:   PetscViewerASCIIPrintf(viewer,"  pivotingflag:   %s n",s);

139:   PetscViewerASCIIPrintf(viewer,"  tau:            %g n",lu->options.tau);
140:   PetscViewerASCIIPrintf(viewer,"  seed:           %d n",lu->options.seed);
141:   PetscViewerASCIIPrintf(viewer,"  msglvl:         %d n",lu->options.msglvl);

143:   switch (lu->options.ordering) {
144:   case 0: s = "BestOfNDandMS"; break;
145:   case 1: s = "MMD"; break;
146:   case 2: s = "MS"; break;
147:   case 3: s = "ND"; break;
148:   }
149:   PetscViewerASCIIPrintf(viewer,"  ordering:       %s n",s);
150:   PetscViewerASCIIPrintf(viewer,"  maxdomainsize:  %d n",lu->options.maxdomainsize);
151:   PetscViewerASCIIPrintf(viewer,"  maxzeros:       %d n",lu->options.maxzeros);
152:   PetscViewerASCIIPrintf(viewer,"  maxsize:        %d n",lu->options.maxsize);
153:   PetscViewerASCIIPrintf(viewer,"  FrontMtxInfo:   %d n",lu->options.FrontMtxInfo);

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

167: #endif