From a456e9ae92bd2744cb2ab1c91ed51daad25f0ca4 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 24 Feb 2020 17:41:06 +0100 Subject: [PATCH] STYLE: relocate nonCoupledBoundaryTree into meshSearcher - use point::uniform in more places --- .../Test-findSphereFeatureEdges-octree.C | 5 +- .../conformalVoronoiMeshConformToSurface.C | 9 +- .../surface/surfaceHookUp/surfaceHookUp.C | 5 +- src/OpenFOAM/meshes/meshTools/matchPoints.C | 15 ++- src/OpenFOAM/meshes/meshTools/matchPoints.H | 5 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 6 +- .../refinementFeatures/refinementFeatures.C | 9 +- .../snappySnapDriverFeature.C | 6 +- .../extendedEdgeMesh/extendedEdgeMesh.C | 14 +-- .../mappedPolyPatch/mappedPatchBase.C | 8 +- src/meshTools/meshSearch/meshSearch.C | 108 +++++++++++------- src/meshTools/meshSearch/meshSearch.H | 40 ++++--- .../searchableExtrudedCircle.C | 6 +- .../triSurfaceMesh/triSurfaceMesh.C | 4 +- .../triSurfaceSearch/triSurfaceRegionSearch.C | 6 +- .../triSurfaceSearch/triSurfaceSearch.C | 6 +- src/sampling/probes/patchProbes.C | 7 +- .../sampledSet/patchSeed/patchSeedSet.C | 6 +- .../sampledTriSurfaceMesh.C | 60 +--------- .../sampledTriSurfaceMesh.H | 5 +- 20 files changed, 163 insertions(+), 167 deletions(-) diff --git a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C index e02426085e0..faba97041bc 100644 --- a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C +++ b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,8 +69,8 @@ int main(int argc, char *argv[]) efem.points() ); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); labelList allEdges(identity(efem.edges().size())); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index b9237123f98..2ba63abf1ae 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1983,8 +1984,8 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) ); - overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.min() -= Foam::point::uniform(ROOTVSMALL); + overallBb.max() += Foam::point::uniform(ROOTVSMALL); edgeLocationTreePtr_.reset ( @@ -2010,8 +2011,8 @@ void Foam::conformalVoronoiMesh::buildSurfacePtLocationTree geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) ); - overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.min() -= Foam::point::uniform(ROOTVSMALL); + overallBb.max() += Foam::point::uniform(ROOTVSMALL); surfacePtLocationTreePtr_.reset ( diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index 90739ac792f..b36a009750f 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -180,8 +181,8 @@ void createBoundaryEdgeTrees treeBoundBox(UList<point>(surf.localPoints())).extend(rndGen, 1e-4) ); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); bEdgeTrees.set ( diff --git a/src/OpenFOAM/meshes/meshTools/matchPoints.C b/src/OpenFOAM/meshes/meshTools/matchPoints.C index d9836fee292..0dbf828ef43 100644 --- a/src/OpenFOAM/meshes/meshTools/matchPoints.C +++ b/src/OpenFOAM/meshes/meshTools/matchPoints.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,12 +49,17 @@ bool Foam::matchPoints point compareOrigin = origin; - if (origin == point(VGREAT, VGREAT, VGREAT)) + if (origin == point::max) { if (pts1.size()) { compareOrigin = sum(pts1)/pts1.size(); } + else + { + // Unusable, but avoid comparison with VGREAT! + compareOrigin = point::zero; + } } SortableList<scalar> pts0MagSqr(magSqr(pts0 - compareOrigin)); @@ -160,12 +166,17 @@ bool Foam::matchPoints point compareOrigin = origin; - if (origin == point(VGREAT, VGREAT, VGREAT)) + if (origin == point::max) { if (pts1.size()) { compareOrigin = sum(pts1)/pts1.size(); } + else + { + // Unusable, but avoid comparison with VGREAT! + compareOrigin = point::zero; + } } SortableList<scalar> pts0MagSqr(magSqr(pts0 - compareOrigin)); diff --git a/src/OpenFOAM/meshes/meshTools/matchPoints.H b/src/OpenFOAM/meshes/meshTools/matchPoints.H index e8f43cbcfcf..944d6f12dd0 100644 --- a/src/OpenFOAM/meshes/meshTools/matchPoints.H +++ b/src/OpenFOAM/meshes/meshTools/matchPoints.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,7 +59,7 @@ bool matchPoints const UList<scalar>& matchDistance, const bool verbose, labelList& from0To1, - const point& origin = point::zero + const point& origin = point::zero //!< point::max = use average origin ); @@ -75,7 +76,7 @@ bool matchPoints const UList<scalar>& matchDistance, const bool verbose, labelList& from0To1, - const point& origin = point::zero + const point& origin = point::zero //!< point::max = use average origin ); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index c7622a2c8ca..6032025cf75 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -901,8 +901,8 @@ Foam::polyMesh::cellTree() const Random rndGen(261782); overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.min() -= point::uniform(ROOTVSMALL); + overallBb.max() += point::uniform(ROOTVSMALL); cellTreePtr_.reset ( diff --git a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C index b8054d58fd7..8f749490364 100644 --- a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C +++ b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -297,8 +298,8 @@ void Foam::refinementFeatures::buildTrees(const label featI) // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); edgeTrees_.set ( @@ -438,8 +439,8 @@ Foam::refinementFeatures::regionEdgeTrees() const // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); trees.set ( diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 29f54124f53..33d22fcce9a 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -3174,8 +3174,8 @@ void Foam::snappySnapDriver::reverseAttractMeshPoints // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); } // Collect candidate points for attraction diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index 2f54e45ede7..de7a4a8f242 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -848,8 +848,8 @@ Foam::extendedEdgeMesh::pointTree() const treeBoundBox(points()).extend(rndGen, 1e-4) ); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); const labelList featurePointLabels = identity(nonFeatureStart_); @@ -888,8 +888,8 @@ Foam::extendedEdgeMesh::edgeTree() const treeBoundBox(points()).extend(rndGen, 1e-4) ); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); labelList allEdges(identity(edges().size())); @@ -932,8 +932,8 @@ Foam::extendedEdgeMesh::edgeTreesByType() const treeBoundBox(points()).extend(rndGen, 1e-4) ); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); labelListList sliceEdges(nEdgeTypes); diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index af6b90cf2e4..f2875329363 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -294,8 +294,8 @@ void Foam::mappedPatchBase::findSamples 1e-4 ) ); - patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + patchBb.min() -= point::uniform(ROOTVSMALL); + patchBb.max() += point::uniform(ROOTVSMALL); indexedOctree<treeDataFace> boundaryTree ( @@ -366,8 +366,8 @@ void Foam::mappedPatchBase::findSamples 1e-4 ) ); - patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + patchBb.min() -= point::uniform(ROOTVSMALL); + patchBb.max() += point::uniform(ROOTVSMALL); indexedOctree<treeDataPoint> boundaryTree ( diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index cd066624fcd..64c987905eb 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -603,30 +603,33 @@ Foam::meshSearch::~meshSearch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::indexedOctree<Foam::treeDataFace>& -Foam::meshSearch::boundaryTree() const +const Foam::treeBoundBox& Foam::meshSearch::dataBoundBox() const { - if (!boundaryTreePtr_.valid()) + if (!overallBbPtr_.valid()) { - // - // Construct tree - // + Random rndGen(261782); + overallBbPtr_.reset + ( + new treeBoundBox(mesh_.points()) + ); - if (!overallBbPtr_.valid()) - { - Random rndGen(261782); - overallBbPtr_.reset - ( - new treeBoundBox(mesh_.points()) - ); + treeBoundBox& overallBb = overallBbPtr_(); - treeBoundBox& overallBb = overallBbPtr_(); - // Extend slightly and make 3D - overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - } + // Extend slightly and make 3D + overallBb = overallBb.extend(rndGen, 1e-4); + overallBb.min() -= point::uniform(ROOTVSMALL); + overallBb.max() += point::uniform(ROOTVSMALL); + } + return *overallBbPtr_; +} + + +const Foam::indexedOctree<Foam::treeDataFace>& +Foam::meshSearch::boundaryTree() const +{ + if (!boundaryTreePtr_.valid()) + { // All boundary faces (not just walls) labelList bndFaces ( @@ -643,7 +646,7 @@ Foam::meshSearch::boundaryTree() const mesh_, bndFaces // boundary faces only ), - overallBbPtr_(), // overall search domain + dataBoundBox(), // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -655,30 +658,57 @@ Foam::meshSearch::boundaryTree() const } -const Foam::indexedOctree<Foam::treeDataCell>& -Foam::meshSearch::cellTree() const + +const Foam::indexedOctree<Foam::treeDataFace>& +Foam::meshSearch::nonCoupledBoundaryTree() const { - if (!cellTreePtr_.valid()) + if (!nonCoupledBoundaryTreePtr_.valid()) { - // - // Construct tree - // + // All non-coupled boundary faces (not just walls) + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + labelList bndFaces(mesh_.nBoundaryFaces()); - if (!overallBbPtr_.valid()) + label bndi = 0; + for (const polyPatch& pp : patches) { - Random rndGen(261782); - overallBbPtr_.reset + if (!pp.coupled()) + { + forAll(pp, i) + { + bndFaces[bndi++] = pp.start()+i; + } + } + } + bndFaces.setSize(bndi); + + nonCoupledBoundaryTreePtr_.reset + ( + new indexedOctree<treeDataFace> ( - new treeBoundBox(mesh_.points()) - ); + treeDataFace // all information needed to search faces + ( + false, // do not cache bb + mesh_, + bndFaces // boundary faces only + ), + dataBoundBox(), // overall search domain + 8, // maxLevel + 10, // leafsize + 3.0 // duplicity + ) + ); + } - treeBoundBox& overallBb = overallBbPtr_(); - // Extend slightly and make 3D - overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - } + return *nonCoupledBoundaryTreePtr_; +} + +const Foam::indexedOctree<Foam::treeDataCell>& +Foam::meshSearch::cellTree() const +{ + if (!cellTreePtr_.valid()) + { cellTreePtr_.reset ( new indexedOctree<treeDataCell> @@ -689,7 +719,7 @@ Foam::meshSearch::cellTree() const mesh_, cellDecompMode_ // cell decomposition mode for inside tests ), - overallBbPtr_(), + dataBoundBox(), // overall search domain 8, // maxLevel 10, // leafsize 6.0 // duplicity diff --git a/src/meshTools/meshSearch/meshSearch.H b/src/meshTools/meshSearch/meshSearch.H index 0f75dbe3453..6f03d160394 100644 --- a/src/meshTools/meshSearch/meshSearch.H +++ b/src/meshTools/meshSearch/meshSearch.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +48,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class treeDataCell; class treeDataFace; template<class Type> class indexedOctree; @@ -60,7 +60,7 @@ class treeBoundBox; class meshSearch { - // Private data + // Private Data //- Reference to mesh const polyMesh& mesh_; @@ -73,6 +73,7 @@ class meshSearch //- Demand driven octrees mutable autoPtr<indexedOctree<treeDataFace>> boundaryTreePtr_; + mutable autoPtr<indexedOctree<treeDataFace>> nonCoupledBoundaryTreePtr_; mutable autoPtr<indexedOctree<treeDataCell>> cellTreePtr_; @@ -98,6 +99,12 @@ class meshSearch ); + // Points + + //- Demand-driven bounding box for mesh points + const treeBoundBox& dataBoundBox() const; + + // Cells //- Nearest cell centre using octree @@ -127,7 +134,6 @@ class meshSearch label findNearestFaceWalk(const point&, const label) const; - // Boundary faces //- Walk from seed to find nearest boundary face. Gets stuck in @@ -148,11 +154,11 @@ class meshSearch public: - // Declare name of the class and its debug switch + //- Declare type-name (with debug switch) ClassName("meshSearch"); - // Static data members + // Static Data //- Tolerance on linear dimensions static scalar tol_; @@ -160,17 +166,17 @@ public: // Constructors - //- Construct from components. Constructs bb slightly bigger than - // mesh points bb. - meshSearch + //- Construct from components. + // Constructs bb slightly bigger than mesh points bb. + explicit meshSearch ( const polyMesh& mesh, const polyMesh::cellDecomposition = polyMesh::CELL_TETS ); - //- Construct with a custom bounding box. Any mesh element outside - // bb will not be found. Up to user to make sure bb - // extends slightly beyond wanted elements. + //- Construct with a custom bounding box. + // Any mesh element outside bb will not be found. + // Up to user to ensure bb extends slightly beyond wanted elements. meshSearch ( const polyMesh& mesh, @@ -178,6 +184,7 @@ public: const polyMesh::cellDecomposition = polyMesh::CELL_TETS ); + //- Destructor ~meshSearch(); @@ -196,11 +203,14 @@ public: return cellDecompMode_; } - //- Get (demand driven) reference to octree holding all - // boundary faces + //- Demand-driven reference to octree holding all boundary faces const indexedOctree<treeDataFace>& boundaryTree() const; - //- Get (demand driven) reference to octree holding all cells + //- Demand-driven reference to octree holding all + //- non-coupled boundary faces + const indexedOctree<treeDataFace>& nonCoupledBoundaryTree() const; + + //- Demand-driven reference to octree holding all cells const indexedOctree<treeDataCell>& cellTree() const; diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C index 6f71aa4c321..dbe6598fcc7 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -100,8 +100,8 @@ Foam::searchableExtrudedCircle::searchableExtrudedCircle // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); edgeTree_.reset ( diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 57012de980f..3db3cb4159d 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -759,8 +759,8 @@ Foam::triSurfaceMesh::edgeTree() const // geometry there are less face/edge aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); } diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C index dbca50c732a..f5b8dbef344 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015,2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -157,8 +157,8 @@ Foam::triSurfaceRegionSearch::treeByRegion() const // on symmetric geometry there are fewer face/edge // aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); } treeByRegion_.set diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 948105b14d0..f58dc0691f2 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2017 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -231,8 +231,8 @@ Foam::triSurfaceSearch::tree() const // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. bb = bb.extend(rndGen, 1e-4); - bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.min() -= point::uniform(ROOTVSMALL); + bb.max() += point::uniform(ROOTVSMALL); } const scalar oldTol = indexedOctree<treeDataTriSurface>::perturbTol(); diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index 0dcb4b361fa..617e0dd06ed 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,6 @@ License #include "treeDataFace.H" #include "addToRunTimeSelectionTable.H" - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam @@ -90,8 +89,8 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) Random rndGen(123456); overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.min() -= point::uniform(ROOTVSMALL); + overallBb.max() += point::uniform(ROOTVSMALL); const indexedOctree<treeDataFace> boundaryTree ( diff --git a/src/sampling/sampledSet/patchSeed/patchSeedSet.C b/src/sampling/sampledSet/patchSeed/patchSeedSet.C index 81182ef4fc9..e547968c33f 100644 --- a/src/sampling/sampledSet/patchSeed/patchSeedSet.C +++ b/src/sampling/sampledSet/patchSeed/patchSeedSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,8 +120,8 @@ void Foam::patchSeedSet::calcSamples 1e-4 ) ); - patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + patchBb.min() -= point::uniform(ROOTVSMALL); + patchBb.max() += point::uniform(ROOTVSMALL); indexedOctree<treeDataFace> boundaryTree ( diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C index 11e74c7c7fc..14181bff0d4 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -108,61 +108,6 @@ void Foam::sampledTriSurfaceMesh::setZoneMap // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -const Foam::indexedOctree<Foam::treeDataFace>& -Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const -{ - // Variant of meshSearch::boundaryTree() that only does non-coupled - // boundary faces. - - if (!boundaryTreePtr_.valid()) - { - // all non-coupled boundary faces (not just walls) - const polyBoundaryMesh& patches = mesh().boundaryMesh(); - - labelList bndFaces(patches.nFaces()); - label bndI = 0; - for (const polyPatch& pp : patches) - { - if (!pp.coupled()) - { - forAll(pp, i) - { - bndFaces[bndI++] = pp.start()+i; - } - } - } - bndFaces.setSize(bndI); - - - treeBoundBox overallBb(mesh().points()); - Random rndGen(123456); - // Extend slightly and make 3D - overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - - boundaryTreePtr_.reset - ( - new indexedOctree<treeDataFace> - ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh(), - bndFaces // boundary faces only - ), - overallBb, // overall search domain - 8, // maxLevel - 10, // leafsize - 3.0 // duplicity - ) - ); - } - - return *boundaryTreePtr_; -} - - bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher) { // Find the cells the triangles of the surface are in. @@ -224,10 +169,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher) { // Search for nearest boundaryFace - ////- Search on all (including coupled) boundary faces - //const indexedOctree<treeDataFace>& bTree = meshSearcher.boundaryTree() //- Search on all non-coupled boundary faces - const indexedOctree<treeDataFace>& bTree = nonCoupledboundaryTree(); + const indexedOctree<treeDataFace>& bTree = + meshSearcher.nonCoupledBoundaryTree(); forAll(fc, triI) { diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H index ba53bd6241b..45d87dffaf8 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -169,9 +169,6 @@ private: // Private Member Functions - //- Get tree of all non-coupled boundary faces - const indexedOctree<treeDataFace>& nonCoupledboundaryTree() const; - //- Sample volume field onto surface faces template<class Type> tmp<Field<Type>> sampleOnFaces -- GitLab