34 #define checkField(gf1, gf2, op) \ 35 if ((gf1).mesh() != (gf2).mesh()) \ 37 FatalErrorIn("checkField(gf1, gf2, op)") \ 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 DimensionedField<Type, GeoMesh>::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
105 "GeometricField<Type, PatchField, GeoMesh>::readIfPresent()" 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;
110 else if (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
115 if (this->size() != GeoMesh::size(this->
mesh()))
119 "GeometricField<Type, PatchField, GeoMesh>::" 121 this->readStream(typeName)
122 ) <<
" number of field elements = " << this->size()
123 <<
" number of mesh elements = " 124 << GeoMesh::size(this->
mesh())
128 readOldTimeIfPresent();
137 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
146 IOobject::READ_IF_PRESENT,
147 IOobject::AUTO_WRITE,
148 this->registerObject()
151 if (field0.headerOk())
155 Info<<
"Reading old time level for field" 159 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
165 field0Ptr_->timeIndex_ = timeIndex_ - 1;
167 if (!field0Ptr_->readOldTimeIfPresent())
169 field0Ptr_->oldTime();
181 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
187 const word& patchFieldType
191 timeIndex_(this->time().timeIndex()),
193 fieldPrevIterPtr_(NULL),
194 boundaryField_(mesh.boundary(), *
this, patchFieldType)
198 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 207 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
218 timeIndex_(this->time().timeIndex()),
220 fieldPrevIterPtr_(NULL),
221 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
225 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 234 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
240 const word& patchFieldType
244 timeIndex_(this->time().timeIndex()),
246 fieldPrevIterPtr_(NULL),
247 boundaryField_(mesh.boundary(), *
this, patchFieldType)
251 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 256 boundaryField_ == dt.value();
262 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
273 timeIndex_(this->time().timeIndex()),
275 fieldPrevIterPtr_(NULL),
276 boundaryField_(mesh.boundary(), *
this, patchFieldTypes, actualPatchTypes)
280 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 285 boundaryField_ == dt.value();
291 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
298 const PtrList<PatchField<Type> >& ptfl
302 timeIndex_(this->time().timeIndex()),
304 fieldPrevIterPtr_(NULL),
305 boundaryField_(mesh.boundary(), *
this, ptfl)
309 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 310 "constructing from components" 318 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
326 timeIndex_(this->time().timeIndex()),
328 fieldPrevIterPtr_(NULL),
329 boundaryField_(mesh.boundary())
335 if (this->size() != GeoMesh::size(this->
mesh()))
339 "GeometricField<Type, PatchField, GeoMesh>::GeometricField" 340 "(const IOobject&, const Mesh&)",
341 this->readStream(typeName)
342 ) <<
" number of field elements = " << this->size()
343 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
347 readOldTimeIfPresent();
351 Info<<
"Finishing read-construct of " 352 "GeometricField<Type, PatchField, GeoMesh>" 358 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
367 timeIndex_(this->time().timeIndex()),
369 fieldPrevIterPtr_(NULL),
370 boundaryField_(mesh.boundary())
376 if (this->size() != GeoMesh::size(this->
mesh()))
380 "GeometricField<Type, PatchField, GeoMesh>::GeometricField" 381 "(const IOobject&, const Mesh&, const dictionary&)" 382 ) <<
" number of field elements = " << this->size()
383 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
387 readOldTimeIfPresent();
391 Info<<
"Finishing dictionary-construct of " 392 "GeometricField<Type, PatchField, GeoMesh>" 398 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
407 fieldPrevIterPtr_(NULL),
408 boundaryField_(*
this, gf.boundaryField_)
412 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 413 "constructing as copy" 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_)
448 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 449 "constructing as copy" 453 this->writeOpt() = IOobject::NO_WRITE;
460 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
470 fieldPrevIterPtr_(NULL),
471 boundaryField_(*
this, gf.boundaryField_)
475 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 476 "constructing as copy resetting IO params" 480 if (!readIfPresent() && gf.field0Ptr_)
491 #ifndef NoConstructFromTmp 492 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
505 timeIndex_(tgf().timeIndex()),
507 fieldPrevIterPtr_(NULL),
508 boundaryField_(*
this, tgf().boundaryField_)
512 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 513 "constructing from tmp resetting IO params" 524 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
534 fieldPrevIterPtr_(NULL),
535 boundaryField_(*
this, gf.boundaryField_)
539 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 540 "constructing as copy resetting name" 544 if (!readIfPresent() && gf.field0Ptr_)
555 #ifndef NoConstructFromTmp 556 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
569 timeIndex_(tgf().timeIndex()),
571 fieldPrevIterPtr_(NULL),
572 boundaryField_(*
this, tgf().boundaryField_)
576 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 577 "constructing from tmp resetting name" 586 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
591 const word& patchFieldType
597 fieldPrevIterPtr_(NULL),
598 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
602 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 603 "constructing as copy resetting IO params" 607 boundaryField_ == gf.boundaryField_;
609 if (!readIfPresent() && gf.field0Ptr_)
620 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
633 fieldPrevIterPtr_(NULL),
644 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : " 645 "constructing as copy resetting IO params and patch types" 649 boundaryField_ == gf.boundaryField_;
651 if (!readIfPresent() && gf.field0Ptr_)
664 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
674 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
685 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
696 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
703 return boundaryField_;
707 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
713 && timeIndex_ != this->time().
timeIndex()
715 this->
name().size() > 2
716 && this->
name()(this->
name().size()-2, 2) ==
"_0" 724 timeIndex_ = this->time().timeIndex();
728 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
733 field0Ptr_->storeOldTime();
737 Info<<
"Storing old time field for field" <<
endl 738 << this->info() <<
endl;
741 *field0Ptr_ == *
this;
742 field0Ptr_->timeIndex_ = timeIndex_;
744 if (field0Ptr_->field0Ptr_)
746 field0Ptr_->writeOpt() = this->writeOpt();
752 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
757 return field0Ptr_->nOldTimes() + 1;
766 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
781 this->registerObject()
795 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
806 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
809 if (!fieldPrevIterPtr_)
813 Info<<
"Allocating previous iteration field" <<
endl 814 << this->info() <<
endl;
819 this->
name() +
"PrevIter",
825 *fieldPrevIterPtr_ == *
this;
830 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
834 if (!fieldPrevIterPtr_)
838 "GeometricField<Type, PatchField, GeoMesh>::prevIter() const" 839 ) <<
"previous iteration field" <<
endl << this->info() <<
endl 841 <<
" Use field.storePrevIter() at start of iteration." 845 return *fieldPrevIterPtr_;
849 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
855 boundaryField_.evaluate();
859 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
869 if (boundaryField_[
patchi].fixesValue())
882 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
889 "GeometricField<Type, PatchField, GeoMesh>::relax" 890 "(const scalar alpha)" 891 ) <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
894 operator==(prevIter() + alpha*(*
this - prevIter()));
898 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
905 this->
mesh().data::template lookupOrDefault<bool>
915 if (this->
mesh().relaxField(name))
917 relax(this->
mesh().fieldRelaxationFactor(name));
922 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
930 return this->
name() +
"Final";
939 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
945 os <<
"min/max(" << this->
name() <<
") = " 952 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
963 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
973 this->
name() +
".T()",
983 Foam::T(result().boundaryField(), boundaryField());
989 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
994 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1026 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1039 boundaryField().replace(d, gcf.boundaryField());
1043 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1051 boundaryField().replace(d, ds.
value());
1055 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1066 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1077 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1081 boundaryField().negate();
1087 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1088 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1097 "GeometricField<Type, PatchField, GeoMesh>::operator=" 1098 "(const GeometricField<Type, PatchField, GeoMesh>&)" 1099 ) <<
"attempted assignment to self" 1112 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1113 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1118 if (
this == &(tgf()))
1122 "GeometricField<Type, PatchField, GeoMesh>::operator=" 1123 "(const tmp<GeometricField<Type, PatchField, GeoMesh> >&)" 1124 ) <<
"attempted assignment to self" 1148 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1149 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1155 boundaryField() = dt.
value();
1159 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1160 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1178 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1179 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1185 boundaryField() == dt.
value();
1189 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1191 template<class Type, template<class> class PatchField, class GeoMesh> \ 1192 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1194 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1197 checkField(*this, gf, #op); \ 1199 dimensionedInternalField() op gf.dimensionedInternalField(); \ 1200 boundaryField() op gf.boundaryField(); \ 1203 template<class Type, template<class> class PatchField, class GeoMesh> \ 1204 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1206 const tmp<GeometricField<TYPE, PatchField, GeoMesh> >& tgf \ 1209 operator op(tgf()); \ 1213 template<class Type, template<class> class PatchField, class GeoMesh> \ 1214 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1216 const dimensioned<TYPE>& dt \ 1219 dimensionedInternalField() op dt; \ 1220 boundaryField() op dt.value(); \ 1228 #undef COMPUTED_ASSIGNMENT 1233 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1247 "Ostream& operator<<(Ostream&, " 1248 "const GeometricField<Type, PatchField, GeoMesh>&)" 1255 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
#define COMPUTED_ASSIGNMENT(TYPE, op)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
faceListList boundary(nPatches)
Field< Type >::cmptType cmptType
virtual ~GeometricField()
Destructor.
bool needReference() const
Does the field need a reference level for solution.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
word name(const complex &)
Return a string representation of a complex.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void deleteDemandDrivenData(DataPtr &dataPtr)
A class for handling words, derived from string.
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)
InternalField & internalField()
Return internal field.
DimensionedInternalField & dimensionedInternalField()
Return dimensioned internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
void writeMinMax(Ostream &os) const
Helper function to write the min and max to an Ostream.
#define checkField(gf1, gf2, op)
Generic dimensioned Type class.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
#define WarningIn(functionName)
Report a warning using Foam::Warning.
void readFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
GeometricField(const IOobject &, const Mesh &, const dimensionSet &, const word &patchFieldType=PatchField< Type >::calculatedType())
Constructor given IOobject, mesh, dimensions and patch type.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Dimension set for the base types.
const GeometricField< Type, PatchField, GeoMesh > & prevIter() const
Return previous iteration field.
bool good() const
Return true if next operation might succeed.
label nOldTimes() const
Return the number of old time fields stored.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Template functions to aid in the implementation of demand driven data.
const dimensionSet & dimensions() const
Return dimensions.
#define InfoIn(functionName)
Report a information message using Foam::Info.
Pre-declare SubField and related Field type.
errorManip< error > abort(error &err)
const word & name() const
Return name.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
rDeltaT dimensionedInternalField()
Generic GeometricField class.
const GeometricField< Type, PatchField, GeoMesh > & oldTime() const
Return old time field.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
void correctBoundaryConditions()
Correct boundary field.
void replace(const direction, const GeometricField< cmptType, PatchField, GeoMesh > &)
void max(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
label timeIndex() const
Return the time index of the field.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
void storeOldTimes() const
Store the old-time fields.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
bool writeData(Ostream &) const
WriteData member function required by regIOobject.
void storePrevIter() const
Store the field as the previous iteration value.
void relax()
Relax field (for steady-state solution).
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
void min(const dimensioned< Type > &)
A class for managing temporary objects.
void storeOldTime() const
Store the old-time field.
conserve internalField()+
const Type & value() const
Return const reference to value.
word select(bool final) const
Select the final iteration parameters if `final' is true.