36 #define checkField(fld1, fld2, op) \ 37 if (&(fld1).mesh() != &(fld2).mesh()) \ 39 FatalErrorInFunction \ 40 << "Different mesh for fields " \ 41 << (fld1).name() << " and " << (fld2).name() \ 42 << " during operation " << op \ 43 << abort(FatalError); \ 49 template<
class Type,
class GeoMesh>
52 const label fieldSize = this->size();
55 const label meshSize = GeoMesh::size(this->mesh_);
56 if (fieldSize != meshSize)
59 <<
"size of field = " << fieldSize
60 <<
" is not the same as the size of mesh = " 70 template<
class Type,
class GeoMesh>
88 template<
class Type,
class GeoMesh>
106 template<
class Type,
class GeoMesh>
124 template<
class Type,
class GeoMesh>
134 Field<Type>(tfield.constCast(), tfield.movable()),
143 template<
class Type,
class GeoMesh>
149 const bool checkIOFlags
164 template<
class Type,
class GeoMesh>
170 const dimensionSet& dims,
171 const bool checkIOFlags
175 Field<Type>(GeoMesh::size(
mesh)),
187 template<
class Type,
class GeoMesh>
192 const dimensioned<Type>& dt,
193 const bool checkIOFlags
196 DimensionedField<Type, GeoMesh>
207 template<
class Type,
class GeoMesh>
216 dimensions_(df.dimensions_),
217 oriented_(df.oriented_)
221 template<
class Type,
class GeoMesh>
231 template<
class Type,
class GeoMesh>
239 Field<Type>(df, reuse),
241 dimensions_(df.dimensions_),
242 oriented_(df.oriented_)
246 template<
class Type,
class GeoMesh>
258 template<
class Type,
class GeoMesh>
268 dimensions_(df.dimensions_),
269 oriented_(df.oriented_)
273 template<
class Type,
class GeoMesh>
284 template<
class Type,
class GeoMesh>
293 Field<Type>(df, reuse),
295 dimensions_(df.dimensions_),
296 oriented_(df.oriented_)
300 template<
class Type,
class GeoMesh>
313 template<
class Type,
class GeoMesh>
323 dimensions_(df.dimensions_),
324 oriented_(df.oriented_)
328 template<
class Type,
class GeoMesh>
339 template<
class Type,
class GeoMesh>
348 Field<Type>(df, reuse),
350 dimensions_(df.dimensions_),
351 oriented_(df.oriented_)
355 template<
class Type,
class GeoMesh>
368 template<
class Type,
class GeoMesh>
378 template<
class Type,
class GeoMesh>
388 template<
class Type,
class GeoMesh>
414 template<
class Type,
class GeoMesh>
418 const DimensionedField
420 typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh
424 Field<Type>::replace(d, df);
428 template<
class Type,
class GeoMesh>
436 typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh
446 template<
class Type,
class GeoMesh>
463 template<
class Type,
class GeoMesh>
472 this->
name() +
".average()",
479 template<
class Type,
class GeoMesh>
489 this->
name() +
".weightedAverage(weights)",
496 template<
class Type,
class GeoMesh>
511 template<
class Type,
class GeoMesh>
524 dimensions_ = df.dimensions();
525 oriented_ = df.oriented();
530 template<
class Type,
class GeoMesh>
536 auto& df = tdf.constCast();
545 dimensions_ = df.dimensions();
546 oriented_ = df.oriented();
552 template<
class Type,
class GeoMesh>
559 Field<Type>::operator=(dt.
value());
563 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 565 template<class Type, class GeoMesh> \ 566 void Foam::DimensionedField<Type, GeoMesh>::operator op \ 568 const DimensionedField<TYPE, GeoMesh>& df \ 571 checkField(*this, df, #op); \ 573 dimensions_ op df.dimensions(); \ 574 oriented_ op df.oriented(); \ 575 Field<Type>::operator op(df); \ 578 template<class Type, class GeoMesh> \ 579 void Foam::DimensionedField<Type, GeoMesh>::operator op \ 581 const tmp<DimensionedField<TYPE, GeoMesh>>& tdf \ 584 operator op(tdf()); \ 588 template<class Type, class GeoMesh> \ 589 void Foam::DimensionedField<Type, GeoMesh>::operator op \ 591 const dimensioned<TYPE>& dt \ 594 dimensions_ op dt.dimensions(); \ 595 Field<Type>::operator op(dt.value()); \ 603 #undef COMPUTED_ASSIGNMENT tmp< DimensionedField< Type, GeoMesh > > clone() const
Clone.
const Type & value() const noexcept
Return const reference to value.
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
dimensioned< Type > average(const label comm=UPstream::worldComm) const
Return the global arithmetic average.
void replace(const direction d, const DimensionedField< cmptType, GeoMesh > &df)
Replace a component field of the field.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensioned< Type > weightedAverage(const DimensionedField< scalar, GeoMesh > &weights, const label comm=UPstream::worldComm) const
Return the global weighted average.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
DimensionedField(const IOobject &io, const Mesh &mesh, const dimensionSet &dims, const Field< Type > &field)
Construct from components, copy initial field content.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Generic dimensioned Type class.
Field< Type >::cmptType cmptType
Component type of the field elements.
tmp< DimensionedField< cmptType, GeoMesh > > component(const direction d) const
Return a component field of the field.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Generic templated field type.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
Type weightedAverage(const UList< scalar > &weights, const UList< Type > &fld)
The local weighted average of a field, using the mag() of the weights.
tmp< DimensionedField< Type, GeoMesh > > T() const
Return the field transpose (only defined for second rank tensors)
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
virtual ~DimensionedField()
Destructor.
errorManip< error > abort(error &err)
#define COMPUTED_ASSIGNMENT(TYPE, op)
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define checkField(fld1, fld2, op)
const Field< Type > & field() const noexcept
Return const-reference to the primitive field values.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)