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),
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),
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())
406 <<
"Finishing dictionary-construct of " 412 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
421 fieldPrevIterPtr_(
nullptr),
422 boundaryField_(*
this, gf.boundaryField_)
427 <<
"Constructing as copy" <<
endl << this->info() <<
endl;
438 this->writeOpt() = IOobject::NO_WRITE;
442 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
451 fieldPrevIterPtr_(
nullptr),
452 boundaryField_(move(gf.boundaryField_))
457 <<
"Constructing by moving" <<
endl << this->info() <<
endl;
462 field0Ptr_ = gf.field0Ptr_;
463 gf.field0Ptr_ =
nullptr;
466 this->writeOpt() = IOobject::NO_WRITE;
470 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
481 timeIndex_(tgf().timeIndex()),
483 fieldPrevIterPtr_(
nullptr),
484 boundaryField_(*
this, tgf().boundaryField_)
489 <<
"Constructing from tmp" <<
endl << this->info() <<
endl;
492 this->writeOpt() = IOobject::NO_WRITE;
498 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
508 fieldPrevIterPtr_(
nullptr),
509 boundaryField_(*
this, gf.boundaryField_)
514 <<
"Constructing as copy resetting IO params" 518 if (!readIfPresent() && gf.field0Ptr_)
529 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
542 timeIndex_(tgf().timeIndex()),
544 fieldPrevIterPtr_(
nullptr),
545 boundaryField_(*
this, tgf().boundaryField_)
550 <<
"Constructing from tmp resetting IO params" 560 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
570 fieldPrevIterPtr_(
nullptr),
571 boundaryField_(*
this, gf.boundaryField_)
576 <<
"Constructing as copy resetting name" 580 if (!readIfPresent() && gf.field0Ptr_)
591 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
604 timeIndex_(tgf().timeIndex()),
606 fieldPrevIterPtr_(
nullptr),
607 boundaryField_(*
this, tgf().boundaryField_)
612 <<
"Constructing from tmp resetting name" 620 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
625 const word& patchFieldType
631 fieldPrevIterPtr_(
nullptr),
632 boundaryField_(this->
mesh().
boundary(), *
this, patchFieldType)
637 <<
"Constructing as copy resetting IO params" 641 boundaryField_ == gf.boundaryField_;
643 if (!readIfPresent() && gf.field0Ptr_)
654 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
667 fieldPrevIterPtr_(
nullptr),
679 <<
"Constructing as copy resetting IO params and patch types" 683 boundaryField_ == gf.boundaryField_;
685 if (!readIfPresent() && gf.field0Ptr_)
696 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
711 timeIndex_(tgf().timeIndex()),
713 fieldPrevIterPtr_(
nullptr),
725 <<
"Constructing from tmp resetting IO params and patch types" 729 boundaryField_ == tgf().boundaryField_;
735 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
746 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
752 const PtrList<PatchField<Type>>& ptfl
762 diField.
mesh().thisDb().time().timeName(),
763 diField.
mesh().thisDb(),
766 diField.
mesh().thisDb().cacheTemporaryObject(name)
775 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
782 const word& patchFieldType
792 mesh.thisDb().time().timeName(),
796 mesh.thisDb().cacheTemporaryObject(name)
806 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
813 const word& patchFieldType
823 mesh.thisDb().time().timeName(),
827 mesh.thisDb().cacheTemporaryObject(name)
838 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
856 mesh.thisDb().time().timeName(),
860 mesh.thisDb().cacheTemporaryObject(name)
871 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
891 tgf().db().cacheTemporaryObject(newName)
899 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
905 const word& patchFieldType
920 tgf().db().cacheTemporaryObject(newName)
929 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
951 tgf().db().cacheTemporaryObject(newName)
963 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
966 this->db().cacheTemporaryObject(*
this);
975 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
986 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
997 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1002 this->setUpToDate();
1004 return boundaryField_;
1008 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1014 && timeIndex_ != this->time().
timeIndex()
1016 this->
name().size() > 2
1017 && this->
name()(this->
name().size()-2, 2) ==
"_0" 1025 timeIndex_ = this->time().timeIndex();
1029 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1034 field0Ptr_->storeOldTime();
1039 <<
"Storing old time field for field" <<
endl 1040 << this->info() <<
endl;
1043 *field0Ptr_ == *
this;
1044 field0Ptr_->timeIndex_ = timeIndex_;
1046 if (field0Ptr_->field0Ptr_)
1048 field0Ptr_->writeOpt() = this->writeOpt();
1054 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1059 return field0Ptr_->nOldTimes() + 1;
1068 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1078 this->
name() +
"_0",
1083 this->registerObject()
1097 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1108 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1111 if (!fieldPrevIterPtr_)
1116 <<
"Allocating previous iteration field" <<
endl 1117 << this->info() <<
endl;
1122 this->
name() +
"PrevIter",
1128 *fieldPrevIterPtr_ == *
this;
1133 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1137 if (!fieldPrevIterPtr_)
1140 <<
"previous iteration field" <<
endl << this->info() <<
endl 1142 <<
" Use field.storePrevIter() at start of iteration." 1146 return *fieldPrevIterPtr_;
1150 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1154 this->setUpToDate();
1156 boundaryField_.evaluate();
1160 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1166 bool needRef =
true;
1170 if (boundaryField_[
patchi].fixesValue())
1183 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1189 <<
"Relaxing" <<
endl << this->info() <<
" by " << alpha <<
endl;
1192 operator==(prevIter() + alpha*(*
this - prevIter()));
1196 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1201 this->
mesh().data::template lookupOrDefault<bool>
1206 && this->
mesh().relaxField(this->
name() +
"Final")
1209 relax(this->
mesh().fieldRelaxationFactor(this->
name() +
"Final"));
1211 else if (this->
mesh().relaxField(this->
name()))
1218 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1226 return this->
name() +
"Final";
1230 return this->
name();
1235 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1241 os <<
"min/max(" << this->
name() <<
") = " 1248 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1259 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1267 this->
name() +
".T()",
1273 Foam::T(result.
ref().primitiveFieldRef(), primitiveField());
1274 Foam::T(result.
ref().boundaryFieldRef(), boundaryField());
1280 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1285 typename Foam::GeometricField<Type, PatchField, GeoMesh>::cmptType,
1312 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1325 boundaryFieldRef().replace(d, gcf.boundaryField());
1329 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1337 boundaryFieldRef().replace(d, ds.
value());
1341 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1352 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1363 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1377 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1381 boundaryFieldRef().negate();
1387 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1388 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1396 <<
"attempted assignment to self" 1409 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1410 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1418 <<
"attempted assignment to self" 1431 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1432 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1437 if (
this == &(tgf()))
1440 <<
"attempted assignment to self" 1471 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1472 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1478 boundaryFieldRef() = dt.
value();
1482 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1483 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
1489 boundaryFieldRef() =
Zero;
1493 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1494 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1512 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1513 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1519 boundaryFieldRef() == dt.
value();
1523 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1524 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
1530 boundaryFieldRef() ==
Zero;
1534 #define COMPUTED_ASSIGNMENT(TYPE, op) \ 1536 template<class Type, template<class> class PatchField, class GeoMesh> \ 1537 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1539 const GeometricField<TYPE, PatchField, GeoMesh>& gf \ 1542 checkField(*this, gf, #op); \ 1545 boundaryFieldRef() op gf.boundaryField(); \ 1548 template<class Type, template<class> class PatchField, class GeoMesh> \ 1549 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1551 const tmp<GeometricField<TYPE, PatchField, GeoMesh>>& tgf \ 1554 operator op(tgf()); \ 1558 template<class Type, template<class> class PatchField, class GeoMesh> \ 1559 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \ 1561 const dimensioned<TYPE>& dt \ 1565 boundaryFieldRef() op dt.value(); \ 1573 #undef COMPUTED_ASSIGNMENT 1578 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1592 "Ostream& operator<<(Ostream&, " 1593 "const GeometricField<Type, PatchField, GeoMesh>&)" 1600 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.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
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 field 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 Mesh & mesh() const
Return mesh.
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.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
void storePrevIter() const
Store the field as the previous iteration value.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
A class for managing temporary objects.
void deleteDemandDrivenData(DataPtr &dataPtr)
word patchFieldType(const PatchField &pf)
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.