From 98598ba0bba6c71d89b8cf08c86e64af2d6e335f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 14 Nov 2022 16:28:12 +0100 Subject: [PATCH] ENH: use simpler constructor forms for treeData types --- .../Test-findSphereFeatureEdges-octree.C | 11 +---- .../surface/surfaceHookUp/surfaceHookUp.C | 11 ++--- .../polyMeshAdder/faceCoupleInfo.C | 15 +++---- .../refinementFeatures/refinementFeatures.C | 19 +++------ .../cellClassification/cellClassification.C | 2 +- .../extendedEdgeMesh/extendedEdgeMesh.C | 42 ++++++------------- .../mappedPolyPatch/mappedPatchBase.C | 16 +++---- src/meshTools/meshSearch/meshSearch.C | 18 +++----- .../searchableExtrudedCircle.C | 9 +--- .../triSurfaceMesh/triSurfaceMesh.C | 15 ++----- .../surfaceFeatures/surfaceFeatures.C | 34 ++++++--------- .../triSurfaceSearch/triSurfaceRegionSearch.C | 1 - .../triSurfaceSearch/triSurfaceSearch.C | 2 +- .../calculateMeshToMesh0Addressing.C | 4 +- src/sampling/probes/patchProbes.C | 8 +--- .../sampledSet/patchCloud/patchCloudSet.C | 8 +--- .../sampledSet/patchSeed/patchSeedSet.C | 8 +--- 17 files changed, 68 insertions(+), 155 deletions(-) diff --git a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C index c87cf7543a..2714b60a42 100644 --- a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C +++ b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C @@ -67,17 +67,10 @@ int main(int argc, char *argv[]) treeBoundBox bb(efem.points()); bb.grow(ROOTVSMALL); - labelList allEdges(identity(efem.edges().size())); - indexedOctree edgeTree ( - treeDataEdge - ( - false, // cachebb - efem.edges(), // edges - efem.points(), // points - allEdges // selected edges - ), + treeDataEdge(efem.edges(), efem.points()), // All edges + bb, // bb 8, // maxLevel 10, // leafsize diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index d5bc7d3e11..603f07b43f 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -166,11 +166,7 @@ void createBoundaryEdgeTrees // Boundary edges treeBoundaryEdges[surfI] = - identity - ( - surf.nEdges() - surf.nInternalEdges(), - surf.nInternalEdges() - ); + identity(surf.nBoundaryEdges(), surf.nInternalEdges()); Random rndGen(17301893); @@ -188,9 +184,8 @@ void createBoundaryEdgeTrees ( treeDataEdge ( - false, // cachebb - surf.edges(), // edges - surf.localPoints(), // points + surf.edges(), + surf.localPoints(), treeBoundaryEdges[surfI] // selected edges ), bb, // bb diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 477a492518..effa13b496 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -989,23 +989,20 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster ) { // Construct octree from all mesh0 boundary faces - labelList bndFaces - ( - identity(mesh0.nBoundaryFaces(), mesh0.nInternalFaces()) - ); - - treeBoundBox overallBb(mesh0.points()); Random rndGen(123456); + treeBoundBox overallBb(mesh0.points()); + indexedOctree tree ( - treeDataFace // all information needed to search faces + treeDataFace ( - false, // do not cache bb mesh0, - bndFaces // boundary faces only + // boundary faces only + identity(mesh0.nBoundaryFaces(), mesh0.nInternalFaces()) ), + overallBb.extend(rndGen, 1e-4), // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C index 02ace61b73..ce8eb29cfb 100644 --- a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C +++ b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C @@ -304,13 +304,8 @@ void Foam::refinementFeatures::buildTrees(const label featI) featI, new indexedOctree ( - treeDataEdge - ( - false, // do not cache bb - edges, - points, - identity(edges.size()) - ), + treeDataEdge(edges, points), // All edges + bb, // overall search domain 8, // maxLevel 10, // leafsize @@ -327,6 +322,7 @@ void Foam::refinementFeatures::buildTrees(const label featI) new indexedOctree ( treeDataPoint(points, featurePoints), + bb, // overall search domain 8, // maxLevel 10, // leafsize @@ -443,13 +439,8 @@ Foam::refinementFeatures::regionEdgeTrees() const featI, new indexedOctree ( - treeDataEdge - ( - false, // do not cache bb - edges, - points, - eMesh.regionEdges() - ), + treeDataEdge(edges, points, eMesh.regionEdges()), + bb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/cellClassification/cellClassification.C b/src/meshTools/cellClassification/cellClassification.C index af53b27d9a..23c30cc804 100644 --- a/src/meshTools/cellClassification/cellClassification.C +++ b/src/meshTools/cellClassification/cellClassification.C @@ -167,7 +167,7 @@ Foam::boolList Foam::cellClassification::markFaces indexedOctree faceTree ( - treeDataFace(false, mesh_, allFaces), + treeDataFace(mesh_, allFaces), allBb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index ec49e31603..4a224af40d 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -815,11 +815,8 @@ Foam::extendedEdgeMesh::pointTree() const ( new indexedOctree ( - treeDataPoint - ( - points(), - featurePointLabels - ), + treeDataPoint(points(), featurePointLabels), + bb, // bb 8, // maxLevel 10, // leafsize @@ -846,19 +843,12 @@ Foam::extendedEdgeMesh::edgeTree() const treeBoundBox(points()).extend(rndGen, 1e-4, ROOTVSMALL) ); - labelList allEdges(identity(edges().size())); - edgeTree_.reset ( new indexedOctree ( - treeDataEdge - ( - false, // cachebb - edges(), // edges - points(), // points - allEdges // selected edges - ), + treeDataEdge(edges(), points()), // All edges + bb, // bb 8, // maxLevel 10, // leafsize @@ -885,24 +875,22 @@ Foam::extendedEdgeMesh::edgeTreesByType() const treeBoundBox(points()).extend(rndGen, 1e-4, ROOTVSMALL) ); - labelListList sliceEdges(nEdgeTypes); + List sliceEdges(nEdgeTypes); // External edges - sliceEdges[0] = - identity((internalStart_ - externalStart_), externalStart_); + sliceEdges[0].reset(externalStart_, (internalStart_ - externalStart_)); // Internal edges - sliceEdges[1] = identity((flatStart_ - internalStart_), internalStart_); + sliceEdges[1].reset(internalStart_, (flatStart_ - internalStart_)); // Flat edges - sliceEdges[2] = identity((openStart_ - flatStart_), flatStart_); + sliceEdges[2].reset(flatStart_, (openStart_ - flatStart_)); // Open edges - sliceEdges[3] = identity((multipleStart_ - openStart_), openStart_); + sliceEdges[3].reset(openStart_, (multipleStart_ - openStart_)); // Multiple edges - sliceEdges[4] = - identity((edges().size() - multipleStart_), multipleStart_); + sliceEdges[4].reset(multipleStart_, (edges().size() - multipleStart_)); edgeTreesByType_.resize(nEdgeTypes); @@ -914,13 +902,9 @@ Foam::extendedEdgeMesh::edgeTreesByType() const i, new indexedOctree ( - treeDataEdge - ( - false, // cachebb - edges(), // edges - points(), // points - sliceEdges[i] // selected edges - ), + // Selected edges + treeDataEdge(edges(), points(), sliceEdges[i]), + bb, // bb 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 1db1558ce6..96fe5fb199 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -403,12 +403,8 @@ void Foam::mappedPatchBase::findLocalSamples indexedOctree boundaryTree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh, - identity(pp.range()) // boundary faces only - ), + treeDataFace(mesh, pp.range()), // Patch faces + patchBb, // overall search domain 8, // maxLevel 10, // leafsize @@ -479,11 +475,9 @@ void Foam::mappedPatchBase::findLocalSamples indexedOctree boundaryTree ( - treeDataPoint // all information needed to search faces - ( - mesh.points(), - pp.meshPoints() // selection of points to search on - ), + // Patch points + treeDataPoint(mesh.points(), pp.meshPoints()), + patchBb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index 347532c5dd..aa217ea4a7 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -628,12 +628,8 @@ Foam::meshSearch::boundaryTree() const ( new indexedOctree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh_, - bndFaces // boundary faces only - ), + treeDataFace(mesh_, bndFaces), // Boundary faces + dataBoundBox(), // overall search domain 8, // maxLevel 10, // leafsize @@ -668,18 +664,14 @@ Foam::meshSearch::nonCoupledBoundaryTree() const } } } - bndFaces.setSize(bndi); + bndFaces.resize(bndi); nonCoupledBoundaryTreePtr_.reset ( new indexedOctree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh_, - bndFaces // boundary faces only - ), + treeDataFace(mesh_, bndFaces), // Boundary faces + dataBoundBox(), // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C index 052d1c2838..46b3ea18e7 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C @@ -104,13 +104,8 @@ Foam::searchableExtrudedCircle::searchableExtrudedCircle ( new indexedOctree ( - treeDataEdge - ( - false, // do not cache bb - edges, - points, - identity(edges.size()) - ), + treeDataEdge(edges, points), // All edges + bb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 8a87d50dba..324f882ecc 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -768,10 +768,7 @@ Foam::triSurfaceMesh::edgeTree() const } // Boundary edges - labelList bEdges - ( - identity(nEdges() - nInternalEdges(), nInternalEdges()) - ); + const labelRange bEdges(nInternalEdges(), nBoundaryEdges()); treeBoundBox bb(point::zero); @@ -808,13 +805,9 @@ Foam::triSurfaceMesh::edgeTree() const ( new indexedOctree ( - treeDataEdge - ( - false, // cachebb - edges(), // edges - localPoints(), // points - bEdges // selected edges - ), + // Boundary edges + treeDataEdge(edges(), localPoints(), bEdges), + bb, // bb maxTreeDepth(), // maxLevel 10, // leafsize diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index c140fb39b6..022ed5cf24 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -1243,13 +1243,13 @@ Foam::Map Foam::surfaceFeatures::nearestSamples { // Build tree out of all samples. - // Note: cannot be done one the fly - gcc4.4 compiler bug. - treeBoundBox bb(samples); + // Define bound box here (gcc-4.8.5) + const treeBoundBox overallBb(samples); indexedOctree ppTree ( - treeDataPoint(samples), // all information needed to do checks - bb, // overall search domain + treeDataPoint(samples), + overallBb, 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -1330,13 +1330,13 @@ Foam::Map Foam::surfaceFeatures::nearestSamples scalar maxSearchSqr = max(maxDistSqr); - //Note: cannot be done one the fly - gcc4.4 compiler bug. - treeBoundBox bb(samples); + // Define bound box here (gcc-4.8.5) + const treeBoundBox overallBb(samples); indexedOctree ppTree ( - treeDataPoint(samples), // all information needed to do checks - bb, // overall search domain + treeDataPoint(samples), + overallBb, 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -1468,11 +1468,10 @@ Foam::Map Foam::surfaceFeatures::nearestEdges ( treeDataEdge ( - false, sampleEdges, samplePoints, selectedSampleEdges - ), // geometric info container for edges + ), treeBoundBox(samplePoints), // overall search domain 8, // maxLevel 10, // leafsize @@ -1626,11 +1625,10 @@ void Foam::surfaceFeatures::nearestSurfEdge ( treeDataEdge ( - false, surf_.edges(), localPoints, selectedEdges - ), // all information needed to do geometric checks + ), searchDomain, // overall search domain 8, // maxLevel 10, // leafsize @@ -1694,11 +1692,10 @@ void Foam::surfaceFeatures::nearestSurfEdge ( treeDataEdge ( - false, surf_.edges(), surf_.localPoints(), selectedEdges - ), // all information needed to do geometric checks + ), searchDomain, // overall search domain 8, // maxLevel 10, // leafsize @@ -1751,13 +1748,8 @@ void Foam::surfaceFeatures::nearestFeatEdge indexedOctree ppTree ( - treeDataEdge - ( - false, - edges, - points, - identity(edges.size()) - ), // all information needed to do geometric checks + treeDataEdge(edges, points), // All edges + searchDomain, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C index d58ec499bf..cb8a67db5c 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C @@ -165,7 +165,6 @@ Foam::triSurfaceRegionSearch::treeByRegion() const ( treeDataIndirectTriSurface ( - false, //true, indirectRegionPatches_[regionI], tolerance() ), diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 156b545dea..33fa142a61 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -240,7 +240,7 @@ Foam::triSurfaceSearch::tree() const ( new indexedOctree ( - treeDataTriSurface(false, surface_, tolerance_), + treeDataTriSurface(surface_, tolerance_), bb, maxTreeDepth_, // maxLevel 10, // leafsize diff --git a/src/sampling/meshToMesh0/calculateMeshToMesh0Addressing.C b/src/sampling/meshToMesh0/calculateMeshToMesh0Addressing.C index 82b62bbcac..bbc6858477 100644 --- a/src/sampling/meshToMesh0/calculateMeshToMesh0Addressing.C +++ b/src/sampling/meshToMesh0/calculateMeshToMesh0Addressing.C @@ -90,7 +90,7 @@ void Foam::meshToMesh0::calcAddressing() indexedOctree cellTree ( - treeDataCell(false, fromMesh_, polyMesh::CELL_TETS), + treeDataCell(fromMesh_, polyMesh::CELL_TETS), shiftedBb, // overall bounding box 8, // maxLevel 10, // leafsize @@ -162,7 +162,7 @@ void Foam::meshToMesh0::calcAddressing() // is not as big as all boundary faces indexedOctree faceTree ( - treeDataFace(false, fromPatch), + treeDataFace(fromPatch), shiftedBb, // overall search domain 12, // maxLevel 10, // leafsize diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index a69c416fbd..ff86016e41 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -93,12 +93,8 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) const indexedOctree boundaryTree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh, - bndFaces // patch faces only - ), + treeDataFace(mesh, bndFaces), // patch faces only + overallBb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/sampling/sampledSet/patchCloud/patchCloudSet.C b/src/sampling/sampledSet/patchCloud/patchCloudSet.C index 535551f582..aec479e9ce 100644 --- a/src/sampling/sampledSet/patchCloud/patchCloudSet.C +++ b/src/sampling/sampledSet/patchCloud/patchCloudSet.C @@ -94,12 +94,8 @@ void Foam::patchCloudSet::calcSamples indexedOctree patchTree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh(), - patchFaces // boundary faces only - ), + treeDataFace(mesh(), patchFaces), // boundary faces only + bb, // overall search domain 8, // maxLevel 10, // leafsize diff --git a/src/sampling/sampledSet/patchSeed/patchSeedSet.C b/src/sampling/sampledSet/patchSeed/patchSeedSet.C index 79d7ba62e3..825345a370 100644 --- a/src/sampling/sampledSet/patchSeed/patchSeedSet.C +++ b/src/sampling/sampledSet/patchSeed/patchSeedSet.C @@ -114,12 +114,8 @@ void Foam::patchSeedSet::calcSamples indexedOctree boundaryTree ( - treeDataFace // all information needed to search faces - ( - false, // do not cache bb - mesh(), - patchFaces // boundary faces only - ), + treeDataFace(mesh(), patchFaces), // boundary faces only + patchBb, // overall search domain 8, // maxLevel 10, // leafsize