From e5006a62d73e6ded3158a3a3a24dd47d7dde471a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Nov 2022 12:15:08 +0100 Subject: [PATCH] ENH: use simpler boundBox handling - use default initialize boundBox instead of invertedBox - reset() instead of assigning from invertedBox - extend (three parameter version) and grow method - inflate(Random) instead of extend + re-assigning --- .../findCell-octree/Test-findCell-octree.C | 9 ++--- .../extrude/extrudeMesh/extrudeMesh.C | 3 +- .../backgroundMeshDecomposition.C | 4 +- .../conformalVoronoiMeshConformToSurface.C | 10 +---- .../conformationSurfaces.C | 7 +--- .../foamyHexMeshSurfaceSimplify_non_octree.C | 6 +-- .../manipulation/checkMesh/checkTopology.C | 15 ++++---- .../viewFactorsGen/searchingEngine.H | 5 +-- .../viewFactorsGen/searchingEngine_CGAL.H | 5 +-- .../surface/surfaceHookUp/surfaceHookUp.C | 5 +-- .../surfaceRedistributePar.C | 7 +--- src/OpenFOAM/algorithms/AABBTree/AABBTree.C | 4 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 7 +--- .../PatchTools/PatchToolsSearch.C | 2 +- .../polyMeshGeometry/polyMeshGeometry.C | 2 +- .../faMesh/faMeshDemandDrivenData.C | 22 +++-------- .../turbulentDFSEMInletFvPatchVectorField.C | 4 +- .../fieldExtents/fieldExtentsTemplates.C | 6 +-- .../field/streamLine/streamLineBase.C | 2 +- .../energySpectrum/energySpectrum.C | 10 ++--- ...surfaceDisplacementPointPatchVectorField.C | 5 +-- ...aceSlipDisplacementPointPatchVectorField.C | 7 ++-- .../basic/InteractionLists/InteractionLists.C | 38 +++++-------------- src/mesh/blockMesh/PDRblockMesh/PDRblock.C | 2 +- .../projectVertex/projectVertex.C | 2 +- .../meshRefinement/meshRefinement.C | 9 +++-- .../refinementFeatures/refinementFeatures.C | 8 +--- .../shellSurfaces/shellSurfaces.C | 2 +- .../snappySnapDriverFeature.C | 4 +- .../advancingFrontAMI/advancingFrontAMI.C | 2 +- .../faceAreaWeightAMI2D/faceAreaWeightAMI2D.C | 6 +-- .../extendedEdgeMesh/extendedEdgeMesh.C | 15 ++------ .../mappedPolyPatch/mappedPatchBase.C | 22 +++++------ src/meshTools/meshSearch/meshSearch.C | 38 +++++++------------ src/meshTools/processorLOD/cellBox/cellBox.C | 14 +++---- .../searchableExtrudedCircle.C | 25 +++++------- .../searchableSurfaceCollection.C | 4 +- .../searchableSurfacesQueries.C | 2 +- .../triSurfaceMesh/triSurfaceMesh.C | 27 ++++--------- .../triSurfaceSearch/triSurfaceRegionSearch.C | 6 +-- .../triSurfaceSearch/triSurfaceSearch.C | 8 ++-- .../inverseDistanceCellCellStencil.C | 17 +++------ .../trackingInverseDistanceCellCellStencil.C | 18 ++++----- .../distributedTriSurfaceMesh.C | 19 +++++----- .../exact/exactPatchDistMethod.C | 4 +- .../meshToMeshMethod/meshToMeshMethod.C | 8 +--- .../calculateMeshToMesh0Addressing.C | 25 +++++------- src/sampling/probes/patchProbes.C | 6 +-- .../sampledSet/cellCentre/cellCentreSet.C | 2 +- .../sampledSet/cellCentre/cellCentreSet.H | 2 +- .../sampledSet/patchCloud/patchCloudSet.C | 7 +--- .../sampledSet/patchSeed/patchSeedSet.C | 21 ++-------- .../sampledCuttingSurface.C | 2 +- .../sampledCuttingSurface.H | 2 +- .../sampledPlane/sampledPlane.C | 2 +- .../surface/isoSurface/isoSurfaceParams.C | 2 +- .../surface/isoSurface/isoSurfacePoint.C | 2 +- src/surfMesh/triSurface/triSurfaceIO.C | 2 +- .../solarLoad/faceReflecting/faceReflecting.C | 10 ++--- .../solarLoad/faceShading/faceShading.C | 10 ++--- 60 files changed, 189 insertions(+), 353 deletions(-) diff --git a/applications/test/findCell-octree/Test-findCell-octree.C b/applications/test/findCell-octree/Test-findCell-octree.C index aa8db650aa..2210753eda 100644 --- a/applications/test/findCell-octree/Test-findCell-octree.C +++ b/applications/test/findCell-octree/Test-findCell-octree.C @@ -53,20 +53,17 @@ int main(int argc, char *argv[]) const polyMesh::cellDecomposition decompMode = polyMesh::CELL_TETS; treeBoundBox meshBb(mesh.bounds()); + treeBoundBox shiftedBb(meshBb); // Calculate typical cell related size to shift bb by. scalar typDim = meshBb.avgDim()/(2.0*Foam::cbrt(scalar(mesh.nCells()))); - treeBoundBox shiftedBb - ( - meshBb.min(), - meshBb.max() + vector(typDim, typDim, typDim) - ); + shiftedBb.max() += vector::uniform(typDim); Info<< "Mesh" << endl; Info<< " bounding box : " << meshBb << endl; Info<< " bounding box (shifted) : " << shiftedBb << endl; - Info<< " typical dimension : " << shiftedBb.typDim() << endl; + Info<< " typical dimension : " << shiftedBb.avgDim() << endl; Info<< "Initialised mesh in " << runTime.cpuTimeIncrement() << " s" << endl; diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index cd84e849cc..7ea12e1f2a 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -890,11 +890,10 @@ int main(int argc, char *argv[]) const boundBox& bb = mesh.bounds(); - const vector span = bb.span(); const scalar mergeDim = mergeTol * bb.minDim(); Info<< "Mesh bounding box : " << bb << nl - << " with span : " << span << nl + << " with span : " << bb.span() << nl << "Merge distance : " << mergeDim << nl << endl; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index ad3db870f4..a224a42ebd 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -577,7 +577,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // // weightEstimate += sampleVol/pow3(s); // } // -// if (sqr(spanScale_)*sqr(minCellSize) < magSqr(cellBb.span())) +// if (sqr(spanScale_)*sqr(minCellSize) < cellBb.magSqr()) // { // return true; // } @@ -695,7 +695,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() Pstream::allGatherList(allBackgroundMeshBounds_); // find global bounding box - globalBackgroundBounds_ = treeBoundBox(boundBox::invertedBox); + globalBackgroundBounds_.reset(); forAll(allBackgroundMeshBounds_, proci) { globalBackgroundBounds_.add(allBackgroundMeshBounds_[proci]); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 8591f6bb0c..57bcc5f761 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1965,12 +1965,9 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4, ROOTVSMALL) ); - overallBb.min() -= Foam::point::uniform(ROOTVSMALL); - overallBb.max() += Foam::point::uniform(ROOTVSMALL); - edgeLocationTreePtr_.reset ( new dynamicIndexedOctree @@ -1992,12 +1989,9 @@ void Foam::conformalVoronoiMesh::buildSurfacePtLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4, ROOTVSMALL) ); - overallBb.min() -= Foam::point::uniform(ROOTVSMALL); - overallBb.max() += Foam::point::uniform(ROOTVSMALL); - surfacePtLocationTreePtr_.reset ( new dynamicIndexedOctree diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index a52d0c6dcc..57cb21f66e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -564,12 +564,9 @@ Foam::conformationSurfaces::conformationSurfaces // Extend the global bounds to stop the bound box sitting on the surfaces // to be conformed to - //globalBounds_ = globalBounds_.extend(rndGen, 1e-4); + //globalBounds_.inflate(rndGen, 1e-4); - vector newSpan = 1e-4*globalBounds_.span(); - - globalBounds_.min() -= newSpan; - globalBounds_.max() += newSpan; + globalBounds_.grow(1e-4*globalBounds_.span()); // Look at all surfaces at determine whether the locationInMesh point is // inside or outside each, to establish a signature for the domain to be diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C index 1cfd57f9e8..442c83c700 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C @@ -122,11 +122,7 @@ int main(int argc, char *argv[]) // Extend treeBoundBox bb = geometryToConformTo.globalBounds(); - { - const vector smallVec = 0.1*bb.span(); - bb.min() -= smallVec; - bb.max() += smallVec; - } + bb.grow(0.1*bb.span()); Info<< "Meshing to bounding box " << bb << nl << endl; diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index 8aa4e36325..f461e45c43 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -871,17 +871,16 @@ Foam::label Foam::checkTopology Info<< " " << setw(20) << "PointZone" << setw(8) << "Points" - << "BoundingBox" << endl; + << "BoundingBox" << nl; for (const auto& zone : pointZones) { - boundBox bb; - for (const label pointi : zone) - { - bb.add(mesh.points()[pointi]); - } - - bb.reduce(); // Global min/max + boundBox bb + ( + mesh.points(), + static_cast(zone), + true // Reduce (global min/max) + ); Info<< " " << setw(20) << zone.name() diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H index df38326ded..39664a65ad 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H @@ -4,10 +4,7 @@ Random rndGen(653213); List meshBb ( 1, - treeBoundBox - ( - boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H index 796e2a3dc3..66375be8b3 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H @@ -4,10 +4,7 @@ Random rndGen(653213); List meshBb ( 1, - treeBoundBox - ( - boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index bc99d0e172..955680be35 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -178,12 +178,9 @@ void createBoundaryEdgeTrees // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(UList(surf.localPoints())).extend(rndGen, 1e-4) + treeBoundBox(surf.localPoints()).extend(rndGen, 1e-4, ROOTVSMALL) ); - bb.min() -= point::uniform(ROOTVSMALL); - bb.max() += point::uniform(ROOTVSMALL); - bEdgeTrees.set ( surfI, diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index 3b8552ea55..d5d887d973 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -193,10 +193,7 @@ int main(int argc, char *argv[]) meshBb[Pstream::myProcNo()] = List ( 1, - treeBoundBox - ( - boundBox(mesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(mesh.points()).extend(rndGen, 1e-3) ); Pstream::allGatherList(meshBb); } @@ -243,7 +240,7 @@ int main(int argc, char *argv[]) } else { - bbs = List(1, treeBoundBox(boundBox::invertedBox)); + bbs = List(1, treeBoundBox::null()); } dictionary dict; diff --git a/src/OpenFOAM/algorithms/AABBTree/AABBTree.C b/src/OpenFOAM/algorithms/AABBTree/AABBTree.C index 4bd0231819..df4a4c48e4 100644 --- a/src/OpenFOAM/algorithms/AABBTree/AABBTree.C +++ b/src/OpenFOAM/algorithms/AABBTree/AABBTree.C @@ -195,10 +195,10 @@ void Foam::AABBTree::createBoxes // Assign the objects to min or max bin DynamicList