35void Foam::dimensioned<Type>::initialize(Istream& is,
const bool checkDims)
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);
56 if (checkDims && curr != dimensions_)
59 <<
"The dimensions " << dimensions_
60 <<
" provided do not match the expected dimensions "
62 <<
abort(FatalIOError);
73bool Foam::dimensioned<Type>::readEntry
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();
96 initialize(is, checkDims);
98 dict.checkITstream(is, key);
102 else if (IOobjectOption::isReadRequired(readOpt))
105 <<
"Entry '" <<
key <<
"' not found in dictionary "
107 <<
exit(FatalIOError);
195 dimensions_(dt.dimensions_),
213 initialize(is,
false);
233 initialize(is,
true);
278 const word& entryName
344 initialize(is,
true);
432 dimensions_ = dc.dimensions();
433 value_.replace(d, dc.value());
454 const word& entryName,
466 const word& entryName,
486 dimensions_.read(is, mult);
506 dimensions_.
read(is, mult, readSet);
529 dimensions_.
read(is, mult, readSet);
549 os.writeKeyword(keyword);
551 if (keyword != name_)
560 os.writeKeyword(name_);
565 dimensions_.write(
os, mult);
594 dimensions_ += dt.dimensions_;
605 dimensions_ -= dt.dimensions_;
632template<
class Type, Foam::direction r>
636 return dimensioned<typename powProduct<Type, r>::type>
638 "pow(" + dt.name() +
',' +
name(r) +
')',
639 pow(dt.dimensions(), r),
646Foam::dimensioned<typename Foam::outerProduct<Type, Type>::type>
651 "sqr(" + dt.name() +
')',
652 sqr(dt.dimensions()),
658Foam::dimensioned<typename Foam::typeOfMag<Type>::type>
665 "magSqr(" + dt.name() +
')',
672Foam::dimensioned<typename Foam::typeOfMag<Type>::type>
679 "mag(" + dt.name() +
')',
695 "cmptMultiply(" + dt1.name() +
',' + dt2.name() +
')',
710 "cmptDivide(" + dt1.name() +
',' + dt2.name() +
')',
711 cmptDivide(dt1.dimensions(), dt2.dimensions()),
726 "max(" + a.name() +
',' +
b.
name() +
')',
728 max(a.value(),
b.value())
742 "min(" + a.name() +
',' +
b.
name() +
')',
744 min(a.value(),
b.value())
761 lerp(a.value(),
b.value(), t)
771 dt.initialize(is,
false);
785 dt.dimensions().write(
os, mult);
800 const dimensioned<Type>& dt1,
801 const dimensioned<Type>& dt2
804 return dt1.value() < dt2.value();
811 const dimensioned<Type>& dt1,
812 const dimensioned<Type>& dt2
815 return dt2.value() < dt1.value();
820Foam::dimensioned<Type> Foam::operator+
828 '(' + dt1.
name() +
'+' + dt2.name() +
')',
830 dt1.
value() + dt2.value()
848Foam::dimensioned<Type> Foam::operator-
856 '(' + dt1.
name() +
'-' + dt2.name() +
')',
858 dt1.
value() - dt2.value()
864Foam::dimensioned<Type> Foam::operator*
872 '(' + ds.
name() +
'*' + dt.name() +
')',
874 ds.
value() * dt.value()
880Foam::dimensioned<Type> Foam::operator/
888 '(' + dt.name() +
'|' + ds.
name() +
')',
890 dt.value() / ds.
value()
895#define PRODUCT_OPERATOR(product, op, opFunc) \
897template<class Type1, class Type2> \
898Foam::dimensioned<typename Foam::product<Type1, Type2>::type> \
901 const dimensioned<Type1>& dt1, \
902 const dimensioned<Type2>& dt2 \
905 return dimensioned<typename product<Type1, Type2>::type> \
907 '(' + dt1.name() + #op + dt2.name() + ')', \
908 dt1.dimensions() op dt2.dimensions(), \
909 dt1.value() op dt2.value() \
913template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \
914Foam::dimensioned<typename Foam::product<Type, Form>::type> \
917 const dimensioned<Type>& dt1, \
918 const VectorSpace<Form,Cmpt,nCmpt>& t2 \
921 return dimensioned<typename product<Type, Form>::type> \
923 '(' + dt1.name() + #op + name(t2) + ')', \
925 dt1.value() op static_cast<const Form&>(t2) \
929template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \
930Foam::dimensioned<typename Foam::product<Form, Type>::type> \
933 const VectorSpace<Form,Cmpt,nCmpt>& t1, \
934 const dimensioned<Type>& dt2 \
937 return dimensioned<typename product<Form, Type>::type> \
939 '(' + name(t1) + #op + dt2.name() + ')', \
941 static_cast<const Form&>(t1) op dt2.value() \
951#undef PRODUCT_OPERATOR
propsDict readIfPresent("fields", acceptFields)
const dimensionSet & dimensions() const noexcept
Return dimensions.
A HashTable similar to std::unordered_map.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
const word & name() const noexcept
Return the object name.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
virtual Istream & read(token &)=0
Return next token from stream.
virtual const fileName & name() const override
Read/write access to the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endEntry()
Write end entry (';') followed by newline.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Generic dimensioned Type class.
dimensioned< cmptType > component(const direction d) const
Return a component as a dimensioned<cmptType>.
void replace(const direction d, const dimensioned< cmptType > &dc)
Return a component with a dimensioned<cmptType>.
dimensioned()
A dimensionless Zero, named "0".
bool read(const dictionary &dict)
Update the value of dimensioned<Type>, lookup in dictionary with the name().
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
pTraits< Type >::cmptType cmptType
Component type.
void writeEntry(const word &keyword, Ostream &os) const
Write as a dictionary entry with keyword.
const word & name() const noexcept
Return const reference to name.
bool readIfPresent(const dictionary &dict)
Update the value of dimensioned<Type> if found in the dictionary, lookup in dictionary with the name(...
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.
const Type & value() const noexcept
Return const reference to value.
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.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
A traits class, which is primarily used for primitives and vector-space.
symmTypeOfRank< typenamepTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank)>::type type
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
pTraits< typenamepTraits< arg1 >::cmptType >::magType type
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define PRODUCT_OPERATOR(product, op, opFunc)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
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))
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const dimensionSet dimless
Dimensionless.
bool read(const char *buf, int32_t &val)
Same as readInt32.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)