Parameters

The parameters system. More...

Collaboration diagram for Parameters:

Functions

template<class Param >
auto Opm::Parameters::Get (bool errorIfNotRegistered=true)
 Retrieve a runtime parameter. More...
 
template<class Param >
auto Opm::Parameters::SetDefault (decltype(Param::value) new_value)
 Set a runtime parameter. More...
 
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 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...
 
void Opm::Parameters::parseParameterFile (const std::string &fileName, bool overwrite=true)
 Read the parameters from an INI-style file. More...
 
void Opm::Parameters::printValues (std::ostream &os=std::cout)
 Print values of the run-time parameters. More...
 
bool Opm::Parameters::printUnused (std::ostream &os=std::cout)
 Print the list of unused run-time parameters. More...
 
template<class Param >
void Opm::Parameters::Register (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 Param >
auto Opm::Parameters::Get ( bool  errorIfNotRegistered = true)

Retrieve a runtime parameter.

The default value is specified in the parameter struct.

Example:

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

References Opm::Parameters::MetaData::mutableRegistry(), Opm::Parameters::MetaData::registrationOpen(), Opm::Parameters::MetaData::registry(), and Opm::Parameters::MetaData::tree().

Referenced by Opm::FvBaseProblem< TypeTag >::nextTimeStepSize(), and Opm::NcpNewtonMethod< TypeTag >::preSolve_().

◆ parseCommandLineOptions()

template<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_(), Opm::Parameters::printUsage(), Opm::Parameters::transformKey_(), and Opm::Parameters::MetaData::tree().

◆ parseParameterFile()

void Opm::Parameters::parseParameterFile ( const std::string &  fileName,
bool  overwrite = true 
)
inline

◆ printUnused()

bool Opm::Parameters::printUnused ( std::ostream &  os = std::cout)
inline

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_(), Opm::Parameters::MetaData::registry(), and Opm::Parameters::MetaData::tree().

Referenced by start().

◆ printUsage()

void Opm::Parameters::printUsage ( const std::string &  helpPreamble,
const std::string &  errorMsg = "",
std::ostream &  os = std::cerr,
const bool  showAll = false 
)
inline

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_(), Opm::Parameters::MetaData::registry(), and Opm::Parameters::ParamInfo::usageString.

Referenced by Opm::Parameters::parseCommandLineOptions(), and start().

◆ printValues()

void Opm::Parameters::printValues ( std::ostream &  os = std::cout)
inline

Print values of the run-time parameters.

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

References Opm::Parameters::getFlattenedKeyList_(), Opm::Parameters::printParamList_(), Opm::Parameters::MetaData::registry(), and Opm::Parameters::MetaData::tree().

Referenced by start().

◆ Register()

template<class Param >
void Opm::Parameters::Register ( 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."
Register<UpwindWeight>("Relative weight of the upwind node.");

References Opm::Parameters::ParamInfo::defaultValue, Opm::Parameters::ParamInfo::isHidden, Opm::Parameters::MetaData::mutableRegistry(), Opm::Parameters::ParamInfo::paramName, Opm::Parameters::ParamInfo::paramTypeName, Opm::Parameters::MetaData::registrationFinalizers(), Opm::Parameters::MetaData::registrationOpen(), Opm::Parameters::MetaData::registry(), and Opm::Parameters::ParamInfo::usageString.

◆ SetDefault()

template<class Param >
auto Opm::Parameters::SetDefault ( decltype(Param::value)  new_value)

Set a runtime parameter.

Override the default value specified.

Example:

// Set the value UpwindWeight
::Opm::Parameters::Set<::Opm::Parameters::UpwindWeight>(3.0);

References Opm::Parameters::MetaData::mutableRegistry(), and Opm::Parameters::MetaData::registry().