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>
204 this->
resize(bmesh_.size());
206 label nUnset = this->size();
213 if (dEntry.isDict() && dEntry.keyword().isLiteral())
215 const label patchi = bmesh_.findPatchID(dEntry.keyword());
245 for (
auto iter =
dict.crbegin(); iter !=
dict.crend(); ++iter)
247 const entry& dEntry = *iter;
249 if (dEntry.isDict() && 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,
305 dict.subDict(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,
357 const word& patchFieldType
384 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
387 const BoundaryMesh& bmesh,
388 const DimensionedField<Type, GeoMesh>&
field,
393 FieldField<PatchField, Type>(bmesh.size()),
403 patchFieldTypes.size() != this->size()
404 || (constraintTypes.size() && (constraintTypes.size() != this->size()))
408 <<
"Incorrect number of patch type specifications given" <<
nl 409 <<
" Number of patches in mesh = " << bmesh.size()
410 <<
" number of patch type specifications = " 411 << patchFieldTypes.size()
415 if (constraintTypes.size())
424 patchFieldTypes[patchi],
425 constraintTypes[patchi],
441 patchFieldTypes[patchi],
451 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
454 const BoundaryMesh& bmesh,
455 const DimensionedField<Type, GeoMesh>&
field,
456 const PtrList<PatchField<Type>>& ptfl
459 FieldField<PatchField, Type>(bmesh.size()),
469 this->
set(patchi, ptfl[patchi].clone(
field));
474 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
477 const DimensionedField<Type, GeoMesh>&
field,
478 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
481 FieldField<PatchField, Type>(btf.size()),
491 this->
set(patchi, btf[patchi].clone(
field));
496 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
499 const DimensionedField<Type, GeoMesh>&
field,
500 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
502 const word& patchFieldType
505 FieldField<PatchField, Type>(btf.size()),
529 if (!this->
set(patchi))
531 this->
set(patchi, btf[patchi].clone(
field));
537 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
540 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
543 FieldField<PatchField, Type>(btf),
553 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
556 const BoundaryMesh& bmesh,
557 const DimensionedField<Type, GeoMesh>&
field,
558 const dictionary&
dict 561 FieldField<PatchField, Type>(bmesh.size()),
570 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
578 for (
auto& pfld : *
this)
585 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
593 const UPstream::commsTypes commsType = UPstream::defaultCommsType;
594 const label startOfRequests = UPstream::nRequests();
598 commsType == UPstream::commsTypes::blocking
599 || commsType == UPstream::commsTypes::nonBlocking
602 for (
auto& pfld : *
this)
604 pfld.initEvaluate(commsType);
608 if (commsType == Pstream::commsTypes::nonBlocking)
610 UPstream::waitRequests(startOfRequests);
613 for (
auto& pfld : *
this)
615 pfld.evaluate(commsType);
618 else if (commsType == UPstream::commsTypes::scheduled)
621 bmesh_.mesh().globalData().patchSchedule();
623 for (
const auto& schedEval : patchSchedule)
625 const label patchi = schedEval.patch;
626 auto& pfld = (*this)[patchi];
630 pfld.initEvaluate(commsType);
634 pfld.evaluate(commsType);
641 <<
"Unsupported communications type " 642 << UPstream::commsTypeNames[commsType]
648 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
656 auto& pf = (*this)[patchi];
660 const label startOfRequests = UPstream::nRequests();
662 pf.initEvaluate(UPstream::commsTypes::nonBlocking);
664 UPstream::waitRequests(startOfRequests);
666 pf.evaluate(UPstream::commsTypes::nonBlocking);
671 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
679 if (!localConsistency)
684 const UPstream::commsTypes commsType = UPstream::defaultCommsType;
685 const label startOfRequests = UPstream::nRequests();
689 commsType == UPstream::commsTypes::blocking
690 || commsType == UPstream::commsTypes::nonBlocking
693 for (
auto& pfld : *
this)
695 pfld.initEvaluateLocal(commsType);
699 if (commsType == Pstream::commsTypes::nonBlocking)
701 UPstream::waitRequests(startOfRequests);
704 for (
auto& pfld : *
this)
706 pfld.evaluateLocal(commsType);
709 else if (commsType == UPstream::commsTypes::scheduled)
712 bmesh_.mesh().globalData().patchSchedule();
714 for (
const auto& schedEval : patchSchedule)
716 const label patchi = schedEval.patch;
717 auto& pfld = (*this)[patchi];
721 pfld.initEvaluateLocal(commsType);
725 pfld.evaluateLocal(commsType);
732 <<
"Unsupported communications type " 733 << UPstream::commsTypeNames[commsType]
739 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
740 template<
class CoupledPatchType>
751 const label startOfRequests = UPstream::nRequests();
755 commsType == UPstream::commsTypes::blocking
756 || commsType == UPstream::commsTypes::nonBlocking
759 for (
auto& pfld : *
this)
761 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
763 if (cpp && cpp->coupled())
765 pfld.initEvaluate(commsType);
770 if (commsType == UPstream::commsTypes::nonBlocking)
772 UPstream::waitRequests(startOfRequests);
775 for (
auto& pfld : *
this)
777 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
779 if (cpp && cpp->coupled())
781 pfld.evaluate(commsType);
785 else if (commsType == UPstream::commsTypes::scheduled)
788 bmesh_.mesh().globalData().patchSchedule();
790 for (
const auto& schedEval : patchSchedule)
792 const label patchi = schedEval.patch;
793 auto& pfld = (*this)[patchi];
795 const auto* cpp = isA<CoupledPatchType>(pfld.patch());
797 if (cpp && cpp->coupled())
801 pfld.initEvaluate(commsType);
805 pfld.evaluate(commsType);
813 <<
"Unsupported communications type " 814 << UPstream::commsTypeNames[commsType]
820 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
824 const FieldField<PatchField, Type>& pff = *
this;
830 list[patchi] = pff[patchi].type();
837 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
846 result[patchi] == this->operator[](patchi).patchInternalField();
853 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
862 isA<LduInterfaceField<Type>>(this->operator[](patchi));
866 list.
set(patchi, lduPtr);
874 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
884 isA<lduInterfaceField>(this->operator[](patchi));
888 list.
set(patchi, lduPtr);
896 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
903 os.beginBlock(keyword);
904 this->writeEntries(
os);
911 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
917 for (
const auto& pfld : *
this)
919 os.beginBlock(pfld.patch().name());
926 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
939 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
942 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
949 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
959 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
969 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
972 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
977 this->operator[](patchi) == bf[patchi];
982 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
985 const FieldField<PatchField, Type>& bf
990 this->operator[](patchi) == bf[patchi];
995 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1003 this->operator[](patchi) == val;
1010 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1014 const GeometricBoundaryField<Type, PatchField, GeoMesh>& bf
1017 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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
patchWriters resize(patchIds.size())
commsTypes
Communications types.
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.
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.
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
A field of fields is a PtrList of fields with reference counting.
#define forAll(list, i)
Loop across all elements in list.
void evaluate()
Evaluate boundary conditions.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void evaluateLocal()
Evaluate boundary conditions after change in local values.
A class for handling words, derived from Foam::string.
void evaluateSelected(const UList< label > &patchIDs)
Evaluate boundary conditions for selected patches.
void evaluateCoupled()
Evaluate boundary conditions on a subset of coupled patches.
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.
void readField(const DimensionedField< Type, GeoMesh > &field, const dictionary &dict)
Read the boundary field.
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...
GeometricBoundaryField boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
void writeEntries(Ostream &os) const
Write dictionary entries of the individual boundary fields.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
List< label > labelList
A List of labels.
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 ...