Dimension set for the base types, which can be used to implement rigorous dimension checking for algebraic manipulation. More...
#include <dimensionSet.H>
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. | |
Public Member Functions | |
| ClassName ("dimensionSet") | |
| dimensionSet () | |
| Default construct (dimensionless). | |
| 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. | |
| dimensionSet (const FixedList< scalar, 7 > &dimensions) | |
| Construct from exponents for all seven dimensions. | |
| dimensionSet (const dimensionSet &ds) | |
| Copy construct. | |
| dimensionSet (const word &entryName, const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) | |
| Construct from dictionary entry (usually "dimensions"). | |
| autoPtr< dimensionSet > | clone () const |
| Construct and return a clone. | |
| dimensionSet (Istream &is) | |
| Construct from Istream. | |
| bool | dimensionless () const |
| Return true if it is dimensionless. | |
| const FixedList< scalar, 7 > & | values () const noexcept |
| Const access to the exponents as a list. | |
| FixedList< scalar, 7 > & | values () noexcept |
| Non-const access to the exponents as a list. | |
| void | clear () |
| Clear exponents - resets to be dimensionless. | |
| void | reset (const dimensionSet &ds) |
| Copy assign the exponents from the dimensionSet. | |
| 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. | |
| 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. | |
| Istream & | read (Istream &is, scalar &multiplier, const dictionary &) |
| Read using provided units, return scaling in multiplier. Used only in initial parsing. | |
| Istream & | read (Istream &is, scalar &multiplier, const HashTable< dimensionedScalar > &) |
| Read using provided units, return scaling in multiplier. | |
| Istream & | read (Istream &is, scalar &multiplier) |
| Read using system units, return scaling in multiplier. | |
| Ostream & | write (Ostream &os, scalar &multiplier, const dimensionSets &writeUnits) const |
| Write using provided write units, return scaling in multiplier. | |
| Ostream & | write (Ostream &os, scalar &multiplier) const |
| Write using system units, return scaling in multiplier. | |
| scalar | operator[] (const dimensionType) const |
| scalar & | operator[] (const dimensionType) |
| scalar | operator[] (const int) const |
| scalar & | operator[] (const int) |
| bool | operator== (const dimensionSet &) const |
| bool | operator!= (const dimensionSet &) const |
| bool | operator= (const dimensionSet &) const |
| Assignment operation, checks for identical dimensions. Use reset() to change the dimensions. | |
| bool | operator+= (const dimensionSet &) const |
| Addition operation, checks for identical dimensions. | |
| bool | operator-= (const dimensionSet &) const |
| Subtraction operation, checks for identical dimensions. | |
| bool | operator*= (const dimensionSet &) |
| Multiplication, modifies the exponents. | |
| bool | operator/= (const dimensionSet &) |
| Division, modifies the exponents. | |
Static Public Member Functions | |
| static bool | checking (bool on) noexcept |
| Turn dimension checking on/off. | |
| static bool | checking () noexcept |
| True if dimension checking is enabled (the usual default). | |
Static Public Attributes | |
| static constexpr int | nDimensions = 7 |
| There are 7 base dimensions. | |
| static const scalar | smallExponent = SMALL |
| Tolerance for 'small' exponents, for near-zero rounding. | |
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.
Referenced by dimensionSet(), operator!=(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), operator==(), read(), and reset().

| 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 70 of file dimensionSet.C.
References CURRENT, LENGTH, LUMINOUS_INTENSITY, MASS, MOLES, TEMPERATURE, and TIME.
| 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.
References dimensionSet().

| 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 30 of file dimensionSetIO.C.
References dict, readEntry(), and Foam::Zero.

|
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.
Referenced by Foam::atan2(), Foam::checkMethod(), Foam::checkMethod(), Foam::checkMethod(), Foam::checkMethod(), Foam::checkMethod(), Foam::checkMethod(), Foam::clamp(), Foam::hypot(), Foam::lerp(), Foam::max(), Foam::min(), Foam::operator+(), operator+=(), Foam::operator-(), operator-=(), operator=(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::stabilise(), and Foam::trans().

|
inlinestaticnoexcept |
True if dimension checking is enabled (the usual default).
Definition at line 241 of file dimensionSet.H.
References Foam::noexcept.
Referenced by SemiImplicitSource< Type >::addSup(), and fvExprDriver::getOrReadFieldImpl().

|
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.
References smallExponent.
Referenced by Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), Foam::pow(), and Foam::trans().

|
noexcept |
Const access to the exponents as a list.
Definition at line 123 of file dimensionSet.C.
References Foam::noexcept.
Referenced by Foam::operator*(), Foam::operator/(), and read().

