54 bool Foam::unitSet::compare
58 const bool compareMultiplier
61 if (a.any())
return true;
62 if (
b.any())
return true;
63 if (a.none())
return false;
64 if (
b.none())
return false;
67 if (a.dimensions_ !=
b.dimensions_)
return false;
74 mag(a.exponents_[i] -
b.exponents_[i])
83 return !compareMultiplier || a.multiplier_ ==
b.multiplier_;
94 const scalar multiplier
97 dimensions_(dimensions),
98 multiplier_(multiplier)
101 exponents_[
ANGLE] = angle;
107 dimensions_(dimensions),
111 exponents_[
ANGLE] = 0;
119 dimensions_.reset(units.dimensions_);
122 exponents_[i] = units.exponents_[i];
124 multiplier_ = units.multiplier_;
132 if (units.
any())
return units;
138 pow(units.dimensions_,
exp),
139 units.exponents_[0]*
exp,
140 units.exponents_[1]*
exp,
141 pow(units.multiplier_,
exp)
154 if (a.any())
return b;
155 if (
b.any())
return a;
159 if (!unitSet::compare(a,
b,
true))
162 <<
"Different units for +" <<
endl
163 <<
" units : " << a <<
" + " <<
b <<
endl
177 if (a.any())
return a;
178 if (
b.any())
return b;
185 a.dimensions_*
b.dimensions_,
186 a.exponents_[0] +
b.exponents_[0],
187 a.exponents_[1] +
b.exponents_[1],
188 a.multiplier_*
b.multiplier_
199 if (a.any())
return a;
200 if (
b.any())
return b;
207 a.dimensions_/
b.dimensions_,
208 a.exponents_[0] -
b.exponents_[0],
209 a.exponents_[1] -
b.exponents_[1],
210 a.multiplier_/
b.multiplier_
Initialise the NamedEnum HashTable from the static list of names.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Dimension set for the base types.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
bool none() const
Return whether this is the "none" unit. I.e., the case where unit.
unitSet(const dimensionSet &, const scalar fraction, const scalar angle, const scalar multiplier)
Construct from components.
static const scalar smallExponent
A small exponent with which to perform inexact comparisons.
static const NamedEnum< dimlessUnitType, 2 > & dimlessUnitTypeNames_
Names of the dimensionless units.
void reset(const unitSet &)
Reset the unit conversion.
bool any() const
Return whether this is the "any" unit. I.e., the case where.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedScalar exp(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
const Foam::autoPtr< Foam::NamedEnum< Foam::unitSet::dimlessUnitType, 2 > > dimlessUnitTypeNamesPtr_(new Foam::NamedEnum< Foam::unitSet::dimlessUnitType, 2 >({ "fraction", "angle" }))