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>
669 const word& patchFieldType
675 fieldPrevIterPtr_(
nullptr),
676 boundaryField_(*
this, gf.boundaryField_, patchIDs, patchFieldType)
679 <<
"Copy construct, resetting IO params and setting patchFieldType "
680 <<
"for patchIDs" <<
nl
681 << this->info() <<
endl;
683 if (!readIfPresent() && gf.field0Ptr_)
694 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
703 Internal(io, tgf.constCast(), tgf.movable()),
704 timeIndex_(tgf().timeIndex()),
706 fieldPrevIterPtr_(
nullptr),
716 <<
"Constructing from tmp resetting IO params and patch types" <<
nl
717 << this->info() <<
endl;
719 boundaryField_ == tgf().boundaryField_;
725 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
735 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
745 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
750 const bool updateAccessTime
753 if (updateAccessTime)
762 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
767 const bool updateAccessTime
770 if (updateAccessTime)
779 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
784 const bool updateAccessTime
787 if (updateAccessTime)
792 return boundaryField_;
796 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
802 && timeIndex_ != this->time().
timeIndex()
803 && !this->
name().ends_with(
"_0")
807 timeIndex_ = this->time().timeIndex();
815 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
820 field0Ptr_->storeOldTime();
823 <<
"Storing old time field for field" <<
nl << this->info() <<
endl;
825 *field0Ptr_ == *
this;
826 field0Ptr_->timeIndex_ = timeIndex_;
828 if (field0Ptr_->field0Ptr_)
830 field0Ptr_->writeOpt(this->writeOpt());
836 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
841 return field0Ptr_->nOldTimes() + 1;
848 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
863 this->registerObject()
871 <<
"created old time field " << field0Ptr_->info() <<
endl;
875 error::printStack(
Info);
888 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
899 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
902 if (!fieldPrevIterPtr_)
905 <<
"Allocating previous iteration field" <<
nl
906 << this->info() <<
endl;
910 this->
name() +
"PrevIter",
916 *fieldPrevIterPtr_ == *
this;
921 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
925 if (!fieldPrevIterPtr_)
928 <<
"previous iteration field" <<
endl << this->info() <<
endl
930 <<
" Use field.storePrevIter() at start of iteration."
934 return *fieldPrevIterPtr_;
938 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
944 boundaryField_.evaluate();
948 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
956 forAll(boundaryField_, patchi)
958 if (boundaryField_[patchi].fixesValue())
971 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
975 <<
"Relaxing" <<
nl << this->info() <<
" by " <<
alpha <<
endl;
981 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
988 this->
mesh().data::template getOrDefault<bool>
1005 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1013 return this->
name() +
"Final";
1016 return this->
name();
1020 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1028 os <<
"min/max(" << this->
name() <<
") = "
1033 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1044 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1052 this->
name() +
".T()",
1060 Foam::T(tresult.ref().primitiveFieldRef(), primitiveField());
1061 Foam::T(tresult.ref().boundaryFieldRef(), boundaryField());
1067 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1094 Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d);
1095 Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d);
1101 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1105 const GeometricField
1107 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
1114 boundaryFieldRef().replace(d, gcf.boundaryField());
1118 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1126 boundaryFieldRef().replace(d, ds.
value());
1130 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1141 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1152 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1163 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1177 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1184 this->
clip(minVal, maxVal);
1188 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1192 boundaryFieldRef().negate();
1198 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1218 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1224 const auto& gf = tgf();
1235 this->dimensions() = gf.dimensions();
1236 this->oriented() = gf.oriented();
1254 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1261 boundaryFieldRef() = dt.
value();
1265 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1271 const auto& gf = tgf();
1284 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1291 boundaryFieldRef() == dt.
value();
1295 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1297 template<class Type, template<class> class PatchField, class GeoMesh> \
1298 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1300 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1303 checkField(*this, gf, #op); \
1306 boundaryFieldRef() op gf.boundaryField(); \
1309 template<class Type, template<class> class PatchField, class GeoMesh> \
1310 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1312 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \
1315 operator op(tgf()); \
1319 template<class Type, template<class> class PatchField, class GeoMesh> \
1320 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1322 const dimensioned<TYPE>& dt \
1326 boundaryFieldRef() op dt.value(); \
1334 #undef COMPUTED_ASSIGNMENT
1339 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1355 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)
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, which can be used to implement rigorous dimension checking for alge...
word select(bool final) const
Select the final iteration parameters if `final' is true.
conserve primitiveFieldRef()+
void clip(const dimensioned< MinMax< Type >> &range)
Clip the field to be bounded within the specified range.
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.
void maxMin(const dimensioned< Type > &minVal, const dimensioned< Type > &maxVal)
Deprecated(2019-01) identical to clip()
#define forAll(list, i)
Loop across all elements in list.
label nOldTimes() const
Return the number of old time fields stored.
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 negate()
Negate the field inplace.
Generic templated field type.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
messageStream Info
Information stream (stdout output on master, null elsewhere)
#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.
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,...
reduce(hasMovingMesh, orOp< bool >())
OBJstream os(runTime.globalPath()/outputName)
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.
const word & name() const noexcept
Return name.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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,...
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...
const dimensionSet dimless
Dimensionless.