diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 610affe33c2365a97a4eb02c4ab195135e1fa54d..eaf1ebeb5a013419e4b53036835b96f3bf20ce4d 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -45,8 +45,7 @@ const Foam::Enum > Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethodNames_ ({ - { interpolationMethod::imDirect, "directAMI" }, - { interpolationMethod::imMapNearest, "mapNearestAMI" }, + { interpolationMethod::imNearestFace, "nearestFaceAMI" }, { interpolationMethod::imFaceAreaWeight, "faceAreaWeightAMI" }, { interpolationMethod::imPartialFaceAreaWeight, "partialFaceAreaWeightAMI" } }); diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index a3c5a61aa223a59d3e8ebd006afcc01c6db4432a..82848433c58d145c6ba35893dde50b84ee6db518 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -91,8 +91,7 @@ public: //- Enumeration specifying interpolation method enum interpolationMethod { - imDirect, - imMapNearest, + imNearestFace, imFaceAreaWeight, imPartialFaceAreaWeight }; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.C deleted file mode 100644 index 58170bbe322eeac96b0d2838590436b6c0f452a2..0000000000000000000000000000000000000000 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.C +++ /dev/null @@ -1,329 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2013-2016 OpenFOAM Foundation -------------------------------------------------------------------------------- -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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "directAMI.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class SourcePatch, class TargetPatch> -void Foam::directAMI<SourcePatch, TargetPatch>::appendToDirectSeeds -( - labelList& mapFlag, - labelList& srcTgtSeed, - DynamicList<label>& srcSeeds, - DynamicList<label>& nonOverlapFaces, - label& srcFacei, - label& tgtFacei -) const -{ - const labelList& srcNbr = this->srcPatch().faceFaces()[srcFacei]; - const labelList& tgtNbr = this->tgtPatch().faceFaces()[tgtFacei]; - - const pointField& srcPoints = this->srcPatch().points(); - const pointField& tgtPoints = this->tgtPatch().points(); - - const vectorField& srcCf = this->srcPatch().faceCentres(); - - for (const label srcI : srcNbr) - { - if ((mapFlag[srcI] == 0) && (srcTgtSeed[srcI] == -1)) - { - // first attempt: match by comparing face centres - const face& srcF = this->srcPatch()[srcI]; - const point& srcC = srcCf[srcI]; - - scalar tol = GREAT; - forAll(srcF, fpI) - { - const point& p = srcPoints[srcF[fpI]]; - scalar d2 = magSqr(p - srcC); - if (d2 < tol) - { - tol = d2; - } - } - tol = max(SMALL, 0.0001*sqrt(tol)); - - bool found = false; - for (const label tgtI : tgtNbr) - { - const face& tgtF = this->tgtPatch()[tgtI]; - const point tgtC = tgtF.centre(tgtPoints); - - if (mag(srcC - tgtC) < tol) - { - // new match - append to lists - found = true; - - srcTgtSeed[srcI] = tgtI; - srcSeeds.append(srcI); - - break; - } - } - - // second attempt: match by shooting a ray into the tgt face - if (!found) - { - const vector srcN = srcF.areaNormal(srcPoints); - - for (const label tgtI : tgtNbr) - { - const face& tgtF = this->tgtPatch()[tgtI]; - pointHit ray = tgtF.ray(srcCf[srcI], srcN, tgtPoints); - - if (ray.hit()) - { - // new match - append to lists - found = true; - - srcTgtSeed[srcI] = tgtI; - srcSeeds.append(srcI); - - break; - } - } - } - - // no match available for source face srcI - if (!found) - { - mapFlag[srcI] = -1; - nonOverlapFaces.append(srcI); - - if (debug) - { - Pout<< "source face not found: id=" << srcI - << " centre=" << srcCf[srcI] - << " normal=" << srcF.areaNormal(srcPoints) - << " points=" << srcF.points(srcPoints) - << endl; - - Pout<< "target neighbours:" << nl; - for (const label tgtI : tgtNbr) - { - const face& tgtF = this->tgtPatch()[tgtI]; - - Pout<< "face id: " << tgtI - << " centre=" << tgtF.centre(tgtPoints) - << " normal=" << tgtF.areaNormal(tgtPoints) - << " points=" << tgtF.points(tgtPoints) - << endl; - } - } - } - } - } - - if (srcSeeds.size()) - { - srcFacei = srcSeeds.remove(); - tgtFacei = srcTgtSeed[srcFacei]; - } - else - { - srcFacei = -1; - tgtFacei = -1; - } -} - - -template<class SourcePatch, class TargetPatch> -void Foam::directAMI<SourcePatch, TargetPatch>::restartAdvancingFront -( - labelList& mapFlag, - DynamicList<label>& nonOverlapFaces, - label& srcFacei, - label& tgtFacei -) const -{ - forAll(mapFlag, facei) - { - if (mapFlag[facei] == 0) - { - tgtFacei = this->findTargetFace(facei); - - if (tgtFacei < 0) - { - mapFlag[facei] = -1; - nonOverlapFaces.append(facei); - } - else - { - srcFacei = facei; - break; - } - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template<class SourcePatch, class TargetPatch> -Foam::directAMI<SourcePatch, TargetPatch>::directAMI -( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, - const faceAreaIntersect::triangulationMode& triMode, - const bool reverseTarget, - const bool requireMatch -) -: - AMIMethod<SourcePatch, TargetPatch> - ( - srcPatch, - tgtPatch, - triMode, - reverseTarget, - requireMatch - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class SourcePatch, class TargetPatch> -bool Foam::directAMI<SourcePatch, TargetPatch>::calculate -( - labelListList& srcAddress, - scalarListList& srcWeights, - pointListList& srcCentroids, - labelListList& tgtAddress, - scalarListList& tgtWeights, - scalarList& srcMagSf, - scalarList& tgtMagSf, - autoPtr<mapDistribute>& srcMapPtr, - autoPtr<mapDistribute>& tgtMapPtr, - label srcFacei, - label tgtFacei -) -{ - bool ok = - this->initialise - ( - srcAddress, - srcWeights, - tgtAddress, - tgtWeights, - srcFacei, - tgtFacei - ); - - if (!ok) - { - return false; - } - - NotImplemented; - // temporary storage for addressing and weights - List<DynamicList<label>> srcAddr(this->srcPatch0_.size()); - List<DynamicList<label>> tgtAddr(this->tgtPatch0_.size()); - - - // construct weights and addressing - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // list of faces currently visited for srcFacei to avoid multiple hits - DynamicList<label> srcSeeds(10); - - // list to keep track of tgt faces used to seed src faces - labelList srcTgtSeed(srcAddr.size(), -1); - srcTgtSeed[srcFacei] = tgtFacei; - - // list to keep track of whether src face can be mapped - // 1 = mapped, 0 = untested, -1 = cannot map - labelList mapFlag(srcAddr.size(), Zero); - - label nTested = 0; - DynamicList<label> nonOverlapFaces; - do - { - srcAddr[srcFacei].append(tgtFacei); - tgtAddr[tgtFacei].append(srcFacei); - - mapFlag[srcFacei] = 1; - - nTested++; - - // Do advancing front starting from srcFacei, tgtFacei - appendToDirectSeeds - ( - mapFlag, - srcTgtSeed, - srcSeeds, - nonOverlapFaces, - srcFacei, - tgtFacei - ); - - if (srcFacei < 0 && nTested < this->srcPatch().size()) - { - restartAdvancingFront(mapFlag, nonOverlapFaces, srcFacei, tgtFacei); - } - - } while (srcFacei >= 0); - - if (nonOverlapFaces.size() != 0) - { - Pout<< " AMI: " << nonOverlapFaces.size() - << " non-overlap faces identified" - << endl; - - this->srcNonOverlap_.transfer(nonOverlapFaces); - } - - // transfer data to persistent storage - forAll(srcAddr, i) - { - scalar magSf = this->srcMagSf_[i]; - srcAddress[i].transfer(srcAddr[i]); - srcWeights[i] = scalarList(1, magSf); - } - forAll(tgtAddr, i) - { - scalar magSf = this->tgtMagSf_[i]; - tgtAddress[i].transfer(tgtAddr[i]); - tgtWeights[i] = scalarList(1, magSf); - } - - return true; -} - - -template<class SourcePatch, class TargetPatch> -void Foam::directAMI<SourcePatch, TargetPatch>::normaliseWeights -( - const bool verbose, - AMIInterpolation<SourcePatch, TargetPatch>& inter -) -{ - inter.normaliseWeights(this->conformal(), verbose); -} - - -// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.H deleted file mode 100644 index 9eaf8df29e0b57c8be1afe6730723d799667a7b9..0000000000000000000000000000000000000000 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/directAMI/directAMI.H +++ /dev/null @@ -1,168 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2013-2016 OpenFOAM Foundation -------------------------------------------------------------------------------- -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 <http://www.gnu.org/licenses/>. - -Class - Foam::directAMI - -Description - Direct mapped Arbitrary Mesh Interface (AMI) method - -SourceFiles - directAMI.C - -\*---------------------------------------------------------------------------*/ - -#ifndef directAMI_H -#define directAMI_H - -#include "AMIMethod.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class directAMI Declaration -\*---------------------------------------------------------------------------*/ - -template<class SourcePatch, class TargetPatch> -class directAMI -: - public AMIMethod<SourcePatch, TargetPatch> -{ - -private: - - // Private Member Functions - - //- No copy construct - directAMI(const directAMI&) = delete; - - //- No copy assignment - void operator=(const directAMI&) = delete; - - // Marching front - - //- Append to list of src face seed indices - void appendToDirectSeeds - ( - labelList& mapFlag, - labelList& srcTgtSeed, - DynamicList<label>& srcSeeds, - DynamicList<label>& nonOverlapFaces, - label& srcFacei, - label& tgtFacei - ) const; - - //- Restart the advancing front - typically happens for - // disconnected regions - void restartAdvancingFront - ( - labelList& mapFlag, - DynamicList<label>& nonOverlapFaces, - label& srcFacei, - label& tgtFacei - ) const; - - - // Evaluation - - //- Area of intersection between source and target faces - scalar interArea - ( - const label srcFacei, - const label tgtFacei - ) const; - - -public: - - //- Runtime type information - TypeName("directAMI"); - - - // Constructors - - //- Construct from components - directAMI - ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, - const faceAreaIntersect::triangulationMode& triMode, - const bool reverseTarget = false, - const bool requireMatch = true - ); - - - //- Destructor - virtual ~directAMI() = default; - - - // Member Functions - - // Manipulation - - //- Update addressing and weights - virtual bool calculate - ( - labelListList& srcAddress, - scalarListList& srcWeights, - pointListList& srcCentroids, - labelListList& tgtAddress, - scalarListList& tgtWeights, - scalarList& srcMagSf, - scalarList& tgtMagSf, - autoPtr<mapDistribute>& srcMapPtr, - autoPtr<mapDistribute>& tgtMapPtr, - label srcFacei = -1, - label tgtFacei = -1 - ); - - //- Normalise the weight. Can optionally subset addressing - // (e.g. for mapNearest) - virtual void normaliseWeights - ( - const bool verbose, - AMIInterpolation<SourcePatch, TargetPatch>& inter - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "directAMI.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.C index 3db4e09a0e6a0998043c82c8048b918455d5c942..67c21724613da2da09aa5b5e04d544a06e452cf3 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.C @@ -27,7 +27,6 @@ License #include "AMIPatchToPatchInterpolation.H" #include "AMIMethod.H" -#include "directAMI.H" #include "nearestFaceAMI.H" #include "faceAreaWeightAMI.H" #include "partialFaceAreaWeightAMI.H" @@ -38,7 +37,6 @@ namespace Foam { makeAMIMethod(AMIPatchToPatchInterpolation); - makeAMIMethodType(AMIPatchToPatchInterpolation, directAMI); makeAMIMethodType(AMIPatchToPatchInterpolation, nearestFaceAMI); makeAMIMethodType(AMIPatchToPatchInterpolation, faceAreaWeightAMI); makeAMIMethodType(AMIPatchToPatchInterpolation, partialFaceAreaWeightAMI); diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index 591f67fc5e18db7baa5d8b47bf4d9dbc64d8d034..2a19e45f245cffade7a36ef2e105a0b5caa16d38 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -640,12 +640,12 @@ Foam::meshToMesh::interpolationMethodAMI(const interpolationMethod method) { case interpolationMethod::imDirect: { - return AMIPatchToPatchInterpolation::imDirect; + return AMIPatchToPatchInterpolation::imNearestFace; break; } case interpolationMethod::imMapNearest: { - return AMIPatchToPatchInterpolation::imMapNearest; + return AMIPatchToPatchInterpolation::imNearestFace; break; } case interpolationMethod::imCellVolumeWeight: @@ -662,7 +662,7 @@ Foam::meshToMesh::interpolationMethodAMI(const interpolationMethod method) } } - return AMIPatchToPatchInterpolation::imDirect; + return AMIPatchToPatchInterpolation::imNearestFace; }