1 /* 2 Routines to determine options set in the options database. 3 */ 4 #if !defined(__PETSCOPTIONS_H) 5 #define __PETSCOPTIONS_H 6 #include "petscsys.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 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 PETSC_DLLEXPORT 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 PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscOptionsGetEList(const char[],const char[],const char*const*,PetscInt,PetscInt*,PetscTruth*); 30 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsGetEnum(const char[],const char[],const char*const*,PetscEnum*,PetscTruth*); 31 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsValidKey(const char[],PetscTruth*); 32 33 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsSetAlias(const char[],const char[]); 34 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsSetValue(const char[],const char[]); 35 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsClearValue(const char[]); 36 37 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsAllUsed(int*); 38 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsLeft(void); 39 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsPrint(FILE *); 40 41 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsCreate(void); 42 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsInsert(int*,char ***,const char[]); 43 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsInsertFile(MPI_Comm,const char[],PetscTruth); 44 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsInsertString(const char[]); 45 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsDestroy(void); 46 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsClear(void); 47 48 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsReject(const char[],const char[]); 49 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsGetAll(char*[]); 50 51 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscTruth *); 52 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsAtoi(const char[],PetscInt*); 53 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsAtod(const char[],PetscReal*); 54 55 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void*)); 56 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorCancel(void); 57 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsMonitorDefault(const char[], const char[], void *); 58 59 extern PETSC_DLLEXPORT PetscTruth PetscOptionsPublish; 60 extern PETSC_DLLEXPORT PetscInt PetscOptionsPublishCount; 61 62 /*MC 63 PetscOptionsBegin - Begins a set of queries on the options database that are related and should be 64 displayed on the same window of a GUI that allows the user to set the options interactively. 65 66 Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 67 68 Collective on MPI_Comm 69 70 Input Parameters: 71 + comm - communicator that shares GUI 72 . prefix - options prefix for all options displayed on window 73 . title - short descriptive text, for example "Krylov Solver Options" 74 - mansec - section of manual pages for options, for example KSP 75 76 Level: intermediate 77 78 Notes: Needs to be ended by a call the PetscOptionsEnd() 79 Can add subheadings with PetscOptionsHead() 80 81 Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -options_gui. When PetscOptionsPublish is set the 82 $ loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise 83 $ the loop is run ONCE with a PetscOptionsPublishCount of 1. 84 $ = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc 85 $ = 0 : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options 86 $ database updated updated with user changes; PetscOptionsGetInt() etc are also called 87 $ = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and 88 $ default values are printed if -help was given. 89 $ When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1) 90 $ and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of 91 $ options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never 92 $ currently set. 93 94 95 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 96 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 97 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 98 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 99 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 100 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 101 PetscOptionsList(), PetscOptionsEList() 102 103 M*/ 104 #define PetscOptionsBegin(comm,prefix,mess,sec) 0; {\ 105 for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\ 106 PetscErrorCode _5_ierr = PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr); 107 108 /*MC 109 PetscOptionsEnd - Ends a set of queries on the options database that are related and should be 110 displayed on the same window of a GUI that allows the user to set the options interactively. 111 112 Collective on the MPI_Comm used in PetscOptionsBegin() 113 114 Synopsis: PetscErrorCode PetscOptionsEnd(void) 115 116 Level: intermediate 117 118 Notes: Needs to be preceded by a call to PetscOptionsBegin() 119 120 .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 121 PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth() 122 PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsTruth(), 123 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 124 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 125 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 126 PetscOptionsList(), PetscOptionsEList() 127 128 M*/ 129 #define PetscOptionsEnd() _5_ierr = PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}} 130 131 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]); 132 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnd_Private(void); 133 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsHead(const char[]); 134 135 /*MC 136 PetscOptionsTail - Ends a section of options begun with PetscOptionsHead() 137 See, for example, KSPSetFromOptions_GMRES(). 138 139 Collective on the communicator passed in PetscOptionsBegin() 140 141 Synopsis: PetscErrorCode PetscOptionsTail(void) 142 143 Level: intermediate 144 145 Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 146 147 Must be preceded by a call to PetscOptionsHead() in the same function. 148 149 This needs to be used only if the code below PetscOptionsTail() can be run ONLY once. 150 See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit 151 from the function. 152 153 This is only for use with the PETSc options GUI; which does not currently exist. 154 155 Concepts: options database^subheading 156 157 .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 158 PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsTruth(), 159 PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 160 PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 161 PetscOptionsTruthGroupBegin(), PetscOptionsTruthGroup(), PetscOptionsTruthGroupEnd(), 162 PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum() 163 M*/ 164 #define PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);} 165 166 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEnum(const char[],const char[],const char[],const char *const*,PetscEnum,PetscEnum*,PetscTruth*); 167 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscTruth*); 168 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscTruth*); 169 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscTruth*); 170 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsName(const char[],const char[],const char[],PetscTruth*); 171 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscTruth*); 172 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruth(const char[],const char[],const char[],PetscTruth,PetscTruth*,PetscTruth*); 173 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupBegin(const char[],const char[],const char[],PetscTruth*); 174 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroup(const char[],const char[],const char[],PetscTruth*); 175 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthGroupEnd(const char[],const char[],const char[],PetscTruth*); 176 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],size_t,PetscTruth*); 177 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsEList(const char[],const char[],const char[],const char*const*,PetscInt,const char[],PetscInt*,PetscTruth*); 178 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscTruth*); 179 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscTruth*); 180 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscTruth*); 181 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsTruthArray(const char[],const char[],const char[],PetscTruth[],PetscInt*,PetscTruth*); 182 183 EXTERN PetscErrorCode PETSC_DLLEXPORT PetscOptionsSetFromOptions(void); 184 PETSC_EXTERN_CXX_END 185 186 /* 187 See manual page for PetscOptionsBegin() 188 */ 189 typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD,OPTION_INT_ARRAY} PetscOptionType; 190 typedef struct _p_PetscOptions* PetscOptions; 191 struct _p_PetscOptions { 192 char *option; 193 char *text; 194 void *data; /* used to hold the default value and then any value it is changed to by GUI */ 195 PetscFList flist; /* used for available values for PetscOptionsList() */ 196 char *man; 197 size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */ 198 PetscTruth set; /* the user has changed this value in the GUI */ 199 PetscOptionType type; 200 PetscOptions next; 201 }; 202 203 typedef struct { 204 PetscOptions next; 205 char *prefix,*mprefix; 206 char *title; 207 MPI_Comm comm; 208 PetscTruth printhelp,changedmethod,alreadyprinted; 209 } PetscOptionsObjectType; 210 #endif 211