svMultiPhysics
|
The Parameter class template is used to store a named paramater and its scalar value as a basic type: bool, double, int and string. More...
#include <Parameters.h>
Public Member Functions | |
Parameter (const std::string &name, T value, bool required, std::vector< T > range={}) | |
std::string | name () const |
T | value () const |
T | operator() () const |
bool | defined () const |
std::string | svalue () |
Get the value of a parameter as a string. More... | |
void | set (const std::string &name, bool required, T value) |
Set the parameter name and value, and if it is required. More... | |
void | set (const std::string &str_value) |
Set the parameter value from a string. More... | |
bool | check_required_set () |
Public Attributes | |
T | value_ = T{0} |
std::string | name_ = "" |
bool | required_ = false |
bool | value_set_ = false |
std::vector< T > | range_ |
The Parameter class template is used to store a named paramater and its scalar value as a basic type: bool, double, int and string.
The classes defined here are used to process svFSIplus simulation parameters read in from an Extensible Markup Language (XML) format file. XML is a simple text-based format for representing structured information.
An XML document is formed as an element tree. The XML tree starts at a root element and branches from the root to sub-elements. All elements can have sub-elements:
The elements in the svFSIplus simulation file are represented by sections of related parameters. Sub-elements are refered to as sub-sections.
The Parameters class is the top level class. It contains objects used to store parameters for the sections making up an XML simulation parameters file
1) General (GeneralSimulationParameters) 2) Mesh (MeshParameters) 3) Equation (EquationParameters) 4) Projection (ProjectionParameters)
Each object contains methods to parse the XML file for the parameters defined for it. These section objects may also contain objects representing the sub-sections defined for each section.
Each section object contains objects representing parameters. A parameter's name and value is stored using either a Parameter and VectorParamater template objects. A parameter value is stored as a basic type: bool, double, int and string.
Parameter objects in a section class are named using the same XML element name with the 1st character lower case.
Example: GeneralSimulationParameters class
The name and default value for each parameter is defined in a section object's constructor.
Parameter values are set using the set_values() method which contains calls to tinyxml2
to parse parameter values from an XML file.
Each section object inherits from the ParameterLists class. This class provides methods to store parameters in a map and process iterated over them for setting values and other operations.
|
inline |
Set the parameter name and value, and if it is required.
|
inline |
Set the parameter value from a string.
|
inline |
Get the value of a parameter as a string.