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   PetscOptionsGetTruthArray(const char[],const char[],PetscTruth[],PetscInt *,PetscTruth*);
 24: PetscPolymorphicSubroutine(PetscOptionsGetTruthArray,(const char b[],PetscTruth i[],PetscInt *ii,PetscTruth *f),(PETSC_NULL,b,i,ii,f))
 25: EXTERN PetscErrorCode   PetscOptionsGetString(const char[],const char[],char[],size_t,PetscTruth*);
 26: PetscPolymorphicSubroutine(PetscOptionsGetString,(const char b[],char i[],size_t s,PetscTruth *f),(PETSC_NULL,b,i,s,f))
 27: EXTERN PetscErrorCode   PetscOptionsGetStringArray(const char[],const char[],char*[],PetscInt*,PetscTruth*);
 28: PetscPolymorphicSubroutine(PetscOptionsGetStringArray,(const char b[],char *i[],PetscInt *ii,PetscTruth *f),(PETSC_NULL,b,i,ii,f))
 29: EXTERN PetscErrorCode  PetscOptionsGetEList(const char[],const char[],const char**,PetscInt,PetscInt*,PetscTruth*);
 30: EXTERN PetscErrorCode  PetscOptionsGetEnum(const char[],const char[],const char**,PetscEnum*,PetscTruth*);

 32: EXTERN PetscErrorCode   PetscOptionsSetAlias(const char[],const char[]);
 33: EXTERN PetscErrorCode   PetscOptionsSetValue(const char[],const char[]);
 34: EXTERN PetscErrorCode   PetscOptionsClearValue(const char[]);

 36: EXTERN PetscErrorCode   PetscOptionsAllUsed(int*);
 37: EXTERN PetscErrorCode   PetscOptionsLeft(void);
 38: EXTERN PetscErrorCode   PetscOptionsPrint(FILE *);

 40: EXTERN PetscErrorCode   PetscOptionsCreate(void);
 41: EXTERN PetscErrorCode   PetscOptionsInsert(int*,char ***,const char[]);
 42: EXTERN PetscErrorCode   PetscOptionsInsertFile(MPI_Comm,const char[],PetscTruth);
 43: EXTERN PetscErrorCode   PetscOptionsInsertString(const char[]);
 44: EXTERN PetscErrorCode   PetscOptionsDestroy(void);
 45: EXTERN PetscErrorCode   PetscOptionsClear(void);

 47: EXTERN PetscErrorCode   PetscOptionsReject(const char[],const char[]);
 48: EXTERN PetscErrorCode   PetscOptionsGetAll(char*[]);

 50: EXTERN PetscErrorCode   PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscTruth *);
 51: EXTERN PetscErrorCode   PetscOptionsAtoi(const char[],PetscInt*);
 52: EXTERN PetscErrorCode   PetscOptionsAtod(const char[],PetscReal*);

 54: EXTERN PetscErrorCode  PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void*));
 55: EXTERN PetscErrorCode  PetscOptionsMonitorCancel(void);
 56: EXTERN PetscErrorCode  PetscOptionsMonitorDefault(const char[], const char[], void *);


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

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

 67:     Collective on MPI_Comm

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

 75:   Level: intermediate

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

 79:          Can add subheadings with PetscOptionsHead()

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

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

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

 98:     Collective on the MPI_Comm used in PetscOptionsBegin()

100:    Synopsis: PetscErrorCode PetscOptionsEnd(void)

102:   Level: intermediate

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

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

114: M*/
115: #define    PetscOptionsEnd() _5_PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}}

117: EXTERN PetscErrorCode  PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]);
118: EXTERN PetscErrorCode  PetscOptionsEnd_Private(void);
119: EXTERN PetscErrorCode  PetscOptionsHead(const char[]);

121: /*MC
122:      PetscOptionsTail - Ends a section of options begun with PetscOptionsHead()
123:             See, for example, KSPSetFromOptions_GMRES().

125:    Collective on the communicator passed in PetscOptionsBegin()

127:    Synopsis: PetscErrorCode PetscOptionsTail(void)

129:   Level: intermediate

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

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

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

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

141:    Concepts: options database^subheading

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

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

169: EXTERN PetscErrorCode  PetscOptionsSetFromOptions(void);

172: typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD} PetscOptionType;
173: typedef struct _p_PetscOptions* PetscOptions;
174: struct _p_PetscOptions {
175:   char            *option;
176:   char            *text;
177:   void            *data;
178:   void            *edata;
179:   char            *man;
180:   int             arraylength;
181:   PetscTruth      set;
182:   PetscOptionType type;
183:   PetscOptions    next;
184: };

186: typedef struct _p_PetscOptionsHelp* PetscOptionsHelp;
187: struct _p_PetscOptionsHelp {
188:   char             *prefix;
189:   char             *title;
190:   char             *mansec;
191:   PetscOptionsHelp next;
192: };

194: typedef struct {
195:   PetscOptions     next;
196:   char             *prefix,*mprefix;
197:   char             *title;
198:   MPI_Comm         comm;
199:   PetscTruth       printhelp,changedmethod,alreadyprinted;
200:   PetscOptionsHelp help;
201: } PetscOptionsObjectType;
202: #endif