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 9ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsHasName(const char[],const char[],PetscBool *); 10ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsHasName,(const char b[],PetscBool *f),(PETSC_NULL,b,f)) 11ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetInt(const char[],const char [],PetscInt *,PetscBool *); 12ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetInt,(const char b[],PetscInt *i,PetscBool *f),(PETSC_NULL,b,i,f)) 13*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetBool(const char[],const char [],PetscBool *,PetscBool *); 14*acfcf0e5SJed Brown PetscPolymorphicSubroutine(PetscOptionsGetBool,(const char b[],PetscBool *i,PetscBool *f),(PETSC_NULL,b,i,f)) 15ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetReal(const char[],const char[],PetscReal *,PetscBool *); 16ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetReal,(const char b[],PetscReal *i,PetscBool *f),(PETSC_NULL,b,i,f)) 17ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetScalar(const char[],const char[],PetscScalar *,PetscBool *); 18ace3abfcSBarry Smith PetscPolymorphicSubroutine(PetscOptionsGetScalar,(const char b[],PetscScalar i[],PetscBool *f),(PETSC_NULL,b,i,f)) 19ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT 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)) 21ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT 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)) 23*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetBoolArray(const char[],const char[],PetscBool [],PetscInt *,PetscBool *); 24*acfcf0e5SJed Brown PetscPolymorphicSubroutine(PetscOptionsGetBoolArray,(const char b[],PetscBool i[],PetscInt *ii,PetscBool *f),(PETSC_NULL,b,i,ii,f)) 25ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT 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)) 27ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT 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)) 29ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetEList(const char[],const char[],const char*const*,PetscInt,PetscInt*,PetscBool *); 30ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetEnum(const char[],const char[],const char*const*,PetscEnum*,PetscBool *); 31ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsValidKey(const char[],PetscBool *); 323a3b2205SBarry Smith 338738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsSetAlias(const char[],const char[]); 348738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsSetValue(const char[],const char[]); 358738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsClearValue(const char[]); 363a3b2205SBarry Smith 378738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsAllUsed(int*); 388738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsLeft(void); 398738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsPrint(FILE *); 404b0e389bSBarry Smith 418738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsCreate(void); 428738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsInsert(int*,char ***,const char[]); 43ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsInsertFile(MPI_Comm,const char[],PetscBool ); 448738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsInsertString(const char[]); 458738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsDestroy(void); 468738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsClear(void); 478738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsPrefixPush(const char[]); 488738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsPrefixPop(void); 495d0dffe5SBarry Smith 508738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsReject(const char[],const char[]); 518738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetAll(char*[]); 525d0dffe5SBarry Smith 53ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsGetenv(MPI_Comm,const char[],char[],size_t,PetscBool *); 548738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsAtoi(const char[],PetscInt*); 558738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsAtod(const char[],PetscReal*); 562e8a6d31SBarry Smith 578738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsMonitorSet(PetscErrorCode (*)(const char[], const char[], void*), void *, PetscErrorCode (*)(void*)); 588738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsMonitorCancel(void); 598738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsMonitorDefault(const char[], const char[], void *); 60081c24baSBoyana Norris 61ace3abfcSBarry Smith extern PETSCSYS_DLLEXPORT PetscBool PetscOptionsPublish; 628738c821SJed Brown extern PETSCSYS_DLLEXPORT PetscInt PetscOptionsPublishCount; 6330de9b25SBarry Smith 6430de9b25SBarry Smith /*MC 6530de9b25SBarry Smith PetscOptionsBegin - Begins a set of queries on the options database that are related and should be 6630de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 6730de9b25SBarry Smith 68d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsBegin(MPI_Comm comm,const char prefix[],const char title[],const char mansec[]) 6930de9b25SBarry Smith 7030de9b25SBarry Smith Collective on MPI_Comm 7130de9b25SBarry Smith 7230de9b25SBarry Smith Input Parameters: 7330de9b25SBarry Smith + comm - communicator that shares GUI 7430de9b25SBarry Smith . prefix - options prefix for all options displayed on window 7530de9b25SBarry Smith . title - short descriptive text, for example "Krylov Solver Options" 7630de9b25SBarry Smith - mansec - section of manual pages for options, for example KSP 7730de9b25SBarry Smith 7830de9b25SBarry Smith Level: intermediate 7930de9b25SBarry Smith 8030de9b25SBarry Smith Notes: Needs to be ended by a call the PetscOptionsEnd() 8130de9b25SBarry Smith Can add subheadings with PetscOptionsHead() 8230de9b25SBarry Smith 83aee2cecaSBarry Smith Developer notes: PetscOptionsPublish is set in PetscOptionsCheckInitial_Private() with -options_gui. When PetscOptionsPublish is set the 84aee2cecaSBarry Smith $ loop between PetscOptionsBegin() and PetscOptionsEnd() is run THREE times with PetscOptionsPublishCount of values -1,0,1 otherwise 85aee2cecaSBarry Smith $ the loop is run ONCE with a PetscOptionsPublishCount of 1. 86aee2cecaSBarry Smith $ = -1 : The PetscOptionsInt() etc just call the PetscOptionsGetInt() etc 87aee2cecaSBarry Smith $ = 0 : The GUI objects are created in PetscOptionsInt() etc and displayed in PetscOptionsEnd() and the options 88c8e70145SBarry Smith $ database updated updated with user changes; PetscOptionsGetInt() etc are also called 89c8e70145SBarry Smith $ = 1 : The PetscOptionsInt() etc again call the PetscOptionsGetInt() etc (possibly getting new values), in addition the help message and 90c8e70145SBarry Smith $ default values are printed if -help was given. 91538aa990SBarry Smith $ When PetscOptionsObject.changedmethod is set this causes PetscOptionsPublishCount to be reset to -2 (so in the next loop iteration it is -1) 92538aa990SBarry Smith $ and the whole process is repeated. This is to handle when, for example, the KSPType is changed thus changing the list of 93538aa990SBarry Smith $ options available so they need to be redisplayed so the user can change the. Chaning PetscOptionsObjects.changedmethod is never 94538aa990SBarry Smith $ currently set. 95aee2cecaSBarry Smith 96aee2cecaSBarry Smith 9730de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 98*acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 99*acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 10030de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 10130de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 102*acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 10330de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 10430de9b25SBarry Smith 10530de9b25SBarry Smith M*/ 106b0a32e0cSBarry Smith #define PetscOptionsBegin(comm,prefix,mess,sec) 0; {\ 107b0a32e0cSBarry Smith for (PetscOptionsPublishCount=(PetscOptionsPublish?-1:1); PetscOptionsPublishCount<2; PetscOptionsPublishCount++) {\ 1087c307921SBarry Smith PetscErrorCode _5_ierr = PetscOptionsBegin_Private(comm,prefix,mess,sec);CHKERRQ(_5_ierr); 10930de9b25SBarry Smith 11030de9b25SBarry Smith /*MC 11130de9b25SBarry Smith PetscOptionsEnd - Ends a set of queries on the options database that are related and should be 11230de9b25SBarry Smith displayed on the same window of a GUI that allows the user to set the options interactively. 11330de9b25SBarry Smith 11430de9b25SBarry Smith Collective on the MPI_Comm used in PetscOptionsBegin() 11530de9b25SBarry Smith 116d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsEnd(void) 11730de9b25SBarry Smith 11830de9b25SBarry Smith Level: intermediate 11930de9b25SBarry Smith 12030de9b25SBarry Smith Notes: Needs to be preceded by a call to PetscOptionsBegin() 12130de9b25SBarry Smith 12230de9b25SBarry Smith .seealso: PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetInt(), 123*acfcf0e5SJed Brown PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool() 124*acfcf0e5SJed Brown PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsBool(), 12530de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 12630de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 127*acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 12830de9b25SBarry Smith PetscOptionsList(), PetscOptionsEList() 12930de9b25SBarry Smith 13030de9b25SBarry Smith M*/ 131ef66eb69SBarry Smith #define PetscOptionsEnd() _5_ierr = PetscOptionsEnd_Private();CHKERRQ(_5_ierr);}} 13230de9b25SBarry Smith 1338738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBegin_Private(MPI_Comm,const char[],const char[],const char[]); 1348738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsEnd_Private(void); 1358738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsHead(const char[]); 13630de9b25SBarry Smith 13730de9b25SBarry Smith /*MC 13830de9b25SBarry Smith PetscOptionsTail - Ends a section of options begun with PetscOptionsHead() 13930de9b25SBarry Smith See, for example, KSPSetFromOptions_GMRES(). 14030de9b25SBarry Smith 14130de9b25SBarry Smith Collective on the communicator passed in PetscOptionsBegin() 14230de9b25SBarry Smith 143d360dc6fSBarry Smith Synopsis: PetscErrorCode PetscOptionsTail(void) 14430de9b25SBarry Smith 14530de9b25SBarry Smith Level: intermediate 14630de9b25SBarry Smith 14730de9b25SBarry Smith Notes: Must be between a PetscOptionsBegin() and a PetscOptionsEnd() 14830de9b25SBarry Smith 14930de9b25SBarry Smith Must be preceded by a call to PetscOptionsHead() in the same function. 15030de9b25SBarry Smith 151b52f573bSBarry Smith This needs to be used only if the code below PetscOptionsTail() can be run ONLY once. 152b52f573bSBarry Smith See, for example, PCSetFromOptions_Composite(). This is a return(0) in it for early exit 153b52f573bSBarry Smith from the function. 154b52f573bSBarry Smith 155b52f573bSBarry Smith This is only for use with the PETSc options GUI; which does not currently exist. 156b52f573bSBarry Smith 15730de9b25SBarry Smith Concepts: options database^subheading 15830de9b25SBarry Smith 15930de9b25SBarry Smith .seealso: PetscOptionsGetInt(), PetscOptionsGetReal(), 160*acfcf0e5SJed Brown PetscOptionsHasName(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), 16130de9b25SBarry Smith PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHead(), 16230de9b25SBarry Smith PetscOptionsStringArray(),PetscOptionsRealArray(), PetscOptionsScalar(), 163*acfcf0e5SJed Brown PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), 1649dcbbd2bSBarry Smith PetscOptionsList(), PetscOptionsEList(), PetscOptionsEnum() 16530de9b25SBarry Smith M*/ 166b0a32e0cSBarry Smith #define PetscOptionsTail() 0; {if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);} 167186905e3SBarry Smith 168ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsEnum(const char[],const char[],const char[],const char *const*,PetscEnum,PetscEnum*,PetscBool *); 169ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsInt(const char[],const char[],const char[],PetscInt,PetscInt*,PetscBool *); 170ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsReal(const char[],const char[],const char[],PetscReal,PetscReal*,PetscBool *); 171ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsScalar(const char[],const char[],const char[],PetscScalar,PetscScalar*,PetscBool *); 172ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsName(const char[],const char[],const char[],PetscBool *); 173ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsString(const char[],const char[],const char[],const char[],char*,size_t,PetscBool *); 174*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBool(const char[],const char[],const char[],PetscBool ,PetscBool *,PetscBool *); 175*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBoolGroupBegin(const char[],const char[],const char[],PetscBool *); 176*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBoolGroup(const char[],const char[],const char[],PetscBool *); 177*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBoolGroupEnd(const char[],const char[],const char[],PetscBool *); 178ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsList(const char[],const char[],const char[],PetscFList,const char[],char[],size_t,PetscBool *); 179ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsEList(const char[],const char[],const char[],const char*const*,PetscInt,const char[],PetscInt*,PetscBool *); 180ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsRealArray(const char[],const char[],const char[],PetscReal[],PetscInt*,PetscBool *); 181ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsIntArray(const char[],const char[],const char[],PetscInt[],PetscInt*,PetscBool *); 182ace3abfcSBarry Smith EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsStringArray(const char[],const char[],const char[],char*[],PetscInt*,PetscBool *); 183*acfcf0e5SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsBoolArray(const char[],const char[],const char[],PetscBool [],PetscInt*,PetscBool *); 184e9fa29b7SSatish Balay 1858738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsSetFromOptions(void); 1868738c821SJed Brown EXTERN PetscErrorCode PETSCSYS_DLLEXPORT PetscOptionsAMSDestroy(void); 187e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 188f8d0b74dSMatthew Knepley 189e26ddf31SBarry Smith /* 190e26ddf31SBarry Smith See manual page for PetscOptionsBegin() 191e26ddf31SBarry Smith */ 1921ae3d29cSBarry 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; 1936e655a9bSJed Brown typedef struct _n_PetscOptions* PetscOptions; 1946e655a9bSJed Brown struct _n_PetscOptions { 195f8d0b74dSMatthew Knepley char *option; 196f8d0b74dSMatthew Knepley char *text; 1973cc1e11dSBarry Smith void *data; /* used to hold the default value and then any value it is changed to by GUI */ 1983cc1e11dSBarry Smith PetscFList flist; /* used for available values for PetscOptionsList() */ 1991ae3d29cSBarry Smith const char *const *list; /* used for available values for PetscOptionsEList() */ 2001ae3d29cSBarry Smith char nlist; /* number of entries in list */ 201f8d0b74dSMatthew Knepley char *man; 2023cc1e11dSBarry Smith size_t arraylength; /* number of entries in data in the case that it is an array (of PetscInt etc) */ 203ace3abfcSBarry Smith PetscBool set; /* the user has changed this value in the GUI */ 204e3ed6ec8SBarry Smith PetscOptionType type; 205f8d0b74dSMatthew Knepley PetscOptions next; 2061bc75a8dSBarry Smith char *pman; 20771f08665SBarry Smith void *edata; 208f8d0b74dSMatthew Knepley }; 209f8d0b74dSMatthew Knepley 210f8d0b74dSMatthew Knepley typedef struct { 211f8d0b74dSMatthew Knepley PetscOptions next; 2121bc75a8dSBarry Smith char *prefix,*pprefix; 213f8d0b74dSMatthew Knepley char *title; 214f8d0b74dSMatthew Knepley MPI_Comm comm; 215ace3abfcSBarry Smith PetscBool printhelp,changedmethod,alreadyprinted; 216f8d0b74dSMatthew Knepley } PetscOptionsObjectType; 2173a3b2205SBarry Smith #endif 218