dimensionSet Class Reference

Dimension set for the base types. 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 dictionary &dict, const word &entryName)
 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
 Return const access to the exponents as a list. More...
 
FixedList< scalar, 7 > & values ()
 Return non-const access to the exponents as a list. More...
 
void clear ()
 Reset exponents to be dimensionless. More...
 
void reset (const dimensionSet &ds)
 Copy assign the exponents from the dimensionSet. More...
 
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 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.

This type may be used to implement rigorous dimension checking for algebraic manipulation.

Source files

Definition at line 65 of file dimensionSet.H.

Member Typedef Documentation

◆ list_type

typedef FixedList<scalar,7> list_type

The array of dimension exponents.

Definition at line 70 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 79 of file dimensionSet.H.

Constructor & Destructor Documentation

◆ dimensionSet() [1/6]

Default construct (dimensionless).

Definition at line 71 of file dimensionSet.C.

◆ dimensionSet() [2/6]

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

◆ dimensionSet() [3/6]

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

Construct from exponents for all seven dimensions.

Definition at line 100 of file dimensionSet.C.

◆ dimensionSet() [4/6]

dimensionSet ( const dimensionSet ds)

Copy construct.

Definition at line 106 of file dimensionSet.C.

◆ dimensionSet() [5/6]

dimensionSet ( const dictionary dict,
const word entryName 
)

Construct from dictionary entry - usually "dimensions".

Definition at line 36 of file dimensionSetIO.C.

References dict, Foam::constant::electromagnetic::e, and keyType::LITERAL.

◆ dimensionSet() [6/6]

dimensionSet ( Istream is)
explicit

Construct from Istream.

Definition at line 47 of file dimensionSetIO.C.

Member Function Documentation

◆ ClassName()

ClassName ( "dimensionSet"  )

◆ clone()

autoPtr<dimensionSet> clone ( ) const
inline

Construct and return a clone.

Definition at line 200 of file dimensionSet.H.

References autoPtr< T >::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

Return const access to the exponents as a list.

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

Return non-const access to the exponents as a list.

Definition at line 135 of file dimensionSet.C.

◆ clear()

void clear ( )

Reset exponents to be dimensionless.

Definition at line 141 of file dimensionSet.C.

References Foam::Zero.

Referenced by Foam::transform().

Here is the caller graph for this function:

◆ reset()

void reset ( const dimensionSet ds)

Copy assign the exponents from the dimensionSet.

Definition at line 147 of file dimensionSet.C.

Referenced by dimensionSet::read().

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 500 of file dimensionSetIO.C.

References token::BEGIN_SQR, IOstream::check(), dimensionSet::CURRENT, Foam::dimless, token::END_SQR, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, IOstream::info(), token::isNumber(), token::isWord(), 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 413 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 490 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 624 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, Foam::pow(), Ostream::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 696 of file dimensionSetIO.C.

References Foam::vtk::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 155 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 161 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 167 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 173 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 179 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 197 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 203 of file dimensionSet.C.

References Foam::checkDims(), and Foam::expressions::patchExpr::debug.

Here is the call graph for this function:

◆ operator+=()

bool operator+= ( const dimensionSet ds) const

Definition at line 214 of file dimensionSet.C.

References Foam::checkDims(), and Foam::expressions::patchExpr::debug.

Here is the call graph for this function:

◆ operator-=()

bool operator-= ( const dimensionSet ds) const

Definition at line 225 of file dimensionSet.C.

References Foam::checkDims(), and Foam::expressions::patchExpr::debug.

Here is the call graph for this function:

◆ operator*=()

bool operator*= ( const dimensionSet ds)

Definition at line 236 of file dimensionSet.C.

◆ operator/=()

bool operator/= ( const dimensionSet ds)

Definition at line 244 of file dimensionSet.C.

Member Data Documentation

◆ nDimensions

constexpr int nDimensions = 7
staticconstexpr

There are 7 base dimensions.

Definition at line 76 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 94 of file dimensionSet.H.

Referenced by Foam::operator>>().


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