37 #define checkFieldAssignment(df1, df2) \
41 static_cast<const regIOobject*>(&df1) \
42 == static_cast<const regIOobject*>(&df2) \
45 FatalErrorInFunction \
46 << "attempted assignment to self for field " \
47 << (df1).name() << abort(FatalError); \
51 #define checkFieldOperation(df1, df2, op) \
53 if (&(df1).mesh() != &(df2).mesh()) \
55 FatalErrorInFunction \
56 << "different mesh for fields " \
57 << (df1).name() << " and " << (df2).name() \
58 << " during operation " << op \
59 << abort(FatalError); \
65 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
71 const PrimitiveField<Type>& field
75 PrimitiveField<Type>(field),
80 if (field.size() && field.size() !=
mesh.size())
83 <<
"size of field = " << field.size()
84 <<
" is not the same as the size of mesh = "
91 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
97 const tmp<PrimitiveField<Type>>& tfield
101 PrimitiveField<Type>(tfield),
106 if (this->size() && this->size() !=
mesh.size())
109 <<
"size of field = " << this->size()
110 <<
" is not the same as the size of mesh = "
117 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
123 const bool checkIOFlags
127 PrimitiveField<Type>(
mesh.size()),
142 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
148 const bool checkIOFlags
164 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
171 PrimitiveField<Type>(df),
174 dimensions_(df.dimensions_)
178 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
185 PrimitiveField<Type>(move(df)),
188 dimensions_(move(df.dimensions_))
192 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
193 template<
template<
class>
class PrimitiveField2>
200 PrimitiveField<Type>(df),
203 dimensions_(df.dimensions())
207 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
208 template<
template<
class>
class PrimitiveField2>
216 PrimitiveField<Type>(df, reuse),
219 dimensions_(df.dimensions())
223 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
237 dimensions_(tdf().dimensions_)
243 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
244 template<
template<
class>
class PrimitiveField2>
249 const bool checkIOFlags
253 PrimitiveField<Type>(df),
256 dimensions_(df.dimensions_)
258 if (!checkIOFlags || !readIfPresent())
260 copyOldTimes(io, df);
265 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
266 template<
template<
class>
class PrimitiveField2>
272 const bool checkIOFlags
276 PrimitiveField<Type>(df, reuse),
279 dimensions_(df.dimensions_)
288 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
293 const bool checkIOFlags
304 dimensions_(tdf().dimensions_)
315 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
316 template<
template<
class>
class PrimitiveField2>
324 PrimitiveField<Type>(df),
327 dimensions_(df.dimensions_)
333 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
334 template<
template<
class>
class PrimitiveField2>
343 PrimitiveField<Type>(df, reuse),
346 dimensions_(df.dimensions_)
350 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
365 dimensions_(tdf().dimensions_)
371 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
382 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
389 const PrimitiveField<Type>& field
416 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
423 const tmp<PrimitiveField<Type>>& tfield
450 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
483 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
516 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
517 template<
template<
class>
class PrimitiveField2>
548 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
556 const bool cacheTmp = tdf().db().temporaryObjectCached(newName);
581 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
584 db().cacheTemporaryObject(*
this);
590 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
591 PrimitiveField<Type>&
600 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
631 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
632 template<
template<
class>
class PrimitiveField2>
644 PrimitiveField<Type>::replace(d, df);
648 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
649 template<
template<
class>
class PrimitiveField2>
669 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
689 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
695 this->
name() +
".average()",
704 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
705 template<
template<
class>
class PrimitiveField2>
716 this->
name() +
".weightedAverage(weights)",
718 gSum(weightField*primitiveField())/
gSum(weightField)
724 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
725 template<
template<
class>
class PrimitiveField2>
733 tweightField.clear();
738 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
739 template<
template<
class>
class PrimitiveField2>
752 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
777 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
778 template<
template<
class>
class PrimitiveField2>
790 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
800 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
810 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
824 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
834 PrimitiveField<Type>::operator=(df);
838 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
848 PrimitiveField<Type>::operator=(move(df));
852 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
878 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
879 template<
template<
class>
class PrimitiveField2>
888 PrimitiveField<Type>::operator=(df);
892 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
893 template<
template<
class>
class PrimitiveField2>
904 PrimitiveField<Type>::operator=(df);
909 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
916 PrimitiveField<Type>::operator=(dt.
value());
920 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
923 PrimitiveField<Type>::operator=(
Zero);
927 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
928 template<
template<
class>
class PrimitiveField2>
938 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
939 template<
template<
class>
class PrimitiveField2>
945 this->operator=(tdf);
949 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
959 template<
class Type,
class GeoMesh,
template<
class>
class PrimitiveField>
962 this->operator=(
Zero);
966 #define COMPUTED_ASSIGNMENT(TYPE, op) \
968 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
969 template<template<class> class PrimitiveField2> \
970 void DimensionedField<Type, GeoMesh, PrimitiveField>::operator op \
972 const DimensionedField<TYPE, GeoMesh, PrimitiveField2>& df \
975 checkFieldOperation(*this, df, #op); \
977 dimensions_ op df.dimensions(); \
978 PrimitiveField<Type>::operator op(df); \
981 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
982 template<template<class> class PrimitiveField2> \
983 void DimensionedField<Type, GeoMesh, PrimitiveField>::operator op \
985 const tmp<DimensionedField<TYPE, GeoMesh, PrimitiveField2>>& tdf \
988 operator op(tdf()); \
992 template<class Type, class GeoMesh, template<class> class PrimitiveField> \
993 void DimensionedField<Type, GeoMesh, PrimitiveField>::operator op \
995 const dimensioned<TYPE>& dt \
998 dimensions_ op dt.dimensions(); \
999 PrimitiveField<Type>::operator op(dt.value()); \
1007 #undef COMPUTED_ASSIGNMENT
1012 #undef checkFieldAssignment
1013 #undef checkFieldOperation
#define checkFieldOperation(df1, df2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
#define checkFieldAssignment(df1, df2)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
PrimitiveField< Type >::cmptType cmptType
Component type of the elements of the field.
friend class DimensionedField
Declare friendship with other dimensioned fields.
const dimensionSet & dimensions() const
Return dimensions.
PrimitiveField< Type > & primitiveFieldRef()
Return a reference to the internal field.
const GeoMesh & mesh() const
Return mesh.
const PrimitiveField< Type > & primitiveField() const
Return a const-reference to the primitive field.
Pre-declare SubField and related Field type.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const fileName & local() const
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
const objectRegistry & db() const
Return the local objectRegistry.
Class to add into field types to provide old-time storage and retrieval.
void copyOldTimes(const IOobject &io, const OtherOldTime< OtherPrimitiveField > &)
Copy the old-times from the given field.
Dimension set for the base types.
Generic dimensioned Type class.
const dimensionSet & dimensions() const
Return const reference to dimensions.
const Type & value() const
Return const reference to value.
const word & name() const
Return const reference to name.
virtual const objectRegistry & db() const
Return the object registry - resolve conflict polyMesh/lduMesh.
label size() const
Return fvMesh size.
const Time & time() const
Return time.
bool temporaryObjectCached(const word &name) const
Return true if given name is in the cacheTemporaryObjects set.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gAverage(const UList< Type > &f, const label comm)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
errorManip< error > abort(error &err)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Type gSum(const UList< Type > &f, const label comm)
void component(GeometricField< typename GeometricField< Type, GeoMesh, PrimitiveField1 >::cmptType, GeoMesh, PrimitiveField1 > &gcf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf, const direction d)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
points setSize(newPointi)
conserve primitiveFieldRef()+