ENH: add GeometricBoundaryField evaluateCoupled method (#2436)

- allows restricted evaluation to specific coupled patch types.
  Code relocated/refactored from redistributePar.

STYLE: ensure use of waitRequests() also corresponds to nonBlocking

ENH: additional copy/move construct GeometricField from DimensionedField

STYLE: processorPointPatch owner()/neighbour() as per processorPolyPatch

STYLE: orientedType with bool cast operator and noexcept
This commit is contained in:
Mark Olesen
2022-04-21 21:50:48 +02:00
parent 7bdd355ef7
commit b68193088c
36 changed files with 515 additions and 292 deletions

View File

@ -948,84 +948,10 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllIters(flds, iter)
for (const word& fldName : flds.sortedToc())
{
GeoField& fld = *iter();
typename GeoField::Boundary& bfld = fld.boundaryFieldRef();
if
(
Pstream::defaultCommsType == Pstream::commsTypes::blocking
|| Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
)
{
const label nReq = Pstream::nRequests();
forAll(bfld, patchi)
{
auto& pfld = bfld[patchi];
const auto& fvp = mesh.boundary()[patchi];
const auto* ppPtr = isA<CoupledPatchType>(fvp);
if (ppPtr && ppPtr->coupled())
{
pfld.initEvaluate(Pstream::defaultCommsType);
}
}
// Block for any outstanding requests
if
(
Pstream::parRun()
&& Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
)
{
Pstream::waitRequests(nReq);
}
for (auto& pfld : bfld)
{
const auto& fvp = pfld.patch();
const auto* ppPtr = isA<CoupledPatchType>(fvp);
if (ppPtr && ppPtr->coupled())
{
pfld.evaluate(Pstream::defaultCommsType);
}
}
}
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
{
const lduSchedule& patchSchedule =
fld.mesh().globalData().patchSchedule();
for (const auto& schedEval : patchSchedule)
{
const label patchi = schedEval.patch;
const auto& fvp = mesh.boundary()[patchi];
auto& pfld = bfld[patchi];
const auto* ppPtr = isA<CoupledPatchType>(fvp);
if (ppPtr && ppPtr->coupled())
{
if (schedEval.init)
{
pfld.initEvaluate(Pstream::commsTypes::scheduled);
}
else
{
pfld.evaluate(Pstream::commsTypes::scheduled);
}
}
}
}
else
{
FatalErrorInFunction
<< "Unsupported communications type "
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
<< exit(FatalError);
}
GeoField& fld = *(flds[fldName]);
fld.boundaryFieldRef().template evaluateCoupled<CoupledPatchType>();
}
}

View File

@ -41,16 +41,17 @@ namespace Foam
template<class Type>
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
{
typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& fldBf = fld.boundaryFieldRef();
auto& fldBf = fld.boundaryFieldRef();
const UPstream::commsTypes commsType(UPstream::defaultCommsType);
if
(
Pstream::defaultCommsType == Pstream::commsTypes::blocking
|| Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
commsType == UPstream::commsTypes::blocking
|| commsType == UPstream::commsTypes::nonBlocking
)
{
const label nReq = Pstream::nRequests();
const label startOfRequests = UPstream::nRequests();
forAll(fldBf, patchi)
{
@ -62,18 +63,18 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.initEvaluate(Pstream::defaultCommsType);
tgtField.initEvaluate(commsType);
}
}
// Block for any outstanding requests
// Wait for outstanding requests
if
(
Pstream::parRun()
&& Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
UPstream::parRun()
&& commsType == UPstream::commsTypes::nonBlocking
)
{
Pstream::waitRequests(nReq);
UPstream::waitRequests(startOfRequests);
}
forAll(fldBf, patchi)
@ -86,11 +87,11 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.evaluate(Pstream::defaultCommsType);
tgtField.evaluate(commsType);
}
}
}
else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
else if (commsType == UPstream::commsTypes::scheduled)
{
const lduSchedule& patchSchedule =
fld.mesh().globalData().patchSchedule();
@ -109,11 +110,11 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
{
if (schedEval.init)
{
tgtField.initEvaluate(Pstream::commsTypes::scheduled);
tgtField.initEvaluate(commsType);
}
else
{
tgtField.evaluate(Pstream::commsTypes::scheduled);
tgtField.evaluate(commsType);
}
}
}