34 #define checkField(gf1, gf2, op) \ 35 if ((gf1).mesh() != (gf2).mesh()) \ 37 FatalErrorInFunction \ 38 << "different mesh for fields " \ 39 << (gf1).name() << " and " << (gf2).name() \ 40 << " during operatrion " << op \ 41 << abort(FatalError); \ 47 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
50 const dictionary& dict
53 Internal::readField(dict,
"internalField");
55 boundaryField_.readField(*
this, dict.subDict(
"boundaryField"));
57 if (dict.found(
"referenceLevel"))
59 Type fieldAverage(pTraits<Type>(dict.lookup(
"referenceLevel")));
61 Field<Type>::operator+=(fieldAverage);
65 boundaryField_[
patchi] == boundaryField_[
patchi] + fieldAverage;
71 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
74 const IOdictionary
dict 85 this->readStream(typeName)
94 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
99 this->readOpt() == IOobject::MUST_READ
100 || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
104 <<
"read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED" 105 <<
" suggests that a read constructor for field " << this->
name()
106 <<
" would be more appropriate." <<
endl;
108 else if (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
113 if (this->size() != GeoMesh::size(this->
mesh()))
116 <<
" number of field elements = " << this->size()
117 <<
" number of mesh elements = " 118 << GeoMesh::size(this->
mesh())
122 readOldTimeIfPresent();
131 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
140 IOobject::READ_IF_PRESENT,
141 IOobject::AUTO_WRITE,
142 this->registerObject()
145 if (field0.headerOk())
153 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
159 field0Ptr_->timeIndex_ = timeIndex_ - 1;
161 if (!field0Ptr_->readOldTimeIfPresent())
163 field0Ptr_->oldTime();
175 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
181 const word& patchFieldType
187 fieldPrevIterPtr_(NULL),
188 boundaryField_(mesh.boundary(), *
this, patchFieldType)
199 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
212 fieldPrevIterPtr_(NULL),
213 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
224 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
230 const word& patchFieldType
236 fieldPrevIterPtr_(NULL),
237 boundaryField_(mesh.boundary(), *
this, patchFieldType)
244 boundaryField_ == dt.
value();
250 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
263 fieldPrevIterPtr_(NULL),
264 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
271 boundaryField_ == dt.
value();
277 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
282 const PtrList<PatchField<Type>>& ptfl
288 fieldPrevIterPtr_(NULL),
294 <<
"Constructing from components" <<
endl << this->info() <<
endl;
301 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
308 const PtrList<PatchField<Type>>& ptfl
314 fieldPrevIterPtr_(NULL),
315 boundaryField_(mesh.boundary(), *
this, ptfl)
320 <<
"Constructing from components" <<
endl << this->info() <<
endl;
327 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
337 fieldPrevIterPtr_(NULL),
338 boundaryField_(mesh.boundary())
344 if (this->size() != GeoMesh::size(this->
mesh()))
347 <<
" number of field elements = " << this->size()
348 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
352 readOldTimeIfPresent();
357 <<
"Finishing read-construction of" <<
endl << this->info() <<
endl;
362 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
373 fieldPrevIterPtr_(NULL),
374 boundaryField_(mesh.boundary())
380 if (this->size() != GeoMesh::size(this->
mesh()))
383 <<
" number of field elements = " << this->size()
384 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
388 readOldTimeIfPresent();
393 <<
"Finishing dictionary-construct of " 399 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
408 fieldPrevIterPtr_(NULL),
409 boundaryField_(*
this, gf.boundaryField_)
414 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
425 this->writeOpt() = IOobject::NO_WRITE;
429 #ifndef NoConstructFromTmp 430 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
441 timeIndex_(tgf().timeIndex()),
443 fieldPrevIterPtr_(NULL),
444 boundaryField_(*
this, tgf().boundaryField_)
449 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
452 this->writeOpt() = IOobject::NO_WRITE;
459 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
469 fieldPrevIterPtr_(NULL),
470 boundaryField_(*
this, gf.boundaryField_)
475 <<
"Constructing as copy resetting IO params" 479 if (!readIfPresent() && gf.field0Ptr_)
490 #ifndef NoConstructFromTmp 491 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
504 timeIndex_(tgf().timeIndex()),
506 fieldPrevIterPtr_(NULL),
507 boundaryField_(*
this, tgf().boundaryField_)
512 <<
"Constructing from tmp resetting IO params" 523 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
533 fieldPrevIterPtr_(NULL),
534 boundaryField_(*
this, gf.boundaryField_)
539 <<
"Constructing as copy resetting name" 543 if (!readIfPresent() && gf.field0Ptr_)
554 #ifndef NoConstructFromTmp 555 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
568 timeIndex_(tgf().timeIndex()),
570 fieldPrevIterPtr_(NULL),
571 boundaryField_(*
this, tgf().boundaryField_)
576 <<
"Constructing from tmp resetting name" 585 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
590 const word& patchFieldType
596 fieldPrevIterPtr_(NULL),
597 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
602 <<
"Constructing as copy resetting IO params" 606 boundaryField_ == gf.boundaryField_;
608 if (!readIfPresent() && gf.field0Ptr_)
619 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
632 fieldPrevIterPtr_(NULL),
644 <<
"Constructing as copy resetting IO params and patch types" 648 boundaryField_ == gf.boundaryField_;
650 if (!readIfPresent() && gf.field0Ptr_)
661 #ifndef NoConstructFromTmp 662 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
677 timeIndex_(tgf().timeIndex()),
679 fieldPrevIterPtr_(NULL),
691 <<
"Constructing from tmp resetting IO params and patch types" 695 boundaryField_ == tgf().boundaryField_;
704 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
714 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
725 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
736 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
743 return boundaryField_;
747 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
753 && timeIndex_ != this->time().
timeIndex()
755 this->
name().size() > 2
756 && this->
name()(this->
name().size()-2, 2) ==
"_0" 764 timeIndex_ = this->time().timeIndex();
768 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
773 field0Ptr_->storeOldTime();
778 <<
"Storing old time field for field" <<
endl 779 << this->info() <<
endl;
782 *field0Ptr_ == *
this;
783 field0Ptr_->timeIndex_ = timeIndex_;
785 if (field0Ptr_->field0Ptr_)
787 field0Ptr_->writeOpt() = this->writeOpt();
793 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
798 return field0Ptr_->nOldTimes() + 1;
807 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
822 this->registerObject()
836 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
847 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
850 if (!fieldPrevIterPtr_)
855 <<
"Allocating previous iteration field" <<
endl 856 << this->info() <<
endl;
861 this->
name() +
"PrevIter",
867 *fieldPrevIterPtr_ == *
this;
872 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
876 if (!fieldPrevIterPtr_)
879 <<
"previous iteration field" <<
endl << this->info() <<
endl 881 <<
" Use field.storePrevIter() at start of iteration." 885 return *fieldPrevIterPtr_;
889 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
895 boundaryField_.evaluate();
899 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
909 if (boundaryField_[
patchi].fixesValue())
922 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
928 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
931 operator==(prevIter() + alpha*(*
this - prevIter()));
935 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
942 this->
mesh().data::template lookupOrDefault<bool>
952 if (this->
mesh().relaxField(name))
954 relax(this->
mesh().fieldRelaxationFactor(name));
959 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
967 return this->
name() +
"Final";
976 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
982 os <<
"min/max(" << this->
name() <<
") = " 989 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1000 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1010 this->
name() +
".T()",
1019 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1020 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1026 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1031 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1063 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1076 boundaryFieldRef().replace(d, gcf.boundaryField());
1080 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1088 boundaryFieldRef().replace(d, ds.
value());
1092 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1103 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1114 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1118 boundaryFieldRef().negate();
1124 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1125 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1133 <<
"attempted assignment to self" 1146 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1147 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1152 if (
this == &(tgf()))
1155 <<
"attempted assignment to self" 1179 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1180 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1186 boundaryFieldRef() = dt.
value();
1190 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1191 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1209 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1210 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1216 boundaryFieldRef() == dt.
value();
1220 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1222 template<class Type, template<class> class PatchField, class GeoMesh> \ 1223 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1225 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1228 checkField(*this, gf, #op); \ 1231 boundaryFieldRef() op gf.boundaryField(); \ 1234 template<class Type, template<class> class PatchField, class GeoMesh> \ 1235 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1237 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1240 operator op(tgf()); \ 1244 template<class Type, template<class> class PatchField, class GeoMesh> \ 1245 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1247 const dimensioned<TYPE>& dt \ 1251 boundaryFieldRef() op dt.value(); \ 1259 #undef COMPUTED_ASSIGNMENT 1264 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1278 "Ostream& operator<<(Ostream&, " 1279 "const GeometricField<Type, PatchField, GeoMesh>&)" 1286 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
bool needReference() const
Does the field need a reference level for solution.
void replace(const direction, const GeometricField< cmptType, PatchField, GeoMesh > &)
#define COMPUTED_ASSIGNMENT(TYPE, op)
void storeOldTime() const
Store the old-time field.
#define forAll(list, i)
Loop across all elements in list.
#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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
Field< Type >::cmptType cmptType
bool good() const
Return true if next operation might succeed.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
const Type & value() const
Return const reference to value.
Generic GeometricField class.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
Generic dimensioned Type class.
conserve primitiveFieldRef()+
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.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
Dimension set for the base types.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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.
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
label timeIndex() const
Return the time index of the field.
word select(bool final) const
Select the final iteration parameters if `final' is true.
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)
const dimensionSet & dimensions() const
Return dimensions.
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...
label nOldTimes() const
Return the number of old time fields stored.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal 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.
Internal & ref()
Return a reference to the dimensioned internal field.
Template functions to aid in the implementation of demand driven data.
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...
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
void correctBoundaryConditions()
Correct boundary field.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
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 storePrevIter() const
Store the field as the previous iteration value.
void relax()
Relax field (for steady-state solution).
const word & name() const
Return name.
#define InfoInFunction
Report an information message using Foam::Info.
void storeOldTimes() const
Store the old-time fields.