1f26ada1bSBarry Smith /* 237f753daSBarry Smith Routines to determine options set in the options database. 3f26ada1bSBarry Smith */ 46524c165SJacob Faibussowitsch #ifndef PETSCOPTIONS_H 526bd1501SBarry Smith #define PETSCOPTIONS_H 6ac09b921SBarry Smith 72c8e378dSBarry Smith #include <petscsys.h> 8c619b03eSJed Brown #include <petscviewertypes.h> 93a3b2205SBarry Smith 10ac09b921SBarry Smith /* SUBMANSEC = Sys */ 11ac09b921SBarry Smith 129355ec05SMatthew G. Knepley typedef enum { 139355ec05SMatthew G. Knepley PETSC_OPT_CODE, 149355ec05SMatthew G. Knepley PETSC_OPT_COMMAND_LINE, 159355ec05SMatthew G. Knepley PETSC_OPT_FILE, 169355ec05SMatthew G. Knepley PETSC_OPT_ENVIRONMENT, 179355ec05SMatthew G. Knepley NUM_PETSC_OPT_SOURCE 189355ec05SMatthew G. Knepley } PetscOptionSource; 199355ec05SMatthew G. Knepley 20c5c1f447SLisandro Dalcin #define PETSC_MAX_OPTION_NAME 512 21c5929fdfSBarry Smith typedef struct _n_PetscOptions *PetscOptions; 22c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsCreate(PetscOptions *); 23b4205f0bSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPush(PetscOptions); 24b4205f0bSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPop(void); 25c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsDestroy(PetscOptions *); 262d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsCreateDefault(void); 272d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsDestroyDefault(void); 28c5929fdfSBarry Smith 292d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsHasHelp(PetscOptions, PetscBool *); 30c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsHasName(PetscOptions, const char[], const char[], PetscBool *); 31c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetBool(PetscOptions, const char[], const char[], PetscBool *, PetscBool *); 322d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetInt(PetscOptions, const char[], const char[], PetscInt *, PetscBool *); 332d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEnum(PetscOptions, const char[], const char[], const char *const *, PetscEnum *, PetscBool *); 342d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEList(PetscOptions, const char[], const char[], const char *const *, PetscInt, PetscInt *, PetscBool *); 35c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetReal(PetscOptions, const char[], const char[], PetscReal *, PetscBool *); 36c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetScalar(PetscOptions, const char[], const char[], PetscScalar *, PetscBool *); 372d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetString(PetscOptions, const char[], const char[], char[], size_t, PetscBool *); 382d747510SLisandro Dalcin 392d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetBoolArray(PetscOptions, const char[], const char[], PetscBool[], PetscInt *, PetscBool *); 402d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetEnumArray(PetscOptions, const char[], const char[], const char *const *, PetscEnum *, PetscInt *, PetscBool *); 41c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetIntArray(PetscOptions, const char[], const char[], PetscInt[], PetscInt *, PetscBool *); 42c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetRealArray(PetscOptions, const char[], const char[], PetscReal[], PetscInt *, PetscBool *); 43c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetScalarArray(PetscOptions, const char[], const char[], PetscScalar[], PetscInt *, PetscBool *); 44c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetStringArray(PetscOptions, const char[], const char[], char *[], PetscInt *, PetscBool *); 453a3b2205SBarry Smith 462d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsValidKey(const char[], PetscBool *); 47c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSetAlias(PetscOptions, const char[], const char[]); 48c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSetValue(PetscOptions, const char[], const char[]); 49c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsClearValue(PetscOptions, const char[]); 502d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsFindPair(PetscOptions, const char[], const char[], const char *[], PetscBool *); 513a3b2205SBarry Smith 522d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsGetAll(PetscOptions, char *[]); 53c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsAllUsed(PetscOptions, PetscInt *); 542d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsUsed(PetscOptions, const char[], PetscBool *); 55c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsLeft(PetscOptions); 561ab23d95SFande Kong PETSC_EXTERN PetscErrorCode PetscOptionsLeftGet(PetscOptions, PetscInt *, char ***, char ***); 575b191818SFande Kong PETSC_EXTERN PetscErrorCode PetscOptionsLeftRestore(PetscOptions, PetscInt *, char ***, char ***); 58c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsView(PetscOptions, PetscViewer); 594b0e389bSBarry Smith 602d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsReject(PetscOptions, const char[], const char[], const char[]); 61c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsert(PetscOptions, int *, char ***, const char[]); 62c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsertFile(MPI_Comm, PetscOptions, const char[], PetscBool); 635c23ca1cSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsInsertFileYAML(MPI_Comm, PetscOptions, const char[], PetscBool); 64c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInsertString(PetscOptions, const char[]); 65080f0011SToby Isaac PETSC_EXTERN PetscErrorCode PetscOptionsInsertStringYAML(PetscOptions, const char[]); 66d06005cbSLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsInsertArgs(PetscOptions, int, char **); 67c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsClear(PetscOptions); 68c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPush(PetscOptions, const char[]); 69c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsPrefixPop(PetscOptions); 705d0dffe5SBarry Smith 71014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsGetenv(MPI_Comm, const char[], char[], size_t, PetscBool *); 722d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsStringToBool(const char[], PetscBool *); 73014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsStringToInt(const char[], PetscInt *); 74014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscOptionsStringToReal(const char[], PetscReal *); 752d747510SLisandro Dalcin PETSC_EXTERN PetscErrorCode PetscOptionsStringToScalar(const char[], PetscScalar *); 762e8a6d31SBarry Smith 779355ec05SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], PetscOptionSource, void *), void *, PetscErrorCode (*)(void **)); 789355ec05SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscOptionsMonitorDefault(const char[], const char[], PetscOptionSource, void *); 79081c24baSBoyana Norris 8084761bfeSJed Brown PETSC_EXTERN PetscErrorCode PetscObjectSetOptions(PetscObject, PetscOptions); 8184761bfeSJed Brown PETSC_EXTERN PetscErrorCode PetscObjectGetOptions(PetscObject, PetscOptions *); 8284761bfeSJed Brown 83014dd563SJed Brown PETSC_EXTERN PetscBool PetscOptionsPublish; 84e55864a3SBarry Smith 85e55864a3SBarry Smith /* 86e55864a3SBarry Smith See manual page for PetscOptionsBegin() 874416b707SBarry Smith 884416b707SBarry Smith PetscOptionsItem and PetscOptionsItems are a single option (such as ksp_type) and a collection of such single 894416b707SBarry Smith options being handled with a PetscOptionsBegin/End() 904416b707SBarry Smith 91e55864a3SBarry Smith */ 929371c9d4SSatish Balay typedef enum { 939371c9d4SSatish Balay OPTION_INT, 949371c9d4SSatish Balay OPTION_BOOL, 959371c9d4SSatish Balay OPTION_REAL, 969371c9d4SSatish Balay OPTION_FLIST, 979371c9d4SSatish Balay OPTION_STRING, 989371c9d4SSatish Balay OPTION_REAL_ARRAY, 999371c9d4SSatish Balay OPTION_SCALAR_ARRAY, 1009371c9d4SSatish Balay OPTION_HEAD, 1019371c9d4SSatish Balay OPTION_INT_ARRAY, 1029371c9d4SSatish Balay OPTION_ELIST, 1039371c9d4SSatish Balay OPTION_BOOL_ARRAY, 1049371c9d4SSatish Balay OPTION_STRING_ARRAY 1059371c9d4SSatish Balay } PetscOptionType; 1069355ec05SMatthew G. Knepley 1074416b707SBarry Smith typedef struct _n_PetscOptionItem *PetscOptionItem; 1084416b707SBarry Smith struct _n_PetscOptionItem { 109e55864a3SBarry Smith char *option; 110e55864a3SBarry Smith char *text; 111e55864a3SBarry Smith void *data; /* used to hold the default value and then any value it is changed to by GUI */ 112e55864a3SBarry Smith PetscFunctionList flist; /* used for available values for PetscOptionsList() */ 113e55864a3SBarry Smith const char *const *list; /* used for available values for PetscOptionsEList() */ 114e55864a3SBarry Smith char nlist; /* number of entries in list */ 115e55864a3SBarry Smith char *man; 116e55864a3SBarry Smith size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */ 117e55864a3SBarry Smith PetscBool set; /* the user has changed this value in the GUI */ 118e55864a3SBarry Smith PetscOptionType type; 1194416b707SBarry Smith PetscOptionItem next; 120e55864a3SBarry Smith char *pman; 121e55864a3SBarry Smith void *edata; 122e55864a3SBarry Smith }; 123e55864a3SBarry Smith 1244416b707SBarry Smith typedef struct _p_PetscOptionItems { 125e55864a3SBarry Smith PetscInt count; 1264416b707SBarry Smith PetscOptionItem next; 127e55864a3SBarry Smith char *prefix, *pprefix; 128e55864a3SBarry Smith char *title; 129e55864a3SBarry Smith MPI_Comm comm; 130e55864a3SBarry Smith PetscBool printhelp, changedmethod, alreadyprinted; 131e55864a3SBarry Smith PetscObject object; 132c5929fdfSBarry Smith PetscOptions options; 1334416b707SBarry Smith } PetscOptionItems; 13430de9b25SBarry Smith 1355f80ce2aSJacob Faibussowitsch #if defined(PETSC_CLANG_STATIC_ANALYZER) 13694bad497SJacob Faibussowitsch extern PetscOptionItems *PetscOptionsObject; /* declare this so that the PetscOptions stubs work */ 1375f80ce2aSJacob Faibussowitsch PetscErrorCode PetscOptionsBegin(MPI_Comm, const char *, const char *, const char *); 1385f80ce2aSJacob Faibussowitsch PetscErrorCode PetscObjectOptionsBegin(PetscObject); 1395f80ce2aSJacob Faibussowitsch PetscErrorCode PetscOptionsEnd(void); 1405f80ce2aSJacob Faibussowitsch #else 14130de9b25SBarry Smith /*MC 14230de9b25SBarry Smith PetscOptionsBegin - Begins a set of queries on the options database that are related and should be 1431957e957SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. Often one should 14416a05f60SBarry Smith use `PetscObjectOptionsBegin()` rather than this call. 14530de9b25SBarry Smith 146f2ba6396SBarry Smith Synopsis: 147aaa7dc30SBarry Smith #include <petscoptions.h> 148f2ba6396SBarry Smith PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 14930de9b25SBarry Smith 150fb455bf4SPatrick Sanan Collective 15130de9b25SBarry Smith 15230de9b25SBarry Smith Input Parameters: 15330de9b25SBarry Smith + comm - communicator that shares GUI 15476280437SVaclav Hapla . prefix - options prefix for all options displayed on window (optional) 15530de9b25SBarry Smith . title - short descriptive text, for example "Krylov Solver Options" 15687497f52SBarry Smith - mansec - section of manual pages for options, for example `KSP` (optional) 15730de9b25SBarry Smith 15830de9b25SBarry Smith Level: intermediate 15930de9b25SBarry Smith 16095452b02SPatrick Sanan Notes: 161d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 162d0609cedSBarry Smith 16387497f52SBarry Smith The set of queries needs to be ended by a call to `PetscOptionsEnd()`. 164fb455bf4SPatrick Sanan 16587497f52SBarry Smith One can add subheadings with `PetscOptionsHeadBegin()`. 16630de9b25SBarry Smith 16795452b02SPatrick Sanan Developer Notes: 16816a05f60SBarry Smith `PetscOptionsPublish` is set in `PetscOptionsCheckInitial_Private()` with `-saws_options`. When `PetscOptionsPublish` is set the 16916a05f60SBarry Smith loop between `PetscOptionsBegin()` and `PetscOptionsEnd()` is run THREE times with `PetscOptionsPublishCount` of values -1,0,1. 17016a05f60SBarry Smith Otherwise the loop is run ONCE with a `PetscOptionsPublishCount` of 1. 17116a05f60SBarry Smith + \-1 - `PetscOptionsInt()` etc. just call `PetscOptionsGetInt()` etc. 17216a05f60SBarry Smith . 0 - The GUI objects are created in `PetscOptionsInt()` etc. and displayed in `PetscOptionsEnd()` and the options 17316a05f60SBarry Smith database updated with user changes; `PetscOptionsGetInt()` etc. are also called. 17416a05f60SBarry Smith - 1 - `PetscOptionsInt()` etc. again call `PetscOptionsGetInt()` etc. (possibly getting new values), in addition the help message and 175fb455bf4SPatrick Sanan default values are printed if -help was given. 17616a05f60SBarry Smith When `PetscOptionsObject.changedmethod` is set this causes `PetscOptionsPublishCount` to be reset to -2 (so in the next loop iteration it is -1) 17716a05f60SBarry Smith and the whole process is repeated. This is to handle when, for example, the `KSPType` is changed thus changing the list of 17816a05f60SBarry Smith options available so they need to be redisplayed so the user can change the. Changing `PetscOptionsObjects.changedmethod` is never 179fb455bf4SPatrick Sanan currently set. 180aee2cecaSBarry Smith 181db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`, 182db781477SPatrick Sanan `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()` 183db781477SPatrick Sanan `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`, 184db781477SPatrick Sanan `PetscOptionsName()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, 185c2e3fba1SPatrick Sanan `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, 186db781477SPatrick Sanan `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, 187db781477SPatrick Sanan `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscObjectOptionsBegin()` 18830de9b25SBarry Smith M*/ 1899371c9d4SSatish Balay #define PetscOptionsBegin(comm, prefix, mess, sec) \ 1909371c9d4SSatish Balay do { \ 1914416b707SBarry Smith PetscOptionItems PetscOptionsObjectBase; \ 1924416b707SBarry Smith PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; \ 193d0609cedSBarry Smith PetscCall(PetscMemzero(PetscOptionsObject, sizeof(*PetscOptionsObject))); \ 194e55864a3SBarry Smith for (PetscOptionsObject->count = (PetscOptionsPublish ? -1 : 1); PetscOptionsObject->count < 2; PetscOptionsObject->count++) { \ 1959566063dSJacob Faibussowitsch PetscCall(PetscOptionsBegin_Private(PetscOptionsObject, comm, prefix, mess, sec)) 19630de9b25SBarry Smith 1975fefd1ebSJed Brown /*MC 1985fefd1ebSJed Brown PetscObjectOptionsBegin - Begins a set of queries on the options database that are related and should be 1995fefd1ebSJed Brown displayed on the same window of a GUI that allows the user to set the options interactively. 2005fefd1ebSJed Brown 201f2ba6396SBarry Smith Synopsis: 202aaa7dc30SBarry Smith #include <petscoptions.h> 203f2ba6396SBarry Smith PetscErrorCode PetscObjectOptionsBegin(PetscObject obj) 2045fefd1ebSJed Brown 205c3339decSBarry Smith Collective 2065fefd1ebSJed Brown 2072fe279fdSBarry Smith Input Parameter: 2085fefd1ebSJed Brown . obj - object to set options for 2095fefd1ebSJed Brown 2105fefd1ebSJed Brown Level: intermediate 2115fefd1ebSJed Brown 21295452b02SPatrick Sanan Notes: 213d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 214d0609cedSBarry Smith 21587497f52SBarry Smith Needs to be ended by a call the `PetscOptionsEnd()` 216d0609cedSBarry Smith 21787497f52SBarry Smith Can add subheadings with `PetscOptionsHeadBegin()` 2185fefd1ebSJed Brown 219db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`, 220db781477SPatrick Sanan `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()` 221db781477SPatrick Sanan `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`, 222db781477SPatrick Sanan `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, 223c2e3fba1SPatrick Sanan `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, 224db781477SPatrick Sanan `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, 225db781477SPatrick Sanan `PetscOptionsFList()`, `PetscOptionsEList()` 2265fefd1ebSJed Brown M*/ 2279371c9d4SSatish Balay #define PetscObjectOptionsBegin(obj) \ 2289371c9d4SSatish Balay do { \ 2294416b707SBarry Smith PetscOptionItems PetscOptionsObjectBase; \ 2304416b707SBarry Smith PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; \ 231c5929fdfSBarry Smith PetscOptionsObject->options = ((PetscObject)obj)->options; \ 232e55864a3SBarry Smith for (PetscOptionsObject->count = (PetscOptionsPublish ? -1 : 1); PetscOptionsObject->count < 2; PetscOptionsObject->count++) { \ 233dbbe0bcdSBarry Smith PetscCall(PetscObjectOptionsBegin_Private(obj, PetscOptionsObject)) 2343194b578SJed Brown 23530de9b25SBarry Smith /*MC 23630de9b25SBarry Smith PetscOptionsEnd - Ends a set of queries on the options database that are related and should be 23730de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 23830de9b25SBarry Smith 239f2ba6396SBarry Smith Synopsis: 240aaa7dc30SBarry Smith #include <petscoptions.h> 241f2ba6396SBarry Smith PetscErrorCode PetscOptionsEnd(void) 24230de9b25SBarry Smith 243*7cdbe19fSJose E. Roman Collective on the comm used in `PetscOptionsBegin()` or obj used in `PetscObjectOptionsBegin()` 244*7cdbe19fSJose E. Roman 24530de9b25SBarry Smith Level: intermediate 24630de9b25SBarry Smith 24795452b02SPatrick Sanan Notes: 24887497f52SBarry Smith Needs to be preceded by a call to `PetscOptionsBegin()` or `PetscObjectOptionsBegin()` 24930de9b25SBarry Smith 250d0609cedSBarry Smith This is a macro that handles its own error checking, it does not return an error code. 251d0609cedSBarry Smith 252db781477SPatrick Sanan .seealso: `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`, 253db781477SPatrick Sanan `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()` 254db781477SPatrick Sanan `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsBool()`, 255db781477SPatrick Sanan `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsHeadBegin()`, 256c2e3fba1SPatrick Sanan `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, 257db781477SPatrick Sanan `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, 258db781477SPatrick Sanan `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscObjectOptionsBegin()` 25930de9b25SBarry Smith M*/ 2609371c9d4SSatish Balay #define PetscOptionsEnd() \ 2619371c9d4SSatish Balay PetscCall(PetscOptionsEnd_Private(PetscOptionsObject)); \ 2629371c9d4SSatish Balay } \ 2639371c9d4SSatish Balay } \ 2649371c9d4SSatish Balay while (0) 2655f80ce2aSJacob Faibussowitsch #endif /* PETSC_CLANG_STATIC_ANALYZER */ 26630de9b25SBarry Smith 2674416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBegin_Private(PetscOptionItems *, MPI_Comm, const char[], const char[], const char[]); 268dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectOptionsBegin_Private(PetscObject, PetscOptionItems *); 2694416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnd_Private(PetscOptionItems *); 270d0609cedSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsHeadBegin(PetscOptionItems *, const char[]); 27130de9b25SBarry Smith 2725f80ce2aSJacob Faibussowitsch #if defined(PETSC_CLANG_STATIC_ANALYZER) 2739371c9d4SSatish Balay template <typename... T> 2749371c9d4SSatish Balay void PetscOptionsHeadBegin(T...); 275d0609cedSBarry Smith void PetscOptionsHeadEnd(void); 2769371c9d4SSatish Balay template <typename... T> 2779371c9d4SSatish Balay PetscErrorCode PetscOptionsEnum(T...); 2789371c9d4SSatish Balay template <typename... T> 2799371c9d4SSatish Balay PetscErrorCode PetscOptionsInt(T...); 2809371c9d4SSatish Balay template <typename... T> 2819371c9d4SSatish Balay PetscErrorCode PetscOptionsBoundedInt(T...); 2829371c9d4SSatish Balay template <typename... T> 2839371c9d4SSatish Balay PetscErrorCode PetscOptionsRangeInt(T...); 2849371c9d4SSatish Balay template <typename... T> 2859371c9d4SSatish Balay PetscErrorCode PetscOptionsReal(T...); 2869371c9d4SSatish Balay template <typename... T> 2879371c9d4SSatish Balay PetscErrorCode PetscOptionsScalar(T...); 2889371c9d4SSatish Balay template <typename... T> 2899371c9d4SSatish Balay PetscErrorCode PetscOptionsName(T...); 2909371c9d4SSatish Balay template <typename... T> 2919371c9d4SSatish Balay PetscErrorCode PetscOptionsString(T...); 2929371c9d4SSatish Balay template <typename... T> 2939371c9d4SSatish Balay PetscErrorCode PetscOptionsBool(T...); 2949371c9d4SSatish Balay template <typename... T> 2959371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroupBegin(T...); 2969371c9d4SSatish Balay template <typename... T> 2979371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroup(T...); 2989371c9d4SSatish Balay template <typename... T> 2999371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolGroupEnd(T...); 3009371c9d4SSatish Balay template <typename... T> 3019371c9d4SSatish Balay PetscErrorCode PetscOptionsFList(T...); 3029371c9d4SSatish Balay template <typename... T> 3039371c9d4SSatish Balay PetscErrorCode PetscOptionsEList(T...); 3049371c9d4SSatish Balay template <typename... T> 3059371c9d4SSatish Balay PetscErrorCode PetscOptionsRealArray(T...); 3069371c9d4SSatish Balay template <typename... T> 3079371c9d4SSatish Balay PetscErrorCode PetscOptionsScalarArray(T...); 3089371c9d4SSatish Balay template <typename... T> 3099371c9d4SSatish Balay PetscErrorCode PetscOptionsIntArray(T...); 3109371c9d4SSatish Balay template <typename... T> 3119371c9d4SSatish Balay PetscErrorCode PetscOptionsStringArray(T...); 3129371c9d4SSatish Balay template <typename... T> 3139371c9d4SSatish Balay PetscErrorCode PetscOptionsBoolArray(T...); 3149371c9d4SSatish Balay template <typename... T> 3159371c9d4SSatish Balay PetscErrorCode PetscOptionsEnumArray(T...); 3169371c9d4SSatish Balay template <typename... T> 3179371c9d4SSatish Balay PetscErrorCode PetscOptionsDeprecated(T...); 3189371c9d4SSatish Balay template <typename... T> 3199371c9d4SSatish Balay PetscErrorCode PetscOptionsDeprecatedNoObject(T...); 3205f80ce2aSJacob Faibussowitsch #else 32130de9b25SBarry Smith /*MC 322d0609cedSBarry Smith PetscOptionsHeadBegin - Puts a heading before listing any more published options. Used, for example, 32316a05f60SBarry Smith in `KSPSetFromOptions_GMRES()`. 324d0609cedSBarry Smith 32516a05f60SBarry Smith Logically Collective on the communicator passed in `PetscOptionsBegin()` 326d0609cedSBarry Smith 327d0609cedSBarry Smith Input Parameter: 328d0609cedSBarry Smith . head - the heading text 329d0609cedSBarry Smith 33087497f52SBarry Smith Level: developer 331d0609cedSBarry Smith 332d0609cedSBarry Smith Notes: 333d0609cedSBarry Smith Handles errors directly, hence does not return an error code 334d0609cedSBarry Smith 33516a05f60SBarry Smith Must be between a `PetscOptionsBegin()` and a `PetscOptionsEnd()`, and `PetscOptionsObject` created in `PetscOptionsBegin()` should be the first argument 336d0609cedSBarry Smith 33787497f52SBarry Smith Must be followed by a call to `PetscOptionsHeadEnd()` in the same function. 338d0609cedSBarry Smith 339db781477SPatrick Sanan .seealso: `PetscOptionsGetInt()`, `PetscOptionsGetReal()`, 340db781477SPatrick Sanan `PetscOptionsHasName()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`, 341db781477SPatrick Sanan `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, 342c2e3fba1SPatrick Sanan `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, 343db781477SPatrick Sanan `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, 344db781477SPatrick Sanan `PetscOptionsFList()`, `PetscOptionsEList()` 345d0609cedSBarry Smith @*/ 3469371c9d4SSatish Balay #define PetscOptionsHeadBegin(PetscOptionsObject, head) \ 3479371c9d4SSatish Balay do { \ 34848a46eb9SPierre Jolivet if (PetscOptionsObject->printhelp && PetscOptionsObject->count == 1 && !PetscOptionsObject->alreadyprinted) PetscCall((*PetscHelpPrintf)(PetscOptionsObject->comm, " %s\n", head)); \ 349d0609cedSBarry Smith } while (0) 350d0609cedSBarry Smith 351d0609cedSBarry Smith #define PetscOptionsHead(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use PetscOptionsHeadBegin() (since version 3.18)\"") PetscOptionsHeadBegin(__VA_ARGS__) 352d0609cedSBarry Smith 353d0609cedSBarry Smith /*MC 35487497f52SBarry Smith PetscOptionsHeadEnd - Ends a section of options begun with `PetscOptionsHeadBegin()` 35516a05f60SBarry Smith See, for example, `KSPSetFromOptions_GMRES()`. 35630de9b25SBarry Smith 357f2ba6396SBarry Smith Synopsis: 358aaa7dc30SBarry Smith #include <petscoptions.h> 359d0609cedSBarry Smith PetscErrorCode PetscOptionsHeadEnd(void) 36030de9b25SBarry Smith 361*7cdbe19fSJose E. Roman Collective on the comm used in `PetscOptionsBegin()` or obj used in `PetscObjectOptionsBegin()` 362*7cdbe19fSJose E. Roman 36330de9b25SBarry Smith Level: intermediate 36430de9b25SBarry Smith 36595452b02SPatrick Sanan Notes: 36687497f52SBarry Smith Must be between a `PetscOptionsBegin()` or `PetscObjectOptionsBegin()` and a `PetscOptionsEnd()` 36730de9b25SBarry Smith 36887497f52SBarry Smith Must be preceded by a call to `PetscOptionsHeadBegin()` in the same function. 36930de9b25SBarry Smith 37087497f52SBarry Smith This needs to be used only if the code below `PetscOptionsHeadEnd()` can be run ONLY once. 37116a05f60SBarry Smith See, for example, `PCSetFromOptions_Composite()`. This is a `return(0)` in it for early exit 372b52f573bSBarry Smith from the function. 373b52f573bSBarry Smith 37456752e42SBarry Smith This is only for use with the PETSc options GUI 375b52f573bSBarry Smith 376db781477SPatrick Sanan .seealso: `PetscOptionsGetInt()`, `PetscOptionsGetReal()`, 377db781477SPatrick Sanan `PetscOptionsHasName()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`, 378db781477SPatrick Sanan `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, 379c2e3fba1SPatrick Sanan `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, 380db781477SPatrick Sanan `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, 381db781477SPatrick Sanan `PetscOptionsFList()`, `PetscOptionsEList()`, `PetscOptionsEnum()` 38230de9b25SBarry Smith M*/ 3839371c9d4SSatish Balay #define PetscOptionsHeadEnd() \ 3849371c9d4SSatish Balay do { \ 3853ba16761SJacob Faibussowitsch if (PetscOptionsObject->count != 1) PetscFunctionReturn(PETSC_SUCCESS); \ 3869371c9d4SSatish Balay } while (0) 387d0609cedSBarry Smith 388d0609cedSBarry Smith #define PetscOptionsTail(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use PetscOptionsHeadEnd() (since version 3.18)\"") PetscOptionsHeadEnd(__VA_ARGS__) 389186905e3SBarry Smith 390e55864a3SBarry Smith #define PetscOptionsEnum(a, b, c, d, e, f, g) PetscOptionsEnum_Private(PetscOptionsObject, a, b, c, d, e, f, g) 3915a856986SBarry Smith #define PetscOptionsInt(a, b, c, d, e, f) PetscOptionsInt_Private(PetscOptionsObject, a, b, c, d, e, f, PETSC_MIN_INT, PETSC_MAX_INT) 3925a856986SBarry Smith #define PetscOptionsBoundedInt(a, b, c, d, e, f, g) PetscOptionsInt_Private(PetscOptionsObject, a, b, c, d, e, f, g, PETSC_MAX_INT) 3935a856986SBarry Smith #define PetscOptionsRangeInt(a, b, c, d, e, f, g, h) PetscOptionsInt_Private(PetscOptionsObject, a, b, c, d, e, f, g, h) 394e55864a3SBarry Smith #define PetscOptionsReal(a, b, c, d, e, f) PetscOptionsReal_Private(PetscOptionsObject, a, b, c, d, e, f) 395e55864a3SBarry Smith #define PetscOptionsScalar(a, b, c, d, e, f) PetscOptionsScalar_Private(PetscOptionsObject, a, b, c, d, e, f) 396e55864a3SBarry Smith #define PetscOptionsName(a, b, c, d) PetscOptionsName_Private(PetscOptionsObject, a, b, c, d) 397e55864a3SBarry Smith #define PetscOptionsString(a, b, c, d, e, f, g) PetscOptionsString_Private(PetscOptionsObject, a, b, c, d, e, f, g) 398e55864a3SBarry Smith #define PetscOptionsBool(a, b, c, d, e, f) PetscOptionsBool_Private(PetscOptionsObject, a, b, c, d, e, f) 399e55864a3SBarry Smith #define PetscOptionsBoolGroupBegin(a, b, c, d) PetscOptionsBoolGroupBegin_Private(PetscOptionsObject, a, b, c, d) 400e55864a3SBarry Smith #define PetscOptionsBoolGroup(a, b, c, d) PetscOptionsBoolGroup_Private(PetscOptionsObject, a, b, c, d) 401e55864a3SBarry Smith #define PetscOptionsBoolGroupEnd(a, b, c, d) PetscOptionsBoolGroupEnd_Private(PetscOptionsObject, a, b, c, d) 40283355fc5SBarry Smith #define PetscOptionsFList(a, b, c, d, e, f, g, h) PetscOptionsFList_Private(PetscOptionsObject, a, b, c, d, e, f, g, h) 403e55864a3SBarry Smith #define PetscOptionsEList(a, b, c, d, e, f, g, h) PetscOptionsEList_Private(PetscOptionsObject, a, b, c, d, e, f, g, h) 404e55864a3SBarry Smith #define PetscOptionsRealArray(a, b, c, d, e, f) PetscOptionsRealArray_Private(PetscOptionsObject, a, b, c, d, e, f) 405050cccc3SHong Zhang #define PetscOptionsScalarArray(a, b, c, d, e, f) PetscOptionsScalarArray_Private(PetscOptionsObject, a, b, c, d, e, f) 406e55864a3SBarry Smith #define PetscOptionsIntArray(a, b, c, d, e, f) PetscOptionsIntArray_Private(PetscOptionsObject, a, b, c, d, e, f) 407e55864a3SBarry Smith #define PetscOptionsStringArray(a, b, c, d, e, f) PetscOptionsStringArray_Private(PetscOptionsObject, a, b, c, d, e, f) 408e55864a3SBarry Smith #define PetscOptionsBoolArray(a, b, c, d, e, f) PetscOptionsBoolArray_Private(PetscOptionsObject, a, b, c, d, e, f) 409d3e47460SLisandro Dalcin #define PetscOptionsEnumArray(a, b, c, d, e, f, g) PetscOptionsEnumArray_Private(PetscOptionsObject, a, b, c, d, e, f, g) 4109f3a6782SPatrick Sanan #define PetscOptionsDeprecated(a, b, c, d) PetscOptionsDeprecated_Private(PetscOptionsObject, a, b, c, d) 411b0bdc838SStefano Zampini #define PetscOptionsDeprecatedNoObject(a, b, c, d) PetscOptionsDeprecated_Private(NULL, a, b, c, d) 4125f80ce2aSJacob Faibussowitsch #endif /* PETSC_CLANG_STATIC_ANALYZER */ 413e55864a3SBarry Smith 4144416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnum_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscEnum, PetscEnum *, PetscBool *); 4155a856986SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsInt_Private(PetscOptionItems *, const char[], const char[], const char[], PetscInt, PetscInt *, PetscBool *, PetscInt, PetscInt); 4164416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsReal_Private(PetscOptionItems *, const char[], const char[], const char[], PetscReal, PetscReal *, PetscBool *); 4174416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsScalar_Private(PetscOptionItems *, const char[], const char[], const char[], PetscScalar, PetscScalar *, PetscBool *); 4184416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsName_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *); 4194416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsString_Private(PetscOptionItems *, const char[], const char[], const char[], const char[], char *, size_t, PetscBool *); 4204416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBool_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool, PetscBool *, PetscBool *); 4214416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupBegin_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *); 4224416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroup_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *); 4234416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolGroupEnd_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool *); 4244416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsFList_Private(PetscOptionItems *, const char[], const char[], const char[], PetscFunctionList, const char[], char[], size_t, PetscBool *); 4254416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEList_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscInt, const char[], PetscInt *, PetscBool *); 4264416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsRealArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscReal[], PetscInt *, PetscBool *); 4274416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsScalarArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscScalar[], PetscInt *, PetscBool *); 4284416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsIntArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscInt[], PetscInt *, PetscBool *); 4294416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsStringArray_Private(PetscOptionItems *, const char[], const char[], const char[], char *[], PetscInt *, PetscBool *); 4304416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsBoolArray_Private(PetscOptionItems *, const char[], const char[], const char[], PetscBool[], PetscInt *, PetscBool *); 4314416b707SBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsEnumArray_Private(PetscOptionItems *, const char[], const char[], const char[], const char *const *, PetscEnum[], PetscInt *, PetscBool *); 4329f3a6782SPatrick Sanan PETSC_EXTERN PetscErrorCode PetscOptionsDeprecated_Private(PetscOptionItems *, const char[], const char[], const char[], const char[]); 433cffb1e40SBarry Smith 434e04113cfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsSAWsDestroy(void); 435f8d0b74dSMatthew Knepley 436dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectAddOptionsHandler(PetscObject, PetscErrorCode (*)(PetscObject, PetscOptionItems *, void *), PetscErrorCode (*)(PetscObject, void *), void *); 437dbbe0bcdSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectProcessOptionsHandlers(PetscObject, PetscOptionItems *); 438447ac60bSBarry Smith PETSC_EXTERN PetscErrorCode PetscObjectDestroyOptionsHandlers(PetscObject); 439447ac60bSBarry Smith 440f4bc716fSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsLeftError(void); 4413a3b2205SBarry Smith #endif 442