diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C index 013f4ad179..cfdc342b3a 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C @@ -31,11 +31,6 @@ License #include "OFstream.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template -Foam::scalar Foam::dynamicIndexedOctree::perturbTol_ = 10*SMALL; - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -2046,13 +2041,6 @@ Foam::dynamicIndexedOctree::dynamicIndexedOctree // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar& Foam::dynamicIndexedOctree::perturbTol() -{ - return perturbTol_; -} - - template Foam::pointIndexHit Foam::dynamicIndexedOctree::findNearest ( diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H index 8512c1882b..3c71965879 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H @@ -89,15 +89,6 @@ class dynamicIndexedOctree : public dynamicIndexedOctreeBase { - // Static data - - //- Relative perturbation tolerance. Determines when point is - // considered to be close to face/edge of bb of node. - // The tolerance is relative to the bounding box of the smallest - // node. - static scalar perturbTol_; - - // Private Data //- Underlying shapes for geometric queries. @@ -333,10 +324,6 @@ class dynamicIndexedOctree public: - //- Get the perturbation tolerance - static scalar& perturbTol(); - - // Constructors //- Construct from shapes diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index 4a71b43fa7..6d09bdc263 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -32,12 +32,6 @@ License #include "ListOps.H" #include "memInfo.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template -Foam::scalar Foam::indexedOctree::perturbTol_ = 10*SMALL; - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -2293,13 +2287,6 @@ Foam::indexedOctree::indexedOctree // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar& Foam::indexedOctree::perturbTol() -{ - return perturbTol_; -} - - template Foam::pointIndexHit Foam::indexedOctree::findNearest ( diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H index 9f39421b3d..6d9bee036b 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H @@ -178,6 +178,16 @@ public: protected: + // Static Data + + //- Relative perturbation tolerance. + // Determines when point is considered to be close to face/edge + // of bb of node. + // The tolerance is relative to the bounding box of the smallest + // node. + static scalar perturbTol_; + + // Protected Member Functions // Encode node addressing @@ -204,6 +214,18 @@ protected: public: + //- Get the perturbation tolerance + static scalar& perturbTol() noexcept { return perturbTol_; } + + //- Set the perturbation tolerance, return the old value + static scalar perturbTol(scalar tol) noexcept + { + scalar old(perturbTol_); + perturbTol_ = tol; + return old; + } + + //- Runtime type information ClassName("indexedOctree"); @@ -236,15 +258,6 @@ class indexedOctree : public indexedOctreeBase { - // Static data - - //- Relative perturbation tolerance. Determines when point is - // considered to be close to face/edge of bb of node. - // The tolerance is relative to the bounding box of the smallest - // node. - static scalar perturbTol_; - - // Private Data //- Underlying shapes for geometric queries. @@ -489,10 +502,6 @@ class indexedOctree public: - //- Get the perturbation tolerance - static scalar& perturbTol(); - - // Constructors //- Construct null diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeBase.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeBase.C index 416c39a8c7..854859fdb7 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeBase.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeBase.C @@ -34,6 +34,8 @@ License namespace Foam { defineTypeNameAndDebug(indexedOctreeBase, 0); + + scalar indexedOctreeBase::perturbTol_ = 10*SMALL; } diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 4714300105..8a87d50dba 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -801,8 +801,8 @@ Foam::triSurfaceMesh::edgeTree() const << "calculating edge tree for bb:" << bb << endl; } - scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); edgeTree_.reset ( @@ -822,7 +822,7 @@ Foam::triSurfaceMesh::edgeTree() const ) ); - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); if (debug) { @@ -1221,8 +1221,8 @@ void Foam::triSurfaceMesh::getVolumeType List& volType ) const { - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); if (debug) { @@ -1258,7 +1258,8 @@ void Foam::triSurfaceMesh::getVolumeType } } - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); + if (debug) { Pout<< "triSurfaceMesh::getVolumeType :" diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C index 54e5c35245..d58ec499bf 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C @@ -108,8 +108,7 @@ Foam::triSurfaceRegionSearch::treeByRegion() const forAll(regionsAddressing, regionI) { - scalar oldTol = treeType::perturbTol(); - treeType::perturbTol() = tolerance(); + const scalar oldTol = treeType::perturbTol(tolerance()); indirectRegionPatches_.set ( @@ -177,7 +176,7 @@ Foam::triSurfaceRegionSearch::treeByRegion() const ) ); - treeType::perturbTol() = oldTol; + treeType::perturbTol(oldTol); } } @@ -199,8 +198,7 @@ void Foam::triSurfaceRegionSearch::findNearest } else { - scalar oldTol = treeType::perturbTol(); - treeType::perturbTol() = tolerance(); + const scalar oldTol = treeType::perturbTol(tolerance()); const PtrList& octrees = treeByRegion(); @@ -249,7 +247,7 @@ void Foam::triSurfaceRegionSearch::findNearest } } - treeType::perturbTol() = oldTol; + treeType::perturbTol(oldTol); } } diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 63853a2d3b..156b545dea 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -233,8 +233,8 @@ Foam::triSurfaceSearch::tree() const bb.inflate(rndGen, 1e-4, ROOTVSMALL); } - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance_; + const scalar oldTol = + indexedOctree::perturbTol(tolerance_); treePtr_.reset ( @@ -248,7 +248,7 @@ Foam::triSurfaceSearch::tree() const ) ); - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); } return *treePtr_; @@ -291,8 +291,8 @@ void Foam::triSurfaceSearch::findNearest List& info ) const { - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); const indexedOctree& octree = tree(); @@ -310,7 +310,7 @@ void Foam::triSurfaceSearch::findNearest ); } - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); } @@ -338,15 +338,15 @@ void Foam::triSurfaceSearch::findLine info.setSize(start.size()); - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); forAll(start, i) { info[i] = octree.findLine(start[i], end[i]); } - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); } @@ -361,15 +361,15 @@ void Foam::triSurfaceSearch::findLineAny info.setSize(start.size()); - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); forAll(start, i) { info[i] = octree.findLineAny(start[i], end[i]); } - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); } @@ -384,8 +384,8 @@ void Foam::triSurfaceSearch::findLineAll info.setSize(start.size()); - const scalar oldTol = indexedOctree::perturbTol(); - indexedOctree::perturbTol() = tolerance(); + const scalar oldTol = + indexedOctree::perturbTol(tolerance()); // Work array DynamicList hits; @@ -437,7 +437,7 @@ void Foam::triSurfaceSearch::findLineAll info[pointi].transfer(hits); } - indexedOctree::perturbTol() = oldTol; + indexedOctree::perturbTol(oldTol); }