36template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
37template<
class CheckPatchFieldType>
38bool Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::checkConsistency
44 auto& bfld = this->constCast();
54 <<
" Checking boundary consistency for field "
55 << bfld[0].internalField().name() <<
endl;
59 List<Field<Type>> oldFields(bfld.size());
61 boolList oldManipulated(bfld.size());
65 for (
auto& pfld : bfld)
67 if (isA<CheckPatchFieldType>(pfld))
69 const label patchi = pfld.patch().index();
70 oldFields[patchi] = pfld;
71 oldUpdated[patchi] = pfld.updated();
72 oldManipulated[patchi] = pfld.manipulatedMatrix();
77 if (!nEvaluated)
return true;
81 const label startOfRequests = UPstream::nRequests();
85 for (
auto& pfld : bfld)
87 if (isA<CheckPatchFieldType>(pfld))
89 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);
102 if (--nEvaluated == 0)
break;
111 for (
auto& pfld : bfld)
113 if (isA<CheckPatchFieldType>(pfld))
115 const label patchi = pfld.patch().index();
116 auto& oldPfld = oldFields[patchi];
125 if (tol <
Foam::mag(pfld[facei]-oldPfld[facei]))
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 << endl;
158 FatalError<< exit(FatalError);
163 static_cast<Field<Type>&
>(pfld) = std::move(oldPfld);
164 pfld.setUpdated(oldUpdated[patchi]);
165 pfld.setManipulated(oldManipulated[patchi]);
172 <<
" Result of checking for field "
173 << bfld[0].internalField().name() <<
" : " << allOk <<
endl;
180template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
183 const Internal& iField,
192 this->
resize(bmesh_.size());
194 label nUnset = this->size();
199 for (
const entry& dEntry :
dict)
201 const auto* subdict = dEntry.
dictPtr();
205 const label patchi = bmesh_.findPatchID(dEntry.
keyword());
212 PatchField<Type>::New
235 for (
auto iter =
dict.crbegin(); iter !=
dict.crend(); ++iter)
237 const entry& dEntry = *iter;
238 const auto* subdict = dEntry.
dictPtr();
243 bmesh_.indices(dEntry.
keyword(),
true);
247 if (!this->
set(patchi))
252 PatchField<Type>::New
268 if (!this->
set(patchi))
270 if (bmesh_[patchi].
type() == emptyPolyPatch::typeName)
275 PatchField<Type>::New
277 emptyPolyPatch::typeName,
285 const auto* subdict =
dict.findDict(bmesh_[patchi].
name());
292 PatchField<Type>::New
308 if (!this->
set(patchi))
310 if (bmesh_[patchi].
type() == cyclicPolyPatch::typeName)
313 <<
"Cannot find patchField entry for cyclic "
314 << bmesh_[patchi].name() <<
endl
315 <<
"Is your field uptodate with split cyclics?" <<
endl
316 <<
"Run foamUpgradeCyclics to convert mesh and fields"
322 <<
"Cannot find patchField entry for "
332template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
335 const BoundaryMesh& bmesh
343template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
346 const BoundaryMesh& bmesh,
347 const Internal& iField,
348 const word& patchFieldType
361 PatchField<Type>::New
372template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
375 const BoundaryMesh& bmesh,
376 const Internal& iField,
381 FieldField<PatchField, Type>(bmesh.size()),
388 patchFieldTypes.size() != this->size()
389 || (constraintTypes.size() && (constraintTypes.size() != this->size()))
393 <<
"Incorrect number of patch type specifications given" << nl
394 <<
" Number of patches in mesh = " << bmesh.size()
395 <<
" number of patch type specifications = "
396 << patchFieldTypes.size()
397 << abort(FatalError);
400 if (constraintTypes.size())
402 forAll(bmesh_, patchi)
407 PatchField<Type>::New
409 patchFieldTypes[patchi],
410 constraintTypes[patchi],
424 PatchField<Type>::New
426 patchFieldTypes[patchi],
436template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
439 const BoundaryMesh& bmesh,
440 const Internal& iField,
441 const PtrList<PatchField<Type>>& ptfl
451 this->
set(patchi, ptfl[patchi].
clone(iField));
456template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
459 const Internal& iField,
460 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
463 FieldField<PatchField, Type>(btf.size()),
470 this->
set(patchi, btf[patchi].
clone(iField));
475template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
478 const Internal& iField,
479 const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
481 const word& patchFieldType
484 FieldField<PatchField, Type>(btf.size()),
494 PatchField<Type>::New
505 if (!this->
set(patchi))
507 this->
set(patchi, btf[patchi].
clone(iField));
513template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
524template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
527 const BoundaryMesh& bmesh,
528 const Internal& iField,
541template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
546 for (
auto& pfld : *
this)
553template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
567 for (
auto& pfld : *
this)
569 pfld.initEvaluate(commsType);
575 for (
auto& pfld : *
this)
577 pfld.evaluate(commsType);
583 bmesh_.mesh().globalData().patchSchedule();
585 for (
const auto& schedEval : patchSchedule)
587 const label patchi = schedEval.patch;
588 auto& pfld = (*this)[patchi];
592 pfld.initEvaluate(commsType);
596 pfld.evaluate(commsType);
603 <<
"Unsupported communications type " << int(commsType) <<
nl
609template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
610template<
class UnaryPredicate>
613 const UnaryPredicate& pred,
626 for (
auto& pfld : *
this)
630 pfld.initEvaluate(commsType);
638 if (!nEvaluated)
return;
640 for (
auto& pfld : *
this)
644 pfld.evaluate(commsType);
645 if (--nEvaluated == 0)
break;
652 bmesh_.mesh().globalData().patchSchedule();
654 for (
const auto& schedEval : patchSchedule)
656 const label patchi = schedEval.patch;
657 auto& pfld = (*this)[patchi];
663 pfld.initEvaluate(commsType);
667 pfld.evaluate(commsType);
675 <<
"Unsupported communications type " << int(commsType) <<
nl
681template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
691 auto& pfld = (*this)[patchi];
703 auto& pfld = (*this)[patchi];
710template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
731 for (
auto& pfld : *
this)
733 pfld.initEvaluateLocal(commsType);
739 for (
auto& pfld : *
this)
741 pfld.evaluateLocal(commsType);
747 bmesh_.mesh().globalData().patchSchedule();
749 for (
const auto& schedEval : patchSchedule)
751 const label patchi = schedEval.patch;
752 auto& pfld = (*this)[patchi];
756 pfld.initEvaluateLocal(commsType);
760 pfld.evaluateLocal(commsType);
767 <<
"Unsupported communications type " << int(commsType) <<
nl
773template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
774template<
class CoupledPatchType>
780 if constexpr (std::is_void_v<CoupledPatchType>)
784 [](
const auto& pfld) {
return pfld.coupled(); },
792 [](
const auto& pfld) ->
bool
795 return (cpp && cpp->coupled());
803template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
807 const FieldField<PatchField, Type>& pff = *
this;
813 list[patchi] = pff[patchi].type();
820template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
831 auto& result = tresult.ref();
835 result[patchi] == this->operator[](patchi).patchInternalField();
842template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
861template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
881template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
888 os.beginBlock(keyword);
889 this->writeEntries(
os);
896template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
902 for (
const auto& pfld : *
this)
904 os.beginBlock(pfld.patch().name());
911template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
924template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
934template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
944template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
954template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
964template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
977template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
980 const FieldField<PatchField, Type>& bf
990template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
996 for (
auto& pfld : *
this)
1005template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1006Foam::Ostream& Foam::operator<<
static const this_type & null() noexcept
Return a null DimensionedField (reference to a nullObject).
static int localBoundaryConsistency() noexcept
Get flag for local boundary consistency checks.
A field of fields is a PtrList of fields with reference counting.
constexpr FieldField() noexcept
tmp< FieldField< PatchField, Type > > clone() const
const Type & operator[](const labelPair &index) const
void operator=(const FieldField< Field, Type > &)
Copy assignment.
friend Ostream & operator(Ostream &, const FieldField< PatchField, Type > &)
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Generic GeometricBoundaryField class.
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...
lduInterfaceFieldPtrsList scalarInterfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set.
DimensionedField< Type, GeoMesh > Internal
The internal field type associated with the boundary fields.
void evaluateSelected(const labelUList &patchIDs)
Evaluate boundary conditions for selected patches. Uses non-blocking comms.
wordList types() const
Return a list of the patch types.
LduInterfaceFieldPtrsList< Type > interfaces() const
Return a list of pointers for each patch field with only those pointing to interfaces being set.
void evaluateCoupled(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions on coupled patches of the given type, using specified or default comms.
void writeEntries(Ostream &os) const
Write dictionary entries of the individual boundary fields.
bool check() const
Helper: check if field has been evaluated. See instantiations.
void writeEntry(const word &keyword, Ostream &os) const
Write boundary field as dictionary entry.
void updateCoeffs()
Update the boundary condition coefficients.
GeoMesh::BoundaryMesh BoundaryMesh
The boundary mesh type for the boundary fields.
GeometricBoundaryField(const BoundaryMesh &bmesh)
Construct from a BoundaryMesh, setting patches later.
void readField(const Internal &iField, const dictionary &dict)
Read the boundary field.
void evaluateLocal(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions after change in local values. Uses specified or default comms.
tmp< GeometricBoundaryField > boundaryInternalField() const
Return boundary field of values neighbouring the boundary.
void evaluate(const UPstream::commsTypes commsType=UPstream::defaultCommsType)
Evaluate boundary conditions for each patch field. Uses specified or default comms.
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const PatchField< Type > * set(const label i) const
void size(const label n)
Older name for setAddressableSize.
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests).
commsTypes
Communications types.
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
static void waitRequests()
Wait for all requests to finish.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
label size() const noexcept
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
const keyType & keyword() const noexcept
Return keyword.
virtual const dictionary * dictPtr() const noexcept
Return pointer to dictionary, if entry is a dictionary, otherwise return nullptr.
bool isLiteral() const noexcept
The keyType is treated as literal, not as pattern.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
patchWriters resize(patchIds.size())
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define PoutInFunction
Report using Foam::Pout with FUNCTION_NAME prefix.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
List< word > wordList
List of word.
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< label > labelList
A List of labels.
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
UPtrList< const LduInterfaceField< Type > > LduInterfaceFieldPtrsList
Store lists of LduInterfaceField as a UPtrList.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.