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       = 0;     /* BestOfNDandMS */
     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(A->comm,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[0],&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(A->comm,&size);
    106:
    107:   PetscViewerASCIIPrintf(viewer,"Spooles run parameters:\n");
    108:   switch (lu->options.symflag) {
    109:   case 0:
    110:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:   SPOOLES_SYMMETRIC");
    111:     break;
    112:   case 1:
    113:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:    SPOOLES_HERMITIAN\n");
    114:     break;
    115:   case 2:
    116:     PetscViewerASCIIPrintf(viewer,"  symmetryflag:    SPOOLES_NONSYMMETRIC\n");
    117:     break;
    118:   }

    120:   switch (lu->options.pivotingflag) {
    121:   case 0:
    122:     PetscViewerASCIIPrintf(viewer,"  pivotingflag:   SPOOLES_NO_PIVOTING\n");
    123:     break;
    124:   case 1:
    125:     PetscViewerASCIIPrintf(viewer,"  pivotingflag:   SPOOLES_PIVOTING\n");
    126:     break;
    127:   }
    128:   PetscViewerASCIIPrintf(viewer,"  tau:            %g \n",lu->options.tau);
    129:   PetscViewerASCIIPrintf(viewer,"  seed:           %D \n",lu->options.seed);
    130:   PetscViewerASCIIPrintf(viewer,"  msglvl:         %D \n",lu->options.msglvl);

    132:   switch (lu->options.ordering) {
    133:   case 0:
    134:     PetscViewerASCIIPrintf(viewer,"  ordering:       BestOfNDandMS\n");
    135:     break;
    136:   case 1:
    137:     PetscViewerASCIIPrintf(viewer,"  ordering:       MMD\n");
    138:     break;
    139:   case 2:
    140:     PetscViewerASCIIPrintf(viewer,"  ordering:       MS\n");
    141:     break;
    142:   case 3:
    143:     PetscViewerASCIIPrintf(viewer,"  ordering:       ND\n");
    144:     break;
    145:   }
    146:   PetscViewerASCIIPrintf(viewer,"  maxdomainsize:  %D \n",lu->options.maxdomainsize);
    147:   PetscViewerASCIIPrintf(viewer,"  maxzeros:       %D \n",lu->options.maxzeros);
    148:   PetscViewerASCIIPrintf(viewer,"  maxsize:        %D \n",lu->options.maxsize);
    149:   PetscViewerASCIIPrintf(viewer,"  FrontMtxInfo:   %D \n",lu->options.FrontMtxInfo);

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