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 377087cfbeSBarry Smith extern PetscErrorCode PetscOptionsAllUsed(int*); 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 ); 447087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInsertString(const char[]); 457087cfbeSBarry Smith extern PetscErrorCode PetscOptionsDestroy(void); 467087cfbeSBarry Smith extern PetscErrorCode PetscOptionsClear(void); 477087cfbeSBarry Smith extern PetscErrorCode PetscOptionsPrefixPush(const char[]); 487087cfbeSBarry Smith extern PetscErrorCode PetscOptionsPrefixPop(void); 495d0dffe5SBarry Smith 507087cfbeSBarry Smith extern PetscErrorCode PetscOptionsReject(const char[],const char[]); 517087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetAll(char*[]); 525d0dffe5SBarry Smith 537087cfbeSBarry Smith extern PetscErrorCode PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscBool *); 547087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToInt(const char[],PetscInt*); 557087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToReal(const char[],PetscReal*); 567087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringToBool(const char[],PetscBool*); 572e8a6d31SBarry Smith 58*c2efdce3SBarry Smith extern PetscErrorCode PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void**)); 597087cfbeSBarry Smith extern PetscErrorCode PetscOptionsMonitorCancel(void); 607087cfbeSBarry Smith extern PetscErrorCode PetscOptionsMonitorDefault(const char[], const char[], void *); 61081c24baSBoyana Norris 627087cfbeSBarry Smith extern PetscBool PetscOptionsPublish; 637087cfbeSBarry Smith extern PetscInt PetscOptionsPublishCount; 6430de9b25SBarry Smith 6530de9b25SBarry Smith /*MC 6630de9b25SBarry Smith PetscOptionsBegin - Begins a set of queries on the options database that are related and should be 6730de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 6830de9b25SBarry Smith 69d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 7030de9b25SBarry Smith 7130de9b25SBarry Smith Collective on MPI_Comm 7230de9b25SBarry Smith 7330de9b25SBarry Smith Input Parameters: 7430de9b25SBarry Smith + comm - communicator that shares GUI 7530de9b25SBarry Smith . prefix - options prefix for all options displayed on window 7630de9b25SBarry Smith . title - short descriptive text, for example "Krylov Solver Options" 7730de9b25SBarry Smith - mansec - section of manual pages for options, for example KSP 7830de9b25SBarry Smith 7930de9b25SBarry Smith Level: intermediate 8030de9b25SBarry Smith 8130de9b25SBarry Smith Notes: Needs to be ended by a call the PetscOptionsEnd() 8230de9b25SBarry Smith Can add subheadings with PetscOptionsHead() 8330de9b25SBarry Smith 84aee2cecaSBarry Smith Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -options_gui. When PetscOptionsPublish is set the 85aee2cecaSBarry Smith $ loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise 86aee2cecaSBarry Smith $ the loop is run ONCE with a PetscOptionsPublishCount of 1. 87aee2cecaSBarry Smith $ = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc 88aee2cecaSBarry Smith $ = 0 : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options 89c8e70145SBarry Smith $ database updated updated with user changes; PetscOptionsGetInt() etc are also called 90c8e70145SBarry Smith $ = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and 91c8e70145SBarry Smith $ default values are printed if -help was given. 92538aa990SBarry Smith $ When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1) 93538aa990SBarry Smith $ and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of 94538aa990SBarry Smith $ options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never 95538aa990SBarry Smith $ currently set. 96aee2cecaSBarry Smith 97aee2cecaSBarry Smith 9830de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 99acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 100acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 10130de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 10230de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 103acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 10430de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 10530de9b25SBarry Smith 10630de9b25SBarry Smith M*/ 107b0a32e0cSBarry Smith #define PetscOptionsBegin(comm,prefix,mess,sec) 0; {\ 108b0a32e0cSBarry Smith for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\ 1097c307921SBarry Smith PetscErrorCode _5_ierr = PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr); 11030de9b25SBarry Smith 11130de9b25SBarry Smith /*MC 11230de9b25SBarry Smith PetscOptionsEnd - Ends a set of queries on the options database that are related and should be 11330de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 11430de9b25SBarry Smith 11530de9b25SBarry Smith Collective on the MPI_Comm used in PetscOptionsBegin() 11630de9b25SBarry Smith 117d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsEnd(void) 11830de9b25SBarry Smith 11930de9b25SBarry Smith Level: intermediate 12030de9b25SBarry Smith 12130de9b25SBarry Smith Notes: Needs to be preceded by a call to PetscOptionsBegin() 12230de9b25SBarry Smith 12330de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 124acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 125acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 12630de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 12730de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 128acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 12930de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 13030de9b25SBarry Smith 13130de9b25SBarry Smith M*/ 132ef66eb69SBarry Smith #define PetscOptionsEnd() _5_ierr = PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}} 13330de9b25SBarry Smith 1347087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]); 1357087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEnd_Private(void); 1367087cfbeSBarry Smith extern PetscErrorCode PetscOptionsHead(const char[]); 13730de9b25SBarry Smith 13830de9b25SBarry Smith /*MC 13930de9b25SBarry Smith PetscOptionsTail - Ends a section of options begun with PetscOptionsHead() 14030de9b25SBarry Smith See, for example, KSPSetFromOptions_GMRES(). 14130de9b25SBarry Smith 14230de9b25SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 14330de9b25SBarry Smith 144d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsTail(void) 14530de9b25SBarry Smith 14630de9b25SBarry Smith Level: intermediate 14730de9b25SBarry Smith 14830de9b25SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 14930de9b25SBarry Smith 15030de9b25SBarry Smith Must be preceded by a call to PetscOptionsHead() in the same function. 15130de9b25SBarry Smith 152b52f573bSBarry Smith This needs to be used only if the code below PetscOptionsTail() can be run ONLY once. 153b52f573bSBarry Smith See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit 154b52f573bSBarry Smith from the function. 155b52f573bSBarry Smith 156b52f573bSBarry Smith This is only for use with the PETSc options GUI; which does not currently exist. 157b52f573bSBarry Smith 15830de9b25SBarry Smith Concepts: options database^subheading 15930de9b25SBarry Smith 16030de9b25SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 161acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 16230de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 16330de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 164acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1659dcbbd2bSBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum() 16630de9b25SBarry Smith M*/ 167b0a32e0cSBarry Smith #define PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);} 168186905e3SBarry Smith 1697087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEnum(const char[],const char[],const char[],const char *const*,PetscEnum,PetscEnum*,PetscBool *); 1707087cfbeSBarry Smith extern PetscErrorCode PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscBool *); 1717087cfbeSBarry Smith extern PetscErrorCode PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscBool *); 1727087cfbeSBarry Smith extern PetscErrorCode PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscBool *); 1737087cfbeSBarry Smith extern PetscErrorCode PetscOptionsName(const char[],const char[],const char[],PetscBool *); 1747087cfbeSBarry Smith extern PetscErrorCode PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscBool *); 1757087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBool(const char[],const char[],const char[],PetscBool ,PetscBool *,PetscBool *); 1767087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroupBegin(const char[],const char[],const char[],PetscBool *); 1777087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroup(const char[],const char[],const char[],PetscBool *); 1787087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolGroupEnd(const char[],const char[],const char[],PetscBool *); 1797087cfbeSBarry Smith extern PetscErrorCode PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],size_t,PetscBool *); 1807087cfbeSBarry Smith extern PetscErrorCode PetscOptionsEList(const char[],const char[],const char[],const char*const*,PetscInt,const char[],PetscInt*,PetscBool *); 1817087cfbeSBarry Smith extern PetscErrorCode PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscBool *); 1827087cfbeSBarry Smith extern PetscErrorCode PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscBool *); 1837087cfbeSBarry Smith extern PetscErrorCode PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscBool *); 1847087cfbeSBarry Smith extern PetscErrorCode PetscOptionsBoolArray(const char[],const char[],const char[],PetscBool [],PetscInt*,PetscBool *); 185e9fa29b7SSatish Balay 1867087cfbeSBarry Smith extern PetscErrorCode PetscOptionsSetFromOptions(void); 1877087cfbeSBarry Smith extern PetscErrorCode PetscOptionsAMSDestroy(void); 188e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 189f8d0b74dSMatthew Knepley 190e26ddf31SBarry Smith /* 191e26ddf31SBarry Smith See manual page for PetscOptionsBegin() 192e26ddf31SBarry Smith */ 1931ae3d29cSBarry 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; 1946e655a9bSJed Brown typedef struct _n_PetscOptions* PetscOptions; 1956e655a9bSJed Brown struct _n_PetscOptions { 196f8d0b74dSMatthew Knepley char *option; 197f8d0b74dSMatthew Knepley char *text; 1983cc1e11dSBarry Smith void *data; /* used to hold the default value and then any value it is changed to by GUI */ 1993cc1e11dSBarry Smith PetscFList flist; /* used for available values for PetscOptionsList() */ 2001ae3d29cSBarry Smith const char *const *list; /* used for available values for PetscOptionsEList() */ 2011ae3d29cSBarry Smith char nlist; /* number of entries in list */ 202f8d0b74dSMatthew Knepley char *man; 2033cc1e11dSBarry Smith size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */ 204ace3abfcSBarry Smith PetscBool set; /* the user has changed this value in the GUI */ 205e3ed6ec8SBarry Smith PetscOptionType type; 206f8d0b74dSMatthew Knepley PetscOptions next; 2071bc75a8dSBarry Smith char *pman; 20871f08665SBarry Smith void *edata; 209f8d0b74dSMatthew Knepley }; 210f8d0b74dSMatthew Knepley 211f8d0b74dSMatthew Knepley typedef struct { 212f8d0b74dSMatthew Knepley PetscOptions next; 2131bc75a8dSBarry Smith char *prefix,*pprefix; 214f8d0b74dSMatthew Knepley char *title; 215f8d0b74dSMatthew Knepley MPI_Comm comm; 216ace3abfcSBarry Smith PetscBool printhelp,changedmethod,alreadyprinted; 217f8d0b74dSMatthew Knepley } PetscOptionsObjectType; 2183a3b2205SBarry Smith #endif 219