diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 53c2324aedce2f3c2a0e24e491a2c91c54ddc66c..25d9188e015a631bc73e514c8be59097ae35c593 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -720,7 +720,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() Pstream::scatterList(allBackgroundMeshBounds_); // find global bounding box - globalBackgroundBounds_ = treeBoundBox::invertedBox; + globalBackgroundBounds_ = treeBoundBox(boundBox::invertedBox); forAll(allBackgroundMeshBounds_, proci) { globalBackgroundBounds_.add(allBackgroundMeshBounds_[proci]); diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.C b/src/OpenFOAM/meshes/boundBox/boundBox.C index 1a4baf4af930bf8c2f7448d610ad2e808664a9c7..08da5b207a67b60e698817b7837a44936be73699 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.C +++ b/src/OpenFOAM/meshes/boundBox/boundBox.C @@ -29,11 +29,17 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// (min,max) = (-VGREAT,+VGREAT) -const Foam::boundBox Foam::boundBox::greatBox(point::min, point::max); +const Foam::boundBox Foam::boundBox::greatBox +( + point::uniform(-ROOTVGREAT), + point::uniform(ROOTVGREAT) +); -// (min,max) = (+VGREAT,-VGREAT) -const Foam::boundBox Foam::boundBox::invertedBox(point::max, point::min); +const Foam::boundBox Foam::boundBox::invertedBox +( + point::uniform(ROOTVGREAT), + point::uniform(-ROOTVGREAT) +); const Foam::faceList Foam::boundBox::faces ({ @@ -47,25 +53,15 @@ const Foam::faceList Foam::boundBox::faces }); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -void Foam::boundBox::calculate(const UList<point>& points, bool doReduce) +Foam::boundBox::boundBox(const UList<point>& points, bool doReduce) +: + min_(invertedBox.min()), + max_(invertedBox.max()) { - if (points.empty()) - { - if (doReduce && Pstream::parRun()) - { - // Values that get overwritten by subsequent reduce operation - operator=(invertedBox); - } - } - else - { - operator=(invertedBox); - add(points); - } + add(points); - // Parallel reduction if (doReduce) { reduce(); @@ -73,24 +69,17 @@ void Foam::boundBox::calculate(const UList<point>& points, bool doReduce) } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::boundBox::boundBox(const UList<point>& points, bool doReduce) -: - min_(Zero), - max_(Zero) -{ - calculate(points, doReduce); -} - - Foam::boundBox::boundBox(const tmp<pointField>& tpoints, bool doReduce) : - min_(Zero), - max_(Zero) + min_(invertedBox.min()), + max_(invertedBox.max()) { - calculate(tpoints(), doReduce); - tpoints.clear(); + add(tpoints); + + if (doReduce) + { + reduce(); + } } @@ -101,24 +90,11 @@ Foam::boundBox::boundBox bool doReduce ) : - min_(Zero), - max_(Zero) + min_(invertedBox.min()), + max_(invertedBox.max()) { - if (points.empty() || indices.empty()) - { - if (doReduce && Pstream::parRun()) - { - // Values that get overwritten by subsequent reduce operation - operator=(invertedBox); - } - } - else - { - operator=(invertedBox); - add(points, indices); - } + add(points, indices); - // Parallel reduction if (doReduce) { reduce(); diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.H b/src/OpenFOAM/meshes/boundBox/boundBox.H index a7e6e569f40fbaf7099699178360837b82e66e1a..4a8351ad84684478e6347fac0f55583335964f49 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.H +++ b/src/OpenFOAM/meshes/boundBox/boundBox.H @@ -27,6 +27,11 @@ Class Description A bounding box defined in terms of the points at its extremities. +Note + When a bounding box is created without any points, it creates an inverted + bounding box. Points can be added later and the bounding box will grow to + include them. + \*---------------------------------------------------------------------------*/ #ifndef boundBox_H @@ -63,20 +68,14 @@ class boundBox //- Minimum and maximum points describing the bounding box point min_, max_; - // Private Member Functions - - //- Calculate the bounding box from the given points. - // Does parallel communication (doReduce = true) - void calculate(const UList<point>& points, bool doReduce = true); - public: // Static data members - //- A very large boundBox: min/max == -/+ VGREAT + //- A large boundBox: min/max == -/+ ROOTVGREAT static const boundBox greatBox; - //- A very large inverted boundBox: min/max == +/- VGREAT + //- A large inverted boundBox: min/max == +/- ROOTVGREAT static const boundBox invertedBox; //- Faces to point addressing, as per a 'hex' cell @@ -85,7 +84,7 @@ public: // Constructors - //- Construct null, setting points to zero + //- Construct without any points - an inverted bounding box inline boundBox(); //- Construct a bounding box containing a single initial point @@ -134,6 +133,9 @@ public: //- Bounding box is inverted, contains no points. inline bool empty() const; + //- Clear bounding box of all points - make it an inverted box + inline void clear(); + //- Minimum describing the bounding box inline const point& min() const; diff --git a/src/OpenFOAM/meshes/boundBox/boundBoxI.H b/src/OpenFOAM/meshes/boundBox/boundBoxI.H index 611130477ab166c788a022967604db4924ce5531..c6e668e41dafb18a62a25a7d08b62c4794c2baf7 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBoxI.H +++ b/src/OpenFOAM/meshes/boundBox/boundBoxI.H @@ -30,8 +30,8 @@ License inline Foam::boundBox::boundBox() : - min_(Zero), - max_(Zero) + min_(invertedBox.min()), + max_(invertedBox.max()) {} @@ -63,6 +63,13 @@ inline bool Foam::boundBox::empty() const } +inline void Foam::boundBox::clear() +{ + min_ = invertedBox.min(); + max_ = invertedBox.max(); +} + + inline const Foam::point& Foam::boundBox::min() const { return min_; diff --git a/src/OpenFOAM/meshes/boundBox/boundBoxTemplates.C b/src/OpenFOAM/meshes/boundBox/boundBoxTemplates.C index 0bb02715a8dbeac3e498cc709e73320f786f70eb..502d89ad5eeb4ae05073ea589f61fed36e634d59 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBoxTemplates.C +++ b/src/OpenFOAM/meshes/boundBox/boundBoxTemplates.C @@ -36,25 +36,11 @@ Foam::boundBox::boundBox bool doReduce ) : - min_(Zero), - max_(Zero) + min_(invertedBox.min()), + max_(invertedBox.max()) { - // a FixedList is never empty - if (points.empty()) - { - if (doReduce && Pstream::parRun()) - { - // Values that get overwritten by subsequent reduce operation - operator=(invertedBox); - } - } - else - { - operator=(invertedBox); - add(points, indices); - } + add(points, indices); - // Parallel reduction if (doReduce) { reduce(); diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C index 00af118874bb5d1133103ab037f7801e06ee9351..462c318755e603b05282db2e6829a5e63d60ac6b 100644 --- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C +++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C @@ -27,18 +27,6 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::treeBoundBox Foam::treeBoundBox::greatBox -( - point::uniform(-GREAT), - point::uniform(GREAT) -); - -const Foam::treeBoundBox Foam::treeBoundBox::invertedBox -( - point::uniform(GREAT), - point::uniform(-GREAT) -); - const Foam::faceList Foam::treeBoundBox::faces ({ face{0, 4, 6, 2}, // left diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H index 4a18d906ab61e4f28de49941ec0fbf25de346819..edc42983dfe38ad412d7954b29b6e6627a0690f9 100644 --- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H +++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H @@ -46,6 +46,11 @@ Description For the front plane add 4 to the point labels. +Note + When a bounding box is created without any points, it creates an inverted + bounding box. Points can be added later and the bounding box will grow to + include them. + SourceFiles treeBoundBoxI.H treeBoundBox.C @@ -93,12 +98,6 @@ public: // Static data members - //- As per boundBox::greatBox, but with GREAT instead of VGREAT - static const treeBoundBox greatBox; - - //- As per boundBox::invertedBox, but with GREAT instead of VGREAT - static const treeBoundBox invertedBox; - //- Bits used for octant/point coding. // Every octant/corner point is the combination of three faces. enum octantBit diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index cafa9d3bb7b61248c20f4d56bb5fcd9ea362df7a..0f18e2a0b0f93394767720909dcaf0e8c3bdd592 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -891,11 +891,11 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs // Find bounding box for all triangles on new distribution. - // Initialise to inverted box (GREAT, -GREAT) + // Initialise to inverted box List<List<treeBoundBox>> bbs(Pstream::nProcs()); forAll(bbs, procI) { - bbs[procI].setSize(1, treeBoundBox::invertedBox); + bbs[procI].setSize(1, treeBoundBox(boundBox::invertedBox)); } forAll(s, triI) diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index e550f43533c19b0535a55c2dd8816604e4e5f6ca..6fb89affa5f0f068c4875029813848076053bc77 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -69,7 +69,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) { // Collect mesh faces and bounding box labelList bndFaces(nFaces); - treeBoundBox overallBb(treeBoundBox::invertedBox); + treeBoundBox overallBb(boundBox::invertedBox); nFaces = 0; forAll(patchIDs, i) diff --git a/src/sampling/sampledSet/patchCloud/patchCloudSet.C b/src/sampling/sampledSet/patchCloud/patchCloudSet.C index c5833eeac7596a6030f326127963f30329d259ec..f2f401a778cca4cff49756d2367007eb3c29975e 100644 --- a/src/sampling/sampledSet/patchCloud/patchCloudSet.C +++ b/src/sampling/sampledSet/patchCloud/patchCloudSet.C @@ -74,7 +74,7 @@ void Foam::patchCloudSet::calcSamples labelList patchFaces(sz); sz = 0; - treeBoundBox bb(treeBoundBox::invertedBox); + treeBoundBox bb(boundBox::invertedBox); forAllConstIter(labelHashSet, patchSet_, iter) { const polyPatch& pp = mesh().boundaryMesh()[iter.key()];