55 bool Foam::unitConversion::compare
57 const unitConversion& a,
58 const unitConversion&
b,
59 const bool compareMultiplier
62 if (a.any())
return true;
63 if (
b.any())
return true;
64 if (a.none())
return false;
65 if (
b.none())
return false;
68 if (a.dimensions_ !=
b.dimensions_)
return false;
75 mag(a.exponents_[i] -
b.exponents_[i])
84 return !compareMultiplier || a.multiplier_ ==
b.multiplier_;
93 const scalar fraction,
95 const scalar multiplier
99 multiplier_(multiplier)
102 exponents_[
ANGLE] = angle;
112 exponents_[
ANGLE] = 0;
120 dimensions_.reset(
units.dimensions_);
123 exponents_[i] =
units.exponents_[i];
125 multiplier_ =
units.multiplier_;
155 if (a.any())
return b;
156 if (
b.any())
return a;
160 if (!unitConversion::compare(a,
b,
true))
163 <<
"Different units for +" <<
endl
165 << a <<
" {" << a.multiplier_ <<
"} + "
166 <<
b <<
" {" <<
b.multiplier_ <<
"} + " <<
endl
180 if (a.any())
return a;
181 if (
b.any())
return b;
188 a.dimensions_*
b.dimensions_,
189 a.exponents_[0] +
b.exponents_[0],
190 a.exponents_[1] +
b.exponents_[1],
191 a.multiplier_*
b.multiplier_
202 if (a.any())
return a;
203 if (
b.any())
return b;
210 a.dimensions_/
b.dimensions_,
211 a.exponents_[0] -
b.exponents_[0],
212 a.exponents_[1] -
b.exponents_[1],
213 a.multiplier_/
b.multiplier_
Initialise the NamedEnum HashTable from the static list of names.
Dimension set for the base types.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
static const NamedEnum< dimlessUnitType, 2 > dimlessUnitTypeNames_
Names of the dimensionless units.
static const scalar smallExponent
A small exponent with which to perform inexact comparisons.
unitConversion(const dimensionSet &, const scalar fraction, const scalar angle, const scalar multiplier)
Construct from components.
void reset(const unitConversion &)
Reset the unit conversion.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar exp(const dimensionedScalar &ds)
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
const unitConversion unitNone
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)