38#define checkField(gf1, gf2, op) \
39if ((gf1).mesh() != (gf2).mesh()) \
41 FatalErrorInFunction \
42 << "different mesh for fields " \
43 << (gf1).name() << " and " << (gf2).name() \
44 << " during operation " << op \
45 << abort(FatalError); \
51template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
54 const dictionary&
dict
57 Internal::readField(
dict,
"internalField");
59 boundaryField_.readField(*
this,
dict.subDict(
"boundaryField"));
63 if (
dict.readIfPresent(
"referenceLevel", refLevel))
65 Field<Type>::operator+=(refLevel);
67 forAll(boundaryField_, patchi)
69 boundaryField_[patchi] == boundaryField_[patchi] + refLevel;
75template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
78 const localIOdictionary
dict
99template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
104 this->readOpt() == IOobject::MUST_READ
105 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
109 <<
"read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED"
110 <<
" suggests that a read constructor for field " << this->
name()
111 <<
" would be more appropriate." <<
endl;
115 this->readOpt() == IOobject::READ_IF_PRESENT
116 && this->
template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
125 if (this->size() != GeoMesh::size(this->
mesh()))
128 <<
" number of field elements = " << this->size()
129 <<
" number of mesh elements = "
130 << GeoMesh::size(this->
mesh())
131 <<
exit(FatalIOError);
134 readOldTimeIfPresent();
143template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
152 IOobject::READ_IF_PRESENT,
153 IOobject::AUTO_WRITE,
154 this->registerObject()
166 <<
"Reading old time level for field" <<
nl << this->info() <<
endl;
177 field0Ptr_->oriented() = this->oriented();
179 field0Ptr_->timeIndex_ = timeIndex_ - 1;
181 if (!field0Ptr_->readOldTimeIfPresent())
183 field0Ptr_->oldTime();
195template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
201 const word& patchFieldType
207 fieldPrevIterPtr_(nullptr),
211 <<
"Creating temporary" <<
nl << this->info() <<
endl;
217template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
230 fieldPrevIterPtr_(nullptr),
231 boundaryField_(
mesh.
boundary(), *this, patchFieldTypes, actualPatchTypes)
234 <<
"Creating temporary" <<
nl << this->info() <<
endl;
240template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
252 fieldPrevIterPtr_(nullptr),
256 <<
"Creating temporary" <<
nl << this->info() <<
endl;
258 boundaryField_ == dt.
value();
264template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
277 fieldPrevIterPtr_(
nullptr),
278 boundaryField_(
mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
281 <<
"Creating temporary" <<
nl << this->info() <<
endl;
283 boundaryField_ == dt.
value();
289template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
300 fieldPrevIterPtr_(nullptr),
304 <<
"Copy construct from components" <<
nl << this->info() <<
endl;
310template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
315 const PtrList<PatchField<Type>>& ptfl
321 fieldPrevIterPtr_(nullptr),
325 <<
"Move construct from components" <<
nl << this->info() <<
endl;
331template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
336 const PtrList<PatchField<Type>>& ptfl
342 fieldPrevIterPtr_(nullptr),
346 <<
"Construct from tmp internalField" <<
nl << this->info() <<
endl;
352template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
356 const PtrList<PatchField<Type>>& ptfl
362 fieldPrevIterPtr_(nullptr),
366 <<
"Copy construct from components" <<
nl << this->info() <<
endl;
372template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
376 const PtrList<PatchField<Type>>& ptfl
382 fieldPrevIterPtr_(nullptr),
386 <<
"Move construct from components" <<
nl << this->info() <<
endl;
392template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
399 const word& patchFieldType
405 fieldPrevIterPtr_(nullptr),
409 <<
"Copy construct from internal field" <<
nl << this->
info() <<
endl;
415template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
422 const word& patchFieldType
428 fieldPrevIterPtr_(nullptr),
432 <<
"Move construct from internal field" <<
nl << this->
info() <<
endl;
438template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
445 const PtrList<PatchField<Type>>& ptfl
451 fieldPrevIterPtr_(nullptr),
455 <<
"Copy construct from components" <<
nl << this->
info() <<
endl;
461template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
468 const PtrList<PatchField<Type>>& ptfl
474 fieldPrevIterPtr_(nullptr),
478 <<
"Move construct from components" <<
nl << this->info() <<
endl;
484template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
491 const PtrList<PatchField<Type>>& ptfl
497 fieldPrevIterPtr_(nullptr),
501 <<
"Construct from tmp internalField" <<
nl << this->info() <<
endl;
507template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
512 const bool readOldTime
518 fieldPrevIterPtr_(nullptr),
525 if (this->size() != GeoMesh::size(this->
mesh()))
528 <<
" number of field elements = " << this->size()
529 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
530 <<
exit(FatalIOError);
535 readOldTimeIfPresent();
539 <<
"Finishing read-construction" <<
nl << this->info() <<
endl;
543template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
554 fieldPrevIterPtr_(nullptr),
561 if (this->size() != GeoMesh::size(this->
mesh()))
564 <<
" number of field elements = " << this->size()
565 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
570 <<
"Finishing dictionary-construct" <<
nl << this->info() <<
endl;
574template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
583 fieldPrevIterPtr_(nullptr),
584 boundaryField_(*this, gf.boundaryField_)
587 <<
"Copy construct" <<
nl << this->info() <<
endl;
597 this->writeOpt(IOobject::NO_WRITE);
601template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
607 Internal(tgf.constCast(), tgf.movable()),
610 fieldPrevIterPtr_(nullptr),
611 boundaryField_(*this, tgf().boundaryField_)
614 <<
"Constructing from tmp" <<
nl << this->info() <<
endl;
616 this->writeOpt(IOobject::NO_WRITE);
622template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
632 fieldPrevIterPtr_(nullptr),
633 boundaryField_(*this, gf.boundaryField_)
636 <<
"Copy construct, resetting IO params" <<
nl
650template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
660 fieldPrevIterPtr_(
nullptr),
661 boundaryField_(*
this, tgf().boundaryField_)
664 <<
"Constructing from tmp resetting IO params" <<
nl
665 << this->info() <<
endl;
673template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
683 fieldPrevIterPtr_(nullptr),
684 boundaryField_(*this, gf.boundaryField_)
687 <<
"Copy construct, resetting name" <<
nl
690 if (!readIfPresent() && gf.field0Ptr_)
701template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
708 Internal(newName, tgf.constCast(), tgf.movable()),
711 fieldPrevIterPtr_(nullptr),
712 boundaryField_(*this, tgf().boundaryField_)
715 <<
"Constructing from tmp resetting name" <<
nl
722template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
727 const word& patchFieldType
733 fieldPrevIterPtr_(nullptr),
734 boundaryField_(this->
mesh().
boundary(), *this, patchFieldType)
737 <<
"Copy construct, resetting IO params" <<
nl
740 boundaryField_ == gf.boundaryField_;
742 if (!readIfPresent() && gf.field0Ptr_)
753template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
765 fieldPrevIterPtr_(nullptr),
775 <<
"Copy construct, resetting IO params and patch types" <<
nl
778 boundaryField_ == gf.boundaryField_;
780 if (!readIfPresent() && gf.field0Ptr_)
791template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
797 const word& patchFieldType
803 fieldPrevIterPtr_(nullptr),
804 boundaryField_(*this, gf.boundaryField_, patchIDs, patchFieldType)
807 <<
"Copy construct, resetting IO params and setting patchFieldType "
808 <<
"for patchIDs" <<
nl
811 if (!readIfPresent() && gf.field0Ptr_)
822template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
834 fieldPrevIterPtr_(nullptr),
844 <<
"Constructing from tmp resetting IO params and patch types" <<
nl
847 boundaryField_ == tgf().boundaryField_;
853template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
863template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
873template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
878 const bool updateAccessTime
881 if (updateAccessTime)
890template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
895 const bool updateAccessTime
898 if (updateAccessTime)
907template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
912 const bool updateAccessTime
915 if (updateAccessTime)
920 return boundaryField_;
924template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
930 && timeIndex_ != this->time().
timeIndex()
931 && !this->
name().ends_with(
"_0")
935 timeIndex_ = this->time().timeIndex();
943template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
948 field0Ptr_->storeOldTime();
951 <<
"Storing old time field for field" <<
nl << this->info() <<
endl;
953 *field0Ptr_ == *
this;
954 field0Ptr_->timeIndex_ = timeIndex_;
956 if (field0Ptr_->field0Ptr_)
958 field0Ptr_->writeOpt(this->writeOpt());
964template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
969 return field0Ptr_->nOldTimes() + 1;
976template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
991 this->registerObject()
999 <<
"created old time field " << field0Ptr_->info() <<
endl;
1016template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1027template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1030 if (!fieldPrevIterPtr_)
1033 <<
"Allocating previous iteration field" <<
nl
1034 << this->info() <<
endl;
1038 this->
name() +
"PrevIter",
1044 *fieldPrevIterPtr_ == *
this;
1049template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1053 if (!fieldPrevIterPtr_)
1056 <<
"previous iteration field" <<
endl << this->info() <<
endl
1058 <<
" Use field.storePrevIter() at start of iteration."
1062 return *fieldPrevIterPtr_;
1066template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1070 this->setUpToDate();
1072 boundaryField_.evaluate();
1076template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1082 bool needRef =
true;
1084 forAll(boundaryField_, patchi)
1086 if (boundaryField_[patchi].fixesValue())
1099template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1103 <<
"Relaxing" <<
nl << this->info() <<
" by " <<
alpha <<
endl;
1109template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1116 this->
mesh().data::template getOrDefault<bool>
1133template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1141 return this->
name() +
"Final";
1144 return this->
name();
1148template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1156 os <<
"min/max(" << this->
name() <<
") = "
1161template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1172template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1180 this->
name() +
".T()",
1188 Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
1189 Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
1195template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1222 Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
1223 Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
1229template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1242 boundaryFieldRef().replace(d, gcf.boundaryField());
1246template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1254 boundaryFieldRef().replace(d, ds.
value());
1258template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1269template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1280template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1291template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1305template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1312 this->
clip(minVal, maxVal);
1316template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1320 boundaryFieldRef().negate();
1324template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1328 boundaryFieldRef().normalise();
1334template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1354template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1360 const auto& gf = tgf();
1390template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1397 boundaryFieldRef() = dt.
value();
1401template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1407 const auto& gf = tgf();
1420template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1427 boundaryFieldRef() == dt.
value();
1431#define COMPUTED_ASSIGNMENT(TYPE, op) \
1433template<class Type, template<class> class PatchField, class GeoMesh> \
1434void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1436 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1439 checkField(*this, gf, #op); \
1442 boundaryFieldRef() op gf.boundaryField(); \
1445template<class Type, template<class> class PatchField, class GeoMesh> \
1446void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1448 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1451 operator op(tgf()); \
1455template<class Type, template<class> class PatchField, class GeoMesh> \
1456void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1458 const dimensioned<TYPE>& dt \
1462 boundaryFieldRef() op dt.value(); \
1470#undef COMPUTED_ASSIGNMENT
1475template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1491template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
#define checkField(df1, df2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
const dimensionSet & dimensions() const
Return dimensions.
const orientedType & oriented() const noexcept
Return oriented type.
Generic templated field type.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Generic GeometricBoundaryField class.
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
Generic GeometricField class.
void storeOldTime() const
Store the old-time field.
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
void maxMin(const dimensioned< Type > &minVal, const dimensioned< Type > &maxVal)
Deprecated(2019-01) identical to clip()
void relax()
Relax field (for steady-state solution).
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
GeoMesh::Mesh Mesh
The mesh type for the GeometricField.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void clip(const dimensioned< MinMax< Type > > &range)
Clip the field to be bounded within the specified range.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
bool needReference() const
Does the field need a reference level for solution.
virtual ~GeometricField()
Destructor.
void negate()
Negate the field inplace. See notes in Field.
void storePrevIter() const
Store the field as the previous iteration value.
label nOldTimes() const
Return the number of old time fields stored.
word select(bool final) const
Select the final iteration parameters if `final' is true.
void storeOldTimes() const
Store the old-time fields.
void correctBoundaryConditions()
Correct boundary field.
void normalise()
Normalise the field inplace. See notes in Field.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
InfoProxy< IOobject > info() const
Return info proxy, for printing information to a stream.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool good() const noexcept
True if next operation might succeed.
A min/max value pair with additional methods. In addition to conveniently storing values,...
const T & min() const noexcept
The min value (first)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
reference ref() const
A reference to the entry (Error if not found)
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.
const Type & value() const
Return const reference to value.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static void printStack(Ostream &os)
Helper function to print a stack.
Reads fields from the time directories and adds them to the mesh database for further post-processing...
static const complex min
complex (-VGREAT,-VGREAT)
static const complex max
complex (VGREAT,VGREAT)
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
Template functions to aid in the implementation of demand driven data.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionSet clip(const dimensionSet &ds1, const dimensionSet &ds2)
const dimensionSet dimless
Dimensionless.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void deleteDemandDrivenData(DataPtr &dataPtr)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
propsDict readIfPresent("fields", acceptFields)
conserve primitiveFieldRef()+