Dimension set for the base types, which can be used to implement rigorous dimension checking for algebraic manipulation. More...
Public Types | |
enum | dimensionType { MASS, LENGTH, TIME, TEMPERATURE, MOLES, CURRENT, LUMINOUS_INTENSITY } |
Enumeration for the dimension exponents. More... | |
typedef FixedList< scalar, 7 > | list_type |
The array of dimension exponents. More... | |
Public Member Functions | |
ClassName ("dimensionSet") | |
dimensionSet () | |
Default construct (dimensionless). More... | |
dimensionSet (const scalar mass, const scalar length, const scalar time, const scalar temperature, const scalar moles, const scalar current=0, const scalar luminousIntensity=0) | |
Construct from exponents for the first five or all seven dimensions. More... | |
dimensionSet (const FixedList< scalar, 7 > &dimensions) | |
Construct from exponents for all seven dimensions. More... | |
dimensionSet (const dimensionSet &ds) | |
Copy construct. More... | |
dimensionSet (const word &entryName, const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) | |
Construct from dictionary entry (usually "dimensions") More... | |
autoPtr< dimensionSet > | clone () const |
Construct and return a clone. More... | |
dimensionSet (Istream &is) | |
Construct from Istream. More... | |
bool | dimensionless () const |
Return true if it is dimensionless. More... | |
const FixedList< scalar, 7 > & | values () const noexcept |
Const access to the exponents as a list. More... | |
FixedList< scalar, 7 > & | values () noexcept |
Non-const access to the exponents as a list. More... | |
void | clear () |
Clear exponents - resets to be dimensionless. More... | |
void | reset (const dimensionSet &ds) |
Copy assign the exponents from the dimensionSet. More... | |
bool | readEntry (const word &entryName, const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) |
Update the dimensions from dictionary entry. FatalIOError if it is found and the number of tokens is incorrect, or it is mandatory and not found. More... | |
bool | readIfPresent (const word &entryName, const dictionary &dict) |
Update the dimensions from dictionary entry. FatalIOError if it is found and the number of tokens is incorrect, or it is mandatory and not found. More... | |
Istream & | read (Istream &is, scalar &multiplier, const dictionary &) |
Read using provided units, return scaling in multiplier. Used only in initial parsing. More... | |
Istream & | read (Istream &is, scalar &multiplier, const HashTable< dimensionedScalar > &) |
Read using provided units, return scaling in multiplier. More... | |
Istream & | read (Istream &is, scalar &multiplier) |
Read using system units, return scaling in multiplier. More... | |
Ostream & | write (Ostream &os, scalar &multiplier, const dimensionSets &writeUnits) const |
Write using provided write units, return scaling in multiplier. More... | |
Ostream & | write (Ostream &os, scalar &multiplier) const |
Write using system units, return scaling in multiplier. More... | |
scalar | operator[] (const dimensionType) const |
scalar & | operator[] (const dimensionType) |
scalar | operator[] (const label) const |
scalar & | operator[] (const label) |
bool | operator== (const dimensionSet &) const |
bool | operator!= (const dimensionSet &) const |
bool | operator= (const dimensionSet &) const |
bool | operator+= (const dimensionSet &) const |
bool | operator-= (const dimensionSet &) const |
bool | operator*= (const dimensionSet &) |
bool | operator/= (const dimensionSet &) |
Static Public Member Functions | |
static bool | checking (bool on) noexcept |
Turn dimension checking on/off. More... | |
static bool | checking () noexcept |
True if dimension checking is enabled (the usual default) More... | |
Static Public Attributes | |
static constexpr int | nDimensions = 7 |
There are 7 base dimensions. More... | |
static const scalar | smallExponent = SMALL |
Tolerance for 'small' exponents, for near-zero rounding. More... | |
Dimension set for the base types, which can be used to implement rigorous dimension checking for algebraic manipulation.
The dimensions are specified in the following order (SI units for reference only):
Property | SI Description | SI unit |
---|---|---|
MASS | kilogram | kg |
LENGTH | metre | m |
TIME | second | s |
TEMPERATURE | Kelvin | K |
MOLES | mole | mol |
CURRENT | Ampere | A |
LUMINOUS_INTENSITY | Candela | cd |
Definition at line 105 of file dimensionSet.H.
The array of dimension exponents.
Definition at line 112 of file dimensionSet.H.
enum dimensionType |
Enumeration for the dimension exponents.
Enumerator | |
---|---|
MASS | kilogram |
LENGTH | metre |
TIME | second |
TEMPERATURE | Kelvin |
MOLES | mole |
CURRENT | Ampere |
LUMINOUS_INTENSITY | Candela |
Definition at line 125 of file dimensionSet.H.
dimensionSet | ( | ) |
Default construct (dimensionless).
Definition at line 64 of file dimensionSet.C.
dimensionSet | ( | const scalar | mass, |
const scalar | length, | ||
const scalar | time, | ||
const scalar | temperature, | ||
const scalar | moles, | ||
const scalar | current = 0 , |
||
const scalar | luminousIntensity = 0 |
||
) |
Construct from exponents for the first five or all seven dimensions.
Definition at line 71 of file dimensionSet.C.
dimensionSet | ( | const FixedList< scalar, 7 > & | dimensions | ) |
Construct from exponents for all seven dimensions.
Definition at line 93 of file dimensionSet.C.
dimensionSet | ( | const dimensionSet & | ds | ) |
Copy construct.
Definition at line 99 of file dimensionSet.C.
dimensionSet | ( | const word & | entryName, |
const dictionary & | dict, | ||
IOobjectOption::readOption | readOpt = IOobjectOption::MUST_READ |
||
) |
Construct from dictionary entry (usually "dimensions")
Dimensionless if non-mandatory and not found.
entryName | Lookup key. LITERAL (not REGEX) |
Definition at line 31 of file dimensionSetIO.C.
References dict.
|
explicit |
Construct from Istream.
Definition at line 43 of file dimensionSetIO.C.
ClassName | ( | "dimensionSet" | ) |
|
inlinestaticnoexcept |
Turn dimension checking on/off.
Definition at line 231 of file dimensionSet.H.
References Foam::ensightOutput::debug.
|
inlinestaticnoexcept |
True if dimension checking is enabled (the usual default)
Definition at line 241 of file dimensionSet.H.
References Foam::ensightOutput::debug.
Referenced by Foam::atan2(), Foam::checkMethod(), Foam::clamp(), Foam::hypot(), Foam::lerp(), Foam::max(), Foam::min(), Foam::operator+(), dimensionSet::operator+=(), Foam::operator-(), dimensionSet::operator-=(), dimensionSet::operator=(), Foam::pow(), Foam::stabilise(), and Foam::trans().
|
inline |
Construct and return a clone.
Definition at line 293 of file dimensionSet.H.
References autoPtr< T >::New().
bool dimensionless | ( | ) | const |
Return true if it is dimensionless.
Definition at line 107 of file dimensionSet.C.
Referenced by Foam::pow(), and Foam::trans().
|
noexcept |
Const access to the exponents as a list.
Definition at line 123 of file dimensionSet.C.
Referenced by Foam::operator*(), Foam::operator/(), and dimensionSet::read().
|
noexcept |
Non-const access to the exponents as a list.
Definition at line 130 of file dimensionSet.C.
void clear | ( | ) |
Clear exponents - resets to be dimensionless.
Definition at line 136 of file dimensionSet.C.
References Foam::Zero.
Referenced by Foam::clamp().
void reset | ( | const dimensionSet & | ds | ) |
Copy assign the exponents from the dimensionSet.
Definition at line 142 of file dimensionSet.C.
Referenced by wallShearStress::calcShearStress(), dimensionSet::read(), parseDriver::setResult(), surfMesh::storeField(), polySurface::storeField(), and KinematicCloud< Cloud< basicKinematicCollidingParcel > >::SU().
bool readEntry | ( | const word & | entryName, |
const dictionary & | dict, | ||
IOobjectOption::readOption | readOpt = IOobjectOption::MUST_READ |
||
) |
Update the dimensions from dictionary entry. FatalIOError if it is found and the number of tokens is incorrect, or it is mandatory and not found.
entryName | Lookup key. LITERAL (not REGEX) |
dict | The dictionary |
readOpt | The read option |
Definition at line 409 of file dimensionSetIO.C.
References dict, Foam::constant::electromagnetic::e, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, dictionary::findEntry(), IOobjectOption::isReadRequired(), keyType::LITERAL, Foam::nl, IOobjectOption::NO_READ, and dictionary::relativeName().
Referenced by dimensionSet::readIfPresent().
|
inline |
Update the dimensions from dictionary entry. FatalIOError if it is found and the number of tokens is incorrect, or it is mandatory and not found.
entryName | Lookup key. LITERAL (not REGEX) |
dict | The dictionary |
Definition at line 359 of file dimensionSet.H.
References dict, IOobjectOption::READ_IF_PRESENT, and dimensionSet::readEntry().
Foam::Istream & read | ( | Istream & | is, |
scalar & | multiplier, | ||
const dictionary & | readSet | ||
) |
Read using provided units, return scaling in multiplier. Used only in initial parsing.
Definition at line 533 of file dimensionSetIO.C.
References token::BEGIN_SQR, IOstream::check(), dimensionSet::CURRENT, token::END_SQR, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, IOstream::info(), token::isNumber(), token::isWord(), keyType::LITERAL, dictionary::lookup(), dimensionSet::LUMINOUS_INTENSITY, dimensionSet::MASS, dimensionSet::nDimensions, Foam::nl, token::number(), Foam::pow(), dimensionSet::reset(), s, and token::wordToken().
Referenced by Foam::operator>>().
Foam::Istream & read | ( | Istream & | is, |
scalar & | multiplier, | ||
const HashTable< dimensionedScalar > & | readSet | ||
) |
Read using provided units, return scaling in multiplier.
Definition at line 446 of file dimensionSetIO.C.
References token::BEGIN_SQR, IOstream::check(), dimensionSet::CURRENT, dimensioned< Type >::dimensions(), token::END_SQR, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, IOstream::info(), token::isNumber(), dimensionSet::LUMINOUS_INTENSITY, dimensionSet::MASS, Foam::nl, token::number(), Istream::putBack(), dimensioned< Type >::value(), and dimensionSet::values().
Foam::Istream & read | ( | Istream & | is, |
scalar & | multiplier | ||
) |
Read using system units, return scaling in multiplier.
Definition at line 523 of file dimensionSetIO.C.
References Foam::read(), and Foam::unitSet().
Foam::Ostream & write | ( | Ostream & | os, |
scalar & | multiplier, | ||
const dimensionSets & | writeUnits | ||
) | const |
Write using provided write units, return scaling in multiplier.
Definition at line 657 of file dimensionSetIO.C.
References IOstreamOption::ASCII, token::BEGIN_SQR, IOstream::check(), dimensionSets::coefficients(), token::END_SQR, forAll, IOstreamOption::format(), FUNCTION_NAME, Foam::mag(), dimensioned< Type >::name(), dimensionSet::nDimensions, os(), Foam::pow(), OSstream::precision(), token::SPACE, dimensionSets::units(), dimensionSets::valid(), and dimensioned< Type >::value().
Referenced by Foam::operator<<().
Foam::Ostream & write | ( | Ostream & | os, |
scalar & | multiplier | ||
) | const |
Write using system units, return scaling in multiplier.
Definition at line 729 of file dimensionSetIO.C.
References os(), Foam::vtk::write(), and Foam::writeUnitSet().
Foam::scalar operator[] | ( | const dimensionType | type | ) | const |
Definition at line 150 of file dimensionSet.C.
References Foam::type().
Foam::scalar & operator[] | ( | const dimensionType | type | ) |
Definition at line 156 of file dimensionSet.C.
References Foam::type().
Foam::scalar operator[] | ( | const label | type | ) | const |
Definition at line 162 of file dimensionSet.C.
References Foam::type().
Foam::scalar & operator[] | ( | const label | type | ) |
Definition at line 168 of file dimensionSet.C.
References Foam::type().
bool operator== | ( | const dimensionSet & | ds | ) | const |
Definition at line 174 of file dimensionSet.C.
References Foam::mag().
bool operator!= | ( | const dimensionSet & | ds | ) | const |
Definition at line 192 of file dimensionSet.C.
References Foam::operator==().
bool operator= | ( | const dimensionSet & | ds | ) | const |
Definition at line 198 of file dimensionSet.C.
References Foam::checkDims(), and dimensionSet::checking().
bool operator+= | ( | const dimensionSet & | ds | ) | const |
Definition at line 209 of file dimensionSet.C.
References Foam::checkDims(), and dimensionSet::checking().
bool operator-= | ( | const dimensionSet & | ds | ) | const |
Definition at line 220 of file dimensionSet.C.
References Foam::checkDims(), and dimensionSet::checking().
bool operator*= | ( | const dimensionSet & | ds | ) |
Definition at line 231 of file dimensionSet.C.
bool operator/= | ( | const dimensionSet & | ds | ) |
Definition at line 239 of file dimensionSet.C.
|
static |
There are 7 base dimensions.
Definition at line 120 of file dimensionSet.H.
Referenced by dimensionSet::read(), and dimensionSet::write().
|
static |
Tolerance for 'small' exponents, for near-zero rounding.
Definition at line 142 of file dimensionSet.H.
Referenced by Foam::operator>>().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.