WIP: AMI cache - further updates - TO SQUASH

This commit is contained in:
Andrew Heather
2025-07-14 16:19:38 +01:00
parent 47efb65ef9
commit cb2a89fe08
6 changed files with 62 additions and 55 deletions

View File

@ -345,13 +345,13 @@ Foam::cyclicAMIFvPatchField<Type>::getNeighbourField
template<class Type>
bool Foam::cyclicAMIFvPatchField<Type>::cacheNeighbourField() const
{
const auto& AMI = this->ownerAMI();
// const auto& AMI = this->ownerAMI();
if (AMI.cacheActive())
{
return false;
}
else
// if (AMI.cacheActive())
// {
// return false;
// }
// else
{
return (FieldBase::localBoundaryConsistency() != 0);
}
@ -383,11 +383,12 @@ Foam::cyclicAMIFvPatchField<Type>::getPatchNeighbourField
}
const auto& fvp = this->patch();
const auto& mesh = fvp.boundaryMesh().mesh();
if
(
patchNeighbourFieldPtr_
&& !fvp.boundaryMesh().mesh().upToDatePoints(this->internalField())
&& !mesh.upToDatePoints(this->internalField())
)
{
//DebugPout
@ -451,7 +452,8 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
{
return this->getPatchNeighbourField(true); // checkCommunicator = true
// checkCommunicator = true
return this->getPatchNeighbourField(true);
}

View File

@ -440,18 +440,19 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix
if (cache.index0() == -1 && cache.index1() == -1)
{
if (cyclicACMIInterface_.owner())
{
work = AMI.interpolateToSource(work);
}
else
{
work = AMI.interpolateToTarget(work);
}
solveScalarField pnf(faceCells.size(), Zero);
AMI.weightedSum
(
cyclicACMIInterface_.owner(),
work,
pnf, // result
solveScalarField::null()
);
const labelUList& faceCells = lduAddr.patchAddr(patchId);
this->addToInternalField(result, !add, faceCells, coeffs, work);
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
}
else
{

View File

@ -325,6 +325,10 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
const auto& cache = AMI.cache();
// Assume that sends are also OK
sendRequests_.clear();
sendRequests1_.clear();
if (AMI.distributed() && AMI.comm() != -1)
{
if (commsType != UPstream::commsTypes::nonBlocking)

View File

@ -393,11 +393,11 @@ void Foam::cyclicAMIPolyPatch::resetAMI(const UList<point>& points) const
label refProci = -1;
if (size() > 0)
{
refProci = UPstream::myProcNo();
refProci = UPstream::myProcNo(comm);
}
reduce(refProci, maxOp<label>(), UPstream::msgType(), comm);
if (refProci == UPstream::myProcNo())
if (refProci == UPstream::myProcNo(comm))
{
refPt = points[meshPoints()[0]];
}

View File

@ -99,7 +99,7 @@ protected:
//- Index of other half
mutable label nbrPatchID_;
//- Particle displacement fraction accross AMI
//- Particle displacement fraction across AMI
const scalar fraction_;

View File

@ -131,7 +131,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
const tensorField ownT(cs().R(this->faceCentres()));
Field<Type> localDeflt(defaultValues.size());
if (defaultValues.size() == size())
if (defaultValues.size() != 0 && defaultValues.size() == size())
{
// Transform default values into cylindrical coords (using
// *this faceCentres)
@ -275,50 +275,48 @@ void Foam::cyclicAMIPolyPatch::initInterpolate
if constexpr (transform_supported)
{
const cyclicAMIPolyPatch& nbrPp = this->neighbPatch();
Field<Type> localFld(fld.size());
// Only creates the co-ord system if using periodic AMI
// - convert to cylindrical coordinate system
auto cs = cylindricalCS();
if (cs)
{
Field<Type> localFld(fld.size());
const cyclicAMIPolyPatch& nbrPp = this->neighbPatch();
const tensorField nbrT(cs().R(nbrPp.faceCentres()));
Foam::invTransform(localFld, nbrT, fld);
initInterpolateUntransformed
(
localFld,
sendRequests,
recvRequests,
sendBuffers,
recvBuffers,
sendRequests1,
recvRequests1,
sendBuffers1,
recvBuffers1
);
return;
}
initInterpolateUntransformed
(
localFld,
sendRequests,
recvRequests,
sendBuffers,
recvBuffers,
sendRequests1,
recvRequests1,
sendBuffers1,
recvBuffers1
);
}
else
{
initInterpolateUntransformed
(
fld,
sendRequests,
recvRequests,
sendBuffers,
recvBuffers,
sendRequests1,
recvRequests1,
sendBuffers1,
recvBuffers1
);
}
initInterpolateUntransformed
(
fld,
sendRequests,
recvRequests,
sendBuffers,
recvBuffers,
sendRequests1,
recvRequests1,
sendBuffers1,
recvBuffers1
);
}
@ -333,9 +331,11 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
const UList<Type>& defaultValues
) const
{
// Note: cannot be localFld.size() -> might have been set to null
auto tresult = tmp<Field<Type>>::New(this->size(), Zero);
const auto& AMI = (owner() ? this->AMI() : neighbPatch().AMI());
const auto& cache = AMI.cache();
cache.setDirection(owner());
@ -426,7 +426,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
}
const auto& localDefaultValues =
transform_supported ? localDeflt : defaultValues;
localDeflt.size() ? localDeflt : defaultValues;
if (cache.index0() == -1 && cache.index1() == -1)
{