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
113 && this->
template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
122 if (this->size() != GeoMesh::size(this->
mesh()))
125 <<
" number of field elements = " << this->size()
126 <<
" number of mesh elements = " 127 << GeoMesh::size(this->
mesh())
131 readOldTimeIfPresent();
140 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
149 IOobject::READ_IF_PRESENT,
150 IOobject::AUTO_WRITE,
151 this->registerObject()
156 field0.template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
168 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
174 field0Ptr_->timeIndex_ = timeIndex_ - 1;
176 if (!field0Ptr_->readOldTimeIfPresent())
178 field0Ptr_->oldTime();
190 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
196 const word& patchFieldType
202 fieldPrevIterPtr_(
nullptr),
214 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
227 fieldPrevIterPtr_(
nullptr),
228 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
239 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
245 const word& patchFieldType
251 fieldPrevIterPtr_(
nullptr),
259 boundaryField_ == dt.
value();
265 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
278 fieldPrevIterPtr_(
nullptr),
279 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
286 boundaryField_ == dt.
value();
292 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
297 const PtrList<PatchField<Type>>& ptfl
303 fieldPrevIterPtr_(
nullptr),
309 <<
"Constructing from components" <<
endl << this->info() <<
endl;
316 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
323 const PtrList<PatchField<Type>>& ptfl
329 fieldPrevIterPtr_(
nullptr),
330 boundaryField_(mesh.boundary(), *
this, ptfl)
335 <<
"Constructing from components" <<
endl << this->info() <<
endl;
342 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
352 fieldPrevIterPtr_(
nullptr),
353 boundaryField_(mesh.boundary())
359 if (this->size() != GeoMesh::size(this->
mesh()))
362 <<
" number of field elements = " << this->size()
363 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
367 readOldTimeIfPresent();
372 <<
"Finishing read-construction of" <<
endl << this->info() <<
endl;
377 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
388 fieldPrevIterPtr_(
nullptr),
389 boundaryField_(mesh.boundary())
395 if (this->size() != GeoMesh::size(this->
mesh()))
398 <<
" number of field elements = " << this->size()
399 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
406 <<
"Finishing dictionary-construct of " 412 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
421 fieldPrevIterPtr_(
nullptr),
422 boundaryField_(*
this, gf.boundaryField_)
427 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
438 this->writeOpt() = IOobject::NO_WRITE;
442 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
451 fieldPrevIterPtr_(
nullptr),
452 boundaryField_(*
this, gf.boundaryField_)
457 <<
"Constructing by moving" <<
endl << this->info() <<
endl;
462 field0Ptr_ = gf.field0Ptr_;
463 gf.field0Ptr_ =
nullptr;
466 this->writeOpt() = IOobject::NO_WRITE;
470 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
481 timeIndex_(tgf().timeIndex()),
483 fieldPrevIterPtr_(
nullptr),
484 boundaryField_(*
this, tgf().boundaryField_)
489 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
492 this->writeOpt() = IOobject::NO_WRITE;
498 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
508 fieldPrevIterPtr_(
nullptr),
509 boundaryField_(*
this, gf.boundaryField_)
514 <<
"Constructing as copy resetting IO params" 518 if (!readIfPresent() && gf.field0Ptr_)
529 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
542 timeIndex_(tgf().timeIndex()),
544 fieldPrevIterPtr_(
nullptr),
545 boundaryField_(*
this, tgf().boundaryField_)
550 <<
"Constructing from tmp resetting IO params" 560 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
570 fieldPrevIterPtr_(
nullptr),
571 boundaryField_(*
this, gf.boundaryField_)
576 <<
"Constructing as copy resetting name" 580 if (!readIfPresent() && gf.field0Ptr_)
591 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
604 timeIndex_(tgf().timeIndex()),
606 fieldPrevIterPtr_(
nullptr),
607 boundaryField_(*
this, tgf().boundaryField_)
612 <<
"Constructing from tmp resetting name" 620 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
625 const word& patchFieldType
631 fieldPrevIterPtr_(
nullptr),
632 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
637 <<
"Constructing as copy resetting IO params" 641 boundaryField_ == gf.boundaryField_;
643 if (!readIfPresent() && gf.field0Ptr_)
654 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
667 fieldPrevIterPtr_(
nullptr),
679 <<
"Constructing as copy resetting IO params and patch types" 683 boundaryField_ == gf.boundaryField_;
685 if (!readIfPresent() && gf.field0Ptr_)
696 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
711 timeIndex_(tgf().timeIndex()),
713 fieldPrevIterPtr_(
nullptr),
725 <<
"Constructing from tmp resetting IO params and patch types" 729 boundaryField_ == tgf().boundaryField_;
735 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
746 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
752 const PtrList<PatchField<Type>>& ptfl
755 const bool cacheTmp = diField.
mesh().thisDb().cacheTemporaryObject(name);
764 diField.
mesh().thisDb().time().timeName(),
765 diField.
mesh().thisDb(),
778 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
785 const word& patchFieldType
788 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
797 mesh.thisDb().time().timeName(),
812 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
819 const word& patchFieldType
822 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
831 mesh.thisDb().time().timeName(),
847 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
858 const bool cacheTmp = mesh.thisDb().cacheTemporaryObject(name);
867 mesh.thisDb().time().timeName(),
883 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
891 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
914 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
920 const word& patchFieldType
923 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
947 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
957 const bool cacheTmp = tgf().db().cacheTemporaryObject(newName);
984 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
987 this->db().cacheTemporaryObject(*
this);
996 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1001 this->setUpToDate();
1007 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1012 this->setUpToDate();
1018 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1023 this->setUpToDate();
1025 return boundaryField_;
1029 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1035 && timeIndex_ != this->time().
timeIndex()
1037 this->
name().size() > 2
1038 && this->
name()(this->
name().size()-2, 2) ==
"_0" 1046 timeIndex_ = this->time().timeIndex();
1050 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1055 field0Ptr_->storeOldTime();
1060 <<
"Storing old time field for field" <<
endl 1061 << this->info() <<
endl;
1064 *field0Ptr_ == *
this;
1065 field0Ptr_->timeIndex_ = timeIndex_;
1067 if (field0Ptr_->field0Ptr_)
1069 field0Ptr_->writeOpt() = this->writeOpt();
1075 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1080 return field0Ptr_->nOldTimes() + 1;
1089 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1099 this->
name() +
"_0",
1104 this->registerObject()
1118 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1129 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1132 if (!fieldPrevIterPtr_)
1137 <<
"Allocating previous iteration field" <<
endl 1138 << this->info() <<
endl;
1143 this->
name() +
"PrevIter",
1149 *fieldPrevIterPtr_ == *
this;
1154 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1158 if (!fieldPrevIterPtr_)
1161 <<
"previous iteration field" <<
endl << this->info() <<
endl 1163 <<
" Use field.storePrevIter() at start of iteration." 1167 return *fieldPrevIterPtr_;
1171 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1175 this->setUpToDate();
1177 boundaryField_.evaluate();
1181 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1187 bool needRef =
true;
1191 if (boundaryField_[
patchi].fixesValue())
1204 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1210 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
1213 operator==(prevIter() + alpha*(*
this - prevIter()));
1217 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1222 this->
mesh().data::template lookupOrDefault<bool>
1227 && this->
mesh().relaxField(this->
name() +
"Final")
1230 relax(this->
mesh().fieldRelaxationFactor(this->
name() +
"Final"));
1232 else if (this->
mesh().relaxField(this->
name()))
1239 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1247 return this->
name() +
"Final";
1251 return this->
name();
1256 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1262 os <<
"min/max(" << this->
name() <<
") = " 1269 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1280 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1288 this->
name() +
".T()",
1294 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1295 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1301 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1306 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1333 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1346 boundaryFieldRef().replace(d, gcf.boundaryField());
1350 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1358 boundaryFieldRef().replace(d, ds.
value());
1362 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1373 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1384 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1398 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1402 boundaryFieldRef().negate();
1408 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1409 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1417 <<
"attempted assignment to self" 1430 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1431 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1439 <<
"attempted assignment to self" 1452 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1453 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1458 if (
this == &(tgf()))
1461 <<
"attempted assignment to self" 1492 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1493 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1499 boundaryFieldRef() = dt.
value();
1503 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1504 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1510 boundaryFieldRef() =
Zero;
1514 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1515 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1533 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1534 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1540 boundaryFieldRef() == dt.
value();
1544 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1545 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1551 boundaryFieldRef() ==
Zero;
1555 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1557 template<class Type, template<class> class PatchField, class GeoMesh> \ 1558 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1560 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1563 checkField(*this, gf, #op); \ 1566 boundaryFieldRef() op gf.boundaryField(); \ 1569 template<class Type, template<class> class PatchField, class GeoMesh> \ 1570 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1572 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1575 operator op(tgf()); \ 1579 template<class Type, template<class> class PatchField, class GeoMesh> \ 1580 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1582 const dimensioned<TYPE>& dt \ 1586 boundaryFieldRef() op dt.value(); \ 1594 #undef COMPUTED_ASSIGNMENT 1599 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1613 "Ostream& operator<<(Ostream&, " 1614 "const GeometricField<Type, PatchField, GeoMesh>&)" 1621 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)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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 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.
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.
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)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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.
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.
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.
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.