dune-fem 2.8.0
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
Dune::Fem::ParameterContainer Class Reference

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

Inheritance diagram for Dune::Fem::ParameterContainer:
Inheritance graph

Classes

struct  DGFBlock
 

Public Types

typedef BasicParameterReader< ParameterContainerDataThisType
 

Public Member Functions

 operator ParameterReader () const
 cast into ParameterReader
 
void append (int &argc, char **argv)
 add parameters from the command line
 
void append (const std::string &filename)
 add parameters from a file
 
void append (const std::string &key, const std::string &value, bool force=false)
 add a single parameter to the container
 
template<class T >
std::string toString (const T &value)
 A helper function to convert numbers to scientific strings.
 
template<class NumberType , std::enable_if_t< std::is_floating_point< NumberType >::value||std::is_integral< NumberType >::value, int > = 0>
void append (const std::string &key, NumberType value, bool force=false)
 add a single Floating number parameter to the container
 
void appendDGF (const std::string &filename)
 add parameters from a DGF file
 
void clear ()
 clear all parameters
 
bool verbose () const
 obtain the cached value for fem.verbose
 
std::string commonInputPath () const
 
std::string commonOutputPath () const
 
void write (std::ostream &out, bool writeAll=true) const
 write the parameter database to a stream
 
bool exists (const std::string &key) const
 check, whether a parameter is defined
 
void get (const std::string &key, T &value) const
 get mandatory parameter
 
void get (const std::string &key, const T &defaultValue, T &value) const
 get optional parameter
 
void get (const std::string &key, const char *defaultValue, std::string &value) const
 get optional parameter (special case for string)
 
void getValid (const std::string &key, const Validator &validator, T &value) const
 get mandatory parameter
 
void getValid (const std::string &key, const T &defaultValue, const Validator &validator, T &value) const
 get optional parameter
 
getValue (const std::string &key) const
 get mandatory parameter
 
getValue (const std::string &key, const T &defaultValue) const
 get optional parameter
 
getValidValue (const std::string &key, const Validator &validator) const
 get optional parameter
 
getValidValue (const std::string &key, const T &defaultValue, const Validator &validator) const
 get optional parameter
 
int getEnum (const std::string &key, const std::string(&values)[n]) const
 
int getEnum (const std::string &key, const std::string(&values)[n], int defaultValue) const
 
int getEnum (const std::string &key, const std::vector< std::string > &values) const
 
int getEnum (const std::string &key, const std::vector< std::string > &values, int defaultValue) const
 
ThisTypeclone () const
 
ParameterContainerData parameter ()
 
const ParameterContainerData parameter () const
 
void reset ()
 

Protected Attributes

ParameterContainerData parameter_
 

Member Typedef Documentation

◆ ThisType

Member Function Documentation

◆ append() [1/4]

void Dune::Fem::ParameterContainer::append ( const std::string &  filename)
inline

add parameters from a file

Parameters
[in]filenamename of the file containing the parameters

◆ append() [2/4]

void Dune::Fem::ParameterContainer::append ( const std::string &  key,
const std::string &  value,
bool  force = false 
)
inline

add a single parameter to the container

Parameters
[in]keykey of the parameter to add
[in]valuevalue of the parameter to add
[in]forcereplace parameter, if it exists

◆ append() [3/4]

template<class NumberType , std::enable_if_t< std::is_floating_point< NumberType >::value||std::is_integral< NumberType >::value, int > = 0>
void Dune::Fem::ParameterContainer::append ( const std::string &  key,
NumberType  value,
bool  force = false 
)
inline

add a single Floating number parameter to the container

Parameters
[in]keykey of the parameter to add
[in]valuevalue of the parameter to add
[in]forcereplace parameter, if it exists

◆ append() [4/4]

void Dune::Fem::ParameterContainer::append ( int &  argc,
char **  argv 
)
inline

add parameters from the command line

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()

void Dune::Fem::ParameterContainer::appendDGF ( const std::string &  filename)
inline

add parameters from a DGF file

Parameters can also be read from a DGF file containing a 'FemParameter' block.

Parameters
[in]filenamename of the DGF file containing the parameters

◆ clear()

void Dune::Fem::ParameterContainer::clear ( )
inline

