Actual source code: petscoptions.h

      1: /*
      2:    Routines to determine options set in the options database.
      3: */
     6:  #include petsc.h

      9: EXTERN PetscErrorCode   PetscOptionsHasName(const char[],const char[],PetscTruth*);
     10: PetscPolymorphicSubroutine(PetscOptionsHasName,(const char b[],PetscTruth *f),(PETSC_NULL,b,f))
     11: EXTERN PetscErrorCode   PetscOptionsGetInt(const char[],const char [],PetscInt *,PetscTruth*);
     12: PetscPolymorphicSubroutine(PetscOptionsGetInt,(const char b[],PetscInt *i,PetscTruth *f),(PETSC_NULL,b,i,f))
     13: EXTERN PetscErrorCode   PetscOptionsGetTruth(const char[],const char [],PetscTruth *,PetscTruth*);
     14: PetscPolymorphicSubroutine(PetscOptionsGetTruth,(const char b[],PetscTruth *i,PetscTruth *f),(PETSC_NULL,b,i,f))
     15: EXTERN PetscErrorCode   PetscOptionsGetReal(const char[],const char[],PetscReal *,PetscTruth*);
     16: PetscPolymorphicSubroutine(PetscOptionsGetReal,(const char b[],PetscReal *i,PetscTruth *f),(PETSC_NULL,b,i,f))
     17: EXTERN PetscErrorCode   PetscOptionsGetScalar(const char[],const char[],PetscScalar *,PetscTruth*);
     18: PetscPolymorphicSubroutine(PetscOptionsGetScalar,(const char b[],PetscScalar i[],PetscTruth *f),(PETSC_NULL,b,i,f))
     19: EXTERN PetscErrorCode   PetscOptionsGetIntArray(const char[],const char[],PetscInt[],PetscInt *,PetscTruth*);
     20: PetscPolymorphicSubroutine(PetscOptionsGetIntArray,(const char b[],PetscInt i[],PetscInt *ii,PetscTruth *f),(PETSC_NULL,b,i,ii,f))
     21: EXTERN PetscErrorCode   PetscOptionsGetRealArray(const char[],const char[],PetscReal[],PetscInt *,PetscTruth*);
     22: PetscPolymorphicSubroutine(PetscOptionsGetRealArray,(const char b[],PetscReal i[],PetscInt *ii,PetscTruth *f),(PETSC_NULL,b,i,ii,f))
     23: EXTERN PetscErrorCode   PetscOptionsGetString(const char[],const char[],char[],size_t,PetscTruth*);
     24: PetscPolymorphicSubroutine(PetscOptionsGetString,(const char b[],char i[],size_t s,PetscTruth *f),(PETSC_NULL,b,i,s,f))
     25: EXTERN PetscErrorCode   PetscOptionsGetStringArray(const char[],const char[],char*[],PetscInt*,PetscTruth*);
     26: PetscPolymorphicSubroutine(PetscOptionsGetStringArray,(const char b[],char *i[],PetscInt *ii,PetscTruth *f),(PETSC_NULL,b,i,ii,f))
     27: EXTERN PetscErrorCode  PetscOptionsGetEList(const char[],const char[],const char**,PetscInt,PetscInt*,PetscTruth*);
     28: EXTERN PetscErrorCode  PetscOptionsGetEnum(const char[],const char[],const char**,PetscEnum*,PetscTruth*);

     30: EXTERN PetscErrorCode   PetscOptionsSetAlias(const char[],const char[]);
     31: EXTERN PetscErrorCode   PetscOptionsSetValue(const char[],const char[]);
     32: EXTERN PetscErrorCode   PetscOptionsClearValue(const char[]);

     34: EXTERN PetscErrorCode   PetscOptionsAllUsed(int*);
     35: EXTERN PetscErrorCode   PetscOptionsLeft(void);
     36: EXTERN PetscErrorCode   PetscOptionsPrint(FILE *);

     38: EXTERN PetscErrorCode   PetscOptionsCreate(void);
     39: EXTERN PetscErrorCode   PetscOptionsInsert(int*,char ***,const char[]);
     40: EXTERN PetscErrorCode   PetscOptionsInsertFile(const char[]);
     41: EXTERN PetscErrorCode   PetscOptionsInsertString(const char[]);
     42: EXTERN PetscErrorCode   PetscOptionsDestroy(void);

     44: EXTERN PetscErrorCode   PetscOptionsReject(const char[],const char[]);
     45: EXTERN PetscErrorCode   PetscOptionsGetAll(char*[]);

     47: EXTERN PetscErrorCode   PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscTruth *);
     48: EXTERN PetscErrorCode   PetscOptionsAtoi(const char[],PetscInt*);
     49: EXTERN PetscErrorCode   PetscOptionsAtod(const char[],PetscReal*);

     51: EXTERN PetscErrorCode  PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void*));
     52: EXTERN PetscErrorCode  PetscOptionsMonitorCancel(void);
     53: EXTERN PetscErrorCode  PetscOptionsMonitorDefault(const char[], const char[], void *);

     58: /*MC
     59:     PetscOptionsBegin - Begins a set of queries on the options database that are related and should be
     60:      displayed on the same window of a GUI that allows the user to set the options interactively.

     62:    Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])

     64:     Collective on MPI_Comm

     66:   Input Parameters:
     67: +   comm - communicator that shares GUI
     68: .   prefix - options prefix for all options displayed on window
     69: .   title - short descriptive text, for example "Krylov Solver Options"
     70: -   mansec - section of manual pages for options, for example KSP

     72:   Level: intermediate

     74:   Notes: Needs to be ended by a call the PetscOptionsEnd()

     76:          Can add subheadings with PetscOptionsHead()

     78: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
     79:           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
     80:           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
     81:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
     82:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
     83:           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
     84:           PetscOptionsList(), PetscOptionsEList()

     86: M*/
     87: #define    PetscOptionsBegin(comm,prefix,mess,sec) 0; {\
     88:              for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\
     89:              PetscErrorCode _5_PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr);

     91: /*MC
     92:     PetscOptionsEnd - Ends a set of queries on the options database that are related and should be
     93:      displayed on the same window of a GUI that allows the user to set the options interactively.

     95:     Collective on the MPI_Comm used in PetscOptionsBegin()

     97:    Synopsis: PetscErrorCode PetscOptionsEnd(void)

     99:   Level: intermediate

    101:   Notes: Needs to be preceded by a call to PetscOptionsBegin()

    103: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
    104:           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
    105:           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
    106:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
    107:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
    108:           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
    109:           PetscOptionsList(), PetscOptionsEList()

    111: M*/
    112: #define    PetscOptionsEnd() _5_PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}}

    114: EXTERN PetscErrorCode  PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]);
    115: EXTERN PetscErrorCode  PetscOptionsEnd_Private(void);
    116: EXTERN PetscErrorCode  PetscOptionsHead(const char[]);

    118: /*MC
    119:      PetscOptionsTail - Ends a section of options begun with PetscOptionsHead()
    120:             See, for example, KSPSetFromOptions_GMRES().

    122:    Collective on the communicator passed in PetscOptionsBegin()

    124:    Synopsis: PetscErrorCode PetscOptionsTail(void)

    126:   Level: intermediate

    128:    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()

    130:           Must be preceded by a call to PetscOptionsHead() in the same function.

    132:           This needs to be used only if the code below PetscOptionsTail() can be run ONLY once.
    133:       See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit
    134:       from the function.

    136:           This is only for use with the PETSc options GUI; which does not currently exist.

    138:    Concepts: options database^subheading

    140: .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
    141:            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
    142:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
    143:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
    144:           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
    145:           PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum()
    146: M*/
    147: #define    PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) return(0);}

    149: EXTERN PetscErrorCode  PetscOptionsEnum(const char[],const char[],const char[],const char **,PetscEnum,PetscEnum*,PetscTruth*);
    150: EXTERN PetscErrorCode  PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscTruth*);
    151: EXTERN PetscErrorCode  PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscTruth*);
    152: EXTERN PetscErrorCode  PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscTruth*);
    153: EXTERN PetscErrorCode  PetscOptionsName(const char[],const char[],const char[],PetscTruth*);
    154: EXTERN PetscErrorCode  PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscTruth*);
    155: EXTERN PetscErrorCode  PetscOptionsTruth(const char[],const char[],const char[],PetscTruth,PetscTruth*,PetscTruth*);
    156: EXTERN PetscErrorCode  PetscOptionsTruthGroupBegin(const char[],const char[],const char[],PetscTruth*);
    157: EXTERN PetscErrorCode  PetscOptionsTruthGroup(const char[],const char[],const char[],PetscTruth*);
    158: EXTERN PetscErrorCode  PetscOptionsTruthGroupEnd(const char[],const char[],const char[],PetscTruth*);
    159: EXTERN PetscErrorCode  PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],PetscInt,PetscTruth*);
    160: EXTERN PetscErrorCode  PetscOptionsEList(const char[],const char[],const char[],const char**,PetscInt,const char[],PetscInt*,PetscTruth*);
    161: EXTERN PetscErrorCode  PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscTruth*);
    162: EXTERN PetscErrorCode  PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscTruth*);
    163: EXTERN PetscErrorCode  PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscTruth*);

    165: EXTERN PetscErrorCode  PetscOptionsSetFromOptions();

    168: typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD} OptionType;
    169: typedef struct _p_Options* PetscOptions;
    170: struct _p_Options {
    171:   char         *option;
    172:   char         *text;
    173:   void         *data;
    174:   void         *edata;
    175:   char         *man;
    176:   int          arraylength;
    177:   PetscTruth   set;
    178:   OptionType   type;
    179:   PetscOptions next;
    180: };

    182: typedef struct _p_OptionsHelp* OptionsHelp;
    183: struct _p_OptionsHelp {
    184:   char        *prefix;
    185:   char        *title;
    186:   char        *mansec;
    187:   OptionsHelp next;
    188: };

    190: typedef struct {
    191:   PetscOptions    next;
    192:   char            *prefix,*mprefix;
    193:   char            *title;
    194:   MPI_Comm        comm;
    195:   PetscTruth      printhelp,changedmethod,alreadyprinted;
    196:   OptionsHelp     help;
    197: } PetscOptionsObjectType;
    198: #endif