|
noexcept |
Non-const access to the exponents as a list.
Definition at line 130 of file dimensionSet.C.
References Foam::noexcept.
| void clear | ( | ) |
Clear exponents - resets to be dimensionless.
Definition at line 136 of file dimensionSet.C.
| void reset | ( | const dimensionSet & | ds | ) |
Copy assign the exponents from the dimensionSet.
Definition at line 142 of file dimensionSet.C.
References dimensionSet().
Referenced by wallShearStress::calcShearStress(), Foam::Expression::fvmLaplacianUncorrected(), read(), parseDriver::setResult(), parseDriver::setResult(), and parseDriver::setResult().


| 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 408 of file dimensionSetIO.C.
References dict, e, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, IOobjectOption::isReadRequired(), keyType::LITERAL, Foam::nl, and IOobjectOption::NO_READ.
Referenced by dimensionSet(), and 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 358 of file dimensionSet.H.
References dict, IOobjectOption::READ_IF_PRESENT, readEntry(), and readIfPresent().
Referenced by readIfPresent().


| 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 532 of file dimensionSetIO.C.
References token::BEGIN_SQR, IOstream::check(), CURRENT, dimensionSet(), token::END_SQR, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, IOstream::info(), token::isNumber(), token::isWord(), keyType::LITERAL, dictionary::lookup(), LUMINOUS_INTENSITY, MASS, nDimensions, Foam::nl, token::number(), Foam::pow(), reset(), s(), smallExponent, 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 445 of file dimensionSetIO.C.
References token::BEGIN_SQR, IOstream::check(), CURRENT, dimensioned< Type >::dimensions(), token::END_SQR, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, IOstream::info(), token::isNumber(), LUMINOUS_INTENSITY, MASS, Foam::nl, token::number(), Istream::putBack(), dimensioned< Type >::value(), and values().

| Foam::Istream & read | ( | Istream & | is, |
| scalar & | multiplier ) |
Read using system units, return scaling in multiplier.
Definition at line 522 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 656 of file dimensionSetIO.C.
References IOstreamOption::ASCII, token::BEGIN_SQR, dimensionSets::coefficients(), token::END_SQR, forAll, FUNCTION_NAME, dimensionSets::good(), Foam::mag(), dimensioned< Type >::name(), nDimensions, os(), Foam::pow(), smallExponent, token::SPACE, dimensionSets::units(), 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 728 of file dimensionSetIO.C.
References os(), write(), and Foam::writeUnitSet().

| Foam::scalar operator[] | ( | const dimensionType | type | ) | const |
Definition at line 150 of file dimensionSet.C.
| Foam::scalar & operator[] | ( | const dimensionType | type | ) |
Definition at line 156 of file dimensionSet.C.
| Foam::scalar operator[] | ( | const int | type | ) | const |
Definition at line 162 of file dimensionSet.C.
| Foam::scalar & operator[] | ( | const int | type | ) |
Definition at line 168 of file dimensionSet.C.
| bool operator== | ( | const dimensionSet & | ds | ) | const |
Definition at line 174 of file dimensionSet.C.
References dimensionSet(), Foam::mag(), nDimensions, and smallExponent.

| bool operator!= | ( | const dimensionSet & | ds | ) | const |
Definition at line 192 of file dimensionSet.C.
References dimensionSet(), and Foam::operator==().

| bool operator= | ( | const dimensionSet & | ds | ) | const |
Assignment operation, checks for identical dimensions. Use reset() to change the dimensions.
Definition at line 198 of file dimensionSet.C.
References Foam::checkDims(), checking(), and dimensionSet().

| bool operator+= | ( | const dimensionSet & | ds | ) | const |
Addition operation, checks for identical dimensions.
Definition at line 209 of file dimensionSet.C.
References Foam::checkDims(), checking(), and dimensionSet().

| bool operator-= | ( | const dimensionSet & | ds | ) | const |
Subtraction operation, checks for identical dimensions.
Definition at line 220 of file dimensionSet.C.
References Foam::checkDims(), checking(), and dimensionSet().

| bool operator*= | ( | const dimensionSet & | ds | ) |
Multiplication, modifies the exponents.
Definition at line 231 of file dimensionSet.C.
References dimensionSet(), and reset().

| bool operator/= | ( | const dimensionSet & | ds | ) |
Division, modifies the exponents.
Definition at line 239 of file dimensionSet.C.
References dimensionSet(), and reset().

|
staticconstexpr |
There are 7 base dimensions.
Definition at line 120 of file dimensionSet.H.
Referenced by operator==(), read(), and write().
|
static |
Tolerance for 'small' exponents, for near-zero rounding.
Definition at line 142 of file dimensionSet.H.
Referenced by dimensionless(), operator==(), Foam::operator>>(), read(), and write().