diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 090a3812a2..610affe33c 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -66,7 +66,7 @@ Foam::AMIInterpolation::patchMagSf const faceAreaIntersect::triangulationMode triMode ) { - tmp tResult(new scalarField(patch.size(), Zero)); + auto tResult = tmp::New(patch.size(), Zero); scalarField& result = tResult.ref(); const pointField& patchPoints = patch.localPoints(); @@ -538,7 +538,7 @@ void Foam::AMIInterpolation::constructFromSurface if (surfPtr.valid()) { // Create new patches for source and target - pointField srcPoints = srcPatch.points(); + pointField srcPoints(srcPatch.points()); SourcePatch srcPatch0 ( SubList @@ -559,7 +559,7 @@ void Foam::AMIInterpolation::constructFromSurface } } - pointField tgtPoints = tgtPatch.points(); + pointField tgtPoints(tgtPatch.points()); TargetPatch tgtPatch0 ( SubList @@ -610,27 +610,18 @@ Foam::AMIInterpolation::AMIInterpolation const bool reverseTarget ) : - methodName_(interpolationMethodNames_[method]), - reverseTarget_(reverseTarget), - requireMatch_(requireMatch), - singlePatchProc_(-999), - lowWeightCorrection_(lowWeightCorrection), - srcMagSf_(), - srcAddress_(), - srcWeights_(), - srcWeightsSum_(), - srcCentroids_(), - tgtMagSf_(), - tgtAddress_(), - tgtWeights_(), - tgtWeightsSum_(), - tgtCentroids_(), - triMode_(triMode), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - update(srcPatch, tgtPatch); -} + AMIInterpolation + ( + srcPatch, + tgtPatch, + nullptr, + triMode, + requireMatch, + method, + lowWeightCorrection, + reverseTarget + ) +{} template @@ -645,27 +636,18 @@ Foam::AMIInterpolation::AMIInterpolation const bool reverseTarget ) : - methodName_(methodName), - reverseTarget_(reverseTarget), - requireMatch_(requireMatch), - singlePatchProc_(-999), - lowWeightCorrection_(lowWeightCorrection), - srcMagSf_(), - srcAddress_(), - srcWeights_(), - srcWeightsSum_(), - srcCentroids_(), - tgtMagSf_(), - tgtAddress_(), - tgtWeights_(), - tgtWeightsSum_(), - tgtCentroids_(), - triMode_(triMode), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - update(srcPatch, tgtPatch); -} + AMIInterpolation + ( + srcPatch, + tgtPatch, + nullptr, + triMode, + requireMatch, + interpolationMethodNames_.get(methodName), + lowWeightCorrection, + reverseTarget + ) +{} template @@ -717,27 +699,18 @@ Foam::AMIInterpolation::AMIInterpolation const bool reverseTarget ) : - methodName_(methodName), - reverseTarget_(reverseTarget), - requireMatch_(requireMatch), - singlePatchProc_(-999), - lowWeightCorrection_(lowWeightCorrection), - srcMagSf_(), - srcAddress_(), - srcWeights_(), - srcWeightsSum_(), - srcCentroids_(), - tgtMagSf_(), - tgtAddress_(), - tgtWeights_(), - tgtWeightsSum_(), - tgtCentroids_(), - triMode_(triMode), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - constructFromSurface(srcPatch, tgtPatch, surfPtr); -} + AMIInterpolation + ( + srcPatch, + tgtPatch, + surfPtr, + triMode, + requireMatch, + interpolationMethodNames_.get(methodName), + lowWeightCorrection, + reverseTarget + ) +{} template @@ -873,188 +846,37 @@ void Foam::AMIInterpolation::update << tgtTotalSize << " target faces" << endl; - // Calculate if patches present on multiple processors - singlePatchProc_ = calcDistribution(srcPatch, tgtPatch); - if (singlePatchProc_ == -1) - { - // Convert local addressing to global addressing - globalIndex globalSrcFaces(srcPatch.size()); - globalIndex globalTgtFaces(tgtPatch.size()); - - // Create processor map of overlapping faces. This map gets - // (possibly remote) faces from the tgtPatch such that they (together) - // cover all of the srcPatch - autoPtr mapPtr = calcProcMap(srcPatch, tgtPatch); - const mapDistribute& map = mapPtr(); - - // Create new target patch that fully encompasses source patch - - // Faces and points - faceList newTgtFaces; - pointField newTgtPoints; - - // Original faces from tgtPatch (in globalIndexing since might be - // remote) - labelList tgtFaceIDs; - distributeAndMergePatches + // Calculate AMI interpolation + autoPtr> AMIPtr + ( + AMIMethod::New ( - map, + methodName_, + srcPatch, tgtPatch, - globalTgtFaces, - newTgtFaces, - newTgtPoints, - tgtFaceIDs - ); + triMode_, + reverseTarget_, + requireMatch_ && (lowWeightCorrection_ < 0) + ) + ); - const TargetPatch - newTgtPatch - ( - SubList - ( - newTgtFaces, - newTgtFaces.size() - ), - newTgtPoints - ); + AMIPtr->calculate + ( + srcAddress_, + srcWeights_, + srcCentroids_, + tgtAddress_, + tgtWeights_, + srcMagSf_, + tgtMagSf_, + srcMapPtr_, + tgtMapPtr_ + ); - // Calculate AMI interpolation - autoPtr> AMIPtr - ( - AMIMethod::New - ( - methodName_, - srcPatch, - newTgtPatch, - triMode_, - reverseTarget_, - requireMatch_ && (lowWeightCorrection_ < 0) - ) - ); + AMIPtr->normaliseWeights(true, *this); - AMIPtr->calculate - ( - srcAddress_, - srcWeights_, - srcCentroids_, - tgtAddress_, - tgtWeights_ - ); - - - // Note: using patch face areas calculated by the AMI method - // - TODO: move into the calculate or normalise method? - AMIPtr->setMagSf(tgtPatch, map, srcMagSf_, tgtMagSf_); - - - // Now - // ~~~ - // srcAddress_ : per srcPatch face a list of the newTgtPatch (not - // tgtPatch) faces it overlaps - // tgtAddress_ : per newTgtPatch (not tgtPatch) face a list of the - // srcPatch faces it overlaps - - if (debug) - { - writeFaceConnectivity(srcPatch, newTgtPatch, srcAddress_); - } - - - // Rework newTgtPatch indices into globalIndices of tgtPatch - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - for (labelList& addressing : srcAddress_) - { - for (label& addr : addressing) - { - addr = tgtFaceIDs[addr]; - } - } - - for (labelList& addressing : tgtAddress_) - { - globalSrcFaces.inplaceToGlobal(addressing); - } - - // Send data back to originating procs. Note that contributions - // from different processors get added (ListOps::appendEqOp) - - mapDistributeBase::distribute - ( - Pstream::commsTypes::nonBlocking, - List(), - tgtPatch.size(), - map.constructMap(), - false, // has flip - map.subMap(), - false, // has flip - tgtAddress_, - ListOps::appendEqOp