Flow123d
last_with_con_2.0.0-4-g42e6930
|
Class for representation SI units of Fields. More...
#include <unit_si.hh>
Classes | |
struct | OutputFormat |
Variable parts of output format. Used in the format method. More... | |
Public Member Functions | |
UnitSI () | |
Constructor. More... | |
UnitSI & | m (int exp=1) |
Methods set values of exponents for SI units with similar name. More... | |
UnitSI & | kg (int exp=1) |
UnitSI & | s (int exp=1) |
UnitSI & | A (int exp=1) |
UnitSI & | K (int exp=1) |
UnitSI & | mol (int exp=1) |
UnitSI & | cd (int exp=1) |
UnitSI & | md (int exp=-1) |
The dimension dependent meter: md^y = m^(yd), where 'd' is dimension. More... | |
std::string | format_latex () const |
std::string | format_text () const |
std::string | json () const |
void | undef (bool val=true) |
bool | is_def () const |
Return true if the unit is defined. More... | |
Static Public Member Functions | |
static UnitSI & | N () |
static UnitSI & | J () |
Returns Joule. More... | |
static UnitSI & | W () |
Returns Watt. More... | |
static UnitSI & | Pa () |
Returns Pascal. More... | |
static UnitSI & | dimensionless () |
Returns dimensionless unit. More... | |
static UnitSI & | one () |
Returns dimensionless unit. More... | |
Private Types | |
enum | UnitOrder { order_m =0, order_md =1, order_kg =2, order_s =3, order_A =4, order_K =5, order_mol =6, order_cd =7, n_base_units =8 } |
Values determine positions of exponents in exponents_ vector. More... | |
Private Member Functions | |
std::string | format (OutputFormat form) const |
Generic output formating method. More... | |
Static Private Member Functions | |
static const std::string & | unit_symbol (unsigned int idx) |
Private Attributes | |
std::vector< int > | exponents_ |
bool | undef_ |
Friends | |
UnitSI | operator* (const UnitSI &a, const UnitSI &b) |
Product of two units. More... | |
UnitSI | operator/ (const UnitSI &a, const UnitSI &b) |
Proportion of two units. More... | |
Class for representation SI units of Fields.
Units are set through exponents of basic SI units. These exponents are set in methods with same name as unit symbols (e.g. kg(), K() etc).
Class contains method that provides formated string representing full unit symbol (usable in LaTeX output).
UnitSI object contains flag that says if it is defined
Class contains static methods that return frequently used derived units (Watt, Pascal etc).
Definition at line 40 of file unit_si.hh.
|
private |
Values determine positions of exponents in exponents_ vector.
Enumerator | |
---|---|
order_m | |
order_md | |
order_kg | |
order_s | |
order_A | |
order_K | |
order_mol | |
order_cd | |
n_base_units |
Definition at line 99 of file unit_si.hh.
UnitSI::UnitSI | ( | ) |
Constructor.
Definition at line 27 of file unit_si.cc.
UnitSI & UnitSI::A | ( | int | exp = 1 | ) |
Definition at line 80 of file unit_si.cc.
UnitSI & UnitSI::cd | ( | int | exp = 1 | ) |
Definition at line 98 of file unit_si.cc.
|
static |
Returns dimensionless unit.
Definition at line 53 of file unit_si.cc.
|
private |
Generic output formating method.
Definition at line 142 of file unit_si.cc.
std::string UnitSI::format_latex | ( | ) | const |
Makes unit description string in Latex format, e.g. "$[m.kg^{2}.s^{-2}]$"
Have assert for undefined units.
Definition at line 115 of file unit_si.cc.
std::string UnitSI::format_text | ( | ) | const |
bool UnitSI::is_def | ( | ) | const |
Return true if the unit is defined.
Definition at line 199 of file unit_si.cc.
|
static |
Returns Joule.
Definition at line 38 of file unit_si.cc.
std::string UnitSI::json | ( | ) | const |
Machine readable JSON format. Units are stored as a record with keys given by SI units strings (corresponding to setters). Values of the keys are integer.
Definition at line 181 of file unit_si.cc.
UnitSI & UnitSI::K | ( | int | exp = 1 | ) |
Definition at line 86 of file unit_si.cc.
UnitSI & UnitSI::kg | ( | int | exp = 1 | ) |
UnitSI & UnitSI::m | ( | int | exp = 1 | ) |
Methods set values of exponents for SI units with similar name.
Definition at line 62 of file unit_si.cc.
UnitSI & UnitSI::md | ( | int | exp = -1 | ) |
The dimension dependent meter: md^y = m^(yd), where 'd' is dimension.
Definition at line 104 of file unit_si.cc.
UnitSI & UnitSI::mol | ( | int | exp = 1 | ) |
Definition at line 92 of file unit_si.cc.
|
static |
Methods return frequently used derived units Returns Newton
Definition at line 33 of file unit_si.cc.
|
static |
Returns dimensionless unit.
Definition at line 58 of file unit_si.cc.
|
static |
Returns Pascal.
Definition at line 48 of file unit_si.cc.
UnitSI & UnitSI::s | ( | int | exp = 1 | ) |
void UnitSI::undef | ( | bool | val = true | ) |
Set flag that unit is undefined.
Default value is true (set in constructor). If any exponent is set, undef_
flag is unset. In all fields unit must be defined by user.
Definition at line 195 of file unit_si.cc.
|
staticprivate |
Symbols for individual units. Can not use static variable due to usage in static initialization.
Definition at line 135 of file unit_si.cc.
|
static |
Product of two units.
Definition at line 204 of file unit_si.cc.
Proportion of two units.
Definition at line 217 of file unit_si.cc.
|
private |
Stores exponents of base SI units in the order given by the UnitOrder enum
where md represents value of exponent depended on dimension (m^{-d})
Definition at line 131 of file unit_si.hh.
|
private |
Flag if object is undefined.
Value is set on true in constructor, when any exponent is changed, false value is set.
Definition at line 139 of file unit_si.hh.