A wrapper for physical constants to be shared among functions and classes. More...
#include <constants.h>
Public Member Functions | |
Constants (const std::string §ion_name="", const std::vector< std::string > &names={}, const std::vector< double > &default_values={}, const std::vector< std::string > &optional_names_for_parameter_file={}, const std::vector< std::string > &optional_documentation_strings={}) | |
Build a ParameterAcceptor based collection of constants. More... | |
operator const std::map< std::string, double > & () const | |
Return the constants defined in this class as a map. More... | |
operator const Differentiation::SD::types::substitution_map & () const | |
Return the constants defined in this class as a Differentiation::SD::types::substitution_map. More... | |
const double & | operator[] (const std::string &key) const |
Return the constant associated with the given name. More... | |
![]() | |
ParameterAcceptor (const std::string §ion_name="") | |
unsigned int | get_acceptor_id () const |
virtual | ~ParameterAcceptor () override |
virtual void | declare_parameters (ParameterHandler &prm) |
virtual void | parse_parameters (ParameterHandler &prm) |
std::string | get_section_name () const |
std::vector< std::string > | get_section_path () const |
void | add_parameter (const std::string &entry, ParameterType ¶meter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern=*Patterns::Tools::Convert< ParameterType >::to_pattern()) |
void | enter_subsection (const std::string &subsection) |
void | leave_subsection () |
void | enter_my_subsection (ParameterHandler &prm) |
void | leave_my_subsection (ParameterHandler &prm) |
void | serialize (Archive &ar, const unsigned int version) |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
![]() | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) noexcept | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) noexcept |
void | serialize (Archive &ar, const unsigned int version) |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
Private Attributes | |
std::map< std::string, double > | constants |
The actual constants. More... | |
Differentiation::SD::types::substitution_map | constant_substitution_map |
Return the constants defined in this class as a Differentiation::SD::types::substitution_map. More... | |
std::map< std::string, std::string > | constants_parameter_entries |
The documentation string used to parse the constants from the parameter file. More... | |
std::map< std::string, std::string > | constants_documentation |
The documentation of each constant. More... | |
Additional Inherited Members | |
![]() | |
static void | initialize (const std::string &filename="", const std::string &output_filename="", const ParameterHandler::OutputStyle output_style_for_output_filename=ParameterHandler::Short, ParameterHandler &prm=ParameterAcceptor::prm, const ParameterHandler::OutputStyle output_style_for_filename=ParameterHandler::DefaultStyle) |
static void | initialize (std::istream &input_stream, ParameterHandler &prm=ParameterAcceptor::prm) |
static void | clear () |
static void | parse_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm) |
static void | declare_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm) |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
![]() | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
![]() | |
boost::signals2::signal< void()> | declare_parameters_call_back |
boost::signals2::signal< void()> | parse_parameters_call_back |
![]() | |
static ParameterHandler | prm |
![]() | |
const std::string | section_name |
std::vector< std::string > | subsections |
A wrapper for physical constants to be shared among functions and classes.
This class can be used to store physical constants that are used in a simulation, e.g., elastic parameters, densities, etc., and that could be reused when defining Function objects.
This class behaves like a map, where the keys are strings and the values are the corresponding values.
In addition to constants defined at construction time, this class also provides a list of all mathematical constants defined in the numbers namespace, i.e., PI, E, LOG2_E, etc.
Constants given at construction time takes precedence, so if you use "E" as a constant name, than that value will be used instead of the Nepero constant numbers::E.
Definition at line 43 of file constants.h.
ParsedTools::Constants::Constants | ( | const std::string & | section_name = "" , |
const std::vector< std::string > & | names = {} , |
||
const std::vector< double > & | default_values = {} , |
||
const std::vector< std::string > & | optional_names_for_parameter_file = {} , |
||
const std::vector< std::string > & | optional_documentation_strings = {} |
||
) |
Build a ParameterAcceptor based collection of constants.
An example usage of this class is the following:
The above snippet of code will delcare the ParameterAcceptor::prm ParameterHandler with the following entries:
The optional_names_for_parameter_file
can be left empty, in which case the names of the constants will be used. In the example above, leaving optional_names_for_parameter_file
empty would result in the following parameter entries:
section_name | The name of the section in the parameter file. |
names | The names of the constants. |
default_values | The default values of the constants. |
optional_names_for_parameter_file | Optional names to use instead of the constant names in the parameter file defintion. |
optional_documentation_strings | Optional documentation strings to use in the parameter file defintion. |
Definition at line 24 of file constants.cc.
References ParameterAcceptor::add_parameter(), AssertDimension, constants, constants_documentation, constants_parameter_entries, numbers::E, numbers::LN10, numbers::LN2, numbers::LOG10E, numbers::LOG2E, numbers::PI, numbers::PI_2, numbers::PI_4, numbers::SQRT1_2, and numbers::SQRT2.
ParsedTools::Constants::operator const std::map< std::string, double > & | ( | ) | const |
Return the constants defined in this class as a map.
ParsedTools::Constants::operator const Differentiation::SD::types::substitution_map & | ( | ) | const |
Return the constants defined in this class as a Differentiation::SD::types::substitution_map.
Definition at line 95 of file constants.cc.
const double & ParsedTools::Constants::operator[] | ( | const std::string & | key | ) | const |
Return the constant associated with the given name.
key | The name of the constant. |
Definition at line 83 of file constants.cc.
References constants.
|
private |
The actual constants.
Definition at line 132 of file constants.h.
Referenced by Constants(), and operator[]().
|
mutableprivate |
Return the constants defined in this class as a Differentiation::SD::types::substitution_map.
Definition at line 141 of file constants.h.
|
private |
The documentation string used to parse the constants from the parameter file.
Definition at line 149 of file constants.h.
Referenced by Constants().
|
private |
The documentation of each constant.
Definition at line 154 of file constants.h.
Referenced by Constants().