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"));
60 if (
dict.found(
"sources"))
62 sources_.readField(*
this,
dict.subDict(
"sources"));
66 sources_.readField(*
this, dictionary(
dict, dictionary()));
69 if (
dict.found(
"referenceLevel"))
71 Type fieldAverage(pTraits<Type>(
dict.lookup(
"referenceLevel")));
73 Field<Type>::operator+=(fieldAverage);
77 boundaryField_[
patchi] == boundaryField_[
patchi] + fieldAverage;
83 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
86 const localIOdictionary
dict
107 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
112 this->readOpt() == IOobject::MUST_READ
113 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
117 <<
"read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED"
118 <<
" suggests that a read constructor for field " << this->
name()
119 <<
" would be more appropriate." <<
endl;
123 this->readOpt() == IOobject::READ_IF_PRESENT
130 if (this->size() != GeoMesh::size(this->mesh()))
133 <<
" number of field elements = " << this->size()
134 <<
" number of mesh elements = "
135 << GeoMesh::size(this->mesh())
139 readOldTimeIfPresent();
150 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
161 fieldPrevIterPtr_(nullptr),
174 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
187 fieldPrevIterPtr_(nullptr),
188 boundaryField_(mesh.
boundary(), *this, patchFieldTypes, actualPatchTypes),
189 sources_(*this, fieldSourceTypes)
200 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
211 fieldPrevIterPtr_(nullptr),
220 boundaryField_ == dt.
value();
226 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
239 fieldPrevIterPtr_(
nullptr),
240 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes),
241 sources_(*
this, fieldSourceTypes)
248 boundaryField_ == dt.
value();
254 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
265 fieldPrevIterPtr_(nullptr),
266 boundaryField_(this->mesh().
boundary(), *this, ptfl),
267 sources_(*this, stft)
272 <<
"Constructing from components" <<
endl << this->info() <<
endl;
279 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
286 const PtrList<PatchField<Type>>& ptfl,
292 fieldPrevIterPtr_(
nullptr),
293 boundaryField_(mesh.boundary(), *
this, ptfl),
294 sources_(*
this, stft)
299 <<
"Constructing from components" <<
endl << this->info() <<
endl;
306 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
315 fieldPrevIterPtr_(
nullptr),
316 boundaryField_(mesh.boundary()),
323 if (this->size() != GeoMesh::size(this->mesh()))
326 <<
" number of field elements = " << this->size()
327 <<
" number of mesh elements = " << GeoMesh::size(this->mesh())
331 readOldTimeIfPresent();
336 <<
"Finishing read-construction of" <<
endl << this->info() <<
endl;
341 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
351 fieldPrevIterPtr_(nullptr),
359 if (this->size() != GeoMesh::size(this->mesh()))
362 <<
" number of field elements = " << this->size()
363 <<
" number of mesh elements = " << GeoMesh::size(this->mesh())
370 <<
"Finishing dictionary-construct of "
376 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
384 fieldPrevIterPtr_(nullptr),
385 boundaryField_(*this, gf.boundaryField_),
386 sources_(*this, gf.sources_)
391 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
394 this->writeOpt() = IOobject::NO_WRITE;
398 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
406 fieldPrevIterPtr_(nullptr),
407 boundaryField_(*this, gf.boundaryField_),
408 sources_(*this, gf.sources_)
413 <<
"Constructing by moving" <<
endl << this->info() <<
endl;
416 this->writeOpt() = IOobject::NO_WRITE;
420 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
432 fieldPrevIterPtr_(nullptr),
433 boundaryField_(*this, tgf().boundaryField_),
434 sources_(*this, tgf().sources_)
439 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
442 this->writeOpt() = IOobject::NO_WRITE;
448 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
457 fieldPrevIterPtr_(nullptr),
458 boundaryField_(*this, gf.boundaryField_),
459 sources_(*this, gf.sources_)
464 <<
"Constructing as copy resetting IO params"
468 if (!readIfPresent())
470 copyOldTimes(io, gf);
475 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
490 fieldPrevIterPtr_(nullptr),
491 boundaryField_(*this, tgf().boundaryField_),
492 sources_(*this, tgf().sources_)
497 <<
"Constructing from tmp resetting IO params"
507 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
516 fieldPrevIterPtr_(nullptr),
517 boundaryField_(*this, gf.boundaryField_),
518 sources_(*this, gf.sources_)
523 <<
"Constructing as copy resetting name"
527 copyOldTimes(newName, gf);
531 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
545 fieldPrevIterPtr_(
nullptr),
546 boundaryField_(*
this, tgf().boundaryField_),
547 sources_(*
this, tgf().sources_)
552 <<
"Constructing from tmp resetting name"
560 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
570 fieldPrevIterPtr_(nullptr),
572 sources_(*this, gf.sources_)
577 <<
"Constructing as copy resetting IO params"
581 boundaryField_ == gf.boundaryField_;
583 if (!readIfPresent())
590 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
602 fieldPrevIterPtr_(nullptr),
610 sources_(*this, fieldSourceTypes)
615 <<
"Constructing as copy resetting IO params and patch types"
619 boundaryField_ == gf.boundaryField_;
621 if (!readIfPresent())
628 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
646 fieldPrevIterPtr_(nullptr),
654 sources_(*this, fieldSourceTypes)
659 <<
"Constructing from tmp resetting IO params and patch types"
663 boundaryField_ == tgf().boundaryField_;
671 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
682 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
693 this->mesh().thisDb().time().
name(),
694 this->mesh().thisDb(),
706 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
712 const PtrList<PatchField<Type>>& ptfl,
716 const bool cacheTmp = diField.
mesh().thisDb().cacheTemporaryObject(
name);
725 diField.
mesh().thisDb().time().name(),
726 diField.
mesh().thisDb(),
740 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
750 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
759 mesh.thisDb().time().name(),
774 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
784 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
793 mesh.thisDb().time().name(),
809 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
821 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(
name);
830 mesh.thisDb().time().name(),
847 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
855 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
878 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
887 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
911 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
922 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
950 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
953 this->db().cacheTemporaryObject(*
this);
961 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
972 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
983 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
990 return boundaryField_;
994 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
997 if (!fieldPrevIterPtr_)
1002 <<
"Allocating previous iteration field" <<
endl
1003 << this->info() <<
endl;
1008 this->
name() +
"PrevIter",
1014 *fieldPrevIterPtr_ == *
this;
1019 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1026 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1030 if (!fieldPrevIterPtr_)
1033 <<
"previous iteration field" <<
endl << this->info() <<
endl
1035 <<
" Use field.storePrevIter() at start of iteration."
1039 return *fieldPrevIterPtr_;
1043 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1047 this->setUpToDate();
1049 boundaryField_.evaluate();
1053 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1061 Internal::reset(gf);
1069 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1075 bool needRef =
true;
1079 if (boundaryField_[
patchi].fixesValue())
1092 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1100 <<
"Relaxing" <<
endl << this->info()
1109 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1116 && this->mesh().
solution().relaxField(this->
name() +
"Final")
1119 return this->mesh().solution().fieldRelaxationFactor
1121 this->
name() +
"Final"
1124 else if (this->mesh().
solution().relaxField(this->
name()))
1126 return this->mesh().solution().fieldRelaxationFactor(this->
name());
1135 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1138 relax(relaxationFactor());
1142 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1154 <<
"Relaxing" <<
endl << this->info()
1167 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1173 relax(tgf, relaxationFactor());
1177 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1185 return this->
name() +
"Final";
1189 return this->
name();
1194 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1200 os <<
"min/max(" << this->
name() <<
") = "
1207 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1218 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1226 this->
name() +
".T()",
1232 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1233 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1239 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1264 Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d);
1265 Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
1271 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1275 const GeometricField
1284 boundaryFieldRef().replace(d, gcf.boundaryField());
1288 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1296 boundaryFieldRef().replace(d, ds.
value());
1300 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1311 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1322 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1336 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1340 boundaryFieldRef().negate();
1346 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1355 <<
"attempted assignment to self"
1368 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1377 <<
"attempted assignment to self"
1390 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1396 if (
this == &(tgf()))
1399 <<
"attempted assignment to self"
1426 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1432 internalFieldRef() = dt;
1433 boundaryFieldRef() = dt.
value();
1437 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1443 internalFieldRef() =
Zero;
1444 boundaryFieldRef() =
Zero;
1448 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1477 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1483 internalFieldRef() = dt;
1484 boundaryFieldRef() == dt.
value();
1488 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1494 internalFieldRef() =
Zero;
1495 boundaryFieldRef() ==
Zero;
1499 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1501 template<class Type, template<class> class PatchField, class GeoMesh> \
1502 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1504 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1507 checkField(*this, gf, #op); \
1509 internalFieldRef() op gf.internalField(); \
1510 boundaryFieldRef() op gf.boundaryField(); \
1513 template<class Type, template<class> class PatchField, class GeoMesh> \
1514 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1516 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1519 operator op(tgf()); \
1523 template<class Type, template<class> class PatchField, class GeoMesh> \
1524 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1526 const dimensioned<TYPE>& dt \
1529 internalFieldRef() op dt; \
1530 boundaryFieldRef() op dt.value(); \
1538 #undef COMPUTED_ASSIGNMENT
1543 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1554 if (!gf.sources_.empty())
1563 "Ostream& operator<<(Ostream&, "
1564 "const GeometricField<Type, PatchField, GeoMesh>&)"
1571 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.
void writeEntry(const word &keyword, Ostream &os) const
Write sources as dictionary entry.
Generic GeometricField class.
void max(const dimensioned< Type > &)
Internal & internalFieldRef()
Return a reference to the dimensioned internal field.
Internal::FieldType & primitiveFieldRef()
Return a reference to the primitive field.
const Sources & sources() const
Return const-reference to the sources.
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.
void maxMin(const dimensioned< Type > &minDt, const dimensioned< Type > &maxDt)
const Internal::FieldType & primitiveField() const
Return a const-reference to the primitive 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 > &)
Field< Type >::cmptType cmptType
Component type of the elements of the field.
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.
void clearPrevIter()
Delete the previous iteration field.
void storePrevIter() const
Store the field as the previous iteration value.
word select(bool final) const
Select the final iteration parameters if `final' is true.
void correctBoundaryConditions()
Correct boundary field.
void reset(const tmp< GeometricField< Type, PatchField, GeoMesh >> &)
Reset the field contents to the given field.
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
A HashTable specialisation for hashing pointers.
An STL-conforming hash table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
InfoProxy< IOobject > info() const
Return info proxy.
bool good() const
Return true if next operation might succeed.
Class to add into field types to provide old-time storage and retrieval.
void copyOldTimes(const IOobject &io, const OldTimeField< GeometricField< Type, PatchField, GeoMesh > > &otf)
Copy the old times from the given field.
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.
static bool finalIteration(const objectRegistry ®istry)
Lookup solutionControl from the objectRegistry and return finalIter.
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)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
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)
void deleteDemandDrivenData(DataType *&dataPtr)
errorManip< error > abort(error &err)
const dimensionSet dimless
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)
word patchFieldType(const PatchField &pf)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
faceListList boundary(nPatches)
conserve primitiveFieldRef()+