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>
187 const word& patchFieldType
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>
236 const word& patchFieldType
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),
300 <<
"Constructing from components" <<
endl << this->info() <<
endl;
307 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
314 const PtrList<PatchField<Type>>& ptfl
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),
344 boundaryField_(mesh.boundary())
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),
380 boundaryField_(mesh.boundary())
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;
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;
453 field0Ptr_ = gf.field0Ptr_;
454 gf.field0Ptr_ =
nullptr;
457 this->writeOpt() = IOobject::NO_WRITE;
461 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
472 timeIndex_(tgf().timeIndex()),
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_)
520 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
533 timeIndex_(tgf().timeIndex()),
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_)
582 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
595 timeIndex_(tgf().timeIndex()),
597 fieldPrevIterPtr_(
nullptr),
598 boundaryField_(*
this, tgf().boundaryField_)
603 <<
"Constructing from tmp resetting name" 611 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
616 const word& patchFieldType
622 fieldPrevIterPtr_(
nullptr),
623 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
628 <<
"Constructing as copy resetting IO params" 632 boundaryField_ == gf.boundaryField_;
634 if (!readIfPresent() && 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_)
687 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
702 timeIndex_(tgf().timeIndex()),
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>
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().timeName(),
782 diField.
mesh().thisDb(),
795 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
802 const word& patchFieldType
805 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
814 mesh.thisDb().time().timeName(),
829 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
836 const word& patchFieldType
839 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
848 mesh.thisDb().time().timeName(),
864 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
875 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
884 mesh.thisDb().time().timeName(),
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>
937 const word& patchFieldType
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>
1072 field0Ptr_->storeOldTime();
1077 <<
"Storing old time field for field" <<
endl 1078 << this->info() <<
endl;
1081 *field0Ptr_ == *
this;
1082 field0Ptr_->timeIndex_ = timeIndex_;
1084 if (field0Ptr_->field0Ptr_)
1086 field0Ptr_->writeOpt() = this->writeOpt();
1092 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1097 return field0Ptr_->nOldTimes() + 1;
1106 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1116 this->
name() +
"_0",
1121 this->registerObject()
1135 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1146 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1156 return oldTime().oldTime(n - 1);
1161 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1171 return oldTime().oldTime(n - 1);
1176 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1179 if (!fieldPrevIterPtr_)
1184 <<
"Allocating previous iteration field" <<
endl 1185 << this->info() <<
endl;
1190 this->
name() +
"PrevIter",
1196 *fieldPrevIterPtr_ == *
this;
1201 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1205 if (!fieldPrevIterPtr_)
1208 <<
"previous iteration field" <<
endl << this->info() <<
endl 1210 <<
" Use field.storePrevIter() at start of iteration." 1214 return *fieldPrevIterPtr_;
1218 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1226 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1230 this->setUpToDate();
1232 boundaryField_.evaluate();
1236 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1244 Internal::reset(gf);
1251 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1257 bool needRef =
true;
1261 if (boundaryField_[
patchi].fixesValue())
1274 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1280 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
1283 operator==(prevIter() + alpha*(*
this - prevIter()));
1287 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1292 this->
mesh().data::template lookupOrDefault<bool>
1304 this->
name() +
"Final" 1315 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1323 return this->
name() +
"Final";
1327 return this->
name();
1332 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1338 os <<
"min/max(" << this->
name() <<
") = " 1345 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1356 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1364 this->
name() +
".T()",
1370 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1371 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1377 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1382 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1409 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1422 boundaryFieldRef().replace(d, gcf.boundaryField());
1426 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1434 boundaryFieldRef().replace(d, ds.
value());
1438 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1449 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1460 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1474 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1478 boundaryFieldRef().negate();
1484 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1485 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1493 <<
"attempted assignment to self" 1506 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1507 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1515 <<
"attempted assignment to self" 1528 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1529 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1534 if (
this == &(tgf()))
1537 <<
"attempted assignment to self" 1568 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1569 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1575 boundaryFieldRef() = dt.
value();
1579 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1580 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1586 boundaryFieldRef() =
Zero;
1590 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1591 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1609 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1610 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1616 boundaryFieldRef() == dt.
value();
1620 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1621 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1627 boundaryFieldRef() ==
Zero;
1631 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1633 template<class Type, template<class> class PatchField, class GeoMesh> \ 1634 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1636 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1639 checkField(*this, gf, #op); \ 1642 boundaryFieldRef() op gf.boundaryField(); \ 1645 template<class Type, template<class> class PatchField, class GeoMesh> \ 1646 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1648 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1651 operator op(tgf()); \ 1655 template<class Type, template<class> class PatchField, class GeoMesh> \ 1656 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1658 const dimensioned<TYPE>& dt \ 1662 boundaryFieldRef() op dt.value(); \ 1670 #undef COMPUTED_ASSIGNMENT 1675 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1689 "Ostream& operator<<(Ostream&, " 1690 "const GeometricField<Type, PatchField, GeoMesh>&)" 1697 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
void replace(const direction, const GeometricField< cmptType, PatchField, GeoMesh > &)
#define COMPUTED_ASSIGNMENT(TYPE, op)
#define forAll(list, i)
Loop across all elements in list.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
#define checkField(gf1, gf2, op)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void clearOldTimes()
Delete old time and previous iteration fields.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
Field< Type >::cmptType cmptType
T & ref() const
Return non-const reference or generate a fatal error.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Generic GeometricField class.
const dimensionSet dimless
Generic dimensioned Type class.
label nOldTimes() const
Return the number of old time fields stored.
void maxMin(const dimensioned< Type > &minDt, const dimensioned< Type > &maxDt)
bool good() const
Return true if next operation might succeed.
word select(bool final) const
Select the final iteration parameters if `final' is true.
conserve primitiveFieldRef()+
bool isOldTime() const
Return whether or not this is an old-time field.
bool needReference() const
Does the field need a reference level for solution.
const dimensionSet & dimensions() const
Return dimensions.
Dimension set for the base types.
void storeOldTimes() const
Store the old-time fields.
void reset(const tmp< GeometricField< Type, PatchField, GeoMesh >> &)
Reset the field contents to the given field.
Pre-declare SubField and related Field type.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
void storeOldTime() const
Store the old-time field.
const Type & value() const
Return const reference to value.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
void min(const dimensioned< Type > &)
faceListList boundary(nPatches)
GeoMesh::Mesh Mesh
Type of mesh on which this DimensionedField is instantiated.
errorManip< error > abort(error &err)
GeometricField(const IOobject &, const Mesh &, const dimensionSet &, const word &patchFieldType=PatchField< Type >::calculatedType())
Constructor given IOobject, mesh, dimensions and patch field type.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
const Mesh & mesh() const
Return mesh.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
virtual ~GeometricField()
Destructor.
word name(const complex &)
Return a string representation of a complex.
Generic GeometricBoundaryField class.
label timeIndex() const
Return the time index of the field.
Internal & ref()
Return a reference to the dimensioned internal field.
Template functions to aid in the implementation of demand driven data.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
#define WarningInFunction
Report a warning using Foam::Warning.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
tmp< GeometricField< Type, PatchField, GeoMesh > > cloneUnSliced() const
Clone un-sliced.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
void max(const dimensioned< Type > &)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void correctBoundaryConditions()
Correct boundary field.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
void storePrevIter() const
Store the field as the previous iteration value.
Selector class for relaxation factors, solver type and solution.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
A class for managing temporary objects.
void deleteDemandDrivenData(DataPtr &dataPtr)
word patchFieldType(const PatchField &pf)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void relax()
Relax field (for steady-state solution).
#define InfoInFunction
Report an information message using Foam::Info.