38 is.putBack(nextToken);
41 if (nextToken.isWord())
45 is.putBack(nextToken);
50 if (nextToken == token::BEGIN_SQR)
53 const dimensionSet curr(dimensions_);
54 dimensions_.read(is, mult);
59 <<
"The dimensions " << dimensions_
60 <<
" provided do not match the expected dimensions " 76 const dictionary&
dict,
77 IOobjectOption::readOption readOpt,
79 enum keyType::option matchOpt
82 if (readOpt == IOobjectOption::NO_READ)
90 const entry* eptr =
dict.findEntry(
key, matchOpt);
94 ITstream& is = eptr->stream();
102 else if (IOobjectOption::isReadRequired(readOpt))
105 <<
"Entry '" <<
key <<
"' not found in dictionary " 195 dimensions_(dt.dimensions_),
213 initialize(is,
false);
233 initialize(is,
true);
251 readEntry(
name,
dict, IOobjectOption::MUST_READ,
false);
268 readEntry(
name,
dict, IOobjectOption::MUST_READ);
278 const word& entryName
286 readEntry(entryName,
dict, IOobjectOption::MUST_READ);
304 readEntry(
name,
dict, IOobjectOption::READ_IF_PRESENT);
344 initialize(is,
true);
433 value_.replace(d, dc.value());
454 const word& entryName,
459 return readEntry(entryName,
dict, IOobjectOption::MUST_READ);
466 const word& entryName,
471 return readEntry(entryName,
dict, IOobjectOption::READ_IF_PRESENT);
486 dimensions_.
read(is, mult);
506 dimensions_.
read(is, mult, readSet);
529 dimensions_.
read(is, mult, readSet);
547 os.writeKeyword(keyword);
549 if (keyword != name_)
552 os << name_ << token::SPACE;
557 dimensions_.write(
os, mult);
560 os << token::SPACE << value_/mult << token::END_STATEMENT <<
endl;
585 dimensions_ += dt.dimensions_;
596 dimensions_ -= dt.dimensions_;
623 template<
class Type, Foam::direction r>
629 "pow(" + dt.name() +
',' +
name(r) +
')',
630 pow(dt.dimensions(), r),
642 "sqr(" + dt.name() +
')',
643 sqr(dt.dimensions()),
654 return dimensioned<magType>
656 "magSqr(" + dt.name() +
')',
668 return dimensioned<magType>
670 "mag(" + dt.name() +
')',
680 const dimensioned<Type>& dt1,
681 const dimensioned<Type>& dt2
684 return dimensioned<Type>
686 "cmptMultiply(" + dt1.name() +
',' + dt2.name() +
')',
695 const dimensioned<Type>& dt1,
696 const dimensioned<Type>& dt2
699 return dimensioned<Type>
701 "cmptDivide(" + dt1.name() +
',' + dt2.name() +
')',
702 cmptDivide(dt1.dimensions(), dt2.dimensions()),
711 const dimensioned<Type>& a,
712 const dimensioned<Type>&
b 715 return dimensioned<Type>
717 "max(" + a.name() +
',' +
b.
name() +
')',
727 const dimensioned<Type>& a,
728 const dimensioned<Type>&
b 731 return dimensioned<Type>
733 "min(" + a.name() +
',' +
b.
name() +
')',
743 const dimensioned<Type>& a,
744 const dimensioned<Type>&
b,
748 return dimensioned<Type>
762 dt.initialize(is,
false);
769 Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned<Type>& dt)
772 os << dt.name() << token::SPACE;
776 dt.dimensions().write(
os, mult);
779 os << token::SPACE << dt.value()/mult;
791 const dimensioned<Type>& dt1,
792 const dimensioned<Type>& dt2
795 return dt1.value() < dt2.value();
802 const dimensioned<Type>& dt1,
803 const dimensioned<Type>& dt2
806 return dt2.value() < dt1.value();
813 const dimensioned<Type>& dt1,
814 const dimensioned<Type>& dt2
817 return dimensioned<Type>
819 '(' + dt1.
name() +
'+' + dt2.name() +
')',
821 dt1.
value() + dt2.value()
829 return dimensioned<Type>
841 const dimensioned<Type>& dt1,
842 const dimensioned<Type>& dt2
845 return dimensioned<Type>
847 '(' + dt1.
name() +
'-' + dt2.name() +
')',
849 dt1.
value() - dt2.value()
857 const dimensioned<scalar>& ds,
858 const dimensioned<Type>& dt
861 return dimensioned<Type>
863 '(' + ds.
name() +
'*' + dt.name() +
')',
865 ds.
value() * dt.value()
873 const dimensioned<Type>& dt,
874 const dimensioned<scalar>& ds
877 return dimensioned<Type>
879 '(' + dt.name() +
'|' + ds.
name() +
')',
881 dt.value() / ds.
value()
886 #define PRODUCT_OPERATOR(product, op, opFunc) \ 888 template<class Type1, class Type2> \ 889 Foam::dimensioned<typename Foam::product<Type1, Type2>::type> \ 892 const dimensioned<Type1>& dt1, \ 893 const dimensioned<Type2>& dt2 \ 896 return dimensioned<typename product<Type1, Type2>::type> \ 898 '(' + dt1.name() + #op + dt2.name() + ')', \ 899 dt1.dimensions() op dt2.dimensions(), \ 900 dt1.value() op dt2.value() \ 904 template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \ 905 Foam::dimensioned<typename Foam::product<Type, Form>::type> \ 908 const dimensioned<Type>& dt1, \ 909 const VectorSpace<Form,Cmpt,nCmpt>& t2 \ 912 return dimensioned<typename product<Type, Form>::type> \ 914 '(' + dt1.name() + #op + name(t2) + ')', \ 916 dt1.value() op static_cast<const Form&>(t2) \ 920 template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \ 921 Foam::dimensioned<typename Foam::product<Form, Type>::type> \ 924 const VectorSpace<Form,Cmpt,nCmpt>& t1, \ 925 const dimensioned<Type>& dt2 \ 928 return dimensioned<typename product<Form, Type>::type> \ 930 '(' + name(t1) + #op + dt2.name() + ')', \ 932 static_cast<const Form&>(t1) op dt2.value() \ 942 #undef PRODUCT_OPERATOR dimensioned< cmptType > component(const direction d) const
Return a component as a dimensioned<cmptType>
const Type & value() const noexcept
Return const reference to value.
static dimensioned< Type > getOrDefault(const word &name, const dictionary &dict, const dimensionSet &dims=dimless, const Type &deflt=Type(Zero))
Construct dimensioned from dictionary, with default value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual bool check(const char *operation) const
Check IOstream status for given operation.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool readIfPresent(const dictionary &dict)
Update the value of dimensioned<Type> if found in the dictionary, lookup in dictionary with the name(...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
A traits class, which is primarily used for primitives.
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Generic dimensioned Type class.
const dimensionSet dimless
Dimensionless.
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
#define PRODUCT_OPERATOR(product, op, opFunc)
const dimensionedScalar e
Elementary charge.
pTraits< Type >::cmptType cmptType
Component type.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void writeEntry(const word &keyword, Ostream &os) const
Write as a dictionary entry with keyword.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
Istream & operator>>(Istream &, directionInfo &)
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
A HashTable similar to std::unordered_map.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
bool read(const dictionary &dict)
Update the value of dimensioned<Type>, lookup in dictionary with the name().
An Ostream is an abstract base class for all output systems (streams, files, token lists...
dimensioned()
A dimensionless Zero, named "0".
OBJstream os(runTime.globalPath()/outputName)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
static dimensioned< Type > getOrAddToDict(const word &name, dictionary &dict, const dimensionSet &dims=dimless, const Type &deflt=Type(Zero))
Construct dimensioned from dictionary, with default value.
const word & name() const noexcept
Return const reference to name.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
static bool checkDims(const char *what, const dimensionSet &a, const dimensionSet &b)
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void replace(const direction d, const dimensioned< cmptType > &dc)
Return a component with a dimensioned<cmptType>
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
An input stream of tokens.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)