36#define checkField(fld1, fld2, op) \
37if (&(fld1).mesh() != &(fld2).mesh()) \
39 FatalErrorInFunction \
40 << "Different mesh for fields " \
41 << (fld1).name() << " and " << (fld2).name() \
42 << " during operation " << op \
43 << abort(FatalError); \
49template<
class Type,
class GeoMesh>
50void Foam::DimensionedField<Type, GeoMesh>::checkFieldSize()
const
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 = "
70template<
class Type,
class GeoMesh>
75 const dimensionSet& dims,
76 const Field<Type>&
field
80 DynamicField<Type>(
field),
88template<
class Type,
class GeoMesh>
106template<
class Type,
class GeoMesh>
124template<
class Type,
class GeoMesh>
134 DynamicField<Type>(tfield.constCast(), tfield.movable()),
143template<
class Type,
class GeoMesh>
149 const bool checkIOFlags,
150 const bool extraCapacity
157 std::pair<label,label>
161 + (extraCapacity ?
GeoMesh::boundary_size(
mesh) : label(0))
174template<
class Type,
class GeoMesh>
180 const dimensionSet& dims,
181 const bool checkIOFlags,
182 const bool extraCapacity
189 std::pair<label,label>
193 + (extraCapacity ?
GeoMesh::boundary_size(
mesh) : label(0))
199 if (!checkIOFlags || !readIfPresent())
202 this->
field() = value;
207template<
class Type,
class GeoMesh>
212 const dimensioned<Type>& dt,
213 const bool checkIOFlags,
214 const bool extraCapacity
217 DimensionedField<Type, GeoMesh>
229template<
class Type,
class GeoMesh>
238 dimensions_(df.dimensions_),
239 oriented_(df.oriented_)
243template<
class Type,
class GeoMesh>
253template<
class Type,
class GeoMesh>
263 dimensions_(df.dimensions_),
264 oriented_(df.oriented_)
268template<
class Type,
class GeoMesh>
280template<
class Type,
class GeoMesh>
290 dimensions_(df.dimensions_),
291 oriented_(df.oriented_)
295template<
class Type,
class GeoMesh>
306template<
class Type,
class GeoMesh>
317 dimensions_(df.dimensions_),
318 oriented_(df.oriented_)
322template<
class Type,
class GeoMesh>
335template<
class Type,
class GeoMesh>
345 dimensions_(df.dimensions_),
346 oriented_(df.oriented_)
350template<
class Type,
class GeoMesh>
361template<
class Type,
class GeoMesh>
372 dimensions_(df.dimensions_),
373 oriented_(df.oriented_)
377template<
class Type,
class GeoMesh>
390template<
class Type,
class GeoMesh>
400template<
class Type,
class GeoMesh>
410template<
class Type,
class GeoMesh>
436template<
class Type,
class GeoMesh>
450template<
class Type,
class GeoMesh>
468template<
class Type,
class GeoMesh>
485template<
class Type,
class GeoMesh>
494 this->
name() +
".average()",
501template<
class Type,
class GeoMesh>
511 this->
name() +
".weightedAverage(weights)",
518template<
class Type,
class GeoMesh>
533template<
class Type,
class GeoMesh>
546 dimensions_ = df.dimensions();
547 oriented_ = df.oriented();
552template<
class Type,
class GeoMesh>
558 auto& df = tdf.constCast();
567 dimensions_ = df.dimensions();
568 oriented_ = df.oriented();
574template<
class Type,
class GeoMesh>
580 dimensions_ = dt.dimensions();
585template<
class Type,
class GeoMesh>
592#define COMPUTED_ASSIGNMENT(TYPE, op) \
594template<class Type, class GeoMesh> \
595void Foam::DimensionedField<Type, GeoMesh>::operator op \
597 const DimensionedField<TYPE, GeoMesh>& df \
600 checkField(*this, df, #op); \
602 dimensions_ op df.dimensions(); \
603 oriented_ op df.oriented(); \
604 DynamicField<Type>::operator op(df); \
607template<class Type, class GeoMesh> \
608void Foam::DimensionedField<Type, GeoMesh>::operator op \
610 const tmp<DimensionedField<TYPE, GeoMesh>>& tdf \
613 operator op(tdf()); \
617template<class Type, class GeoMesh> \
618void Foam::DimensionedField<Type, GeoMesh>::operator op \
620 const dimensioned<TYPE>& dt \
623 dimensions_ op dt.dimensions(); \
624 DynamicField<Type>::operator op(dt.value()); \
632#undef COMPUTED_ASSIGNMENT
#define checkField(fld1, fld2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
tmp< DimensionedField< Type, GeoMesh > > T() const
Return the field transpose (only defined for second rank tensors).
tmp< DimensionedField< Type, GeoMesh > > clone() const
Clone.
DimensionedField(const IOobject &io, const Mesh &mesh, const dimensionSet &dims, const Field< Type > &field)
Construct from components, copy initial field content.
GeoMesh::Mesh Mesh
The mesh type for the DimensionedField.
this_type & constCast() const noexcept
Return non-const reference to this field.
const DynamicField< Type > & field() const noexcept
Return const-reference to the primitive field values.
tmp< DimensionedField< cmptType, GeoMesh > > component(const direction d) const
Return a component field of the field.
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
void operator=(const DimensionedField< Type, GeoMesh > &df)
void replace(const direction d, const DimensionedField< cmptType, GeoMesh > &df)
Replace a component field of the field.
Field< Type >::cmptType cmptType
Component type of the field elements.
dimensioned< Type > average(const label comm=UPstream::worldComm) const
Return the global arithmetic average.
friend Ostream & operator(Ostream &os, const DimensionedField< Type, GeoMesh > &df)
Calls DimensionedField::writeData().
dimensioned< Type > weightedAverage(const DimensionedField< scalar, GeoMesh > &weights, const label comm=UPstream::worldComm) const
Return the global weighted average.
static tmp< DimensionedField< Type, GeoMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const Field< Type > &iField)
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions, copy of internal field....
virtual ~DimensionedField()
Destructor.
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void transfer(List< Type > &list)
void operator=(const T &val)
Assign addressed entries to the given value.
constexpr DynamicField() noexcept
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
void replace(const direction, const UList< cmptType > &)
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Generic dimensioned Type class.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
A class for managing temporary objects.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
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.
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.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Type weightedAverage(const UList< scalar > &weights, const UList< Type > &fld)
The local weighted average of a field, using the mag() of the weights.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)