diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 8bc8b86d2e..1be3be8dad 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -56,6 +56,11 @@ Foam::AMIInterpolation::interpolationMethodToWord method = "faceAreaWeightAMI"; break; } + case imPartialFaceAreaWeight: + { + method = "partialFaceAreaWeightAMI"; + break; + } default: { FatalErrorIn @@ -87,7 +92,15 @@ Foam::AMIInterpolation::wordTointerpolationMethod wordList methods ( - IStringStream("(directAMI mapNearestAMI faceAreaWeightAMI)")() + IStringStream + ( + "(" + "directAMI " + "mapNearestAMI " + "faceAreaWeightAMI " + "partialFaceAreaWeightAMI" + ")" + )() ); if (im == "directAMI") @@ -102,6 +115,10 @@ Foam::AMIInterpolation::wordTointerpolationMethod { method = imFaceAreaWeight; } + else if (im == "partialFaceAreaWeightAMI") + { + method = imPartialFaceAreaWeight; + } else { FatalErrorIn @@ -183,6 +200,7 @@ void Foam::AMIInterpolation::normaliseWeights const labelListList& addr, scalarListList& wght, scalarField& wghtSum, + const bool normalise, const bool output ) { @@ -191,12 +209,19 @@ void Foam::AMIInterpolation::normaliseWeights forAll(wght, faceI) { scalarList& w = wght[faceI]; + scalar denom = patchAreas[faceI]; + scalar s = sum(w); - scalar t = s/patchAreas[faceI]; + scalar t = s/denom; + + if (normalise) + { + denom = s; + } forAll(w, i) { - w[i] /= s; + w[i] /= denom; } wghtSum[faceI] = t; @@ -476,6 +501,7 @@ void Foam::AMIInterpolation::agglomerate srcAddress, srcWeights, srcWeightsSum, + true, false ); } @@ -749,7 +775,6 @@ void Foam::AMIInterpolation::update tgtMagSf_[faceI] = tgtPatch[faceI].mag(tgtPatch.points()); } - // Calculate if patches present on multiple processors singlePatchProc_ = calcDistribution(srcPatch, tgtPatch); @@ -794,32 +819,28 @@ void Foam::AMIInterpolation::update newTgtPoints ); - // calculate AMI interpolation - { - autoPtr > AMIPtr + autoPtr > AMIPtr + ( + AMIMethod::New ( - AMIMethod::New - ( - interpolationMethodToWord(method_), - srcPatch, - newTgtPatch, - srcMagSf_, - tgtMagSf_, - triMode_, - reverseTarget_ - ) - ); - - AMIPtr->calculate - ( - srcAddress_, - srcWeights_, - tgtAddress_, - tgtWeights_ - ); - } + interpolationMethodToWord(method_), + srcPatch, + newTgtPatch, + srcMagSf_, + tgtMagSf_, + triMode_, + reverseTarget_ + ) + ); + AMIPtr->calculate + ( + srcAddress_, + srcWeights_, + tgtAddress_, + tgtWeights_ + ); // Now // ~~~ @@ -886,6 +907,7 @@ void Foam::AMIInterpolation::update srcAddress_, srcWeights_, srcWeightsSum_, + AMIPtr->normalise(), true ); normaliseWeights @@ -895,6 +917,7 @@ void Foam::AMIInterpolation::update tgtAddress_, tgtWeights_, tgtWeightsSum_, + AMIPtr->normalise(), true ); @@ -903,7 +926,6 @@ void Foam::AMIInterpolation::update srcMapPtr_.reset(new mapDistribute(globalSrcFaces, tgtAddress_, cMap)); tgtMapPtr_.reset(new mapDistribute(globalTgtFaces, srcAddress_, cMap)); - if (debug) { writeFaceConnectivity(srcPatch, newTgtPatch, srcAddress_); @@ -913,29 +935,27 @@ void Foam::AMIInterpolation::update { // calculate AMI interpolation - { - autoPtr > AMIPtr + autoPtr > AMIPtr + ( + AMIMethod::New ( - AMIMethod::New - ( - interpolationMethodToWord(method_), - srcPatch, - tgtPatch, - srcMagSf_, - tgtMagSf_, - triMode_, - reverseTarget_ - ) - ); + interpolationMethodToWord(method_), + srcPatch, + tgtPatch, + srcMagSf_, + tgtMagSf_, + triMode_, + reverseTarget_ + ) + ); - AMIPtr->calculate - ( - srcAddress_, - srcWeights_, - tgtAddress_, - tgtWeights_ - ); - } + AMIPtr->calculate + ( + srcAddress_, + srcWeights_, + tgtAddress_, + tgtWeights_ + ); normaliseWeights ( @@ -944,6 +964,7 @@ void Foam::AMIInterpolation::update srcAddress_, srcWeights_, srcWeightsSum_, + AMIPtr->normalise(), true ); normaliseWeights @@ -953,6 +974,7 @@ void Foam::AMIInterpolation::update tgtAddress_, tgtWeights_, tgtWeightsSum_, + AMIPtr->normalise(), true ); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index e31eb91e1c..c9df62ee76 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -88,7 +88,8 @@ public: { imDirect, imMapNearest, - imFaceAreaWeight + imFaceAreaWeight, + imPartialFaceAreaWeight }; //- Convert interpolationMethod to word representation @@ -236,6 +237,7 @@ private: const labelListList& addr, scalarListList& wght, scalarField& wghtSum, + const bool normalise, const bool output ); diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/partialFaceAreaWeightAMI/partialFaceAreaWeightAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/partialFaceAreaWeightAMI/partialFaceAreaWeightAMI.C new file mode 100644 index 0000000000..e4a44b925f --- /dev/null +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/partialFaceAreaWeightAMI/partialFaceAreaWeightAMI.C @@ -0,0 +1,542 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "partialFaceAreaWeightAMI.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +bool Foam::partialFaceAreaWeightAMI::processSourceFace +( + const label srcFaceI, + const label tgtStartFaceI, + + // list of tgt face neighbour faces + DynamicList