ENH: AMI - propagate lowWeightOption

This commit is contained in:
Andrew Heather 2024-05-03 17:08:01 +01:00
parent 279abca7fa
commit a083ebb7bf
4 changed files with 67 additions and 77 deletions

View File

@ -311,7 +311,8 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField
defaultValues = Field<Type>(iField, cyclicAMIPatch_.faceCells());
}
tmp<Field<Type>> tpnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
tmp<Field<Type>> tpnf =
cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
if (doTransform())
{
@ -539,7 +540,8 @@ void Foam::cyclicAMIFvPatchField<Type>::evaluate
Field<Type>::null(), // Not used for distributed
recvRequests_,
recvBufs_,
defaultValues
defaultValues,
lowWeightOption_
).ptr()
);
@ -665,7 +667,8 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
solveScalarField::null(), // Not used for distributed
recvRequests_,
scalarRecvBufs_,
defaultValues
defaultValues,
lowWeightOption_
);
// Receive requests all handled by last function call
@ -687,7 +690,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
}
// Multiply the field by coefficients and add into the result
@ -799,7 +802,8 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
Field<Type>::null(), // Not used for distributed
recvRequests_,
recvBufs_,
defaultValues
defaultValues,
lowWeightOption_
);
// Receive requests all handled by last function call
@ -821,7 +825,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
defaultValues = Field<Type>(psiInternal, faceCells);
}
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
}
// Multiply the field by coefficients and add into the result

View File

@ -217,20 +217,34 @@ public:
tmp<Field<Type>> interpolate
(
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>()
const UList<Type>& defaultValues = UList<Type>::null(),
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const
{
return cyclicAMIPolyPatch_.interpolate(fld, defaultValues);
return cyclicAMIPolyPatch_.interpolate
(
fld,
defaultValues,
lwOption
);
}
template<class Type>
tmp<Field<Type>> interpolate
(
const tmp<Field<Type>>& tFld,
const UList<Type>& defaultValues = UList<Type>()
const UList<Type>& defaultValues = UList<Type>::null(),
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const
{
return cyclicAMIPolyPatch_.interpolate(tFld, defaultValues);
return cyclicAMIPolyPatch_.interpolate
(
tFld,
defaultValues,
lwOption
);
}

View File

@ -483,7 +483,9 @@ public:
tmp<Field<Type>> interpolate
(
const Field<Type>& fld,
const UList<Type>& defaultValues = UList<Type>()
const UList<Type>& defaultValues = UList<Type>(),
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const;
//- Interpolate tmp field
@ -491,7 +493,9 @@ public:
tmp<Field<Type>> interpolate
(
const tmp<Field<Type>>& tFld,
const UList<Type>& defaultValues = UList<Type>()
const UList<Type>& defaultValues = UList<Type>(),
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const;
//- Interpolate without periodic
@ -499,7 +503,9 @@ public:
tmp<Field<Type>> interpolateUntransformed
(
const Field<Type>& fld,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const;
//- Low-level interpolate List
@ -541,7 +547,9 @@ public:
const Field<Type>& localFld,
const labelRange& requests, // The receive requests
const PtrList<List<Type>>& recvBuffers,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption =
lowWeightCorrectionBase::option::ASSIGN
) const;

View File

@ -26,22 +26,30 @@ License
\*---------------------------------------------------------------------------*/
#include "AMIFieldOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolateUntransformed
(
const Field<Type>& fld,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption
) const
{
if (owner())
{
return AMI().interpolateToSource(fld, defaultValues);
return AMI().interpolateToSource(fld, defaultValues, lwOption);
}
else
{
return neighbPatch().AMI().interpolateToTarget(fld, defaultValues);
return neighbPatch().AMI().interpolateToTarget
(
fld,
defaultValues,
lwOption
);
}
}
@ -50,7 +58,8 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
(
const Field<Type>& fld,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption
) const
{
autoPtr<coordSystem::cylindrical> cs;
@ -65,7 +74,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
if (!cs)
{
return interpolateUntransformed(fld, defaultValues);
return interpolateUntransformed(fld, defaultValues, lwOption);
}
else
{
@ -141,7 +150,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
return Foam::transform
(
ownT,
interpolateUntransformed(localFld, localDeflt)
interpolateUntransformed(localFld, localDeflt, lwOption)
);
}
}
@ -151,10 +160,11 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
(
const tmp<Field<Type>>& tFld,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption
) const
{
return interpolate(tFld(), defaultValues);
return interpolate(tFld(), defaultValues, lwOption);
}
@ -245,7 +255,8 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
const Field<Type>& localFld,
const labelRange& requests,
const PtrList<List<Type>>& recvBuffers,
const UList<Type>& defaultValues
const UList<Type>& defaultValues,
const lowWeightCorrectionBase::option& lwOption
) const
{
const auto& AMI = (owner() ? this->AMI() : neighbPatch().AMI());
@ -272,13 +283,9 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
if (!cs)
{
AMI.weightedSum
(
owner(),
fld,
tresult.ref(),
defaultValues
);
AMICorrectedMultiplyWeightedOp<Type> cop(AMI, owner(), lwOption);
cop(tresult.ref(), fld, defaultValues);
}
else
{
@ -296,13 +303,8 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
Foam::invTransform(localDeflt, ownT, defaultFld);
}
AMI.weightedSum
(
owner(),
fld,
tresult.ref(),
localDeflt
);
AMICorrectedMultiplyWeightedOp<Type> cop(AMI, owner(), lwOption);
cop(tresult.ref(), fld, defaultValues);
// Transform back
Foam::transform(tresult.ref(), ownT, tresult());
@ -356,26 +358,7 @@ void Foam::cyclicAMIPolyPatch::interpolate
}
// Do actual AMI interpolation
if (owner())
{
AMI().interpolateToSource
(
fld,
cop,
result,
localDeflt
);
}
else
{
neighbPatch().AMI().interpolateToTarget
(
fld,
cop,
result,
localDeflt
);
}
AMI().interpolate(fld, cop, result, defaultValues);
// Transform back. Result is now at *this
Foam::transform(result, ownT, result);
@ -383,26 +366,7 @@ void Foam::cyclicAMIPolyPatch::interpolate
else
*/
{
if (owner())
{
AMI().interpolateToSource
(
fld,
cop,
result,
defaultValues
);
}
else
{
neighbPatch().AMI().interpolateToTarget
(
fld,
cop,
result,
defaultValues
);
}
AMI().interpolate(fld, cop, result, defaultValues);
}
}