35 #define checkField(gf1, gf2, op) \
36 if ((gf1).mesh() != (gf2).mesh()) \
38 FatalErrorInFunction \
39 << "different mesh for fields " \
40 << (gf1).name() << " and " << (gf2).name() \
41 << " during operatrion " << op \
42 << abort(FatalError); \
48 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
51 const dictionary&
dict
54 Internal::readField(
dict,
"internalField");
56 boundaryField_.readField(*
this,
dict.subDict(
"boundaryField"));
58 if (
dict.found(
"referenceLevel"))
60 Type fieldAverage(pTraits<Type>(
dict.lookup(
"referenceLevel")));
62 Field<Type>::operator+=(fieldAverage);
66 boundaryField_[
patchi] == boundaryField_[
patchi] + fieldAverage;
72 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
75 const localIOdictionary
dict
96 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
101 this->readOpt() == IOobject::MUST_READ
102 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
106 <<
"read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED"
107 <<
" suggests that a read constructor for field " << this->
name()
108 <<
" would be more appropriate." <<
endl;
112 this->readOpt() == IOobject::READ_IF_PRESENT
119 if (this->size() != GeoMesh::size(this->mesh()))
122 <<
" number of field elements = " << this->size()
123 <<
" number of mesh elements = "
124 << GeoMesh::size(this->mesh())
128 readOldTimeIfPresent();
137 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
141 typeIOobject<GeometricField<Type, PatchField, GeoMesh>> field0
146 IOobject::READ_IF_PRESENT,
147 IOobject::AUTO_WRITE,
148 this->registerObject()
151 if (field0.headerOk())
159 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
165 field0Ptr_->timeIndex_ = timeIndex_ - 1;
167 if (!field0Ptr_->readOldTimeIfPresent())
169 field0Ptr_->oldTime();
181 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
193 fieldPrevIterPtr_(nullptr),
205 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
218 fieldPrevIterPtr_(nullptr),
219 boundaryField_(mesh.
boundary(), *this, patchFieldTypes, actualPatchTypes)
230 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
242 fieldPrevIterPtr_(nullptr),
250 boundaryField_ == dt.
value();
256 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
269 fieldPrevIterPtr_(
nullptr),
270 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
277 boundaryField_ == dt.
value();
283 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
288 const PtrList<PatchField<Type>>& ptfl
294 fieldPrevIterPtr_(nullptr),
295 boundaryField_(this->mesh().
boundary(), *this, ptfl)
300 <<
"Constructing from components" <<
endl << this->info() <<
endl;
307 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
320 fieldPrevIterPtr_(nullptr),
321 boundaryField_(mesh.
boundary(), *this, ptfl)
326 <<
"Constructing from components" <<
endl << this->info() <<
endl;
333 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
343 fieldPrevIterPtr_(nullptr),
350 if (this->size() != GeoMesh::size(this->mesh()))
353 <<
" number of field elements = " << this->size()
354 <<
" number of mesh elements = " << GeoMesh::size(this->mesh())
358 readOldTimeIfPresent();
363 <<
"Finishing read-construction of" <<
endl << this->info() <<
endl;
368 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
379 fieldPrevIterPtr_(nullptr),
386 if (this->size() != GeoMesh::size(this->mesh()))
389 <<
" number of field elements = " << this->size()
390 <<
" number of mesh elements = " << GeoMesh::size(this->mesh())
397 <<
"Finishing dictionary-construct of "
403 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
412 fieldPrevIterPtr_(nullptr),
413 boundaryField_(*this, gf.boundaryField_)
418 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
421 if (gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
429 this->writeOpt() = IOobject::NO_WRITE;
433 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
442 fieldPrevIterPtr_(nullptr),
443 boundaryField_(*this, gf.boundaryField_)
448 <<
"Constructing by moving" <<
endl << this->info() <<
endl;
451 if (gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
453 field0Ptr_ = gf.field0Ptr_;
454 gf.field0Ptr_ =
nullptr;
457 this->writeOpt() = IOobject::NO_WRITE;
461 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
474 fieldPrevIterPtr_(nullptr),
475 boundaryField_(*this, tgf().boundaryField_)
480 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
483 this->writeOpt() = IOobject::NO_WRITE;
489 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
499 fieldPrevIterPtr_(nullptr),
500 boundaryField_(*this, gf.boundaryField_)
505 <<
"Constructing as copy resetting IO params"
509 if (!readIfPresent() && gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
520 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
535 fieldPrevIterPtr_(nullptr),
536 boundaryField_(*this, tgf().boundaryField_)
541 <<
"Constructing from tmp resetting IO params"
551 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
561 fieldPrevIterPtr_(
nullptr),
562 boundaryField_(*
this, gf.boundaryField_)
567 <<
"Constructing as copy resetting name"
571 if (!readIfPresent() && gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
582 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
597 fieldPrevIterPtr_(nullptr),
598 boundaryField_(*this, tgf().boundaryField_)
603 <<
"Constructing from tmp resetting name"
611 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
622 fieldPrevIterPtr_(nullptr),
628 <<
"Constructing as copy resetting IO params"
632 boundaryField_ == gf.boundaryField_;
634 if (!readIfPresent() && gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
645 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
658 fieldPrevIterPtr_(nullptr),
670 <<
"Constructing as copy resetting IO params and patch types"
674 boundaryField_ == gf.boundaryField_;
676 if (!readIfPresent() && gf.field0Ptr_ &&
notNull(gf.field0Ptr_))
687 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
704 fieldPrevIterPtr_(nullptr),
716 <<
"Constructing from tmp resetting IO params and patch types"
720 boundaryField_ == tgf().boundaryField_;
728 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
739 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
750 this->mesh().thisDb().time().
name(),
751 this->mesh().thisDb(),
763 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
769 const PtrList<PatchField<Type>>& ptfl
772 const bool cacheTmp = diField.
mesh().thisDb().cacheTemporaryObject(
name);
781 diField.
mesh().thisDb().time().name(),
782 diField.
mesh().thisDb(),
795 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
805 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
814 mesh.thisDb().time().name(),
829 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
839 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
848 mesh.thisDb().time().name(),
864 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
875 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
884 mesh.thisDb().time().name(),
900 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
908 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
931 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
940 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
964 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
974 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
1001 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1004 this->db().cacheTemporaryObject(*
this);
1012 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1017 this->setUpToDate();
1023 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1028 this->setUpToDate();
1034 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1039 this->setUpToDate();
1041 return boundaryField_;
1045 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1049 this->
name().size() > 2
1050 && this->
name()(this->
name().size()-2, 2) ==
"_0";
1054 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1057 if (field0Ptr_ && timeIndex_ != this->time().
timeIndex() && !isOldTime())
1063 timeIndex_ = this->time().timeIndex();
1067 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1074 field0Ptr_->storeOldTime();
1079 <<
"Storing old time field for field" <<
endl
1080 << this->info() <<
endl;
1083 *field0Ptr_ == *
this;
1084 field0Ptr_->timeIndex_ = timeIndex_;
1086 if (field0Ptr_->field0Ptr_)
1088 field0Ptr_->writeOpt() = this->writeOpt();
1100 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1111 return field0Ptr_->nOldTimes() + 1;
1121 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1125 if (!field0Ptr_ ||
isNull(field0Ptr_))
1129 field0Ptr_ =
nullptr;
1135 this->
name() +
"_0",
1136 this->time().
name(),
1140 this->registerObject()
1154 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1165 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1175 return oldTime().oldTime(
n - 1);
1180 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1190 return oldTime().oldTime(
n - 1);
1195 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1198 if (!fieldPrevIterPtr_)
1203 <<
"Allocating previous iteration field" <<
endl
1204 << this->info() <<
endl;
1209 this->
name() +
"PrevIter",
1215 *fieldPrevIterPtr_ == *
this;
1220 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1224 if (!fieldPrevIterPtr_)
1227 <<
"previous iteration field" <<
endl << this->info() <<
endl
1229 <<
" Use field.storePrevIter() at start of iteration."
1233 return *fieldPrevIterPtr_;
1237 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1240 if (field0Ptr_ &&
notNull(field0Ptr_))
1249 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1256 nullOldestTimeFound();
1261 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1264 if (field0Ptr_ &&
notNull(field0Ptr_))
1266 if (field0Ptr_->field0Ptr_)
1268 field0Ptr_->nullOldestTimeFound();
1274 NullObjectPtr<GeometricField<Type, PatchField, GeoMesh>>();
1280 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1284 this->setUpToDate();
1286 boundaryField_.evaluate();
1290 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1298 Internal::reset(gf);
1305 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1311 bool needRef =
true;
1315 if (boundaryField_[
patchi].fixesValue())
1328 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1336 <<
"Relaxing" <<
endl << this->info()
1345 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1351 this->mesh().data::template lookupOrDefault<bool>
1356 && this->mesh().
solution().relaxField(this->
name() +
"Final")
1359 return this->mesh().solution().fieldRelaxationFactor
1361 this->
name() +
"Final"
1364 else if (this->mesh().
solution().relaxField(this->
name()))
1366 return this->mesh().solution().fieldRelaxationFactor(this->
name());
1375 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1378 relax(relaxationFactor());
1382 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1394 <<
"Relaxing" <<
endl << this->info()
1407 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1413 relax(tgf, relaxationFactor());
1417 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1425 return this->
name() +
"Final";
1429 return this->
name();
1434 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1440 os <<
"min/max(" << this->
name() <<
") = "
1447 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1458 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1466 this->
name() +
".T()",
1472 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1473 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1479 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1504 Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
1505 Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
1511 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1515 const GeometricField
1524 boundaryFieldRef().replace(d, gcf.boundaryField());
1528 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1536 boundaryFieldRef().replace(d, ds.
value());
1540 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1551 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1562 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1576 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1580 boundaryFieldRef().negate();
1586 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1595 <<
"attempted assignment to self"
1608 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1617 <<
"attempted assignment to self"
1630 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1636 if (
this == &(tgf()))
1639 <<
"attempted assignment to self"
1670 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1677 boundaryFieldRef() = dt.
value();
1681 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1688 boundaryFieldRef() =
Zero;
1692 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1711 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1718 boundaryFieldRef() == dt.
value();
1722 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1729 boundaryFieldRef() ==
Zero;
1733 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1735 template<class Type, template<class> class PatchField, class GeoMesh> \
1736 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1738 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1741 checkField(*this, gf, #op); \
1744 boundaryFieldRef() op gf.boundaryField(); \
1747 template<class Type, template<class> class PatchField, class GeoMesh> \
1748 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1750 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1753 operator op(tgf()); \
1757 template<class Type, template<class> class PatchField, class GeoMesh> \
1758 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1760 const dimensioned<TYPE>& dt \
1764 boundaryFieldRef() op dt.value(); \
1772 #undef COMPUTED_ASSIGNMENT
1777 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1791 "Ostream& operator<<(Ostream&, "
1792 "const GeometricField<Type, PatchField, GeoMesh>&)"
1799 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
#define checkField(gf1, gf2, op)
#define COMPUTED_ASSIGNMENT(TYPE, op)
#define forAll(list, i)
Loop across all elements in list.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
GeoMesh::Mesh Mesh
Type of mesh on which this DimensionedField is instantiated.
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Pre-declare SubField and related 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 max(const dimensioned< Type > &)
Internal & ref()
Return a reference to the dimensioned internal field.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal 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 relax()
Relax current field with respect to the cached previous iteration.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
label timeIndex() const
Return the time index of the field.
void maxMin(const dimensioned< Type > &minDt, const dimensioned< Type > &maxDt)
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)
tmp< GeometricField< Type, PatchField, GeoMesh > > cloneUnSliced() const
Clone un-sliced.
void min(const dimensioned< Type > &)
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
Field< Type >::cmptType cmptType
void replace(const direction, const GeometricField< cmptType, PatchField, GeoMesh > &)
const Boundary & boundaryField() const
Return const-reference to the boundary field.
GeometricField(const IOobject &, const Mesh &, const dimensionSet &, const word &patchFieldType=PatchField< Type >::calculatedType())
Constructor given IOobject, mesh, dimensions and patch field type.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
bool needReference() const
Does the field need a reference level for solution.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
virtual ~GeometricField()
Destructor.
scalar relaxationFactor() const
Return the field relaxation factor read from fvSolution.
bool isOldTime() const
Return whether or not this is an old-time 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 reset(const tmp< GeometricField< Type, PatchField, GeoMesh >> &)
Reset the field contents to the given field.
void nullOldestTime()
Set oldest time field pointer to nullObjectPtr.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
void clearOldTimes()
Delete old time and previous iteration fields.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
InfoProxy< IOobject > info() const
Return info proxy.
const word & name() const
Return name.
bool good() const
Return true if next operation might succeed.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Dimension set for the base types.
Generic dimensioned Type class.
const Type & value() const
Return const reference to value.
Selector class for relaxation factors, solver type and solution.
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...
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.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
errorManip< error > abort(error &err)
const dimensionSet dimless
void deleteDemandDrivenData(DataPtr &dataPtr)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
word patchFieldType(const PatchField &pf)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
word name(const complex &)
Return a string representation of a complex.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
faceListList boundary(nPatches)
conserve primitiveFieldRef()+