Actual source code: petscoptions.h
petsc-3.6.1 2015-08-06
1: /*
2: Routines to determine options set in the options database.
3: */
6: #include <petscsys.h>
7: #include <petscviewertypes.h>
9: PETSC_EXTERN PetscErrorCode PetscOptionsHasName(const char[],const char[],PetscBool *);
10: PETSC_EXTERN PetscErrorCode PetscOptionsGetInt(const char[],const char [],PetscInt *,PetscBool *);
11: PETSC_EXTERN PetscErrorCode PetscOptionsGetBool(const char[],const char [],PetscBool *,PetscBool *);
12: PETSC_EXTERN PetscErrorCode PetscOptionsGetReal(const char[],const char[],PetscReal *,PetscBool *);
13: PETSC_EXTERN PetscErrorCode PetscOptionsGetScalar(const char[],const char[],PetscScalar *,PetscBool *);
14: PETSC_EXTERN PetscErrorCode PetscOptionsGetIntArray(const char[],const char[],PetscInt[],PetscInt *,PetscBool *);
15: PETSC_EXTERN PetscErrorCode PetscOptionsGetRealArray(const char[],const char[],PetscReal[],PetscInt *,PetscBool *);
16: PETSC_EXTERN PetscErrorCode PetscOptionsGetScalarArray(const char[],const char[],PetscScalar[],PetscInt *,PetscBool *);
17: PETSC_EXTERN PetscErrorCode PetscOptionsGetBoolArray(const char[],const char[],PetscBool [],PetscInt *,PetscBool *);
18: PETSC_EXTERN PetscErrorCode PetscOptionsGetString(const char[],const char[],char[],size_t,PetscBool *);
19: PETSC_EXTERN PetscErrorCode PetscOptionsGetStringArray(const char[],const char[],char*[],PetscInt*,PetscBool *);
20: PETSC_EXTERN PetscErrorCode PetscOptionsGetEList(const char[],const char[],const char*const*,PetscInt,PetscInt*,PetscBool *);
21: PETSC_EXTERN PetscErrorCode PetscOptionsGetEnum(const char[],const char[],const char*const*,PetscEnum*,PetscBool *);
22: PETSC_EXTERN PetscErrorCode PetscOptionsGetEnumArray(const char[],const char[],const char*const*,PetscEnum*,PetscInt *,PetscBool *);
23: PETSC_EXTERN PetscErrorCode PetscOptionsValidKey(const char[],PetscBool *);
25: PETSC_EXTERN PetscErrorCode PetscOptionsSetAlias(const char[],const char[]);
26: PETSC_EXTERN PetscErrorCode PetscOptionsSetValue(const char[],const char[]);
27: PETSC_EXTERN PetscErrorCode PetscOptionsClearValue(const char[]);
29: PETSC_EXTERN PetscErrorCode PetscOptionsAllUsed(PetscInt*);
30: PETSC_EXTERN PetscErrorCode PetscOptionsUsed(const char *,PetscBool*);
31: PETSC_EXTERN PetscErrorCode PetscOptionsLeft(void);
32: PETSC_EXTERN PetscErrorCode PetscOptionsView(PetscViewer);
34: PETSC_EXTERN PetscErrorCode PetscOptionsCreate(void);
35: PETSC_EXTERN PetscErrorCode PetscOptionsInsert(int*,char ***,const char[]);
36: PETSC_EXTERN PetscErrorCode PetscOptionsInsertFile(MPI_Comm,const char[],PetscBool );
37: #if defined(PETSC_HAVE_YAML)
38: PETSC_EXTERN PetscErrorCode PetscOptionsInsertFileYAML(MPI_Comm,const char[],PetscBool);
39: #endif
40: PETSC_EXTERN PetscErrorCode PetscOptionsInsertString(const char[]);
41: PETSC_EXTERN PetscErrorCode PetscOptionsDestroy(void);
42: PETSC_EXTERN PetscErrorCode PetscOptionsClear(void);
43: PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPush(const char[]);
44: PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPop(void);
46: PETSC_EXTERN PetscErrorCode PetscOptionsReject(const char[],const char[]);
47: PETSC_EXTERN PetscErrorCode PetscOptionsGetAll(char*[]);
49: PETSC_EXTERN PetscErrorCode PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscBool *);
50: PETSC_EXTERN PetscErrorCode PetscOptionsStringToInt(const char[],PetscInt*);
51: PETSC_EXTERN PetscErrorCode PetscOptionsStringToReal(const char[],PetscReal*);
52: PETSC_EXTERN PetscErrorCode PetscOptionsStringToBool(const char[],PetscBool*);
54: PETSC_EXTERN PetscErrorCode PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void**));
55: PETSC_EXTERN PetscErrorCode PetscOptionsMonitorCancel(void);
56: PETSC_EXTERN PetscErrorCode PetscOptionsMonitorDefault(const char[], const char[], void *);
58: PETSC_EXTERN PetscBool PetscOptionsPublish;
61: /*
62: See manual page for PetscOptionsBegin()
63: */
64: typedef enum {OPTION_INT,OPTION_BOOL,OPTION_REAL,OPTION_FLIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_SCALAR_ARRAY,OPTION_HEAD,OPTION_INT_ARRAY,OPTION_ELIST,OPTION_BOOL_ARRAY,OPTION_STRING_ARRAY} PetscOptionType;
65: typedef struct _n_PetscOption* PetscOption;
66: struct _n_PetscOption{
67: char *option;
68: char *text;
69: void *data; /* used to hold the default value and then any value it is changed to by GUI */
70: PetscFunctionList flist; /* used for available values for PetscOptionsList() */
71: const char *const *list; /* used for available values for PetscOptionsEList() */
72: char nlist; /* number of entries in list */
73: char *man;
74: size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */
75: PetscBool set; /* the user has changed this value in the GUI */
76: PetscOptionType type;
77: PetscOption next;
78: char *pman;
79: void *edata;
80: };
82: typedef struct _p_PetscOptions {
83: PetscInt count;
84: PetscOption next;
85: char *prefix,*pprefix;
86: char *title;
87: MPI_Comm comm;
88: PetscBool printhelp,changedmethod,alreadyprinted;
89: PetscObject object;
90: } PetscOptions;
92: /*MC
93: PetscOptionsBegin - Begins a set of queries on the options database that are related and should be
94: displayed on the same window of a GUI that allows the user to set the options interactively. Often one should
95: use PetscObjectOptionsBegin() rather than this call.
97: Synopsis:
98: #include <petscoptions.h>
99: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
101: Collective on MPI_Comm
103: Input Parameters:
104: + comm - communicator that shares GUI
105: . prefix - options prefix for all options displayed on window
106: . title - short descriptive text, for example "Krylov Solver Options"
107: - mansec - section of manual pages for options, for example KSP
109: Level: intermediate
111: Notes: Needs to be ended by a call the PetscOptionsEnd()
112: Can add subheadings with PetscOptionsHead()
114: Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -saws_options. When PetscOptionsPublish is set the
115: $ loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise
116: $ the loop is run ONCE with a PetscOptionsPublishCount of 1.
117: $ = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc
118: $ = 0 : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options
119: $ database updated updated with user changes; PetscOptionsGetInt() etc are also called
120: $ = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and
121: $ default values are printed if -help was given.
122: $ When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1)
123: $ and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of
124: $ options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never
125: $ currently set.
128: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
129: PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
130: PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
131: PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
132: PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
133: PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
134: PetscOptionsFList(), PetscOptionsEList(), PetscObjectOptionsBegin()
136: M*/
137: #define PetscOptionsBegin(comm,prefix,mess,sec) 0; do {\
138: PetscOptions PetscOptionsObjectBase;\
139: PetscOptions *PetscOptionsObject = &PetscOptionsObjectBase; \
140: PetscMemzero(PetscOptionsObject,sizeof(PetscOptions)); \
141: for (PetscOptionsObject->count=(PetscOptionsPublish?-1:1); PetscOptionsObject->count<2; PetscOptionsObject->count++) {\
142: PetscErrorCode _5_PetscOptionsBegin_Private(PetscOptionsObject,comm,prefix,mess,sec);CHKERRQ(_5_ierr);
144: /*MC
145: PetscObjectOptionsBegin - Begins a set of queries on the options database that are related and should be
146: displayed on the same window of a GUI that allows the user to set the options interactively.
148: Synopsis:
149: #include <petscoptions.h>
150: PetscErrorCode PetscObjectOptionsBegin(PetscObject obj)
152: Collective on PetscObject
154: Input Parameters:
155: . obj - object to set options for
157: Level: intermediate
159: Notes: Needs to be ended by a call the PetscOptionsEnd()
160: Can add subheadings with PetscOptionsHead()
162: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
163: PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
164: PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
165: PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
166: PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
167: PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
168: PetscOptionsFList(), PetscOptionsEList()
170: M*/
171: #define PetscObjectOptionsBegin(obj) 0; do { \
172: PetscOptions PetscOptionsObjectBase;\
173: PetscOptions *PetscOptionsObject = &PetscOptionsObjectBase; \
174: for (PetscOptionsObject->count=(PetscOptionsPublish?-1:1); PetscOptionsObject->count<2; PetscOptionsObject->count++) {\
175: PetscErrorCode _5_PetscObjectOptionsBegin_Private(PetscOptionsObject,obj);CHKERRQ(_5_ierr);
177: /*MC
178: PetscOptionsEnd - Ends a set of queries on the options database that are related and should be
179: displayed on the same window of a GUI that allows the user to set the options interactively.
181: Collective on the MPI_Comm used in PetscOptionsBegin()
183: Synopsis:
184: #include <petscoptions.h>
185: PetscErrorCode PetscOptionsEnd(void)
187: Level: intermediate
189: Notes: Needs to be preceded by a call to PetscOptionsBegin() or PetscObjectOptionsBegin()
191: .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
192: PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool()
193: PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(),
194: PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
195: PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
196: PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
197: PetscOptionsFList(), PetscOptionsEList(), PetscObjectOptionsBegin()
199: M*/
200: #define PetscOptionsEnd() _5_PetscOptionsEnd_Private(PetscOptionsObject);CHKERRQ(_5_ierr);}} while (0)
202: PETSC_EXTERN PetscErrorCode PetscOptionsBegin_Private(PetscOptions *,MPI_Comm,const char[],const char[],const char[]);
203: PETSC_EXTERN PetscErrorCode PetscObjectOptionsBegin_Private(PetscOptions *,PetscObject);
204: PETSC_EXTERN PetscErrorCode PetscOptionsEnd_Private(PetscOptions *);
205: PETSC_EXTERN PetscErrorCode PetscOptionsHead(PetscOptions *,const char[]);
207: /*MC
208: PetscOptionsTail - Ends a section of options begun with PetscOptionsHead()
209: See, for example, KSPSetFromOptions_GMRES().
211: Collective on the communicator passed in PetscOptionsBegin()
213: Synopsis:
214: #include <petscoptions.h>
215: PetscErrorCode PetscOptionsTail(void)
217: Level: intermediate
219: Notes: Must be between a PetscOptionsBegin()/PetscObjectOptionsBegin() and a PetscOptionsEnd()
221: Must be preceded by a call to PetscOptionsHead() in the same function.
223: This needs to be used only if the code below PetscOptionsTail() can be run ONLY once.
224: See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit
225: from the function.
227: This is only for use with the PETSc options GUI
229: Concepts: options database^subheading
231: .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
232: PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(),
233: PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
234: PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
235: PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(),
236: PetscOptionsFList(), PetscOptionsEList(), PetscOptionsEnum()
237: M*/
238: #define PetscOptionsTail() 0; {if (PetscOptionsObject->count != 1) return(0);}
240: #define PetscOptionsEnum(a,b,c,d,e,f,g) PetscOptionsEnum_Private(PetscOptionsObject,a,b,c,d,e,f,g)
241: #define PetscOptionsInt(a,b,c,d,e,f) PetscOptionsInt_Private(PetscOptionsObject,a,b,c,d,e,f)
242: #define PetscOptionsReal(a,b,c,d,e,f) PetscOptionsReal_Private(PetscOptionsObject,a,b,c,d,e,f)
243: #define PetscOptionsScalar(a,b,c,d,e,f) PetscOptionsScalar_Private(PetscOptionsObject,a,b,c,d,e,f)
244: #define PetscOptionsName(a,b,c,d) PetscOptionsName_Private(PetscOptionsObject,a,b,c,d)
245: #define PetscOptionsString(a,b,c,d,e,f,g) PetscOptionsString_Private(PetscOptionsObject,a,b,c,d,e,f,g)
246: #define PetscOptionsBool(a,b,c,d,e,f) PetscOptionsBool_Private(PetscOptionsObject,a,b,c,d,e,f)
247: #define PetscOptionsBoolGroupBegin(a,b,c,d) PetscOptionsBoolGroupBegin_Private(PetscOptionsObject,a,b,c,d)
248: #define PetscOptionsBoolGroup(a,b,c,d) PetscOptionsBoolGroup_Private(PetscOptionsObject,a,b,c,d)
249: #define PetscOptionsBoolGroupEnd(a,b,c,d) PetscOptionsBoolGroupEnd_Private(PetscOptionsObject,a,b,c,d)
250: #define PetscOptionsFList(a,b,c,d,e,f,g,h) PetscOptionsFList_Private(PetscOptionsObject,a,b,c,d,e,f,g,h)
251: #define PetscOptionsEList(a,b,c,d,e,f,g,h) PetscOptionsEList_Private(PetscOptionsObject,a,b,c,d,e,f,g,h)
252: #define PetscOptionsRealArray(a,b,c,d,e,f) PetscOptionsRealArray_Private(PetscOptionsObject,a,b,c,d,e,f)
253: #define PetscOptionsScalarArray(a,b,c,d,e,f) PetscOptionsScalarArray_Private(PetscOptionsObject,a,b,c,d,e,f)
254: #define PetscOptionsIntArray(a,b,c,d,e,f) PetscOptionsIntArray_Private(PetscOptionsObject,a,b,c,d,e,f)
255: #define PetscOptionsStringArray(a,b,c,d,e,f) PetscOptionsStringArray_Private(PetscOptionsObject,a,b,c,d,e,f)
256: #define PetscOptionsBoolArray(a,b,c,d,e,f) PetscOptionsBoolArray_Private(PetscOptionsObject,a,b,c,d,e,f)
257: #define PetscOptionsEnumArray(a,b,c,d,e,f,g) PetscOptionsEnumArray_Private(PetscOptionsObject,a,b,c,d,e,f,g)
260: PETSC_EXTERN PetscErrorCode PetscOptionsEnum_Private(PetscOptions *,const char[],const char[],const char[],const char *const*,PetscEnum,PetscEnum*,PetscBool *);
261: PETSC_EXTERN PetscErrorCode PetscOptionsInt_Private(PetscOptions *,const char[],const char[],const char[],PetscInt,PetscInt*,PetscBool *);
262: PETSC_EXTERN PetscErrorCode PetscOptionsReal_Private(PetscOptions *,const char[],const char[],const char[],PetscReal,PetscReal*,PetscBool *);
263: PETSC_EXTERN PetscErrorCode PetscOptionsScalar_Private(PetscOptions *,const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscBool *);
264: PETSC_EXTERN PetscErrorCode PetscOptionsName_Private(PetscOptions *,const char[],const char[],const char[],PetscBool *);
265: PETSC_EXTERN PetscErrorCode PetscOptionsString_Private(PetscOptions *,const char[],const char[],const char[],const char[],char*,size_t,PetscBool *);
266: PETSC_EXTERN PetscErrorCode PetscOptionsBool_Private(PetscOptions *,const char[],const char[],const char[],PetscBool ,PetscBool *,PetscBool *);
267: PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupBegin_Private(PetscOptions *,const char[],const char[],const char[],PetscBool *);
268: PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroup_Private(PetscOptions *,const char[],const char[],const char[],PetscBool *);
269: PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupEnd_Private(PetscOptions *,const char[],const char[],const char[],PetscBool *);
270: PETSC_EXTERN PetscErrorCode PetscOptionsFList_Private(PetscOptions *,const char[],const char[],const char[],PetscFunctionList,const char[],char[],size_t,PetscBool *);
271: PETSC_EXTERN PetscErrorCode PetscOptionsEList_Private(PetscOptions *,const char[],const char[],const char[],const char*const*,PetscInt,const char[],PetscInt*,PetscBool *);
272: PETSC_EXTERN PetscErrorCode PetscOptionsRealArray_Private(PetscOptions *,const char[],const char[],const char[],PetscReal[],PetscInt*,PetscBool *);
273: PETSC_EXTERN PetscErrorCode PetscOptionsScalarArray_Private(PetscOptions *,const char[],const char[],const char[],PetscScalar[],PetscInt*,PetscBool *);
274: PETSC_EXTERN PetscErrorCode PetscOptionsIntArray_Private(PetscOptions *,const char[],const char[],const char[],PetscInt[],PetscInt*,PetscBool *);
275: PETSC_EXTERN PetscErrorCode PetscOptionsStringArray_Private(PetscOptions *,const char[],const char[],const char[],char*[],PetscInt*,PetscBool *);
276: PETSC_EXTERN PetscErrorCode PetscOptionsBoolArray_Private(PetscOptions *,const char[],const char[],const char[],PetscBool [],PetscInt*,PetscBool *);
277: PETSC_EXTERN PetscErrorCode PetscOptionsEnumArray_Private(PetscOptions *,const char[],const char[],const char[],const char *const*,PetscEnum[],PetscInt*,PetscBool *);
280: PETSC_EXTERN PetscErrorCode PetscOptionsSetFromOptions(void);
281: PETSC_EXTERN PetscErrorCode PetscOptionsSAWsDestroy(void);
283: #endif