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),
203 boundaryField_(mesh.boundary(), *
this, patchFieldType)
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),
252 boundaryField_(mesh.boundary(), *
this, patchFieldType)
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_(move(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>
753 const word& patchFieldType
763 mesh.thisDb().time().timeName(),
777 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
784 const word& patchFieldType
794 mesh.thisDb().time().timeName(),
809 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
827 mesh.thisDb().time().timeName(),
842 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
870 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
904 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
914 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
925 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
936 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
943 return boundaryField_;
947 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
953 && timeIndex_ != this->time().
timeIndex()
955 this->
name().size() > 2
956 && this->
name()(this->
name().size()-2, 2) ==
"_0" 964 timeIndex_ = this->time().timeIndex();
968 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
973 field0Ptr_->storeOldTime();
978 <<
"Storing old time field for field" <<
endl 979 << this->info() <<
endl;
982 *field0Ptr_ == *
this;
983 field0Ptr_->timeIndex_ = timeIndex_;
985 if (field0Ptr_->field0Ptr_)
987 field0Ptr_->writeOpt() = this->writeOpt();
993 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
998 return field0Ptr_->nOldTimes() + 1;
1007 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1017 this->
name() +
"_0",
1022 this->registerObject()
1036 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1047 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1050 if (!fieldPrevIterPtr_)
1055 <<
"Allocating previous iteration field" <<
endl 1056 << this->info() <<
endl;
1061 this->
name() +
"PrevIter",
1067 *fieldPrevIterPtr_ == *
this;
1072 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1076 if (!fieldPrevIterPtr_)
1079 <<
"previous iteration field" <<
endl << this->info() <<
endl 1081 <<
" Use field.storePrevIter() at start of iteration." 1085 return *fieldPrevIterPtr_;
1089 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1093 this->setUpToDate();
1095 boundaryField_.evaluate();
1099 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1105 bool needRef =
true;
1109 if (boundaryField_[
patchi].fixesValue())
1122 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1128 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
1131 operator==(prevIter() + alpha*(*
this - prevIter()));
1135 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1140 this->
mesh().data::template lookupOrDefault<bool>
1145 && this->
mesh().relaxField(this->
name() +
"Final")
1148 relax(this->
mesh().fieldRelaxationFactor(this->
name() +
"Final"));
1150 else if (this->
mesh().relaxField(this->
name()))
1157 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1165 return this->
name() +
"Final";
1169 return this->
name();
1174 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1180 os <<
"min/max(" << this->
name() <<
") = " 1187 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1198 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1206 this->
name() +
".T()",
1212 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1213 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1219 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1224 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1251 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1264 boundaryFieldRef().replace(d, gcf.boundaryField());
1268 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1276 boundaryFieldRef().replace(d, ds.
value());
1280 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1291 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1302 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1316 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1320 boundaryFieldRef().negate();
1326 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1327 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1335 <<
"attempted assignment to self" 1348 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1349 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1357 <<
"attempted assignment to self" 1370 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1371 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1376 if (
this == &(tgf()))
1379 <<
"attempted assignment to self" 1410 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1411 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1417 boundaryFieldRef() = dt.
value();
1421 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1422 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1428 boundaryFieldRef() =
Zero;
1432 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1433 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1451 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1452 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1458 boundaryFieldRef() == dt.
value();
1462 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1463 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1469 boundaryFieldRef() ==
Zero;
1473 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1475 template<class Type, template<class> class PatchField, class GeoMesh> \ 1476 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1478 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1481 checkField(*this, gf, #op); \ 1484 boundaryFieldRef() op gf.boundaryField(); \ 1487 template<class Type, template<class> class PatchField, class GeoMesh> \ 1488 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1490 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1493 operator op(tgf()); \ 1497 template<class Type, template<class> class PatchField, class GeoMesh> \ 1498 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1500 const dimensioned<TYPE>& dt \ 1504 boundaryFieldRef() op dt.value(); \ 1512 #undef COMPUTED_ASSIGNMENT 1517 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1531 "Ostream& operator<<(Ostream&, " 1532 "const GeometricField<Type, PatchField, GeoMesh>&)" 1539 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.
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.
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()+
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Mesh &, const dimensionSet &, const word &patchFieldType=PatchField< Type >::calculatedType())
Return a temporary field constructed from name, mesh, dimensionSet.
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 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 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.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
#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.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
A class for managing temporary objects.
void deleteDemandDrivenData(DataPtr &dataPtr)
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.