dune-fem  2.4.1-rc
Static Public Member Functions | Static Protected Member Functions | List of all members
Dune::Fem::Parameter Class Reference

Container for User Specified Parameters. More...

#include </local/tomalk/somewhere/tmp/dune-fem/dune/fem/io/parameter.hh>

Static Public Member Functions

static ParameterContainercontainer ()
 
static int setVerboseRank (int verboseRank)
 set the rank for verbose output More...
 
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)
 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...
 
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 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 More...
 
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

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)

References Dune::Fem::ParameterContainer::append(), and container().

Referenced by main(), and Dune::Fem::PersistenceManager::restoreValue().

static void Dune::Fem::Parameter::append ( const std::string &  key,
const std::string &  value 
)
inlinestatic

add a single parameter to the container

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

References Dune::Fem::ParameterContainer::append(), and container().

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

References Dune::Fem::ParameterContainer::append(), and container().

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

References Dune::Fem::ParameterContainer::appendDGF(), and container().

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 '.'.

References Dune::Fem::ParameterContainer::commonInputPath(), and container().

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 '.'.

References Dune::Fem::ParameterContainer::commonOutputPath(), container(), and outputPath().

Referenced by outputPath(), readParameterList(), Dune::Fem::IOInterface::readPath(), and write().

static ParameterContainer& Dune::Fem::Parameter::container ( )
inlinestatic
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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::exists().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::get().

Referenced by readParameterList().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::get().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::get().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValid().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValid().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValidValue().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValidValue().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValue().

Referenced by Dune::Fem::SparseRowMatrixObject< DomainFunction::DiscreteFunctionSpaceType, RangeFunction::DiscreteFunctionSpaceType >::SparseRowMatrixObject().

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

References container(), and Dune::Fem::BasicParameterReader< Parameter >::getValue().

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.

References commonOutputPath(), path, and Dune::Fem::MPIManager::rank().

Referenced by commonOutputPath().

static int Dune::Fem::Parameter::setVerboseRank ( int  verboseRank)
inlinestatic

set the rank for verbose output

This mehtod allows to set the fem verbosity within the code.

Parameters
[in]verboseRankthe rank of the processor to have * verbose output (-1: no verbose output)
[out]thevalue used before the change

References container(), and Dune::Fem::ParameterContainer::setVerboseRank().

static bool Dune::Fem::Parameter::verbose ( )
inlinestatic
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

References commonOutputPath(), and Dune::Fem::MPIManager::rank().

Referenced by Dune::Fem::DataOutput< GridImp, DataImp >::init(), Dune::Fem::CheckPointer< GridImp, DataImp >::initialize(), Dune::Fem::PersistenceManager::restoreValue(), verbose(), and write().

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

References container(), and Dune::Fem::ParameterContainer::write().

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

References Dune::Fem::createDirectory(), Dune::Fem::directoryExists(), and write().


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