Loading...
Searching...
No Matches
dolfin::Parameters Class Reference

`#include <Parameters.h>`

Inheritance diagram for dolfin::Parameters:
[legend]

## Public Member Functions

| Parameters (std::string key="parameters")
| Create empty parameter set.
virtual | ~Parameters ()
| Destructor.
| Parameters (const Parameters &parameters)
| Copy constructor.
std::string | name () const
| Return name for parameter set.
void | rename (std::string key)
| Rename parameter set.
void | clear ()
| Clear parameter set.
void | add_unset (std::string key, Parameter::Type type)
| Add unset parameter of specified type.
template<typename T>
void | add (std::string key)
template<typename T>
void | add (std::string key, T min, T max)
void | add (std::string key, std::set< std::string > valid_values)
void | add (std::string key, int value)
| Add int-valued parameter.
void | add (std::string key, int value, int min_value, int max_value)
| Add int-valued parameter with given range.
void | add (std::string key, double value)
| Add double-valued parameter.
void | add (std::string key, double value, double min_value, double max_value)
| Add double-valued parameter with given range.
void | add (std::string key, std::string value)
| Add string-valued parameter.
void | add (std::string key, const char *value)
| Add string-valued parameter.
void | add (std::string key, std::string value, std::set< std::string > range)
| Add string-valued parameter with given range.
void | add (std::string key, const char *value, std::set< std::string > range)
| Add string-valued parameter with given range.
void | add (std::string key, bool value)
| Add bool-valued parameter.
void | add (const Parameters &parameters)
| Add nested parameter set.
void | remove (std::string key)
| Remove parameter or parameter set with given key.
virtual void | parse (int argc, char *argv[])
| Parse parameters from command-line.
void | update (const Parameters &parameters)
| Update parameters with another set of parameters.
Parameter & | operator[] (std::string key)
| Return parameter for given key.
const Parameter & | operator[] (std::string key) const
| Return parameter for given key (const version).
Parameters & | operator() (std::string key)
| Return nested parameter set for given key.
const Parameters & | operator() (std::string key) const
| Return nested parameter set for given key (const).
const Parameters & | operator= (const Parameters &parameters)
| Assignment operator.
bool | has_key (std::string key) const
| Check if parameter set has key (parameter or nested parameter set).
bool | has_parameter (std::string key) const
| Check if parameter set has given parameter.
bool | has_parameter_set (std::string key) const
| Check if parameter set has given nested parameter set.
void | get_parameter_keys (std::vector< std::string > &keys) const
| Return a vector of parameter keys.
void | get_parameter_set_keys (std::vector< std::string > &keys) const
| Return a vector of parameter set keys.
std::string | str (bool verbose) const
| Return informal string representation (pretty-print).
boost::optional< Parameter & > | find_parameter (std::string key)
| Return parameter, if present.
boost::optional< Parameters & > | find_parameter_set (std::string key)
| Return parameter set, if present.
std::size_t | size () const
| Interface for pybind11 iterators.
std::map< std::string, boost::variant< Parameter, Parameters > >::const_iterator | begin () const
| Interface for pybind11 iterators.
std::map< std::string, boost::variant< Parameter, Parameters > >::const_iterator | end () const
| Interface for pybind11 iterators.

## Protected Member Functions

void | parse_common (int argc, char *argv[])
| Parse filtered options (everything except PETSc options).
void | parse_petsc (int argc, char *argv[])
| Parse filtered options (only PETSc options).

## Detailed Description

This class stores a set of parameters. Each parameter is identified by a unique string (the key) and a value of some given value type. Parameter sets can be nested at arbitrary depths.

A parameter may be either int, double, string or boolean valued.

Parameters may be added as follows:

Parameters p("my_parameters");
p.add("relative_tolerance", 1e-15);
p.add("absolute_tolerance", 1e-15);
p.add("gmres_restart", 30);
p.add("monitor_convergence", false);
dolfin::Parameters::Parameters
Parameters(std::string key="parameters")
Create empty parameter set.
Definition Parameters.cpp:34

Parameters may be changed as follows:

p["gmres_restart"] = 50;

Parameter values may be retrieved as follows:

int gmres_restart = p["gmres_restart"];

Parameter sets may be nested as follows:

Parameters q("nested_parameters");
p.add(q);

Nested parameters may then be accessed by

p("nested_parameters")["..."]

Parameters may be nested at arbitrary depths.

Parameters may be parsed from the command-line as follows:

p.parse(argc, argv);

Note: spaces in parameter keys are not allowed (to simplify usage from command-line).

## Member Function Documentation

## add() [1/3]

template<typename T>

void dolfin::Parameters::add | ( | std::string | key | ) |

inline

Add an unset parameter of type T. For example, to create a unset parameter of type bool, do parameters.add<bool>("my_setting")

## add() [2/3]

void dolfin::Parameters::add | ( | std::string | key,
|  | std::set< std::string > | valid_values )

inline

Add an unset parameter of type T with allows parameters. For example, to create a unset parameter of type bool, do parameters.add<bool>("my_setting")

## add() [3/3]

template<typename T>

void dolfin::Parameters::add | ( | std::string | key,
|  | T | min,
|  | T | max )

inline

Add an unset parameter of type T with allows parameters. For example, to create a unset parameter of type bool, do parameters.add<bool>("my_setting")

## parse()

void Parameters::parse | ( | int | argc,
|  | char * | argv[] )

virtual

Parse parameters from command-line.

Reimplemented in dolfin::GlobalParameters.

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

- /build/dolfin-lFBzDh/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/parameter/Parameters.h
- /build/dolfin-lFBzDh/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/parameter/Parameters.cpp