dune-fem 2.12-git
Loading...
Searching...
No Matches
Dune::Fem::Parameter Class Reference

Container for User Specified Parameters. More...

#include <dune/fem/io/parameter.hh>

Static Public Member Functions

static ParameterContainercontainer ()
 
static auto & localParameterLog ()
 
static void append (int &argc, char **argv)
 add parameters from the command line RangeType gRight;
 
static void append (const std::string &key, const std::string &value, const bool force=false)
 add a single parameter to the container
 
template<class NumberType >
static void append (const std::string &key, const NumberType &value, const bool force=false)
 add a single parameter to the container
 
static void append (const std::string &filename)
 add parameters from a file to the container
 
static void appendDGF (const std::string &filename)
 add parameters from a DGF file to the container
 
static bool exists (const std::string &key)
 find out, whether a parameter is defined in the container
 
template<class T >
static void get (const std::string &key, T &value)
 get a mandatory parameter from the container
 
template<class T >
static void get (const std::string &key, const T &defaultValue, T &value)
 get an optional parameter from the container
 
static void get (const std::string &key, const char *defaultValue, std::string &value)
 get an optional parameter from the container special case for string
 
template<class T , class Validator >
static void getValid (const std::string &key, const Validator &validator, T &value)
 get a mandatory parameter from the container
 
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
 
template<class T >
static T getValue (const std::string &key)
 get a mandatory parameter from the container
 
template<class T >
static T getValue (const std::string &key, const T &defaultValue)
 get an optional parameter from the container
 
template<class T , class Validator >
static T getValidValue (const std::string &key, const Validator &validator)
 get an optional parameter from the container
 
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
 
template<int n>
static int getEnum (const std::string &key, const std::string(&values)[n])
 
template<int n>
static int getEnum (const std::string &key, const std::string(&values)[n], int defaultValue)
 
static int getEnum (const std::string &key, const std::vector< std::string > &values)
 
static int getEnum (const std::string &key, const std::vector< std::string > &values, int defaultValue)
 
static std::string commonOutputPath ()
 obtain common output path
 
static std::string outputPath ()
 obtain unique output path for this process
 
static std::string commonInputPath ()
 obtain common input path
 
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
 
static void write (std::ostream &out, bool writeAll=true)
 write the parameter database to a stream
 
static auto write ()
 

Static Public Attributes

static const int solverStatistics = ParameterContainerData::solverStatistics
 
static const int extendedStatistics = ParameterContainerData::extendedStatistics
 
static const int parameterOutput = ParameterContainerData::parameterOutput
 
static const int diagnosticsOutput = ParameterContainerData::diagnosticsOutput
 
static const int debugOutput = ParameterContainerData::debugOutput
 

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
 

Friends

class PersistenceManager
 

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]

static void Dune::Fem::Parameter::append ( const std::string filename)
inlinestatic

add parameters from a file to the container

Parameters
[in]filenamename of the file containing the parameters

◆ append() [2/4]

template<class NumberType >
static void Dune::Fem::Parameter::append ( const std::string key,
const NumberType &  value,
const bool  force = false 
)
inlinestatic

add a single parameter to the container

Parameters
[in]keykey of the parameter to add
[in]valuevalue of the parameter to add

◆ append() [3/4]

static void Dune::Fem::Parameter::append ( const std::string key,
const std::string value,
const bool  force = false 
)
inlinestatic

add a single parameter to the container

Parameters
[in]keykey of the parameter to add
[in]valuevalue of the parameter to add

◆ append() [4/4]

static void Dune::Fem::Parameter::append ( int &  argc,
char **  argv 
)
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]argcnumber of arguments (as given to main)
[in]argvvector of arguments (as given to main)

◆ appendDGF()

static void Dune::Fem::Parameter::appendDGF ( const std::string filename)
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]filenamename of the DGF file containing the parameters

◆ commonInputPath()

static std::string Dune::Fem::Parameter::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()

static std::string Dune::Fem::Parameter::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 '.'.

◆ container()

static ParameterContainer & Dune::Fem::Parameter::container ( )
inlinestatic

◆ exists()

static bool Dune::Fem::Parameter::exists ( const std::string key)
inlinestatic

find out, whether a parameter is defined in the container

Parameters
[in]keyname of the parameter to check
Returns
true, if the parameter is found in the container, false otherwise

◆ get() [1/3]

static void Dune::Fem::Parameter::get ( const std::string key,
const char *  defaultValue,
std::string value 
)
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]keyname of the parameter to get
[in]defaultValuedefault value for this parameter
[out]valuevalue of the parameter

◆ get() [2/3]

template<class T >
static void Dune::Fem::Parameter::get ( const std::string key,
const T &  defaultValue,
T &  value 
)
inlinestatic

get an optional parameter from the container

Note
This method returns a default value, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]defaultValuedefault value for this parameter
[out]valuevalue of the parameter

◆ get() [3/3]

template<class T >
static void Dune::Fem::Parameter::get ( const std::string key,
T &  value 
)
inlinestatic

get a mandatory parameter from the container

Note
This method throws an exception, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[out]valuevalue of the parameter

