38 const unitSet& defaultUnits,
51 else if (nextToken.isWord())
53 name_ = nextToken.wordToken();
61 if (!nextToken.isWord())
63 is.putBack(nextToken);
67 unitSet units(defaultUnits);
71 value_ = pTraits<Type>(is);
74 if (!haveUnits && !is.eof())
144 dimensions_(dt.dimensions_),
196 initialise(
name, units, is);
225 dimensions_(units.dimensions()),
238 const Type& defaultValue
261 const Type& defaultValue
274 const Type& defaultValue
278 dimensions_(units.dimensions()),
356 dimensions_ = dc.dimensions();
357 value_.replace(d, dc.value());
371 isNull(defaultUnits) ? dimensions_ : defaultUnits,
391 isNull(defaultUnits) ? dimensions_ : defaultUnits,
407 const Type& defaultValue,
418 isNull(defaultUnits) ? dimensions_ : defaultUnits,
424 value_ = defaultValue;
442 dimensions_ += dt.dimensions_;
450 dimensions_ -= dt.dimensions_;
471 template<
class Type, Foam::direction r>
477 "pow(" + dt.
name() +
',' +
name(r) +
')',
490 "sqr(" + dt.name() +
')',
491 sqr(dt.dimensions()),
500 return dimensioned<scalar>
502 "magSqr(" + dt.name() +
')',
512 return dimensioned<scalar>
514 "mag(" + dt.name() +
')',
524 const dimensioned<Type>& dt1,
525 const dimensioned<Type>& dt2
528 return dimensioned<Type>
530 "cmptMultiply(" + dt1.name() +
',' + dt2.name() +
')',
540 const dimensioned<Type>& dt1,
541 const dimensioned<Type>& dt2
544 return dimensioned<Type>
546 "cmptDivide(" + dt1.name() +
',' + dt2.name() +
')',
547 cmptDivide(dt1.dimensions(), dt2.dimensions()),
556 const dimensioned<Type>& dt1,
557 const dimensioned<Type>& dt2
560 if (dt1.dimensions() != dt2.dimensions())
563 <<
"dimensions of arguments are not equal"
567 return dimensioned<Type>
569 "max(" + dt1.name() +
',' + dt2.name() +
')',
571 max(dt1.value(), dt2.value())
579 const dimensioned<Type>& dt1,
580 const dimensioned<Type>& dt2
583 if (dt1.dimensions() != dt2.dimensions())
586 <<
"dimensions of arguments are not equal"
590 return dimensioned<Type>
592 "min(" + dt1.name() +
',' + dt2.name() +
')',
594 min(dt1.value(), dt2.value())
626 is.
check(
"Istream& operator>>(Istream&, dimensioned<Type>&)");
639 dt.dimensions().write(os);
647 os.check(
"Ostream& operator<<(Ostream&, const dimensioned<Type>&)");
662 return dt1.value() > dt2.value();
673 return dt1.value() < dt2.value();
680 const dimensioned<Type>& dt1,
681 const dimensioned<Type>& dt2
684 return dimensioned<Type>
686 '(' + dt1.name() +
'+' + dt2.name() +
')',
687 dt1.dimensions() + dt2.dimensions(),
688 dt1.value() + dt2.value()
696 return dimensioned<Type>
708 const dimensioned<Type>& dt1,
709 const dimensioned<Type>& dt2
712 return dimensioned<Type>
714 '(' + dt1.name() +
'-' + dt2.name() +
')',
715 dt1.dimensions() - dt2.dimensions(),
716 dt1.value() - dt2.value()
724 const dimensioned<scalar>& ds,
725 const dimensioned<Type>& dt
728 return dimensioned<Type>
730 '(' + ds.
name() +
'*' + dt.name() +
')',
732 ds.
value() * dt.value()
740 const dimensioned<Type>& dt,
741 const dimensioned<scalar>& ds
744 return dimensioned<Type>
746 '(' + dt.name() +
'|' + ds.
name() +
')',
748 dt.value()/ds.
value()
753 #define PRODUCT_OPERATOR(product, op, opFunc) \
755 template<class Type1, class Type2> \
756 Foam::dimensioned<typename Foam::product<Type1, Type2>::type> \
759 const dimensioned<Type1>& dt1, \
760 const dimensioned<Type2>& dt2 \
763 return dimensioned<typename product<Type1, Type2>::type> \
765 '(' + dt1.name() + #op + dt2.name() + ')', \
766 dt1.dimensions() op dt2.dimensions(), \
767 dt1.value() op dt2.value() \
771 template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \
772 Foam::dimensioned<typename Foam::product<Type, Form>::type> \
775 const dimensioned<Type>& dt1, \
776 const VectorSpace<Form,Cmpt,nCmpt>& t2 \
779 return dimensioned<typename product<Type, Form>::type> \
781 '(' + dt1.name() + #op + name(t2) + ')', \
783 dt1.value() op static_cast<const Form&>(t2) \
787 template<class Type, class Form, class Cmpt, Foam::direction nCmpt> \
788 Foam::dimensioned<typename Foam::product<Form, Type>::type> \
791 const VectorSpace<Form,Cmpt,nCmpt>& t1, \
792 const dimensioned<Type>& dt2 \
795 return dimensioned<typename product<Form, Type>::type> \
797 '(' + name(t1) + #op + dt2.name() + ')', \
799 static_cast<const Form&>(t1) op dt2.value() \
808 #undef PRODUCT_OPERATOR
virtual bool check(const char *operation) const
Check IOstream status for given operation.
virtual const fileName & name() const
Return the name of the stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Dimension set for the base types.
Ostream & write(Ostream &os) const
Write.
Generic dimensioned Type class.
void operator+=(const dimensioned< Type > &)
dimensioned()
Null constructor.
void replace(const direction, const dimensioned< cmptType > &)
Return a component with a dimensioned<cmptType>
const dimensionSet & dimensions() const
Return const reference to dimensions.
void read(const dictionary &, const unitSet &defaultUnits=NullObjectRef< unitSet >())
Update the value of dimensioned<Type>
pTraits< Type >::cmptType cmptType
Component type.
const Type & value() const
Return const reference to value.
dimensioned< cmptType > component(const direction) const
Return a component as a dimensioned<cmptType>
void operator/=(const scalar)
void operator-=(const dimensioned< Type > &)
dimensioned< cmptType > operator[](const direction) const
Return a component as a dimensioned<cmptType>
bool readIfPresent(const dictionary &, const unitSet &defaultUnits=NullObjectRef< unitSet >())
Update the value of dimensioned<Type> if found in the dictionary.
void readOrDefault(const dictionary &, const Type &defaultValue, const unitSet &defaultUnits=NullObjectRef< unitSet >())
Update the value of dimensioned<Type> if found in the dictionary.
const word & name() const
Return const reference to name.
void operator*=(const scalar)
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
Traits class for primitives.
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
static bool haveDefaults(const dictionary &dict)
Return if a dictionary exists to add defaults to for a given.
static dictionary & defaults(const dictionary &dict)
Return the dictionary to add defaults to for a given dictionary.
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
bool readIfPresent(const word &keyword, const dictionary &)
Update if found in the dictionary.
const dimensionSet & dimensions() const
Access the dimensions.
void makeStandard(T &) const
Convert a value to standard units.
A class for handling words, derived from string.
static const word null
An empty word.
#define PRODUCT_OPERATOR(product, op, opFunc)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionSet dimless
Istream & operator>>(Istream &, pointEdgeDist &)
const dimensionSet & dimless
void outer(GeometricField< typename outerProduct< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMultiply(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type, GeoMesh, PrimitiveField2 > &df2)
errorManip< error > abort(error &err)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void component(GeometricField< typename GeometricField< Type, GeoMesh, PrimitiveField1 >::cmptType, GeoMesh, PrimitiveField1 > &gcf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf, const direction d)
tmp< DimensionedField< Type, GeoMesh, Field > > cmptDivide(const DimensionedField< Type, GeoMesh, PrimitiveField1 > &df1, const DimensionedField< Type, GeoMesh, PrimitiveField2 > &df2)
void dotdot(GeometricField< typename scalarProduct< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
tmp< DimensionedField< Type, GeoMesh, Field > > operator-(const DimensionedField< Type, GeoMesh, PrimitiveField > &df1)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void cross(GeometricField< typename crossProduct< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
void dot(GeometricField< typename innerProduct< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)