diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C index f4265f155a..5b3d1bc483 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C @@ -162,7 +162,7 @@ bool Foam::AMIMethod::initialise } // Reset the octree - resetTree(); + treePtr_.reset(createTree(tgtPatch())); // Find initial face match using brute force/octree search if ((srcFacei == -1) || (tgtFacei == -1)) @@ -256,35 +256,31 @@ void Foam::AMIMethod::writeIntersectionOBJ template -void Foam::AMIMethod::resetTree() +template +Foam::autoPtr>> +Foam::AMIMethod::createTree +( + const PatchType& patch +) const { - const auto& tgt = tgtPatch(); + typedef treeDataPrimitivePatch PatchTreeType; - // Clear the old octree - treePtr_.clear(); - - treeBoundBox bb(tgt.points(), tgt.meshPoints()); + treeBoundBox bb(patch.points(), patch.meshPoints()); bb.inflate(0.01); - if (!treePtr_.valid()) - { - treePtr_.reset + return autoPtr>::New + ( + PatchTreeType ( - new indexedOctree - ( - treeType - ( - false, - tgt, - indexedOctree::perturbTol() - ), - bb, // overall search domain - 8, // maxLevel - 10, // leaf size - 3.0 // duplicity - ) - ); - } + false, + patch, + indexedOctree::perturbTol() + ), + bb, // overall search domain + 8, // maxLevel + 10, // leaf size + 3.0 // duplicity + ); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.H index e702f8366a..62efb5d486 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.H @@ -199,7 +199,12 @@ protected: // Common AMI method functions //- Reset the octree for the target patch face search - void resetTree(); + template + autoPtr>> + createTree + ( + const PatchType& patch + ) const; label findTargetFace ( diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C deleted file mode 100644 index e2d57b8599..0000000000 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C +++ /dev/null @@ -1,444 +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 - Copyright (C) 2016 OpenCFD Ltd. -------------------------------------------------------------------------------- -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 "mapNearestAMI.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template -void Foam::mapNearestAMI::findNearestFace -( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, - const label& srcFacei, - label& tgtFacei -) const -{ - const vectorField& srcCf = srcPatch.faceCentres(); - const vectorField& tgtCf = tgtPatch.faceCentres(); - - const vector srcP = srcCf[srcFacei]; - - DynamicList