1f26ada1bSBarry Smith /* 237f753daSBarry Smith Routines to determine options set in the options database. 3f26ada1bSBarry Smith */ 40a835dfdSSatish Balay #if !defined(__PETSCOPTIONS_H) 50a835dfdSSatish Balay #define __PETSCOPTIONS_H 6d382aafbSBarry Smith #include "petscsys.h" 7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 83a3b2205SBarry Smith 97087cfbeSBarry Smith extern PetscErrorCode PetscOptionsHasName(const char[],const char[],PetscBool *); 10ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsHasName,(const char b[],PetscBool *f),(PETSC_NULL,b,f)) 117087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetInt(const char[],const char [],PetscInt *,PetscBool *); 12ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetInt,(const char b[],PetscInt *i,PetscBool *f),(PETSC_NULL,b,i,f)) 137087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetBool(const char[],const char [],PetscBool *,PetscBool *); 14acfcf0e5SJed Brown PetscPolymorphicSubroutine(PetscOptionsGetBool,(const char b[],PetscBool *i,PetscBool *f),(PETSC_NULL,b,i,f)) 157087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetReal(const char[],const char[],PetscReal *,PetscBool *); 16ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetReal,(const char b[],PetscReal *i,PetscBool *f),(PETSC_NULL,b,i,f)) 177087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetScalar(const char[],const char[],PetscScalar *,PetscBool *); 18ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetScalar,(const char b[],PetscScalar i[],PetscBool *f),(PETSC_NULL,b,i,f)) 197087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetIntArray(const char[],const char[],PetscInt[],PetscInt *,PetscBool *); 20ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetIntArray,(const char b[],PetscInt i[],PetscInt *ii,PetscBool *f),(PETSC_NULL,b,i,ii,f)) 217087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetRealArray(const char[],const char[],PetscReal[],PetscInt *,PetscBool *); 22ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetRealArray,(const char b[],PetscReal i[],PetscInt *ii,PetscBool *f),(PETSC_NULL,b,i,ii,f)) 237087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetBoolArray(const char[],const char[],PetscBool [],PetscInt *,PetscBool *); 24acfcf0e5SJed Brown PetscPolymorphicSubroutine(PetscOptionsGetBoolArray,(const char b[],PetscBool i[],PetscInt *ii,PetscBool *f),(PETSC_NULL,b,i,ii,f)) 257087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetString(const char[],const char[],char[],size_t,PetscBool *); 26ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetString,(const char b[],char i[],size_t s,PetscBool *f),(PETSC_NULL,b,i,s,f)) 277087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetStringArray(const char[],const char[],char*[],PetscInt*,PetscBool *); 28ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetStringArray,(const char b[],char *i[],PetscInt *ii,PetscBool *f),(PETSC_NULL,b,i,ii,f)) 297087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetEList(const char[],const char[],const char*const*,PetscInt,PetscInt*,PetscBool *); 307087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetEnum(const char[],const char[],const char*const*,PetscEnum*,PetscBool *); 317087cfbeSBarry Smith extern PetscErrorCode PetscOptionsValidKey(const char[],PetscBool *); 323a3b2205SBarry Smith 337087cfbeSBarry Smith extern PetscErrorCode PetscOptionsSetAlias(const char[],const char[]); 347087cfbeSBarry Smith extern PetscErrorCode PetscOptionsSetValue(const char[],const char[]); 357087cfbeSBarry Smith extern PetscErrorCode PetscOptionsClearValue(const char[]); 363a3b2205SBarry Smith 377582186dSLisandro Dalcin extern PetscErrorCode PetscOptionsAllUsed(PetscInt*); 387087cfbeSBarry Smith extern PetscErrorCode PetscOptionsLeft(void); 3988c29154SBarry Smith extern PetscErrorCode PetscOptionsView(PetscViewer); 404b0e389bSBarry Smith 417087cfbeSBarry Smith extern PetscErrorCode PetscOptionsCreate(void); 427087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInsert(int*,char ***,const char[]); 437087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInsertFile(MPI_Comm,const char[],PetscBool ); 44*3bcbd388SSean Farley #if defined(PETSC_HAVE_YAML) 45*3bcbd388SSean Farley extern PetscErrorCode PetscOptionsInsertFile_YAML(MPI_Comm,const char[],PetscBool); 46*3bcbd388SSean Farley #endif 477087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInsertString(const char[]); 487087cfbeSBarry Smith extern PetscErrorCode PetscOptionsDestroy(void); 497087cfbeSBarry Smith extern PetscErrorCode PetscOptionsClear(void); 507087cfbeSBarry Smith extern PetscErrorCode PetscOptionsPrefixPush(const char[]); 517087cfbeSBarry Smith extern PetscErrorCode PetscOptionsPrefixPop(void); 525d0dffe5SBarry Smith 537087cfbeSBarry Smith extern PetscErrorCode PetscOptionsReject(const char[],const char[]); 547087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetAll(char*[]); 555d0dffe5SBarry Smith 567087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscBool *); 577087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToInt(const char[],PetscInt*); 587087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToReal(const char[],PetscReal*); 597087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToBool(const char[],PetscBool*); 602e8a6d31SBarry Smith 61c2efdce3SBarry Smith extern PetscErrorCode PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void**)); 627087cfbeSBarry Smith extern PetscErrorCode PetscOptionsMonitorCancel(void); 637087cfbeSBarry Smith extern PetscErrorCode PetscOptionsMonitorDefault(const char[], const char[], void *); 64081c24baSBoyana Norris 657087cfbeSBarry Smith extern PetscBool PetscOptionsPublish; 667087cfbeSBarry Smith extern PetscInt PetscOptionsPublishCount; 6730de9b25SBarry Smith 6830de9b25SBarry Smith /*MC 6930de9b25SBarry Smith PetscOptionsBegin - Begins a set of queries on the options database that are related and should be 7030de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 7130de9b25SBarry Smith 72d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 7330de9b25SBarry Smith 7430de9b25SBarry Smith Collective on MPI_Comm 7530de9b25SBarry Smith 7630de9b25SBarry Smith Input Parameters: 7730de9b25SBarry Smith + comm - communicator that shares GUI 7830de9b25SBarry Smith . prefix - options prefix for all options displayed on window 7930de9b25SBarry Smith . title - short descriptive text, for example "Krylov Solver Options" 8030de9b25SBarry Smith - mansec - section of manual pages for options, for example KSP 8130de9b25SBarry Smith 8230de9b25SBarry Smith Level: intermediate 8330de9b25SBarry Smith 8430de9b25SBarry Smith Notes: Needs to be ended by a call the PetscOptionsEnd() 8530de9b25SBarry Smith Can add subheadings with PetscOptionsHead() 8630de9b25SBarry Smith 87aee2cecaSBarry Smith Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -options_gui. When PetscOptionsPublish is set the 88aee2cecaSBarry Smith $ loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise 89aee2cecaSBarry Smith $ the loop is run ONCE with a PetscOptionsPublishCount of 1. 90aee2cecaSBarry Smith $ = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc 91aee2cecaSBarry Smith $ = 0 : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options 92c8e70145SBarry Smith $ database updated updated with user changes; PetscOptionsGetInt() etc are also called 93c8e70145SBarry Smith $ = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and 94c8e70145SBarry Smith $ default values are printed if -help was given. 95538aa990SBarry Smith $ When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1) 96538aa990SBarry Smith $ and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of 97538aa990SBarry Smith $ options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never 98538aa990SBarry Smith $ currently set. 99aee2cecaSBarry Smith 100aee2cecaSBarry Smith 10130de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 102acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 103acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 10430de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 10530de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 106acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 10730de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 10830de9b25SBarry Smith 10930de9b25SBarry Smith M*/ 110b0a32e0cSBarry Smith #define PetscOptionsBegin(comm,prefix,mess,sec) 0; {\ 111b0a32e0cSBarry Smith for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\ 1127c307921SBarry Smith PetscErrorCode _5_ierr = PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr); 11330de9b25SBarry Smith 11430de9b25SBarry Smith /*MC 11530de9b25SBarry Smith PetscOptionsEnd - Ends a set of queries on the options database that are related and should be 11630de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 11730de9b25SBarry Smith 11830de9b25SBarry Smith Collective on the MPI_Comm used in PetscOptionsBegin() 11930de9b25SBarry Smith 120d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsEnd(void) 12130de9b25SBarry Smith 12230de9b25SBarry Smith Level: intermediate 12330de9b25SBarry Smith 12430de9b25SBarry Smith Notes: Needs to be preceded by a call to PetscOptionsBegin() 12530de9b25SBarry Smith 12630de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 127acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 128acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 12930de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 13030de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 131acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 13230de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 13330de9b25SBarry Smith 13430de9b25SBarry Smith M*/ 135ef66eb69SBarry Smith #define PetscOptionsEnd() _5_ierr = PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}} 13630de9b25SBarry Smith 1377087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]); 1387087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEnd_Private(void); 1397087cfbeSBarry Smith extern PetscErrorCode PetscOptionsHead(const char[]); 14030de9b25SBarry Smith 14130de9b25SBarry Smith /*MC 14230de9b25SBarry Smith PetscOptionsTail - Ends a section of options begun with PetscOptionsHead() 14330de9b25SBarry Smith See, for example, KSPSetFromOptions_GMRES(). 14430de9b25SBarry Smith 14530de9b25SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 14630de9b25SBarry Smith 147d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsTail(void) 14830de9b25SBarry Smith 14930de9b25SBarry Smith Level: intermediate 15030de9b25SBarry Smith 15130de9b25SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 15230de9b25SBarry Smith 15330de9b25SBarry Smith Must be preceded by a call to PetscOptionsHead() in the same function. 15430de9b25SBarry Smith 155b52f573bSBarry Smith This needs to be used only if the code below PetscOptionsTail() can be run ONLY once. 156b52f573bSBarry Smith See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit 157b52f573bSBarry Smith from the function. 158b52f573bSBarry Smith 159b52f573bSBarry Smith This is only for use with the PETSc options GUI; which does not currently exist. 160b52f573bSBarry Smith 16130de9b25SBarry Smith Concepts: options database^subheading 16230de9b25SBarry Smith 16330de9b25SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 164acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 16530de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 16630de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 167acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1689dcbbd2bSBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum() 16930de9b25SBarry Smith M*/ 170b0a32e0cSBarry Smith #define PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);} 171186905e3SBarry Smith 1727087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEnum(const char[],const char[],const char[],const char *const*,PetscEnum,PetscEnum*,PetscBool *); 1737087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscBool *); 1747087cfbeSBarry Smith extern PetscErrorCode PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscBool *); 1757087cfbeSBarry Smith extern PetscErrorCode PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscBool *); 1767087cfbeSBarry Smith extern PetscErrorCode PetscOptionsName(const char[],const char[],const char[],PetscBool *); 1777087cfbeSBarry Smith extern PetscErrorCode PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscBool *); 1787087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBool(const char[],const char[],const char[],PetscBool ,PetscBool *,PetscBool *); 1797087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroupBegin(const char[],const char[],const char[],PetscBool *); 1807087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroup(const char[],const char[],const char[],PetscBool *); 1817087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroupEnd(const char[],const char[],const char[],PetscBool *); 1827087cfbeSBarry Smith extern PetscErrorCode PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],size_t,PetscBool *); 1837087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEList(const char[],const char[],const char[],const char*const*,PetscInt,const char[],PetscInt*,PetscBool *); 1847087cfbeSBarry Smith extern PetscErrorCode PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscBool *); 1857087cfbeSBarry Smith extern PetscErrorCode PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscBool *); 1867087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscBool *); 1877087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolArray(const char[],const char[],const char[],PetscBool [],PetscInt*,PetscBool *); 188e9fa29b7SSatish Balay 1897087cfbeSBarry Smith extern PetscErrorCode PetscOptionsSetFromOptions(void); 1907087cfbeSBarry Smith extern PetscErrorCode PetscOptionsAMSDestroy(void); 191e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 192f8d0b74dSMatthew Knepley 193e26ddf31SBarry Smith /* 194e26ddf31SBarry Smith See manual page for PetscOptionsBegin() 195e26ddf31SBarry Smith */ 1961ae3d29cSBarry Smith typedef enum {OPTION_INT,OPTION_LOGICAL,OPTION_REAL,OPTION_LIST,OPTION_STRING,OPTION_REAL_ARRAY,OPTION_HEAD,OPTION_INT_ARRAY,OPTION_ELIST,OPTION_LOGICAL_ARRAY,OPTION_STRING_ARRAY} PetscOptionType; 1976e655a9bSJed Brown typedef struct _n_PetscOptions* PetscOptions; 1986e655a9bSJed Brown struct _n_PetscOptions { 199f8d0b74dSMatthew Knepley char *option; 200f8d0b74dSMatthew Knepley char *text; 2013cc1e11dSBarry Smith void *data; /* used to hold the default value and then any value it is changed to by GUI */ 2023cc1e11dSBarry Smith PetscFList flist; /* used for available values for PetscOptionsList() */ 2031ae3d29cSBarry Smith const char *const *list; /* used for available values for PetscOptionsEList() */ 2041ae3d29cSBarry Smith char nlist; /* number of entries in list */ 205f8d0b74dSMatthew Knepley char *man; 2063cc1e11dSBarry Smith size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */ 207ace3abfcSBarry Smith PetscBool set; /* the user has changed this value in the GUI */ 208e3ed6ec8SBarry Smith PetscOptionType type; 209f8d0b74dSMatthew Knepley PetscOptions next; 2101bc75a8dSBarry Smith char *pman; 21171f08665SBarry Smith void *edata; 212f8d0b74dSMatthew Knepley }; 213f8d0b74dSMatthew Knepley 214f8d0b74dSMatthew Knepley typedef struct { 215f8d0b74dSMatthew Knepley PetscOptions next; 2161bc75a8dSBarry Smith char *prefix,*pprefix; 217f8d0b74dSMatthew Knepley char *title; 218f8d0b74dSMatthew Knepley MPI_Comm comm; 219ace3abfcSBarry Smith PetscBool printhelp,changedmethod,alreadyprinted; 220f8d0b74dSMatthew Knepley } PetscOptionsObjectType; 2213a3b2205SBarry Smith #endif 222