clear all parameters

◆ clone()

ThisType * Dune::Fem::BasicParameterReader< ParameterContainerData >::clone ( ) const
inlineinherited

◆ commonInputPath()

std::string Dune::Fem::ParameterContainer::commonInputPath ( ) const
inline

◆ commonOutputPath()

std::string Dune::Fem::ParameterContainer::commonOutputPath ( ) const
inline

◆ exists()

bool Dune::Fem::BasicParameterReader< ParameterContainerData >::exists ( const std::string &  key) const
inlineinherited

check, whether a parameter is defined

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

◆ get() [1/3]

void Dune::Fem::BasicParameterReader< ParameterContainerData >::get ( const std::string &  key,
const char *  defaultValue,
std::string &  value 
) const
inlineinherited

get optional parameter (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]

void Dune::Fem::BasicParameterReader< ParameterContainerData >::get ( const std::string &  key,
const T &  defaultValue,
T &  value 
) const
inlineinherited

get optional parameter

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]

void Dune::Fem::BasicParameterReader< ParameterContainerData >::get ( const std::string &  key,
T &  value 
) const
inlineinherited

get mandatory parameter

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]

int Dune::Fem::BasicParameterReader< ParameterContainerData >::getEnum ( const std::string &  key,
const std::string(&)  values[n] 
) const
inlineinherited

◆ getEnum() [2/4]

int Dune::Fem::BasicParameterReader< ParameterContainerData >::getEnum ( const std::string &  key,
const std::string(&)  values[n],
int  defaultValue 
) const
inlineinherited

◆ getEnum() [3/4]

int Dune::Fem::BasicParameterReader< ParameterContainerData >::getEnum ( const std::string &  key,
const std::vector< std::string > &  values 
) const
inlineinherited

◆ getEnum() [4/4]

int Dune::Fem::BasicParameterReader< ParameterContainerData >::getEnum ( const std::string &  key,
const std::vector< std::string > &  values,
int  defaultValue 
) const
inlineinherited

◆ getValid() [1/2]

void Dune::Fem::BasicParameterReader< ParameterContainerData >::getValid ( const std::string &  key,
const T &  defaultValue,
const Validator &  validator,
T &  value 
) const
inlineinherited

get optional parameter

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]

void Dune::Fem::BasicParameterReader< ParameterContainerData >::getValid ( const std::string &  key,
const Validator &  validator,
T &  value 
) const
inlineinherited

get mandatory parameter

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]

T Dune::Fem::BasicParameterReader< ParameterContainerData >::getValidValue ( const std::string &  key,
const T &  defaultValue,
const Validator &  validator 
) const
inlineinherited

get optional parameter

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]

T Dune::Fem::BasicParameterReader< ParameterContainerData >::getValidValue ( const std::string &  key,
const Validator &  validator 
) const
inlineinherited

get optional parameter

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]

T Dune::Fem::BasicParameterReader< ParameterContainerData >::getValue ( const std::string &  key) const
inlineinherited

get mandatory parameter

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]

T Dune::Fem::BasicParameterReader< ParameterContainerData >::getValue ( const std::string &  key,
const T &  defaultValue 
) const
inlineinherited

get optional parameter

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

◆ operator ParameterReader()

Dune::Fem::ParameterContainer::operator ParameterReader ( ) const
inline

cast into ParameterReader

◆ parameter() [1/2]

◆ parameter() [2/2]

const ParameterContainerData Dune::Fem::BasicParameterReader< ParameterContainerData >::parameter ( ) const
inlineinherited

◆ reset()

void Dune::Fem::BasicParameterReader< ParameterContainerData >::reset ( )
inlineinherited

◆ toString()

template<class T >
std::string Dune::Fem::ParameterContainer::toString ( const T &  value)
inline

A helper function to convert numbers to scientific strings.

Parameters
[in]valuethe value to be converted (needs a << operator)

◆ verbose()

bool Dune::Fem::ParameterContainer::verbose ( ) const
inline

obtain the cached value for fem.verbose

◆ write()

void Dune::Fem::ParameterContainer::write ( std::ostream &  out,
bool  writeAll = true 
) const
inline

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

Member Data Documentation

◆ parameter_


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