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())
403 readOldTimeIfPresent();
408 <<
"Finishing dictionary-construct of " 414 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
423 fieldPrevIterPtr_(
nullptr),
424 boundaryField_(*
this, gf.boundaryField_)
429 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
440 this->writeOpt() = IOobject::NO_WRITE;
444 #ifndef NoConstructFromTmp 445 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
456 timeIndex_(tgf().timeIndex()),
458 fieldPrevIterPtr_(
nullptr),
459 boundaryField_(*
this, tgf().boundaryField_)
464 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
467 this->writeOpt() = IOobject::NO_WRITE;
474 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
484 fieldPrevIterPtr_(
nullptr),
485 boundaryField_(*
this, gf.boundaryField_)
490 <<
"Constructing as copy resetting IO params" 494 if (!readIfPresent() && gf.field0Ptr_)
505 #ifndef NoConstructFromTmp 506 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
519 timeIndex_(tgf().timeIndex()),
521 fieldPrevIterPtr_(
nullptr),
522 boundaryField_(*
this, tgf().boundaryField_)
527 <<
"Constructing from tmp resetting IO params" 538 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
548 fieldPrevIterPtr_(
nullptr),
549 boundaryField_(*
this, gf.boundaryField_)
554 <<
"Constructing as copy resetting name" 558 if (!readIfPresent() && gf.field0Ptr_)
569 #ifndef NoConstructFromTmp 570 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
583 timeIndex_(tgf().timeIndex()),
585 fieldPrevIterPtr_(
nullptr),
586 boundaryField_(*
this, tgf().boundaryField_)
591 <<
"Constructing from tmp resetting name" 600 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
605 const word& patchFieldType
611 fieldPrevIterPtr_(
nullptr),
612 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
617 <<
"Constructing as copy resetting IO params" 621 boundaryField_ == gf.boundaryField_;
623 if (!readIfPresent() && gf.field0Ptr_)
634 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
647 fieldPrevIterPtr_(
nullptr),
659 <<
"Constructing as copy resetting IO params and patch types" 663 boundaryField_ == gf.boundaryField_;
665 if (!readIfPresent() && gf.field0Ptr_)
676 #ifndef NoConstructFromTmp 677 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
692 timeIndex_(tgf().timeIndex()),
694 fieldPrevIterPtr_(
nullptr),
706 <<
"Constructing from tmp resetting IO params and patch types" 710 boundaryField_ == tgf().boundaryField_;
717 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
730 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
740 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
751 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
762 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
769 return boundaryField_;
773 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
779 && timeIndex_ != this->time().
timeIndex()
781 this->
name().size() > 2
782 && this->
name()(this->
name().size()-2, 2) ==
"_0" 790 timeIndex_ = this->time().timeIndex();
794 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
799 field0Ptr_->storeOldTime();
804 <<
"Storing old time field for field" <<
endl 805 << this->info() <<
endl;
808 *field0Ptr_ == *
this;
809 field0Ptr_->timeIndex_ = timeIndex_;
811 if (field0Ptr_->field0Ptr_)
813 field0Ptr_->writeOpt() = this->writeOpt();
819 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
824 return field0Ptr_->nOldTimes() + 1;
833 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
848 this->registerObject()
862 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
873 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
876 if (!fieldPrevIterPtr_)
881 <<
"Allocating previous iteration field" <<
endl 882 << this->info() <<
endl;
887 this->
name() +
"PrevIter",
893 *fieldPrevIterPtr_ == *
this;
898 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
902 if (!fieldPrevIterPtr_)
905 <<
"previous iteration field" <<
endl << this->info() <<
endl 907 <<
" Use field.storePrevIter() at start of iteration." 911 return *fieldPrevIterPtr_;
915 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
921 boundaryField_.evaluate();
925 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
935 if (boundaryField_[
patchi].fixesValue())
948 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
954 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
957 operator==(prevIter() + alpha*(*
this - prevIter()));
961 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
968 this->
mesh().data::template lookupOrDefault<bool>
978 if (this->
mesh().relaxField(name))
980 relax(this->
mesh().fieldRelaxationFactor(name));
985 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
993 return this->
name() +
"Final";
1002 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1008 os <<
"min/max(" << this->
name() <<
") = " 1015 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1026 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1036 this->
name() +
".T()",
1045 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1046 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1052 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1057 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1089 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1102 boundaryFieldRef().replace(d, gcf.boundaryField());
1106 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1114 boundaryFieldRef().replace(d, ds.
value());
1118 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1129 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1140 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1154 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1158 boundaryFieldRef().negate();
1164 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1165 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1173 <<
"attempted assignment to self" 1186 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1187 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1192 if (
this == &(tgf()))
1195 <<
"attempted assignment to self" 1226 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1227 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1233 boundaryFieldRef() = dt.
value();
1237 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1238 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1256 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1257 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1263 boundaryFieldRef() == dt.
value();
1267 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1269 template<class Type, template<class> class PatchField, class GeoMesh> \ 1270 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1272 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1275 checkField(*this, gf, #op); \ 1278 boundaryFieldRef() op gf.boundaryField(); \ 1281 template<class Type, template<class> class PatchField, class GeoMesh> \ 1282 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1284 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1287 operator op(tgf()); \ 1291 template<class Type, template<class> class PatchField, class GeoMesh> \ 1292 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1294 const dimensioned<TYPE>& dt \ 1298 boundaryFieldRef() op dt.value(); \ 1306 #undef COMPUTED_ASSIGNMENT 1311 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1325 "Ostream& operator<<(Ostream&, " 1326 "const GeometricField<Type, PatchField, GeoMesh>&)" 1333 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()+
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.
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.
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 relax()
Relax field (for steady-state solution).
#define InfoInFunction
Report an information message using Foam::Info.