Actual source code: petscoptions.h

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

 10: PetscPolymorphicSubroutine(PetscOptionsHasName,(const char b[],PetscBool  *f),(PETSC_NULL,b,f))
 12: PetscPolymorphicSubroutine(PetscOptionsGetInt,(const char b[],PetscInt *i,PetscBool  *f),(PETSC_NULL,b,i,f))
 14: PetscPolymorphicSubroutine(PetscOptionsGetBool,(const char b[],PetscBool  *i,PetscBool  *f),(PETSC_NULL,b,i,f))
 16: PetscPolymorphicSubroutine(PetscOptionsGetReal,(const char b[],PetscReal *i,PetscBool  *f),(PETSC_NULL,b,i,f))
 18: PetscPolymorphicSubroutine(PetscOptionsGetScalar,(const char b[],PetscScalar i[],PetscBool  *f),(PETSC_NULL,b,i,f))
 20: PetscPolymorphicSubroutine(PetscOptionsGetIntArray,(const char b[],PetscInt i[],PetscInt *ii,PetscBool  *f),(PETSC_NULL,b,i,ii,f))
 22: PetscPolymorphicSubroutine(PetscOptionsGetRealArray,(const char b[],PetscReal i[],PetscInt *ii,PetscBool  *f),(PETSC_NULL,b,i,ii,f))
 24: PetscPolymorphicSubroutine(PetscOptionsGetBoolArray,(const char b[],PetscBool  i[],PetscInt *ii,PetscBool  *f),(PETSC_NULL,b,i,ii,f))
 26: PetscPolymorphicSubroutine(PetscOptionsGetString,(const char b[],char i[],size_t s,PetscBool  *f),(PETSC_NULL,b,i,s,f))
 28: PetscPolymorphicSubroutine(PetscOptionsGetStringArray,(const char b[],char *i[],PetscInt *ii,PetscBool  *f),(PETSC_NULL,b,i,ii,f))



 44: #if defined(PETSC_HAVE_YAML)
 46: #endif





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

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

 74:     Collective on MPI_Comm

 76:   Input Parameters:
 77: +   comm - communicator that shares GUI
 78: .   prefix - options prefix for all options displayed on window
 79: .   title - short descriptive text, for example "Krylov Solver Options"
 80: -   mansec - section of manual pages for options, for example KSP

 82:   Level: intermediate

 84:   Notes: Needs to be ended by a call the PetscOptionsEnd()
 85:          Can add subheadings with PetscOptionsHead()

 87:   Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -options_gui. When PetscOptionsPublish is set the 
 88: $             loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise
 89: $             the loop is run ONCE with a PetscOptionsPublishCount of 1.
 90: $             = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc
 91: $             = 0  : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options
 92: $                    database updated updated with user changes; PetscOptionsGetInt() etc are also called
 93: $             = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and 
 94: $                   default values are printed if -help was given.
 95: $           When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1)
 96: $           and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of 
 97: $           options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never 
 98: $           currently set.       


101: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
102:           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
103:           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
104:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
105:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
106:           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
107:           PetscOptionsList(), PetscOptionsEList(), PetscObjectOptionsBegin()

109: M*/
110: #define    PetscOptionsBegin(comm,prefix,mess,sec) 0; do {\
111:              for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\
112:              PetscErrorCode _5_PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr);

114: /*MC
115:     PetscObjectOptionsBegin - Begins a set of queries on the options database that are related and should be
116:      displayed on the same window of a GUI that allows the user to set the options interactively.

118:    Synopsis: PetscErrorCode PetscObjectOptionsBegin(PetscObject obj)

120:     Collective on PetscObject

122:   Input Parameters:
123: .   obj - object to set options for

125:   Level: intermediate

127:   Notes: Needs to be ended by a call the PetscOptionsEnd()
128:          Can add subheadings with PetscOptionsHead()

130: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
131:           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
132:           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
133:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
134:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
135:           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
136:           PetscOptionsList(), PetscOptionsEList()

138: M*/
139: #define PetscObjectOptionsBegin(obj) 0; do {                            \
140:   for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) { \
141:   PetscErrorCode _5_PetscObjectOptionsBegin_Private(obj);CHKERRQ(_5_ierr);

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

147:     Collective on the MPI_Comm used in PetscOptionsBegin()

149:    Synopsis: PetscErrorCode PetscOptionsEnd(void)

151:   Level: intermediate

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

155: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
156:           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
157:           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
158:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
159:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
160:           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
161:           PetscOptionsList(), PetscOptionsEList(), PetscObjectOptionsBegin()

163: M*/
164: #define    PetscOptionsEnd() _5_PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}} while (0)


171: /*MC
172:      PetscOptionsTail - Ends a section of options begun with PetscOptionsHead()
173:             See, for example, KSPSetFromOptions_GMRES().

175:    Collective on the communicator passed in PetscOptionsBegin()

177:    Synopsis: PetscErrorCode PetscOptionsTail(void)

179:   Level: intermediate

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

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

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

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

191:    Concepts: options database^subheading

193: .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),  
194:            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
195:           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
196:           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
197:           PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
198:           PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum()
199: M*/
200: #define    PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) return(0);}



223: /* 
224:     See manual page for PetscOptionsBegin() 
225: */
226: typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD,OPTION_INT_ARRAY,OPTION_ELIST,OPTION_LOGICAL_ARRAY,OPTION_STRING_ARRAY} PetscOptionType;
227: typedef struct _n_PetscOptions* PetscOptions;
228: struct _n_PetscOptions {
229:   char              *option;
230:   char              *text;
231:   void              *data;         /* used to hold the default value and then any value it is changed to by GUI */
232:   PetscFList        flist;         /* used for available values for PetscOptionsList() */
233:   const char *const *list;        /* used for available values for PetscOptionsEList() */
234:   char              nlist;         /* number of entries in list */
235:   char              *man;
236:   size_t            arraylength;   /* number of entries in data in the case that it is an array (of PetscInt etc) */
237:   PetscBool         set;           /* the user has changed this value in the GUI */
238:   PetscOptionType   type;
239:   PetscOptions      next;
240:   char              *pman;
241:   void              *edata;
242: };

244: typedef struct {
245:   PetscOptions     next;
246:   char             *prefix,*pprefix;
247:   char             *title;
248:   MPI_Comm         comm;
249:   PetscBool        printhelp,changedmethod,alreadyprinted;
250:   PetscObject      object;
251: } PetscOptionsObjectType;
252: #endif