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->tau            = 100.;
 22:   options->seed           = 10101;
 23:   options->ordering       = 0;     /* BestOfNDandMS */
 24:   options->maxdomainsize  = 500;
 25:   options->maxzeros       = 1000;
 26:   options->maxsize        = 96;
 27:   if ( options->symflag == SPOOLES_SYMMETRIC ) {
 28:     options->patchAndGoFlag = 0;  /* no patch */
 29:     options->storeids       = 1;
 30:     options->storevalues    = 1;
 31:     options->toosmall       = 1.e-9;
 32:     options->fudge          = 1.e-9;
 33:   }

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

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

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

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

 57:     PetscOptionsEList("-mat_spooles_ordering","ordering type","None",
 58:              ordertype,4,ordertype[0],buff,32,&flg);
 59:     while (flg) {
 60:       PetscStrcmp(buff,"BestOfNDandMS",&flg);
 61:       if (flg) {
 62:         options->ordering = 0;
 63:         break;
 64:       }
 65:       PetscStrcmp(buff,"MMD",&flg);
 66:       if (flg) {
 67:         options->ordering = 1;
 68:         break;
 69:       }
 70:       PetscStrcmp(buff,"MS",&flg);
 71:       if (flg) {
 72:         options->ordering = 2;
 73:         break;
 74:       }
 75:       PetscStrcmp(buff,"ND",&flg);
 76:       if (flg) {
 77:         options->ordering = 3;
 78:         break;
 79:       }
 80:       SETERRQ1(1,"Unknown Spooles's ordering %s",buff);
 81:     }
 82: 
 83:     PetscOptionsInt("-mat_spooles_maxdomainsize","maxdomainsize","None", 84:                            options->maxdomainsize,&options->maxdomainsize,PETSC_NULL);
 85:     PetscOptionsInt("-mat_spooles_maxzeros ","maxzeros","None", 86:                            options->maxzeros,&options->maxzeros,PETSC_NULL);
 87:     PetscOptionsInt("-mat_spooles_maxsize","maxsize","None", 88:                            options->maxsize,&options->maxsize,PETSC_NULL);
 89:     if ( options->symflag == SPOOLES_SYMMETRIC ) {
 90:       PetscOptionsInt("-mat_spooles_patchAndGoFlag","patchAndGoFlag","None",  91:                            options->patchAndGoFlag,&options->patchAndGoFlag,PETSC_NULL);
 92: 
 93:       PetscOptionsReal("-mat_spooles_fudge","fudge","None",  94:                            options->fudge,&options->fudge,PETSC_NULL);
 95:       PetscOptionsReal("-mat_spooles_toosmall","toosmall","None",  96:                            options->toosmall,&options->toosmall,PETSC_NULL);
 97:       PetscOptionsInt("-mat_spooles_storeids","storeids","None",  98:                            options->storeids,&options->storeids,PETSC_NULL);
 99:       PetscOptionsInt("-mat_spooles_storevalues","storevalues","None", 100:                            options->storevalues,&options->storevalues,PETSC_NULL);
101: 
102:     }
103:   PetscOptionsEnd();

105:   return(0);
106: }

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

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

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

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

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

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

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

164: #endif