36 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
37 template<
class CheckPatchFieldType>
51 const auto& pfld0 = this->operator[](0);
53 <<
" Checking boundary consistency for field " 54 << pfld0.internalField().name()
58 auto& bfld =
const_cast<GeometricBoundaryField<Type, PatchField, GeoMesh>&
> 65 List<Field<Type>> oldBfld(this->size());
70 for (
auto& pfld : bfld)
72 if (isA<CheckPatchFieldType>(pfld))
74 const label patchi = pfld.patch().index();
75 oldUpdated[patchi] = pfld.updated();
76 oldBfld[patchi] = pfld;
84 const label startOfRequests = UPstream::nRequests();
86 for (
auto& pfld : bfld)
88 if (isA<CheckPatchFieldType>(pfld))
90 pfld.initEvaluate(UPstream::commsTypes::nonBlocking);
95 UPstream::waitRequests(startOfRequests);
97 for (
auto& pfld : bfld)
99 if (isA<CheckPatchFieldType>(pfld))
101 pfld.evaluate(UPstream::commsTypes::nonBlocking);
109 for (
auto& pfld : bfld)
111 if (isA<CheckPatchFieldType>(pfld))
113 const label patchi = pfld.patch().index();
114 const auto& oldPfld = oldBfld[patchi];
118 if (
mag(pfld[facei]-oldPfld[facei]) > tol)
130 << pfld.internalField().name()
131 <<
" is not evaluated?" 132 <<
" On patch " << pfld.patch().name()
133 <<
" type " << pfld.type()
134 <<
" : average of field = " 136 <<
". Average of evaluated field = " 138 <<
". Difference:" <<
average(pfld-oldPfld)
139 <<
". Tolerance:" << tol
145 << pfld.internalField().name()
146 <<
" is not evaluated?" 147 <<
" On patch " << pfld.patch().name()
148 <<
" type " << pfld.type()
149 <<
" : average of field = " 151 <<
". Average of evaluated field = " 153 <<
". Difference:" <<
average(pfld-oldPfld)
154 <<
". Tolerance:" << tol
165 for (
auto& pfld : bfld)
167 if (isA<CheckPatchFieldType>(pfld))
169 const label patchi = pfld.patch().index();
170 pfld.setUpdated(oldUpdated[patchi]);
171 Field<Type>& vals = pfld;
172 vals = std::move(oldBfld[patchi]);
179 const auto& pfld0 = this->operator[](0);
181 <<
" Result of checking for field " 182 << pfld0.internalField().name() <<
" : " << ok <<
endl;
189 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
192 const Internal& iField,
201 this->
resize(bmesh_.size());
203 label nUnset = this->size();
210 const auto* subdict = dEntry.dictPtr();
212 if (subdict && dEntry.keyword().isLiteral())
214 const label patchi = bmesh_.findPatchID(dEntry.keyword());
244 for (
auto iter =
dict.crbegin(); iter !=
dict.crend(); ++iter)
246 const entry& dEntry = *iter;
247 const auto* subdict = dEntry.dictPtr();
249 if (subdict && dEntry.keyword().isLiteral())
252 bmesh_.indices(dEntry.keyword(),
true);
256 if (!this->
set(patchi))
277 if (!this->
set(patchi))
279 if (bmesh_[patchi].
type() == emptyPolyPatch::typeName)
286 emptyPolyPatch::typeName,
294 const auto* subdict =
dict.findDict(bmesh_[patchi].
name());
317 if (!this->
set(patchi))
319 if (bmesh_[patchi].
type() == cyclicPolyPatch::typeName)
322 <<
"Cannot find patchField entry for cyclic " 323 << bmesh_[patchi].name() <<
endl 324 <<
"Is your field uptodate with split cyclics?" <<
endl 325 <<
"Run foamUpgradeCyclics to convert mesh and fields" 331 <<
"Cannot find patchField entry for " 341 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
344 const BoundaryMesh& bmesh
352 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
355 const BoundaryMesh& bmesh,
356 const Internal& iField,
357 const word& patchFieldType
381 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
384 const BoundaryMesh& bmesh,
385 const Internal& iField,
390 FieldField<PatchField, Type>(bmesh.size()),
397 patchFieldTypes.size() != this->size()
398 || (constraintTypes.size() && (constraintTypes.size() != this->size()))
402 <<
"Incorrect number of patch type specifications given" <<
nl 403 <<
" Number of patches in mesh = " << bmesh.size()
404 <<
" number of patch type specifications = " 405 << patchFieldTypes.size()
409 if (constraintTypes.size())
418 patchFieldTypes[patchi],
419 constraintTypes[patchi],
435 patchFieldTypes[patchi],
445 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
448 const BoundaryMesh& bmesh,
449 const Internal& iField,
450 const PtrList<PatchField<Type>>& ptfl
453 FieldField<PatchField, Type>(bmesh.size()),
460 this->
set(patchi, ptfl[patchi].clone(iField));
465 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
468 const Internal& iField,
469 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
472 FieldField<PatchField, Type>(btf.size()),
479 this->
set(patchi, btf[patchi].clone(iField));
484 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
487 const Internal& iField,
488 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
490 const word& patchFieldType
493 FieldField<PatchField, Type>(btf.size()),
514 if (!this->
set(patchi))
516 this->
set(patchi, btf[patchi].clone(iField));
522 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
525 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
533 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
536 const BoundaryMesh& bmesh,
537 const Internal& iField,
550 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
555 for (
auto& pfld : *
this)
562 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
565 const UPstream::commsTypes commsType
570 commsType == UPstream::commsTypes::buffered
571 || commsType == UPstream::commsTypes::nonBlocking
574 const label startOfRequests = UPstream::nRequests();
576 for (
auto& pfld : *
this)
578 pfld.initEvaluate(commsType);
582 UPstream::waitRequests(startOfRequests);
584 for (
auto& pfld : *
this)
586 pfld.evaluate(commsType);
589 else if (commsType == UPstream::commsTypes::scheduled)
592 bmesh_.mesh().globalData().patchSchedule();
594 for (
const auto& schedEval : patchSchedule)
596 const label patchi = schedEval.patch;
597 auto& pfld = (*this)[patchi];
601 pfld.initEvaluate(commsType);
605 pfld.evaluate(commsType);
612 <<
"Unsupported communications type " << int(commsType) <<
nl 618 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
619 template<
class UnaryPredicate>
622 const UnaryPredicate& pred,
623 const UPstream::commsTypes commsType
628 commsType == UPstream::commsTypes::buffered
629 || commsType == UPstream::commsTypes::nonBlocking
632 const label startOfRequests = UPstream::nRequests();
634 for (
auto& pfld : *
this)
638 pfld.initEvaluate(commsType);
643 UPstream::waitRequests(startOfRequests);
645 for (
auto& pfld : *
this)
649 pfld.evaluate(commsType);
653 else if (commsType == UPstream::commsTypes::scheduled)
656 bmesh_.mesh().globalData().patchSchedule();
658 for (
const auto& schedEval : patchSchedule)
660 const label patchi = schedEval.patch;
661 auto& pfld = (*this)[patchi];
667 pfld.initEvaluate(commsType);
671 pfld.evaluate(commsType);
679 <<
"Unsupported communications type " << int(commsType) <<
nl 685 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
691 const label startOfRequests = UPstream::nRequests();
695 auto& pfld = (*this)[patchi];
699 pfld.initEvaluate(UPstream::commsTypes::nonBlocking);
703 UPstream::waitRequests(startOfRequests);
707 auto& pfld = (*this)[patchi];
709 pfld.evaluate(UPstream::commsTypes::nonBlocking);
714 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
717 const UPstream::commsTypes commsType
722 if (!localConsistency)
729 commsType == UPstream::commsTypes::buffered
730 || commsType == UPstream::commsTypes::nonBlocking
733 const label startOfRequests = UPstream::nRequests();
735 for (
auto& pfld : *
this)
737 pfld.initEvaluateLocal(commsType);
741 UPstream::waitRequests(startOfRequests);
743 for (
auto& pfld : *
this)
745 pfld.evaluateLocal(commsType);
748 else if (commsType == UPstream::commsTypes::scheduled)
751 bmesh_.mesh().globalData().patchSchedule();
753 for (
const auto& schedEval : patchSchedule)
755 const label patchi = schedEval.patch;
756 auto& pfld = (*this)[patchi];
760 pfld.initEvaluateLocal(commsType);
764 pfld.evaluateLocal(commsType);
771 <<
"Unsupported communications type " << int(commsType) <<
nl 777 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
778 template<
class CoupledPatchType>
781 const UPstream::commsTypes commsType
800 commsType == UPstream::commsTypes::buffered
801 || commsType == UPstream::commsTypes::nonBlocking
804 const label startOfRequests = UPstream::nRequests();
806 for (
auto& pfld : *
this)
808 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
810 if (cpp && cpp->coupled())
812 pfld.initEvaluate(commsType);
817 UPstream::waitRequests(startOfRequests);
819 for (
auto& pfld : *
this)
821 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
823 if (cpp && cpp->coupled())
825 pfld.evaluate(commsType);
829 else if (commsType == UPstream::commsTypes::scheduled)
832 bmesh_.mesh().globalData().patchSchedule();
834 for (
const auto& schedEval : patchSchedule)
836 const label patchi = schedEval.patch;
837 auto& pfld = (*this)[patchi];
839 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
841 if (cpp && cpp->coupled())
845 pfld.initEvaluate(commsType);
849 pfld.evaluate(commsType);
857 <<
"Unsupported communications type " << int(commsType) <<
nl 863 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
867 const FieldField<PatchField, Type>& pff = *
this;
873 list[patchi] = pff[patchi].type();
880 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
891 auto& result = tresult;
895 result[patchi] == this->operator[](patchi).patchInternalField();
902 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
921 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
933 isA<lduInterfaceField>(this->
operator[](patchi))
941 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
948 os.beginBlock(keyword);
949 this->writeEntries(
os);
956 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
962 for (
const auto& pfld : *
this)
964 os.beginBlock(pfld.patch().name());
971 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
984 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
987 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
994 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1004 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1014 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1017 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
1022 this->operator[](patchi) == bf[patchi];
1027 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1030 const FieldField<PatchField, Type>& bf
1035 this->operator[](patchi) == bf[patchi];
1040 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1048 this->operator[](patchi) == val;
1055 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1059 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
1062 os << static_cast<const FieldField<PatchField, Type>&>(bf);
const labelList patchIDs(pbm.indices(polyPatchNames, true))
GeometricBoundaryField(const BoundaryMesh &bmesh)
Construct from a BoundaryMesh, setting patches later.
tmp< GeometricBoundaryField > boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
patchWriters resize(patchIds.size())
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void evaluate(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for each patch field. Uses specified or default comms.
constexpr char nl
The newline '\n' character (0x0a)
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
wordList types() const
Return a list of the patch types.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
void evaluateCoupled(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions on coupled patches of given type. Uses specified or default comms...
void evaluateLocal(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions after change in local values. Uses specified or default comms...
UList< label > labelUList
A UList of labels.
A field of fields is a PtrList of fields with reference counting.
#define forAll(list, i)
Loop across all elements in list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
void evaluate_if(const UnaryPredicate &pred, const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for patch fields matching the given predicate. Uses specified or default...
void evaluateSelected(const labelUList &patchIDs)
Evaluate boundary conditions for selected patches. Uses non-blocking comms.
void readField(const Internal &iField, const dictionary &dict)
Read the boundary field.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
errorManip< error > abort(error &err)
bool check() const
Helper: check if field has been evaluated. See instantiations.
void updateCoeffs()
Update the boundary condition coefficients.
#define DebugInfo
Report an information message using Foam::Info.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
Generic GeometricBoundaryField class.
List< word > wordList
List of word.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
#define PoutInFunction
Report using Foam::Pout with FUNCTION_NAME prefix.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
LduInterfaceFieldPtrsList< Type > interfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set...
void writeEntries(Ostream &os) const
Write dictionary entries of the individual boundary fields.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
List< label > labelList
A List of labels.
A class for managing temporary objects.
List< bool > boolList
A List of bools.
A keyword and a list of tokens is an 'entry'.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...