◆ getEnum() [1/4]

template<int n>
static int Dune::Fem::Parameter::getEnum ( const std::string key,
const std::string(&)  values[n] 
)
inlinestatic

◆ getEnum() [2/4]

template<int n>
static int Dune::Fem::Parameter::getEnum ( const std::string key,
const std::string(&)  values[n],
int  defaultValue 
)
inlinestatic

◆ getEnum() [3/4]

static int Dune::Fem::Parameter::getEnum ( const std::string key,
const std::vector< std::string > &  values 
)
inlinestatic

◆ getEnum() [4/4]

static int Dune::Fem::Parameter::getEnum ( const std::string key,
const std::vector< std::string > &  values,
int  defaultValue 
)
inlinestatic

◆ getValid() [1/2]

template<class T , class Validator >
static void Dune::Fem::Parameter::getValid ( const std::string key,
const T &  defaultValue,
const Validator &  validator,
T &  value 
)
inlinestatic

get an optional parameter from the container

Note
This method returns a default value, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]defaultValuedefault value for this parameter
[in]validatorvalidator for the parameter value
[out]valuevalue of the parameter

◆ getValid() [2/2]

template<class T , class Validator >
static void Dune::Fem::Parameter::getValid ( const std::string key,
const Validator &  validator,
T &  value 
)
inlinestatic

get a mandatory parameter from the container

Note
This method throws an exception, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]validatorvalidator for the parameter value
[out]valuevalue of the parameter

◆ getValidValue() [1/2]

template<class T , class Validator >
static T Dune::Fem::Parameter::getValidValue ( const std::string key,
const T &  defaultValue,
const Validator &  validator 
)
inlinestatic

get an optional parameter from the container

Note
This method returns a default value, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]defaultValuedefault value for this parameter
[in]validatorvalidator for the parameter value
Returns
value of the parameter

◆ getValidValue() [2/2]

template<class T , class Validator >
static T Dune::Fem::Parameter::getValidValue ( const std::string key,
const Validator &  validator 
)
inlinestatic

get an optional parameter from the container

Note
This method returns a default value, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]validatorvalidator for the parameter value
Returns
value of the parameter

◆ getValue() [1/2]

template<class T >
static T Dune::Fem::Parameter::getValue ( const std::string key)
inlinestatic

get a mandatory parameter from the container

Note
This method throws an exception, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
Returns
value of the parameter

◆ getValue() [2/2]

template<class T >
static T Dune::Fem::Parameter::getValue ( const std::string key,
const T &  defaultValue 
)
inlinestatic

get an optional parameter from the container

Note
This method returns a default value, if the parameter cannot be found.
Parameters
[in]keyname of the parameter to get
[in]defaultValuedefault value for this parameter
Returns
value of the parameter

◆ localParameterLog()

static auto & Dune::Fem::Parameter::localParameterLog ( )
inlinestatic

◆ outputPath()

std::string Dune::Fem::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.

◆ verbose() [1/2]

static bool Dune::Fem::Parameter::verbose ( )
inlinestatic

obtain the cached value for fem.verbose with default verbosity level 2

◆ verbose() [2/2]

static bool Dune::Fem::Parameter::verbose ( const int  level)
inlinestatic

obtain the cached value for fem.verbose

◆ write() [1/4]

static auto Dune::Fem::Parameter::write ( )
inlinestatic

◆ write() [2/4]

void Dune::Fem::Parameter::write ( const std::string filename,
const std::string fileextension = "",
bool  writeAll = true 
)
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]filenamename of the file to store the parameters in; prefix() is used.
[in]fileextensionfile extension if you want to have time stemps in the log files, ! must contain the "." dot for fileextensions !
[in]writeAlldefault is true

◆ write() [3/4]

void Dune::Fem::Parameter::write ( const std::string path,
const std::string filename,
const std::string fileextension,
bool  writeAll = true 
)
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]pathpath where filename is stored (for parallel writing)
[in]filenamename of the file to store the parameters in; prefix() is used.
[in]fileextensionchosen fileextension
[in]writeAlldefault is true

◆ write() [4/4]

static void Dune::Fem::Parameter::write ( std::ostream out,
bool  writeAll = true 
)
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]outstream for the parameters.
[in]writeAlldefault is true

Friends And Related Symbol Documentation

◆ PersistenceManager

friend class PersistenceManager
friend

Member Data Documentation

◆ debugOutput

const int Dune::Fem::Parameter::debugOutput = ParameterContainerData::debugOutput
static

◆ diagnosticsOutput

const int Dune::Fem::Parameter::diagnosticsOutput = ParameterContainerData::diagnosticsOutput
static

◆ extendedStatistics

const int Dune::Fem::Parameter::extendedStatistics = ParameterContainerData::extendedStatistics
static

◆ parameterOutput

const int Dune::Fem::Parameter::parameterOutput = ParameterContainerData::parameterOutput
static

◆ solverStatistics

const int Dune::Fem::Parameter::solverStatistics = ParameterContainerData::solverStatistics
static

The documentation for this class was generated from the following file: