Flow123d
JB_transport-112d700
|
Go to the documentation of this file.
43 {
"*D", { 9.869233E-13,
UnitSI().
m(2) } },
44 {
"*l", { 1e-3,
UnitSI().
m(3) } },
49 {
"min", { 60,
UnitSI().
s() } },
50 {
"h", { 3600,
UnitSI().
s() } },
51 {
"d", { 24*3600,
UnitSI().
s() } },
52 {
"y", { 365.2425*24*3600,
UnitSI().
s() } },
81 for (
it=base_units_map.begin();
it!=base_units_map.end(); ++
it) {
82 if (
it->first.at(0)==
'*') {
83 std::string shortcut =
it->first.substr(1);
84 double coef =
it->second.coef_;
87 std::string key = prefix_it->first + shortcut;
88 units_map_.insert(std::pair<std::string, DerivedUnit>( key, { coef*prefix_it->second,
it->second.unit_ } ));
91 units_map_.insert( std::pair<std::string, DerivedUnit>(
it->first,
it->second ) );
103 "Specify the unit of an input value. "
104 "Evaluation of the unit formula results into a coeficient and a "
105 "unit in terms of powers of base SI units. The unit must match the"
106 "expected SI unit of the value, while the value provided on the input "
107 "is multiplied by the coefficient before further processing. "
108 "The unit formula have a form:\n"
110 "<UnitExpr>;<Variable>=<Number>*<UnitExpr>;...,\n"
112 "where ```<Variable>``` is a variable name and ```<UnitExpr>``` is a units expression "
113 "which consists of products and divisions of terms.\n\n"
114 "A term has a form: "
115 "```<Base>^<N>```, where ```<N>``` is an integer exponent and ```<Base>``` "
116 "is either a base SI unit, a derived unit, or a variable defined in the same unit formula. "
117 "Example, unit for the pressure head:\n\n"
118 "```MPa/rho/g_; rho = 990*kg*m^-3; g_ = 9.8*m*s^-2```"
122 "Definition of unit." )
136 typedef spirit_namespace::position_iterator< std::string::iterator > PosnIterT;
138 std::string::iterator begin = s.begin();
139 std::string::iterator end = s.end();
141 const PosnIterT posn_begin( begin, end );
142 const PosnIterT posn_end( end, end );
147 spirit_namespace::parse( begin, end,
149 spirit_namespace::space_p );
151 }
catch (ExcInvalidUnit &e) {
152 e << EI_UnitDefinition(s);
165 Formula &formula = unit_data.find(
"")->second;
182 ASSERT(
it != unit_data.end())(factor.
factor_).error(
"Undefined unit.");
UnitData read_unit(std::string s)
Parse and check unit defined in string format.
UnitSI unit_si() const
Return unit_si_.
UnitSI & md(int exp=-1)
The dimension dependent meter: md^y = m^(yd), where 'd' is dimension.
UnitData unit_data() const
void add_converted_unit(Factor factor, UnitData &unit_data, UnitSI &unit_si, double &coef)
Calculates UnitSi and coeficient of Factor, recursively calls this method for user defined formula.
Helper class. Defines basic factors of SI, non-SI and derived units.
void multiply(const UnitSI &other, int exp=1)
Multiply with power of given unit.
std::string factor_
string represantation of unit or user defined constant
Definition of unit grammar.
UnitSI & m(int exp=1)
Methods set values of exponents for SI units with similar name.
UnitConverter()
Constructor.
Class for representation SI units of Fields.
double convert(std::string actual_unit)
static const Input::Type::Record & get_input_type()
bool basic_
unit is basic (strict defined in application) / derived (defined by user as formula)
void check_unit_data()
Check unit_data_ object.
void reset()
Reset UnitSI object (set vector of exponents to zeros and set undef flag)
BasicFactors()
Constructor.
static const BasicFactors basic_factors
Define all base and derived units given by their symbol.
Class manages parsing of user defined field unit.
Store structure given by parser.
UnitsMap units_map_
Define all base and derived units given by their symbol.