Go to the documentation of this file.
38 #define checkField(gf1, gf2, op) \
39 if ((gf1).mesh() != (gf2).mesh()) \
41 FatalErrorInFunction \
42 << "different mesh for fields " \
43 << (gf1).name() << " and " << (gf2).name() \
44 << " during operation " << op \
45 << abort(FatalError); \
51 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
54 const dictionary&
dict
57 Internal::readField(
dict,
"internalField");
59 boundaryField_.readField(*
this,
dict.subDict(
"boundaryField"));
63 if (
dict.readIfPresent(
"referenceLevel", refLevel))
65 Field<Type>::operator+=(refLevel);
67 forAll(boundaryField_, patchi)
69 boundaryField_[patchi] == boundaryField_[patchi] + refLevel;
75 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
78 const localIOdictionary
dict
99 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
104 this->readOpt() == IOobject::MUST_READ
105 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
109 <<
"read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED"
110 <<
" suggests that a read constructor for field " << this->
name()
111 <<
" would be more appropriate." <<
endl;
115 this->readOpt() == IOobject::READ_IF_PRESENT
116 && this->
template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
125 if (this->size() != GeoMesh::size(this->
mesh()))
128 <<
" number of field elements = " << this->size()
129 <<
" number of mesh elements = "
130 << GeoMesh::size(this->
mesh())
134 readOldTimeIfPresent();
143 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
152 IOobject::READ_IF_PRESENT,
153 IOobject::AUTO_WRITE,
154 this->registerObject()
159 field0.template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
166 <<
"Reading old time level for field" <<
nl << this->info() <<
endl;
168 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
177 field0Ptr_->oriented() = this->oriented();
179 field0Ptr_->timeIndex_ = timeIndex_ - 1;
181 if (!field0Ptr_->readOldTimeIfPresent())
183 field0Ptr_->oldTime();
195 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
201 const word& patchFieldType
207 fieldPrevIterPtr_(
nullptr),
208 boundaryField_(
mesh.boundary(), *
this, patchFieldType)
211 <<
"Creating temporary" <<
nl << this->info() <<
endl;
217 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
230 fieldPrevIterPtr_(
nullptr),
231 boundaryField_(
mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
234 <<
"Creating temporary" <<
nl << this->info() <<
endl;
240 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
246 const word& patchFieldType
252 fieldPrevIterPtr_(
nullptr),
253 boundaryField_(
mesh.boundary(), *
this, patchFieldType)
256 <<
"Creating temporary" <<
nl << this->info() <<
endl;
258 boundaryField_ == dt.
value();
264 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
277 fieldPrevIterPtr_(
nullptr),
278 boundaryField_(
mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
281 <<
"Creating temporary" <<
nl << this->info() <<
endl;
283 boundaryField_ == dt.
value();
289 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
294 const PtrList<PatchField<Type>>& ptfl
300 fieldPrevIterPtr_(
nullptr),
304 <<
"Copy construct from components" <<
nl << this->info() <<
endl;
310 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
317 const word& patchFieldType
323 fieldPrevIterPtr_(
nullptr),
324 boundaryField_(
mesh.boundary(), *
this, patchFieldType)
327 <<
"Copy construct from internal field" <<
nl << this->info() <<
endl;
333 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
340 const word& patchFieldType
346 fieldPrevIterPtr_(
nullptr),
347 boundaryField_(
mesh.boundary(), *
this, patchFieldType)
350 <<
"Move construct from internal field" <<
nl << this->info() <<
endl;
356 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
363 const PtrList<PatchField<Type>>& ptfl
369 fieldPrevIterPtr_(
nullptr),
370 boundaryField_(
mesh.boundary(), *
this, ptfl)
373 <<
"Copy construct from components" <<
nl << this->info() <<
endl;
379 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
384 const bool readOldTime
390 fieldPrevIterPtr_(
nullptr),
391 boundaryField_(
mesh.boundary())
397 if (this->size() != GeoMesh::size(this->
mesh()))
400 <<
" number of field elements = " << this->size()
401 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
407 readOldTimeIfPresent();
411 <<
"Finishing read-construction" <<
nl << this->info() <<
endl;
415 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
426 fieldPrevIterPtr_(
nullptr),
427 boundaryField_(
mesh.boundary())
433 if (this->size() != GeoMesh::size(this->
mesh()))
436 <<
" number of field elements = " << this->size()
437 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
442 <<
"Finishing dictionary-construct" <<
nl << this->info() <<
endl;
446 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
455 fieldPrevIterPtr_(
nullptr),
456 boundaryField_(*
this, gf.boundaryField_)
459 <<
"Copy construct" <<
nl << this->info() <<
endl;
469 this->writeOpt() = IOobject::NO_WRITE;
473 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
479 Internal(tgf.constCast(), tgf.movable()),
480 timeIndex_(tgf().timeIndex()),
482 fieldPrevIterPtr_(
nullptr),
483 boundaryField_(*
this, tgf().boundaryField_)
486 <<
"Constructing from tmp" <<
nl << this->info() <<
endl;
488 this->writeOpt() = IOobject::NO_WRITE;
494 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
504 fieldPrevIterPtr_(
nullptr),
505 boundaryField_(*
this, gf.boundaryField_)
508 <<
"Copy construct, resetting IO params" <<
nl
509 << this->info() <<
endl;
511 if (!readIfPresent() && gf.field0Ptr_)
522 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
529 Internal(io, tgf.constCast(), tgf.movable()),
530 timeIndex_(tgf().timeIndex()),
532 fieldPrevIterPtr_(
nullptr),
533 boundaryField_(*
this, tgf().boundaryField_)
536 <<
"Constructing from tmp resetting IO params" <<
nl
537 << this->info() <<
endl;
545 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
555 fieldPrevIterPtr_(
nullptr),
556 boundaryField_(*
this, gf.boundaryField_)
559 <<
"Copy construct, resetting name" <<
nl
560 << this->info() <<
endl;
562 if (!readIfPresent() && gf.field0Ptr_)
573 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
580 Internal(newName, tgf.constCast(), tgf.movable()),
581 timeIndex_(tgf().timeIndex()),
583 fieldPrevIterPtr_(
nullptr),
584 boundaryField_(*
this, tgf().boundaryField_)
587 <<
"Constructing from tmp resetting name" <<
nl
588 << this->info() <<
endl;
594 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
599 const word& patchFieldType
605 fieldPrevIterPtr_(
nullptr),
606 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
609 <<
"Copy construct, resetting IO params" <<
nl
610 << this->info() <<
endl;
612 boundaryField_ == gf.boundaryField_;
614 if (!readIfPresent() && gf.field0Ptr_)
625 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
637 fieldPrevIterPtr_(
nullptr),
647 <<
"Copy construct, resetting IO params and patch types" <<
nl
648 << this->info() <<
endl;
650 boundaryField_ == gf.boundaryField_;
652 if (!readIfPresent() && gf.field0Ptr_)
663 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
672 Internal(io, tgf.constCast(), tgf.movable()),
673 timeIndex_(tgf().timeIndex()),
675 fieldPrevIterPtr_(
nullptr),
685 <<
"Constructing from tmp resetting IO params and patch types" <<
nl
686 << this->info() <<
endl;
688 boundaryField_ == tgf().boundaryField_;
694 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
704 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
714 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
719 const bool updateAccessTime
722 if (updateAccessTime)
731 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
736 const bool updateAccessTime
739 if (updateAccessTime)
748 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
753 const bool updateAccessTime
756 if (updateAccessTime)
761 return boundaryField_;
765 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
771 && timeIndex_ != this->time().
timeIndex()
772 && !this->
name().ends_with(
"_0")
776 timeIndex_ = this->time().timeIndex();
784 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
789 field0Ptr_->storeOldTime();
792 <<
"Storing old time field for field" <<
nl << this->info() <<
endl;
794 *field0Ptr_ == *
this;
795 field0Ptr_->timeIndex_ = timeIndex_;
797 if (field0Ptr_->field0Ptr_)
799 field0Ptr_->writeOpt() = this->writeOpt();
805 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
810 return field0Ptr_->nOldTimes() + 1;
817 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
832 this->registerObject()
840 <<
"created old time field " << field0Ptr_->info() <<
endl;
844 error::printStack(
Info);
857 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
868 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
871 if (!fieldPrevIterPtr_)
874 <<
"Allocating previous iteration field" <<
nl
875 << this->info() <<
endl;
879 this->
name() +
"PrevIter",
885 *fieldPrevIterPtr_ == *
this;
890 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
894 if (!fieldPrevIterPtr_)
897 <<
"previous iteration field" <<
endl << this->info() <<
endl
899 <<
" Use field.storePrevIter() at start of iteration."
903 return *fieldPrevIterPtr_;
907 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
913 boundaryField_.evaluate();
917 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
925 forAll(boundaryField_, patchi)
927 if (boundaryField_[patchi].fixesValue())
940 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
944 <<
"Relaxing" <<
nl << this->info() <<
" by " <<
alpha <<
endl;
950 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
957 this->
mesh().data::template lookupOrDefault<bool>
974 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
982 return this->
name() +
"Final";
989 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
997 os <<
"min/max(" << this->
name() <<
") = "
1002 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1013 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1021 this->
name() +
".T()",
1029 Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
1030 Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
1036 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1063 Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
1064 Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
1070 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1074 const GeometricField
1076 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
1083 boundaryFieldRef().replace(d, gcf.boundaryField());
1087 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1095 boundaryFieldRef().replace(d, ds.
value());
1099 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1110 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1121 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1132 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1146 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1153 this->
clip(minVal, maxVal);
1157 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1161 boundaryFieldRef().negate();
1167 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1187 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1193 const auto& gf = tgf();
1204 this->dimensions() = gf.dimensions();
1205 this->oriented() = gf.oriented();
1223 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1230 boundaryFieldRef() = dt.
value();
1234 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1240 const auto& gf = tgf();
1253 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1260 boundaryFieldRef() == dt.
value();
1264 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1266 template<class Type, template<class> class PatchField, class GeoMesh> \
1267 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1269 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1272 checkField(*this, gf, #op); \
1275 boundaryFieldRef() op gf.boundaryField(); \
1278 template<class Type, template<class> class PatchField, class GeoMesh> \
1279 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1281 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1284 operator op(tgf()); \
1288 template<class Type, template<class> class PatchField, class GeoMesh> \
1289 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1291 const dimensioned<TYPE>& dt \
1295 boundaryFieldRef() op dt.value(); \
1303 #undef COMPUTED_ASSIGNMENT
1308 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1324 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
int debug
Static debugging option.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
#define InfoInFunction
Report an information message using Foam::Info.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
const word & name() const
Return name.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
A class for handling words, derived from Foam::string.
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
A class for managing temporary objects.
Template functions to aid in the implementation of demand driven data.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
const T & min() const noexcept
The min value (first)
#define COMPUTED_ASSIGNMENT(TYPE, op)
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
#define checkField(gf1, gf2, op)
GeometricField(const IOobject &io, const Mesh &mesh, const dimensionSet &ds, const word &patchFieldType=PatchField< Type >::calculatedType())
Construct given IOobject, mesh, dimensions and patch type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
Dimension set for the base types.
word select(bool final) const
Select the final iteration parameters if `final' is true.
conserve primitiveFieldRef()+
Field< Type >::cmptType cmptType
void min(const dimensioned< Type > &dt)
Use the minimum of the field and specified value.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
bool needReference() const
Does the field need a reference level for solution.
#define forAll(list, i)
Loop across all elements in list.
label nOldTimes() const
Return the number of old time fields stored.
void maxMin(const dimensioned< Type > &minVal, const dimensioned< Type > &maxVal) FOAM_DEPRECATED_FOR(2019-01
Deprecated(2019-01) identical to clip()
void deleteDemandDrivenData(DataPtr &dataPtr)
void storeOldTimes() const
Store the old-time fields.
volMesh ::Mesh Mesh
Type of mesh on which this GeometricField is instantiated.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void negate()
Negate the field inplace.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Generic templated field type.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
messageStream Info
Information stream (uses stdout - output is on the master only)
#define DebugInFunction
Report an information message using Foam::Info.
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
word name(const complex &c)
Return string representation of complex.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void storeOldTime() const
Store the old-time field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Generic dimensioned Type class.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
errorManip< error > abort(error &err)
label timeIndex() const
Return the time index of the field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
void correctBoundaryConditions()
Correct boundary field.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
void storePrevIter() const
Store the field as the previous iteration value.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionSet clip(const dimensionSet &ds1, const dimensionSet &ds2)
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void relax()
Relax field (for steady-state solution).
virtual ~GeometricField()
Destructor.
void max(const dimensioned< Type > &dt)
Use the maximum of the field and specified value.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool good() const
Return true if next operation might succeed.
Generic GeometricField class.
#define WarningInFunction
Report a warning using Foam::Warning.
A min/max value pair with additional methods. In addition to conveniently storing values,...
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...