DUNE-FEM (unstable)
Container for User Specified Parameters. More...
#include <dune/fem/io/parameter.hh>
Static Public Member Functions | |
static void | append (int &argc, char **argv) |
add parameters from the command line RangeType gRight; More... | |
static void | append (const std::string &key, const std::string &value, const bool force=false) |
add a single parameter to the container More... | |
template<class NumberType > | |
static void | append (const std::string &key, const NumberType &value, const bool force=false) |
add a single parameter to the container More... | |
static void | append (const std::string &filename) |
add parameters from a file to the container More... | |
static void | appendDGF (const std::string &filename) |
add parameters from a DGF file to the container More... | |
static bool | exists (const std::string &key) |
find out, whether a parameter is defined in the container More... | |
template<class T > | |
static void | get (const std::string &key, T &value) |
get a mandatory parameter from the container More... | |
template<class T > | |
static void | get (const std::string &key, const T &defaultValue, T &value) |
get an optional parameter from the container More... | |
static void | get (const std::string &key, const char *defaultValue, std::string &value) |
get an optional parameter from the container special case for string More... | |
template<class T , class Validator > | |
static void | getValid (const std::string &key, const Validator &validator, T &value) |
get a mandatory parameter from the container More... | |
template<class T , class Validator > | |
static void | getValid (const std::string &key, const T &defaultValue, const Validator &validator, T &value) |
get an optional parameter from the container More... | |
template<class T > | |
static T | getValue (const std::string &key) |
get a mandatory parameter from the container More... | |
template<class T > | |
static T | getValue (const std::string &key, const T &defaultValue) |
get an optional parameter from the container More... | |
template<class T , class Validator > | |
static T | getValidValue (const std::string &key, const Validator &validator) |
get an optional parameter from the container More... | |
template<class T , class Validator > | |
static T | getValidValue (const std::string &key, const T &defaultValue, const Validator &validator) |
get an optional parameter from the container More... | |
static std::string | commonOutputPath () |
obtain common output path More... | |
static std::string | outputPath () |
obtain unique output path for this process More... | |
static std::string | commonInputPath () |
obtain common input path More... | |
static bool | verbose () |
obtain the cached value for fem.verbose with default verbosity level 2 | |
static bool | verbose (const int level) |
obtain the cached value for fem.verbose | |
static void | write (const std::string &filename, const std::string &fileextension="", bool writeAll=true) |
write the parameter database to a file More... | |
static void | write (std::ostream &out, bool writeAll=true) |
write the parameter database to a stream More... | |
Static Protected Member Functions | |
static void | write (const std::string &path, const std::string &filename, const std::string &fileextension, bool writeAll=true) |
write the parameter database to a file More... | |
Detailed Description
Container for User Specified Parameters.
The class Parameter provides parameters collected from given parameter files or the command line in a unified and easy to use way.
This class adheres to the singleton concept, i.e., all methods are static and internally use a single instance of this object to store all data.
Member Function Documentation
◆ append() [1/4]
|
inlinestatic |
add parameters from a file to the container
- Parameters
-
[in] filename name of the file containing the parameters
◆ append() [2/4]
|
inlinestatic |
add a single parameter to the container
- Parameters
-
[in] key key of the parameter to add [in] value value of the parameter to add
◆ append() [3/4]
|
inlinestatic |
add a single parameter to the container
- Parameters
-
[in] key key of the parameter to add [in] value value of the parameter to add
◆ append() [4/4]
|
inlinestatic |
add parameters from the command line RangeType gRight;
This mehtod adds all parameters (strings containing a colon) in the command line to the container. The parameters are then removed from the command line.
- Parameters
-
[in] argc number of arguments (as given to main) [in] argv vector of arguments (as given to main)
◆ appendDGF()
|
inlinestatic |
add parameters from a DGF file to the container
Parameters can also be read from a DGF file containing a 'FemParameter' block.
- Parameters
-
[in] filename name of the DGF file containing the parameters
◆ commonInputPath()
|
inlinestatic |
obtain common input path
This common input path could for example be used for the determination of the location of parameter and grid files
- Returns
- value of parameter 'fem.input.prefix', which defaults to '.'.
◆ commonOutputPath()
|
inlinestatic |
obtain common output path
For parallel jobs you need two different output paths:
- Data common to all processes should be written to commonOutputPath(). Only one process (i.e., rank 0) should write this data.
- Data unique to each process should be written to outputPath(). Each process should write this data.
- Returns
- value of parameter 'fem.prefix', which defaults to '.'.
Referenced by outputPath(), Dune::Fem::IOInterface::readPath(), and write().
◆ exists()
|
inlinestatic |
find out, whether a parameter is defined in the container
- Parameters
-
[in] key name of the parameter to check
- Returns
- true, if the parameter is found in the container, false otherwise
◆ get() [1/3]
|
inlinestatic |
get an optional parameter from the container special case for string
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] defaultValue default value for this parameter [out] value value of the parameter
◆ get() [2/3]
|
inlinestatic |
get an optional parameter from the container
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] defaultValue default value for this parameter [out] value value of the parameter
◆ get() [3/3]
|
inlinestatic |
get a mandatory parameter from the container
- Note
- This method throws an exception, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [out] value value of the parameter
◆ getValid() [1/2]
|
inlinestatic |
get an optional parameter from the container
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] defaultValue default value for this parameter [in] validator validator for the parameter value [out] value value of the parameter
◆ getValid() [2/2]
|
inlinestatic |
get a mandatory parameter from the container
- Note
- This method throws an exception, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] validator validator for the parameter value [out] value value of the parameter
◆ getValidValue() [1/2]
|
inlinestatic |
get an optional parameter from the container
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] defaultValue default value for this parameter [in] validator validator for the parameter value
- Returns
- value of the parameter
◆ getValidValue() [2/2]
|
inlinestatic |
get an optional parameter from the container
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] validator validator for the parameter value
- Returns
- value of the parameter
◆ getValue() [1/2]
|
inlinestatic |
get a mandatory parameter from the container
- Note
- This method throws an exception, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get
- Returns
- value of the parameter
◆ getValue() [2/2]
|
inlinestatic |
get an optional parameter from the container
- Note
- This method returns a default value, if the parameter cannot be found.
- Parameters
-
[in] key name of the parameter to get [in] defaultValue default value for this parameter
- Returns
- value of the parameter
◆ outputPath()
|
inlinestatic |
obtain unique output path for this process
For parallel jobs you need two different output paths:
- Data common to all processes should be written to commonOutputPath(). Only one process (i.e., rank 0) should write this data.
- Data unique to each process should be written to outputPath(). Each process should write this data.
- Returns
- <prefix>/p<rank>, where
- <prefix> denotes the value of 'fem.prefix', which defaults to '.',
- <rank> denots the this processes rank.
References commonOutputPath().
◆ write() [1/3]
|
inlinestatic |
write the parameter database to a file
This method writes paramters to the given file. If the second parameter is true all parameters are written; otherwise only used parameters which do not coincide with the default value are written.
- Note
- This method is safe for parallel jobs. Parameters are only written on rank 0.
- Parameters
-
[in] filename name of the file to store the parameters in; prefix() is used. [in] fileextension file extension if you want to have time stemps in the log files, ! must contain the "." dot for fileextensions ! [in] writeAll default is true
References commonOutputPath(), and write().
Referenced by write().
◆ write() [2/3]
|
inlinestaticprotected |
write the parameter database to a file
This method writes paramters to the given file. If the second parameter is true all parameters are written; otherwise only used parameters which do not coincide with the default value are written.
- Note
- This method is safe for parallel jobs. Parameters are only written on rank 0.
- Parameters
-
[in] path path where filename is stored (for parallel writing) [in] filename name of the file to store the parameters in; prefix() is used. [in] fileextension chosen fileextension [in] writeAll default is true
References write().
◆ write() [3/3]
|
inlinestatic |
write the parameter database to a stream
This method writes paramters to the given stream. If the second parameter is true all parameters are written; otherwise only used parameters which do not coincide with the default value are written.
- Note
- This method is not safe for parallel jobs. Parameters are written on all ranks.
- Parameters
-
[in] out stream for the parameters. [in] writeAll default is true
The documentation for this class was generated from the following file:
- dune/fem/io/parameter.hh