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