Parameters

The parameters system. More...

Collaboration diagram for Parameters:

Functions

template<class TypeTag , template< class, class > class Property>
auto Opm::Parameters::get (bool errorIfNotRegistered=true)
 Retrieve a runtime parameter. More...
 
template<class TypeTag >
void Opm::Parameters::printUsage (const std::string &helpPreamble, const std::string &errorMsg="", std::ostream &os=std::cerr, const bool showAll=false)
 Print a usage message for all run-time parameters. More...
 
template<class TypeTag , class PositionalArgumentCallback >
std::string Opm::Parameters::parseCommandLineOptions (int argc, const char **argv, const std::string &helpPreamble="", const PositionalArgumentCallback &posArgCallback=noPositionalParameters_)
 Parse the parameters provided on the command line. More...
 
template<class TypeTag >
void Opm::Parameters::parseParameterFile (const std::string &fileName, bool overwrite=true)
 Read the parameters from an INI-style file. More...
 
template<class TypeTag >
void Opm::Parameters::printValues (std::ostream &os=std::cout)
 Print values of the run-time parameters. More...
 
template<class TypeTag >
bool Opm::Parameters::printUnused (std::ostream &os=std::cout)
 Print the list of unused run-time parameters. More...
 
template<class TypeTag , template< class, class > class Param>
void Opm::Parameters::registerParam (const char *usageString)
 Register a run-time parameter. More...
 

Detailed Description

The parameters system.

Parameters allow to specify values at runtime (either via command line arguments or by means of a .INI file) and thus cannot be used to specify types as properties can. Also all parameters fall back to the value of the property of the same as the parameter, so this property must exist and be defined.

Function Documentation

◆ get()

template<class TypeTag , template< class, class > class Property>
auto Opm::Parameters::get ( bool  errorIfNotRegistered = true)

Retrieve a runtime parameter.

The default value is specified via the property system.

Example:

// Retrieves value UpwindWeight, default
// is taken from the property UpwindWeight
::Opm::Parameters::get<TypeTag, Properties::UpwindWeight>();

Referenced by Opm::VcfvStencil< Scalar, GridView >::updateScvGeometry().

◆ parseCommandLineOptions()

template<class TypeTag , class PositionalArgumentCallback >
std::string Opm::Parameters::parseCommandLineOptions ( int  argc,
const char **  argv,
const std::string &  helpPreamble = "",
const PositionalArgumentCallback &  posArgCallback = noPositionalParameters_ 
)

Parse the parameters provided on the command line.

This function does some basic syntax checks.

Parameters
argcThe number of parameters passed by the operating system to the main() function
argvThe array of strings passed by the operating system to the main() function
helpPreambleIf non-empty, the –help and -h parameters will be recognized and the content of the string will be printed before the list of command line parameters
Returns
Empty string if everything worked out. Otherwise the thing that could not be read.

References Opm::Parameters::parseKey_(), and Opm::Parameters::transformKey_().

◆ parseParameterFile()

template<class TypeTag >
void Opm::Parameters::parseParameterFile ( const std::string &  fileName,
bool  overwrite = true 
)

Read the parameters from an INI-style file.

This function does some basic syntax checks.

References Opm::Parameters::parseKey_(), Opm::Parameters::parseQuotedValue_(), Opm::Parameters::parseUnquotedValue_(), Opm::Parameters::removeLeadingSpace_(), and Opm::Parameters::transformKey_().

◆ printUnused()

template<class TypeTag >
bool Opm::Parameters::printUnused ( std::ostream &  os = std::cout)

Print the list of unused run-time parameters.

Parameters
osThe std::ostream on which the message should be printed
Returns
true if something was printed

References Opm::Parameters::getFlattenedKeyList_().

◆ printUsage()

template<class TypeTag >
void Opm::Parameters::printUsage ( const std::string &  helpPreamble,
const std::string &  errorMsg = "",
std::ostream &  os = std::cerr,
const bool  showAll = false 
)

Print a usage message for all run-time parameters.

Parameters
helpPreambleThe string that is printed after the error message and before the list of parameters.
errorMsgThe error message to be printed, if any
osThe std::ostream which should be used.

References Opm::Parameters::breakLines_(), Opm::Parameters::getTtyWidth_(), Opm::Parameters::ParamInfo::paramName, Opm::Parameters::printParamUsage_(), and Opm::Parameters::ParamInfo::usageString.

◆ printValues()

template<class TypeTag >
void Opm::Parameters::printValues ( std::ostream &  os = std::cout)

Print values of the run-time parameters.

Parameters
osThe std::ostream on which the message should be printed

References Opm::Parameters::getFlattenedKeyList_().

◆ registerParam()

template<class TypeTag , template< class, class > class Param>
void Opm::Parameters::registerParam ( const char *  usageString)

Register a run-time parameter.

In OPM, parameters can only be used after they have been registered.

Example:

// Registers a run-time parameter "UpwindWeight"
and the description "Relative weight of the upwind node."
registerParam<TypeTag,UpwindWeight>("Relative weight of the upwind node.");

References Opm::Parameters::ParamInfo::compileTimeValue, Opm::Parameters::ParamInfo::isHidden, Opm::Parameters::ParamInfo::paramName, Opm::Parameters::ParamInfo::paramTypeName, and Opm::Parameters::ParamInfo::usageString.