dimensionSet Class Reference

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, const bool mandatory=true)
 Construct from dictionary entry (usually "dimensions") More...
 
 dimensionSet (const dictionary &dict, const word &entryName, const bool mandatory=true)
 Construct from dictionary entry (usually "dimensions") More...
 
autoPtr< dimensionSetclone () 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, const bool mandatory=true)
 
Istreamread (Istream &is, scalar &multiplier, const dictionary &)
 Read using provided units. Used only in initial parsing. More...
 
Istreamread (Istream &is, scalar &multiplier, const HashTable< dimensionedScalar > &)
 Read using provided units. More...
 
Istreamread (Istream &is, scalar &multiplier)
 Read using system units. More...
 
Ostreamwrite (Ostream &os, scalar &multiplier, const dimensionSets &) const
 Write using provided units. More...
 
Ostreamwrite (Ostream &os, scalar &multiplier) const
 Write using system units. 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 (const 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...
 

Detailed Description

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
Source files

Definition at line 108 of file dimensionSet.H.

Member Typedef Documentation

◆ list_type

typedef FixedList<scalar,7> list_type

The array of dimension exponents.

Definition at line 113 of file dimensionSet.H.

Member Enumeration Documentation

◆ dimensionType

Enumeration for the dimension exponents.

Enumerator
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 122 of file dimensionSet.H.

Constructor & Destructor Documentation

◆ dimensionSet() [1/7]

Default construct (dimensionless).

Definition at line 71 of file dimensionSet.C.

◆ dimensionSet() [2/7]

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 77 of file dimensionSet.C.

References dimensionSet::CURRENT, dimensionSet::LENGTH, dimensionSet::LUMINOUS_INTENSITY, dimensionSet::MASS, dimensionSet::MOLES, dimensionSet::TEMPERATURE, and dimensionSet::TIME.

◆ dimensionSet() [3/7]

dimensionSet ( const FixedList< scalar, 7 > &  dimensions)

Construct from exponents for all seven dimensions.

Definition at line 100 of file dimensionSet.C.

◆ dimensionSet() [4/7]

dimensionSet ( const dimensionSet ds)

Copy construct.

Definition at line 106 of file dimensionSet.C.

◆ dimensionSet() [5/7]

dimensionSet ( const word entryName,
const dictionary dict,
const bool  mandatory = true 
)

Construct from dictionary entry (usually "dimensions")

Dimensionless if non-mandatory and not found.

Parameters
entryNameLookup key. LITERAL (not REGEX)

Definition at line 37 of file dimensionSetIO.C.

References dict, and dimensionSet::readEntry().

Here is the call graph for this function:

◆ dimensionSet() [6/7]

dimensionSet ( const dictionary dict,
const word entryName,
const bool  mandatory = true 
)

Construct from dictionary entry (usually "dimensions")

Parameters
entryNameLookup key. LITERAL (not REGEX)

Definition at line 50 of file dimensionSetIO.C.

References dict, and dimensionSet::readEntry().

Here is the call graph for this function:

◆ dimensionSet() [7/7]

dimensionSet ( Istream is)
explicit

Construct from Istream.

Definition at line 63 of file dimensionSetIO.C.

Member Function Documentation

◆ ClassName()

ClassName ( "dimensionSet"  )

◆ checking() [1/2]

static bool checking ( const bool  on)
inlinestaticnoexcept

Turn dimension checking on/off.

Returns
the previous value

Definition at line 221 of file dimensionSet.H.

◆ checking() [2/2]

static bool checking ( )
inlinestaticnoexcept

True if dimension checking is enabled (the usual default)

Definition at line 229 of file dimensionSet.H.

Referenced by SemiImplicitSource< Type >::addSup(), Foam::atan2(), Foam::checkMethod(), Foam::clip(), Foam::hypot(), Foam::max(), Foam::min(), Foam::operator+(), dimensionSet::operator+=(), Foam::operator-(), dimensionSet::operator-=(), dimensionSet::operator=(), Foam::pow(), Foam::stabilise(), and Foam::trans().

Here is the caller graph for this function:

◆ clone()

autoPtr< dimensionSet > clone ( ) const
inline

Construct and return a clone.

Definition at line 276 of file dimensionSet.H.

References Time::New().

Here is the call graph for this function:

◆ dimensionless()

bool dimensionless ( ) const

Return true if it is dimensionless.

Definition at line 114 of file dimensionSet.C.

Referenced by Foam::pow(), and Foam::trans().

Here is the caller graph for this function:

◆ values() [1/2]

const Foam::FixedList< Foam::scalar, 7 > & values ( ) const
noexcept

Const access to the exponents as a list.

Definition at line 130 of file dimensionSet.C.

Referenced by Foam::operator*(), Foam::operator/(), and dimensionSet::read().

Here is the caller graph for this function:

◆ values() [2/2]

Foam::FixedList< Foam::scalar, 7 > & values ( )
noexcept

Non-const access to the exponents as a list.

Definition at line 137 of file dimensionSet.C.

◆ clear()

void clear ( )

Clear exponents - resets to be dimensionless.

Definition at line 143 of file dimensionSet.C.

References Foam::Zero.

◆ reset()

void reset ( const dimensionSet ds)

Copy assign the exponents from the dimensionSet.

Definition at line 149 of file dimensionSet.C.

Referenced by wallShearStress::calcShearStress(), dimensionSet::read(), parseDriver::setResult(), polySurface::storeField(), and surfMesh::storeField().

Here is the caller graph for this function:

◆ readEntry()

bool readEntry ( const word entryName,
const dictionary dict,
const bool  mandatory = true 
)

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.

Returns
true if the entry was found.
Parameters
entryNameLookup key. LITERAL (not REGEX)
dictThe dictionary
mandatoryThe entry is mandatory

Definition at line 428 of file dimensionSetIO.C.

References dict, e, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, dictionary::findEntry(), keyType::LITERAL, Foam::nl, and dictionary::relativeName().

Referenced by dimensionSet::dimensionSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read() [1/3]

Foam::Istream & read ( Istream is,
scalar &  multiplier,
const dictionary readSet 
)

Read using provided units. Used only in initial parsing.

Definition at line 547 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>>().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read() [2/3]

Foam::Istream & read ( Istream is,
scalar &  multiplier,
const HashTable< dimensionedScalar > &  readSet 
)

Read using provided units.

Definition at line 460 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().

Here is the call graph for this function:

◆ read() [3/3]

Foam::Istream & read ( Istream is,
scalar &  multiplier 
)

Read using system units.

Definition at line 537 of file dimensionSetIO.C.

References Foam::read(), and Foam::unitSet().

Here is the call graph for this function:

◆ write() [1/2]

Foam::Ostream & write ( Ostream os,
scalar &  multiplier,
const dimensionSets writeUnits 
) const

Write using provided units.

Definition at line 671 of file dimensionSetIO.C.

References STLCore::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<<().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [2/2]

Foam::Ostream & write ( Ostream os,
scalar &  multiplier 
) const

Write using system units.

Definition at line 743 of file dimensionSetIO.C.

References os(), write(), and Foam::writeUnitSet().

Here is the call graph for this function:

◆ operator[]() [1/4]

Foam::scalar operator[] ( const dimensionType  type) const

Definition at line 157 of file dimensionSet.C.

References Foam::type().

Here is the call graph for this function:

◆ operator[]() [2/4]

Foam::scalar & operator[] ( const dimensionType  type)

Definition at line 163 of file dimensionSet.C.

References Foam::type().

Here is the call graph for this function:

◆ operator[]() [3/4]

Foam::scalar operator[] ( const label  type) const

Definition at line 169 of file dimensionSet.C.

References Foam::type().

Here is the call graph for this function:

◆ operator[]() [4/4]

Foam::scalar & operator[] ( const label  type)

Definition at line 175 of file dimensionSet.C.

References Foam::type().

Here is the call graph for this function:

◆ operator==()

bool operator== ( const dimensionSet ds) const

Definition at line 181 of file dimensionSet.C.

References Foam::mag().

Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const dimensionSet ds) const

