From a083ebb7bf6339f1e086c6b448096360b8092d72 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Fri, 3 May 2024 17:08:01 +0100 Subject: [PATCH] ENH: AMI - propagate lowWeightOption --- .../cyclicAMI/cyclicAMIFvPatchField.C | 16 ++-- .../constraint/cyclicAMI/cyclicAMIFvPatch.H | 22 ++++- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H | 16 +++- .../cyclicAMIPolyPatchTemplates.C | 90 ++++++------------- 4 files changed, 67 insertions(+), 77 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index dcf9adc479..e2fd3d7d79 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -311,7 +311,8 @@ Foam::cyclicAMIFvPatchField::patchNeighbourField defaultValues = Field(iField, cyclicAMIPatch_.faceCells()); } - tmp> tpnf = cyclicAMIPatch_.interpolate(pnf, defaultValues); + tmp> tpnf = + cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_); if (doTransform()) { @@ -539,7 +540,8 @@ void Foam::cyclicAMIFvPatchField::evaluate Field::null(), // Not used for distributed recvRequests_, recvBufs_, - defaultValues + defaultValues, + lowWeightOption_ ).ptr() ); @@ -665,7 +667,8 @@ void Foam::cyclicAMIFvPatchField::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::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::updateInterfaceMatrix Field::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::updateInterfaceMatrix defaultValues = Field(psiInternal, faceCells); } - pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues); + pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_); } // Multiply the field by coefficients and add into the result diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H index 30ec8fc718..de544a867b 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H @@ -217,20 +217,34 @@ public: tmp> interpolate ( const Field& fld, - const UList& defaultValues = UList() + const UList& defaultValues = UList::null(), + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const { - return cyclicAMIPolyPatch_.interpolate(fld, defaultValues); + return cyclicAMIPolyPatch_.interpolate + ( + fld, + defaultValues, + lwOption + ); } template tmp> interpolate ( const tmp>& tFld, - const UList& defaultValues = UList() + const UList& defaultValues = UList::null(), + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const { - return cyclicAMIPolyPatch_.interpolate(tFld, defaultValues); + return cyclicAMIPolyPatch_.interpolate + ( + tFld, + defaultValues, + lwOption + ); } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index 094ee1bff5..27776f1d06 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -483,7 +483,9 @@ public: tmp> interpolate ( const Field& fld, - const UList& defaultValues = UList() + const UList& defaultValues = UList(), + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const; //- Interpolate tmp field @@ -491,7 +493,9 @@ public: tmp> interpolate ( const tmp>& tFld, - const UList& defaultValues = UList() + const UList& defaultValues = UList(), + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const; //- Interpolate without periodic @@ -499,7 +503,9 @@ public: tmp> interpolateUntransformed ( const Field& fld, - const UList& defaultValues + const UList& defaultValues, + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const; //- Low-level interpolate List @@ -541,7 +547,9 @@ public: const Field& localFld, const labelRange& requests, // The receive requests const PtrList>& recvBuffers, - const UList& defaultValues + const UList& defaultValues, + const lowWeightCorrectionBase::option& lwOption = + lowWeightCorrectionBase::option::ASSIGN ) const; diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C index 636c77f01a..1bca4e33b1 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatchTemplates.C @@ -26,22 +26,30 @@ License \*---------------------------------------------------------------------------*/ +#include "AMIFieldOps.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template Foam::tmp> Foam::cyclicAMIPolyPatch::interpolateUntransformed ( const Field& fld, - const UList& defaultValues + const UList& 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 Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate ( const Field& fld, - const UList& defaultValues + const UList& defaultValues, + const lowWeightCorrectionBase::option& lwOption ) const { autoPtr cs; @@ -65,7 +74,7 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate if (!cs) { - return interpolateUntransformed(fld, defaultValues); + return interpolateUntransformed(fld, defaultValues, lwOption); } else { @@ -141,7 +150,7 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate return Foam::transform ( ownT, - interpolateUntransformed(localFld, localDeflt) + interpolateUntransformed(localFld, localDeflt, lwOption) ); } } @@ -151,10 +160,11 @@ template Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate ( const tmp>& tFld, - const UList& defaultValues + const UList& defaultValues, + const lowWeightCorrectionBase::option& lwOption ) const { - return interpolate(tFld(), defaultValues); + return interpolate(tFld(), defaultValues, lwOption); } @@ -245,7 +255,8 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate const Field& localFld, const labelRange& requests, const PtrList>& recvBuffers, - const UList& defaultValues + const UList& defaultValues, + const lowWeightCorrectionBase::option& lwOption ) const { const auto& AMI = (owner() ? this->AMI() : neighbPatch().AMI()); @@ -272,13 +283,9 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate if (!cs) { - AMI.weightedSum - ( - owner(), - fld, - tresult.ref(), - defaultValues - ); + AMICorrectedMultiplyWeightedOp cop(AMI, owner(), lwOption); + + cop(tresult.ref(), fld, defaultValues); } else { @@ -296,13 +303,8 @@ Foam::tmp> Foam::cyclicAMIPolyPatch::interpolate Foam::invTransform(localDeflt, ownT, defaultFld); } - AMI.weightedSum - ( - owner(), - fld, - tresult.ref(), - localDeflt - ); + AMICorrectedMultiplyWeightedOp 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); } }