xref: /petsc/include/petscoptions.h (revision 9afaeae2f87bb1e981c47bb9f31bd363e6e7d4da)
1 /*
2    Routines to determine options set in the options database.
3 */
4 #if !defined(__PETSCOPTIONS_H)
5 #define __PETSCOPTIONS_H
6 #include "petsc.h"
7 PETSC_EXTERN_CXX_BEGIN
8 
9 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsHasName(const char[],const char[],PetscTruth*);
10 PetscPolymorphicSubroutine(PetscOptionsHasName,(const char b[],PetscTruth *f),(PETSC_NULL,b,f))
11 EXTERN PetscErrorCode PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT  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 PETSC_DLLEXPORT PetscOptionsGetEList(const char[],const char[],const char**,PetscInt,PetscInt*,PetscTruth*);
28 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsGetEnum(const char[],const char[],const char**,PetscEnum*,PetscTruth*);
29 
30 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsSetAlias(const char[],const char[]);
31 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsSetValue(const char[],const char[]);
32 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsClearValue(const char[]);
33 
34 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsAllUsed(int*);
35 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsLeft(void);
36 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsPrint(FILE *);
37 
38 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsCreate(void);
39 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsInsert(int*,char ***,const char[]);
40 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsInsertFile(const char[]);
41 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsInsertString(const char[]);
42 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsDestroy(void);
43 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsClear(void);
44 
45 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsReject(const char[],const char[]);
46 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsGetAll(char*[]);
47 
48 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscTruth *);
49 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsAtoi(const char[],PetscInt*);
50 EXTERN PetscErrorCode PETSC_DLLEXPORT  PetscOptionsAtod(const char[],PetscReal*);
51 
52 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void*));
53 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorCancel(void);
54 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorDefault(const char[], const char[], void *);
55 
56 extern PETSC_DLLEXPORT PetscTruth PetscOptionsPublish;
57 extern PETSC_DLLEXPORT PetscInt   PetscOptionsPublishCount;
58 
59 /*MC
60     PetscOptionsBegin - Begins a set of queries on the options database that are related and should be
61      displayed on the same window of a GUI that allows the user to set the options interactively.
62 
63    Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[])
64 
65     Collective on MPI_Comm
66 
67   Input Parameters:
68 +   comm - communicator that shares GUI
69 .   prefix - options prefix for all options displayed on window
70 .   title - short descriptive text, for example "Krylov Solver Options"
71 -   mansec - section of manual pages for options, for example KSP
72 
73   Level: intermediate
74 
75   Notes: Needs to be ended by a call the PetscOptionsEnd()
76 
77          Can add subheadings with PetscOptionsHead()
78 
79 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
80           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
81           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
82           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
83           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
84           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
85           PetscOptionsList(), PetscOptionsEList()
86 
87 M*/
88 #define    PetscOptionsBegin(comm,prefix,mess,sec) 0; {\
89              for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\
90              PetscErrorCode _5_ierr = PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr);
91 
92 /*MC
93     PetscOptionsEnd - Ends 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.
95 
96     Collective on the MPI_Comm used in PetscOptionsBegin()
97 
98    Synopsis: PetscErrorCode PetscOptionsEnd(void)
99 
100   Level: intermediate
101 
102   Notes: Needs to be preceded by a call to PetscOptionsBegin()
103 
104 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(),
105           PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth()
106           PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(),
107           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
108           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
109           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
110           PetscOptionsList(), PetscOptionsEList()
111 
112 M*/
113 #define    PetscOptionsEnd() _5_ierr = PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}}
114 
115 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]);
116 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnd_Private(void);
117 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char[]);
118 
119 /*MC
120      PetscOptionsTail - Ends a section of options begun with PetscOptionsHead()
121             See, for example, KSPSetFromOptions_GMRES().
122 
123    Collective on the communicator passed in PetscOptionsBegin()
124 
125    Synopsis: PetscErrorCode PetscOptionsTail(void)
126 
127   Level: intermediate
128 
129    Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd()
130 
131           Must be preceded by a call to PetscOptionsHead() in the same function.
132 
133           This needs to be used only if the code below PetscOptionsTail() can be run ONLY once.
134       See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit
135       from the function.
136 
137           This is only for use with the PETSc options GUI; which does not currently exist.
138 
139    Concepts: options database^subheading
140 
141 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(),
142            PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(),
143           PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(),
144           PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(),
145           PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(),
146           PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum()
147 M*/
148 #define    PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);}
149 
150 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char[],const char[],const char[],const char **,PetscEnum,PetscEnum*,PetscTruth*);
151 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscTruth*);
152 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscTruth*);
153 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscTruth*);
154 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char[],const char[],const char[],PetscTruth*);
155 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscTruth*);
156 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char[],const char[],const char[],PetscTruth,PetscTruth*,PetscTruth*);
157 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char[],const char[],const char[],PetscTruth*);
158 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char[],const char[],const char[],PetscTruth*);
159 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char[],const char[],const char[],PetscTruth*);
160 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],PetscInt,PetscTruth*);
161 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char[],const char[],const char[],const char**,PetscInt,const char[],PetscInt*,PetscTruth*);
162 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscTruth*);
163 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscTruth*);
164 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscTruth*);
165 
166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsSetFromOptions(void);
167 PETSC_EXTERN_CXX_END
168 
169 typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD} PetscOptionType;
170 typedef struct _p_PetscOptions* PetscOptions;
171 struct _p_PetscOptions {
172   char            *option;
173   char            *text;
174   void            *data;
175   void            *edata;
176   char            *man;
177   int             arraylength;
178   PetscTruth      set;
179   PetscOptionType type;
180   PetscOptions    next;
181 };
182 
183 typedef struct _p_PetscOptionsHelp* PetscOptionsHelp;
184 struct _p_PetscOptionsHelp {
185   char             *prefix;
186   char             *title;
187   char             *mansec;
188   PetscOptionsHelp next;
189 };
190 
191 typedef struct {
192   PetscOptions     next;
193   char             *prefix,*mprefix;
194   char             *title;
195   MPI_Comm         comm;
196   PetscTruth       printhelp,changedmethod,alreadyprinted;
197   PetscOptionsHelp help;
198 } PetscOptionsObjectType;
199 #endif
200