diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 7889a6ea3..c55a00332 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -692,8 +692,6 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() // Overall bb treeBoundBox overallBb(boundaryFacesPtr_().localPoints()); - Random& rnd = rndGen_; - bFTreePtr_.reset ( new indexedOctree @@ -704,7 +702,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() boundaryFacesPtr_(), indexedOctree::perturbTol() ), - overallBb.extend(rnd, 1e-4), + overallBb.extend(1e-4), 10, // maxLevel 10, // leafSize 3.0 // duplicity diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 4036f750a..ba0f5ed19 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1978,12 +1978,9 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(1e-4) ); - overallBb.min() -= Foam::point(rootVSmall, rootVSmall, rootVSmall); - overallBb.max() += Foam::point(rootVSmall, rootVSmall, rootVSmall); - edgeLocationTreePtr_.reset ( new dynamicIndexedOctree @@ -2005,12 +2002,9 @@ void Foam::conformalVoronoiMesh::buildSurfacePtLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(1e-4) ); - overallBb.min() -= Foam::point(rootVSmall, rootVSmall, rootVSmall); - overallBb.max() += Foam::point(rootVSmall, rootVSmall, 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 7f5b8e7a0..5de4b45de 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -558,10 +558,7 @@ 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); - vector newSpan = 1e-4*globalBounds_.span(); - globalBounds_.min() -= newSpan; globalBounds_.max() += newSpan; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C index c41a8568e..b7e2a03db 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C @@ -919,11 +919,7 @@ List autoDensity::initialPoints() const else { // Extend the global box to move it off large plane surfaces - hierBB = geometryToConformTo().globalBounds().extend - ( - rndGen(), - 1e-6 - ); + hierBB = geometryToConformTo().globalBounds().extend(1e-6); } DynamicList initialPoints; diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H index 3711aff9b..4518cfc32 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H @@ -7,7 +7,7 @@ List meshBb treeBoundBox ( boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1e-3) + ).extend(1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index a376bf65c..074faecda 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -174,12 +174,9 @@ void createBoundaryEdgeTrees // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(UList(surf.localPoints())).extend(rndGen, 1e-4) + treeBoundBox(UList(surf.localPoints())).extend(1e-4) ); - bb.min() -= point(rootVSmall, rootVSmall, rootVSmall); - bb.max() += point(rootVSmall, rootVSmall, rootVSmall); - bEdgeTrees.set ( surfI, diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index e825a1397..ee419d0bc 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -144,18 +144,13 @@ int main(int argc, char *argv[]) #include "createPolyMesh.H" - Random rndGen(653213); - // Determine mesh bounding boxes: List> meshBb(Pstream::nProcs()); { meshBb[Pstream::myProcNo()] = List ( 1, - treeBoundBox - ( - boundBox(mesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(boundBox(mesh.points(), false)).extend(1e-3) ); Pstream::gatherList(meshBb); Pstream::scatterList(meshBb); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index c9a0011d4..5aca1df36 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -876,14 +876,6 @@ Foam::polyMesh::cellTree() const { if (cellTreePtr_.empty()) { - treeBoundBox overallBb(points()); - - static Random rndGen(261782); - - overallBb = overallBb.extend(rndGen, 1e-4); - overallBb.min() -= point(rootVSmall, rootVSmall, rootVSmall); - overallBb.max() += point(rootVSmall, rootVSmall, rootVSmall); - cellTreePtr_.reset ( new indexedOctree @@ -894,7 +886,7 @@ Foam::polyMesh::cellTree() const *this, CELL_TETS // use tet-decomposition for any inside test ), - overallBb, + treeBoundBox(points()).extend(1e-4), 8, // maxLevel 10, // leafsize 5.0 // duplicity diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H index 8c35577fd..3dcf163ff 100644 --- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H +++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H @@ -344,10 +344,9 @@ public: // 0 : none of the above. label distanceCmp(const point&, const treeBoundBox& other) const; - //- Return slightly wider bounding box - // Extends all dimensions with s*span*Random::scalar01() - // and guarantees in any direction s*mag(span) minimum width - inline treeBoundBox extend(Random&, const scalar s) const; + //- Return asymetrically extended bounding box, with guaranteed + // minimum width of s*mag(span) in any direction + inline treeBoundBox extend(const scalar s) const; // Write diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H index 3480eac00..a4c24794c 100644 --- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H +++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -312,27 +312,18 @@ inline void Foam::treeBoundBox::searchOrder } -//- Return slightly wider bounding box -inline Foam::treeBoundBox Foam::treeBoundBox::extend -( - Random& rndGen, - const scalar s -) const +inline Foam::treeBoundBox Foam::treeBoundBox::extend(const scalar s) const { + // Numbers that don't approximate rational fractions with which to make the + // box asymmetric. These are between one and two. + static const vector a = vector::uniform(sqrt(1.25) + 0.5); + static const vector b = vector::uniform(sqrt(2.0)); + treeBoundBox bb(*this); - vector newSpan = bb.span(); - - // Make 3D - scalar minSpan = s * Foam::mag(newSpan); - - for (direction dir = 0; dir < vector::nComponents; dir++) - { - newSpan[dir] = Foam::max(newSpan[dir], minSpan); - } - - bb.min() -= cmptMultiply(s * rndGen.vector01(), newSpan); - bb.max() += cmptMultiply(s * rndGen.vector01(), newSpan); + const scalar delta = s*Foam::mag(bb.span()); + bb.min() -= Foam::max(delta*a, vector::uniform(rootVSmall)); + bb.max() += Foam::max(delta*b, vector::uniform(rootVSmall)); return bb; } diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 57f7d25f8..b67eb1297 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -980,8 +980,6 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster treeBoundBox overallBb(mesh0.points()); - Random rndGen(123456); - indexedOctree tree ( treeDataFace // all information needed to search faces @@ -990,7 +988,7 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster mesh0, bndFaces // boundary faces only ), - overallBb.extend(rndGen, 1e-4), // overall search domain + overallBb.extend(1e-4), // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index b223232bd..f5bd5fd87 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,8 +39,6 @@ void Foam::InteractionLists::buildInteractionLists() Info<< "Building InteractionLists with interaction distance " << maxDistance_ << endl; - Random rndGen(419715); - const vector interactionVec = maxDistance_*vector::one; treeBoundBox procBb(treeBoundBox(mesh_.points())); @@ -158,7 +156,7 @@ void Foam::InteractionLists::buildInteractionLists() treeBoundBox procBbRndExt ( - treeBoundBox(mesh_.points()).extend(rndGen, 1e-4) + treeBoundBox(mesh_.points()).extend(1e-4) ); indexedOctree coupledPatchRangeTree diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 887ce8dd8..752da9f25 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -2402,13 +2402,10 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map) // Redistribute surface and any fields on it. { - Random rndGen(653213); - // Get local mesh bounding box. Single box for now. List meshBb(1); treeBoundBox& bb = meshBb[0]; - bb = treeBoundBox(mesh_.points()); - bb = bb.extend(rndGen, 1e-4); + bb = treeBoundBox(mesh_.points()).extend(1e-4); // Distribute all geometry (so refinementSurfaces and shellSurfaces) searchableSurfaces& geometry = diff --git a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C index d8bb33a50..e9091dc68 100644 --- a/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C +++ b/src/mesh/snappyHexMesh/refinementFeatures/refinementFeatures.C @@ -253,14 +253,9 @@ void Foam::refinementFeatures::buildTrees(const label featI) // Calculate bb of all points treeBoundBox bb(points); - // Random number generator. Bit dodgy since not exactly random ;-) - Random rndGen(65431); - // 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 = bb.extend(1e-4); edgeTrees_.set ( @@ -394,14 +389,9 @@ Foam::refinementFeatures::regionEdgeTrees() const // Calculate bb of all points treeBoundBox bb(points); - // Random number generator. Bit dodgy since not exactly random ;-) - Random rndGen(65431); - // 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 = bb.extend(1e-4); trees.set ( diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 8f7adad32..648253c86 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -2466,16 +2466,7 @@ void Foam::snappySnapDriver::reverseAttractMeshPoints // Get search domain and extend it a bit treeBoundBox bb(pp.localPoints()); - { - // Random number generator. Bit dodgy since not exactly random ;-) - Random rndGen(65431); - - // 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 = bb.extend(1e-4); // Collect candidate points for attraction DynamicList