35 #define checkField(gf1, gf2, op) \
36 if ((gf1).mesh() != (gf2).mesh()) \
38 FatalErrorIn("checkField(gf1, gf2, op)") \
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>
52 GeometricBoundaryField
56 const dictionary& fieldDict
59 DimensionedField<Type, GeoMesh>::readField(fieldDict,
"internalField");
61 tmp<GeometricBoundaryField> tboundaryField
63 new GeometricBoundaryField
67 fieldDict.subDict(
"boundaryField")
71 if (fieldDict.found(
"referenceLevel"))
73 Type fieldAverage(pTraits<Type>(fieldDict.lookup(
"referenceLevel")));
75 Field<Type>::operator+=(fieldAverage);
81 boundaryField[
patchi] == boundaryField[
patchi] + fieldAverage;
85 return tboundaryField;
89 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
93 GeometricBoundaryField
97 if (is.version() < 2.0)
101 "GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
103 ) <<
"IO versions < 2.0 are not supported."
107 return readField(dictionary(is));
111 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
114 if (this->readOpt() == IOobject::MUST_READ)
118 "GeometricField<Type, PatchField, GeoMesh>::readIfPresent()"
119 ) <<
"read option IOobject::MUST_READ "
120 <<
"suggests that a read constructor for field " << this->
name()
121 <<
" would be more appropriate." <<
endl;
123 else if (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
125 boundaryField_.transfer(readField(this->readStream(typeName))());
129 if (this->size() != GeoMesh::size(this->
mesh()))
133 "GeometricField<Type, PatchField, GeoMesh>::"
135 this->readStream(typeName)
136 ) <<
" number of field elements = " << this->size()
137 <<
" number of mesh elements = "
138 << GeoMesh::size(this->
mesh())
142 readOldTimeIfPresent();
151 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
160 IOobject::READ_IF_PRESENT,
164 if (field0.headerOk())
168 Info<<
"Reading old time level for field"
172 field0Ptr_ =
new GeometricField<Type, PatchField, GeoMesh>
178 field0Ptr_->timeIndex_ = timeIndex_ - 1;
180 if (!field0Ptr_->readOldTimeIfPresent())
182 field0Ptr_->oldTime();
198 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
204 const word& patchFieldType
208 timeIndex_(this->time().timeIndex()),
210 fieldPrevIterPtr_(NULL),
211 boundaryField_(mesh.boundary(), *
this, patchFieldType)
215 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
228 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
238 timeIndex_(this->time().timeIndex()),
240 fieldPrevIterPtr_(NULL),
241 boundaryField_(mesh.boundary(), *
this, patchFieldTypes)
245 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
255 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
261 const word& patchFieldType
265 timeIndex_(this->time().timeIndex()),
267 fieldPrevIterPtr_(NULL),
268 boundaryField_(mesh.boundary(), *
this, patchFieldType)
272 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
277 boundaryField_ == dt.
value();
284 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
294 timeIndex_(this->time().timeIndex()),
296 fieldPrevIterPtr_(NULL),
297 boundaryField_(mesh.boundary(), *
this, patchFieldTypes)
301 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
306 boundaryField_ == dt.
value();
313 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
320 const PtrList<PatchField<Type> >& ptfl
324 timeIndex_(this->time().timeIndex()),
326 fieldPrevIterPtr_(NULL),
327 boundaryField_(mesh.boundary(), *
this, ptfl)
331 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
332 "constructing from components"
340 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
348 timeIndex_(this->time().timeIndex()),
350 fieldPrevIterPtr_(NULL),
351 boundaryField_(*
this, readField(this->readStream(typeName)))
357 if (this->size() != GeoMesh::size(this->
mesh()))
361 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
362 "(const IOobject&, const Mesh&)",
363 this->readStream(typeName)
364 ) <<
" number of field elements = " << this->size()
365 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
369 readOldTimeIfPresent();
373 Info<<
"Finishing read-construct of "
374 "GeometricField<Type, PatchField, GeoMesh>"
380 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
389 timeIndex_(this->time().timeIndex()),
391 fieldPrevIterPtr_(NULL),
392 boundaryField_(*
this, readField(is))
396 if (this->size() != GeoMesh::size(this->
mesh()))
400 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
401 "(const IOobject&, const Mesh&, Istream&)",
403 ) <<
" number of field elements = " << this->size()
404 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
408 readOldTimeIfPresent();
412 Info<<
"Finishing read-construct of "
413 "GeometricField<Type, PatchField, GeoMesh>"
419 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
428 timeIndex_(this->time().timeIndex()),
430 fieldPrevIterPtr_(NULL),
431 boundaryField_(*
this, readField(dict))
435 if (this->size() != GeoMesh::size(this->
mesh()))
439 "GeometricField<Type, PatchField, GeoMesh>::GeometricField"
440 "(const IOobject&, const Mesh&, const dictionary&)"
441 ) <<
" number of field elements = " << this->size()
442 <<
" number of mesh elements = " << GeoMesh::size(this->
mesh())
446 readOldTimeIfPresent();
450 Info<<
"Finishing dictionary-construct of "
451 "GeometricField<Type, PatchField, GeoMesh>"
458 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
467 fieldPrevIterPtr_(NULL),
468 boundaryField_(*
this, gf.boundaryField_)
472 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
473 "constructing as copy"
485 this->writeOpt() = IOobject::NO_WRITE;
489 #ifdef ConstructFromTmp
490 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
503 fieldPrevIterPtr_(NULL),
504 boundaryField_(*this, tgf().boundaryField_)
508 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
509 "constructing as copy"
521 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
522 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
531 fieldPrevIterPtr_(NULL),
532 boundaryField_(*
this, gf.boundaryField_)
536 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
537 "constructing as copy resetting IO params"
553 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
554 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
563 fieldPrevIterPtr_(NULL),
564 boundaryField_(*
this, gf.boundaryField_)
568 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
569 "constructing as copy resetting name"
585 #ifdef ConstructFromTmp
586 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
587 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
601 fieldPrevIterPtr_(NULL),
602 boundaryField_(*this, tgf().boundaryField_)
606 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
607 "constructing from tmp resetting name"
616 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
617 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
621 const word& patchFieldType
627 fieldPrevIterPtr_(NULL),
628 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
632 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
633 "constructing as copy resetting IO params"
637 boundaryField_ == gf.boundaryField_;
651 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
652 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
662 fieldPrevIterPtr_(NULL),
663 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldTypes)
667 Info<<
"GeometricField<Type, PatchField, GeoMesh>::GeometricField : "
668 "constructing as copy resetting IO params"
672 boundaryField_ == gf.boundaryField_;
687 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
697 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
708 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
720 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
727 return boundaryField_;
732 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
738 && timeIndex_ != this->time().
timeIndex()
740 this->
name().size() > 2
741 && this->
name()(this->
name().size()-2, 2) ==
"_0"
749 timeIndex_ = this->time().timeIndex();
753 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
762 Info<<
"Storing old time field for field" <<
endl
763 << this->info() <<
endl;
766 *field0Ptr_ == *
this;
767 field0Ptr_->timeIndex_ = timeIndex_;
769 if (field0Ptr_->field0Ptr_)
771 field0Ptr_->writeOpt() = this->writeOpt();
777 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
791 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
817 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
829 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
832 if (!fieldPrevIterPtr_)
836 Info<<
"Allocating previous iteration field" <<
endl
837 << this->info() <<
endl;
842 this->
name() +
"PrevIter",
848 *fieldPrevIterPtr_ == *
this;
854 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
858 if (!fieldPrevIterPtr_)
862 "GeometricField<Type, PatchField, GeoMesh>::prevIter() const"
863 ) <<
"previous iteration field" <<
endl << this->info() <<
endl
865 <<
" Use field.storePrevIter() at start of iteration."
869 return *fieldPrevIterPtr_;
874 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
880 boundaryField_.evaluate();
885 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
895 if (boundaryField_[
patchi].fixesValue())
908 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
911 operator==(prevIter() + alpha*(*
this - prevIter()));
915 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
932 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
940 return this->
name() +
"Final";
950 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
961 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
971 this->
name() +
".T()",
980 Foam::T(result().internalField(), internalField());
987 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1024 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1028 const GeometricField
1030 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
1036 internalField().
replace(d, gcf.internalField());
1041 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1053 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1064 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1075 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1078 internalField().negate();
1085 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1095 "GeometricField<Type, PatchField, GeoMesh>::operator="
1096 "(const GeometricField<Type, PatchField, GeoMesh>&)"
1097 ) <<
"attempted assignment to self"
1110 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1111 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1116 if (
this == &(tgf()))
1120 "GeometricField<Type, PatchField, GeoMesh>::operator="
1121 "(const tmp<GeometricField<Type, PatchField, GeoMesh> >&)"
1122 ) <<
"attempted assignment to self"
1135 internalField().transfer
1146 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1147 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1152 dimensionedInternalField() = dt;
1157 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1158 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1176 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1177 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1182 dimensionedInternalField() = dt;
1187 #define COMPUTED_ASSIGNMENT(TYPE, op) \
1189 template<class Type, template<class> class PatchField, class GeoMesh> \
1190 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1192 const GeometricField<TYPE, PatchField, GeoMesh>& gf \
1195 checkField(*this, gf, #op); \
1197 dimensionedInternalField() op gf.dimensionedInternalField(); \
1198 boundaryField() op gf.boundaryField(); \
1201 template<class Type, template<class> class PatchField, class GeoMesh> \
1202 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1204 const tmp<GeometricField<TYPE, PatchField, GeoMesh> >& tgf \
1207 operator op(tgf()); \
1211 template<class Type, template<class> class PatchField, class GeoMesh> \
1212 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
1214 const dimensioned<TYPE>& dt \
1217 dimensionedInternalField() op dt; \
1218 boundaryField() op dt.value(); \
1226 #undef COMPUTED_ASSIGNMENT
1231 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1245 "Ostream& operator<<(Ostream&, "
1246 "const GeometricField<Type, PatchField, GeoMesh>&)"
1253 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>