From 24a82f2d037ae356eb5e985cc627f9d06ee4e7ed Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 18 Aug 2011 12:28:44 +0100 Subject: [PATCH] ENH: treeDataCell: increase duplicity --- .../meshes/primitiveMesh/primitiveMesh.C | 2 +- .../basic/InteractionLists/InteractionLists.C | 4 +- src/meshTools/meshSearch/meshSearch.C | 65 ++++++++++++++----- src/meshTools/meshSearch/meshSearch.H | 17 ++++- .../calculateMeshToMeshAddressing.C | 2 +- 5 files changed, 69 insertions(+), 21 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C index cf433a9cb9f..07108b67c4f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C @@ -375,7 +375,7 @@ Foam::primitiveMesh::cellTree() const overallBb, 8, // maxLevel 10, // leafsize - 3.0 // duplicity + 5.0 // duplicity ); } diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index f8a36f656d0..572c66522eb 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -167,7 +167,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists() procBbRndExt, 8, // maxLevel, 10, // leafSize, - 100.0 + 100.0 // duplicity ); ril_.setSize(cellBbsToExchange.size()); @@ -386,7 +386,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists() procBbRndExt, 8, // maxLevel, 10, // leafSize, - 100.0 + 100.0 // duplicity ); rwfil_.setSize(wallFaceBbsToExchange.size()); diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index cb166a452df..115fc3272a0 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -30,7 +30,6 @@ License #include "demandDrivenData.H" #include "treeDataCell.H" #include "treeDataFace.H" -#include "treeDataPoint.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -508,6 +507,21 @@ Foam::meshSearch::meshSearch(const polyMesh& mesh, const bool faceDecomp) {} +// Construct with a custom bounding box +Foam::meshSearch::meshSearch +( + const polyMesh& mesh, + const treeBoundBox& bb, + const bool faceDecomp +) +: + mesh_(mesh), + faceDecomp_(faceDecomp) +{ + overallBbPtr_.reset(new treeBoundBox(bb)); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::meshSearch::~meshSearch() @@ -527,6 +541,21 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() // Construct tree // + if (!overallBbPtr_.valid()) + { + Random rndGen(261782); + overallBbPtr_.reset + ( + new treeBoundBox(mesh_.points()) + ); + + 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); + } + // all boundary faces (not just walls) labelList bndFaces(mesh_.nFaces()-mesh_.nInternalFaces()); forAll(bndFaces, i) @@ -534,12 +563,6 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() bndFaces[i] = mesh_.nInternalFaces() + i; } - treeBoundBox overallBb(mesh_.points()); - Random rndGen(123456); - overallBb = overallBb.extend(rndGen, 1E-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - boundaryTreePtr_.reset ( new indexedOctree<treeDataFace> @@ -550,7 +573,7 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() mesh_, bndFaces // boundary faces only ), - overallBb, // overall search domain + overallBbPtr_(), // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -567,13 +590,24 @@ const { if (!cellTreePtr_.valid()) { - treeBoundBox overallBb(mesh_.points()); + // + // Construct tree + // - Random rndGen(261782); + if (!overallBbPtr_.valid()) + { + Random rndGen(261782); + overallBbPtr_.reset + ( + new treeBoundBox(mesh_.points()) + ); - overallBb = overallBb.extend(rndGen, 1E-4); - overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); - overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + 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); + } cellTreePtr_.reset ( @@ -584,10 +618,10 @@ const false, // not cache bb mesh_ ), - overallBb, + overallBbPtr_(), 8, // maxLevel 10, // leafsize - 3.0 // duplicity + 6.0 // duplicity ) ); } @@ -904,6 +938,7 @@ void Foam::meshSearch::clearOut() { boundaryTreePtr_.clear(); cellTreePtr_.clear(); + overallBbPtr_.clear(); } diff --git a/src/meshTools/meshSearch/meshSearch.H b/src/meshTools/meshSearch/meshSearch.H index 0488b64684b..bf39bca8ff2 100644 --- a/src/meshTools/meshSearch/meshSearch.H +++ b/src/meshTools/meshSearch/meshSearch.H @@ -49,6 +49,7 @@ class polyMesh; class treeDataCell; class treeDataFace; template<class Type> class indexedOctree; +class treeBoundBox; /*---------------------------------------------------------------------------*\ Class meshSearch Declaration @@ -64,8 +65,10 @@ class meshSearch //- Whether to use face decomposition for all geometric tests const bool faceDecomp_; - //- demand driven octrees + //- data bounding box + mutable autoPtr<treeBoundBox> overallBbPtr_; + //- demand driven octrees mutable autoPtr<indexedOctree<treeDataFace> > boundaryTreePtr_; mutable autoPtr<indexedOctree<treeDataCell> > cellTreePtr_; @@ -163,9 +166,19 @@ public: // Constructors - //- Construct from components + //- Construct from components. Constructs bb slightly bigger than + // mesh points bb. meshSearch(const polyMesh& mesh, const bool faceDecomp = true); + //- 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. + meshSearch + ( + const polyMesh& mesh, + const treeBoundBox& bb, + const bool faceDecomp = true + ); //- Destructor ~meshSearch(); diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshAddressing.C b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshAddressing.C index 3b600120ed1..a1566c28b3f 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshAddressing.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshAddressing.C @@ -106,7 +106,7 @@ void Foam::meshToMesh::calcAddressing() shiftedBb, // overall bounding box 8, // maxLevel 10, // leafsize - 3.0 // duplicity + 6.0 // duplicity ); if (debug) -- GitLab