Definition at line 199 of file dimensionSet.C.

References Foam::operator==().

Here is the call graph for this function:

◆ operator=()

bool operator= ( const dimensionSet ds) const

Definition at line 205 of file dimensionSet.C.

References Foam::checkDims(), and dimensionSet::checking().

Here is the call graph for this function:

◆ operator+=()

bool operator+= ( const dimensionSet ds) const

Definition at line 216 of file dimensionSet.C.

References Foam::checkDims(), and dimensionSet::checking().

Here is the call graph for this function:

◆ operator-=()

bool operator-= ( const dimensionSet ds) const

Definition at line 227 of file dimensionSet.C.

References Foam::checkDims(), and dimensionSet::checking().

Here is the call graph for this function:

◆ operator*=()

bool operator*= ( const dimensionSet ds)

Definition at line 238 of file dimensionSet.C.

◆ operator/=()

bool operator/= ( const dimensionSet ds)

Definition at line 246 of file dimensionSet.C.

Member Data Documentation

◆ nDimensions

constexpr int nDimensions = 7
staticconstexpr

There are 7 base dimensions.

Definition at line 119 of file dimensionSet.H.

Referenced by dimensionSet::read(), and dimensionSet::write().

◆ smallExponent

const Foam::scalar smallExponent = SMALL
static

Tolerance for 'small' exponents, for near-zero rounding.

Definition at line 137 of file dimensionSet.H.

Referenced by Foam::operator>>().


The documentation for this class was generated from the following files: