52 bool Foam::unitConversion::compare
54 const unitConversion& a,
55 const unitConversion&
b,
56 const bool compareMultiplier
59 if (a.any())
return true;
60 if (
b.any())
return true;
61 if (a.none())
return false;
62 if (
b.none())
return false;
65 if (a.dimensions_ !=
b.dimensions_)
return false;
72 mag(a.exponents_[i] -
b.exponents_[i])
81 return !compareMultiplier || a.multiplier_ ==
b.multiplier_;
90 const scalar fraction,
92 const scalar multiplier
96 multiplier_(multiplier)
99 exponents_[
ANGLE] = angle;
109 exponents_[
ANGLE] = 0;
117 dimensions_.reset(
units.dimensions_);
120 exponents_[i] =
units.exponents_[i];
122 multiplier_ =
units.multiplier_;
152 if (a.any())
return b;
153 if (
b.any())
return a;
157 if (!unitConversion::compare(a,
b,
true))
160 <<
"Different units for +" <<
endl
161 <<
" units : " << a <<
" + " <<
b <<
endl
175 if (a.any())
return a;
176 if (
b.any())
return b;
183 a.dimensions_*
b.dimensions_,
184 a.exponents_[0] +
b.exponents_[0],
185 a.exponents_[1] +
b.exponents_[1],
186 a.multiplier_*
b.multiplier_
197 if (a.any())
return a;
198 if (
b.any())
return b;
205 a.dimensions_/
b.dimensions_,
206 a.exponents_[0] -
b.exponents_[0],
207 a.exponents_[1] -
b.exponents_[1],
208 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
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void pow(LagrangianPatchField< typename powProduct< Type, r >::type > &f, const LagrangianPatchField< Type > &f1)
defineTypeNameAndDebug(combustionModel, 0)