mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Build cell aabb search tree when required
This is a follow-up to the fix where the assert was removed in 9a71abd8af.
This fix will make sure that the search tree always is created when findIntersectingCells() is called.
This commit is contained in:
@@ -274,25 +274,7 @@ void RigMainGrid::computeCachedData( std::string* aabbTreeInfo )
|
||||
initAllSubCellsMainGridCellIndex();
|
||||
|
||||
m_cellSearchTree = nullptr;
|
||||
|
||||
const double maxNumberOfLeafNodes = 4000000;
|
||||
const double factor = std::ceil( cellCount() / maxNumberOfLeafNodes );
|
||||
const size_t cellsPerBoundingBox = std::max( size_t( 1 ), static_cast<size_t>( factor ) );
|
||||
|
||||
if ( cellsPerBoundingBox > 1 )
|
||||
{
|
||||
buildCellSearchTreeOptimized( cellsPerBoundingBox );
|
||||
}
|
||||
else
|
||||
{
|
||||
buildCellSearchTree();
|
||||
}
|
||||
|
||||
if ( aabbTreeInfo )
|
||||
{
|
||||
*aabbTreeInfo += "Cells per bounding box : " + std::to_string( cellsPerBoundingBox ) + "\n";
|
||||
*aabbTreeInfo += m_cellSearchTree->info();
|
||||
}
|
||||
doBuildCellSearchTree( aabbTreeInfo );
|
||||
|
||||
computeBoundingBox();
|
||||
}
|
||||
@@ -832,6 +814,11 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace( size_t reservoir
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RigMainGrid::findIntersectingCells( const cvf::BoundingBox& inputBB ) const
|
||||
{
|
||||
if ( m_cellSearchTree.isNull() )
|
||||
{
|
||||
doBuildCellSearchTree();
|
||||
}
|
||||
|
||||
std::vector<size_t> cellIndices;
|
||||
if ( m_cellSearchTree.notNull() )
|
||||
{
|
||||
@@ -843,7 +830,32 @@ std::vector<size_t> RigMainGrid::findIntersectingCells( const cvf::BoundingBox&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::buildCellSearchTree()
|
||||
void RigMainGrid::doBuildCellSearchTree( std::string* aabbTreeInfo ) const
|
||||
{
|
||||
const double maxNumberOfLeafNodes = 4000000;
|
||||
const double factor = std::ceil( cellCount() / maxNumberOfLeafNodes );
|
||||
const size_t cellsPerBoundingBox = std::max( size_t( 1 ), static_cast<size_t>( factor ) );
|
||||
|
||||
if ( cellsPerBoundingBox > 1 )
|
||||
{
|
||||
buildCellSearchTreeOptimized( cellsPerBoundingBox );
|
||||
}
|
||||
else
|
||||
{
|
||||
buildCellSearchTree();
|
||||
}
|
||||
|
||||
if ( aabbTreeInfo )
|
||||
{
|
||||
*aabbTreeInfo += "Cells per bounding box : " + std::to_string( cellsPerBoundingBox ) + "\n";
|
||||
*aabbTreeInfo += m_cellSearchTree->info();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::buildCellSearchTree() const
|
||||
{
|
||||
if ( m_cellSearchTree.isNull() )
|
||||
{
|
||||
@@ -906,7 +918,7 @@ void RigMainGrid::buildCellSearchTree()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigMainGrid::buildCellSearchTreeOptimized( size_t cellsPerBoundingBox )
|
||||
void RigMainGrid::buildCellSearchTreeOptimized( size_t cellsPerBoundingBox ) const
|
||||
{
|
||||
int threadCount = RiaOpenMPTools::availableThreadCount();
|
||||
|
||||
|
||||
@@ -130,16 +130,18 @@ protected: // only for use by file readers and internal services. TODO: replace
|
||||
std::vector<RigCell>& reservoirCells();
|
||||
const std::vector<RigCell>& reservoirCells() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
void initAllSubCellsMainGridCellIndex();
|
||||
void buildCellSearchTree();
|
||||
void buildCellSearchTreeOptimized( size_t cellsPerBoundingBox );
|
||||
bool hasFaultWithName( const QString& name ) const;
|
||||
void computeBoundingBox();
|
||||
|
||||
static std::array<double, 6> defaultMapAxes();
|
||||
|
||||
protected:
|
||||
void doBuildCellSearchTree( std::string* aabbTreeInfo = nullptr ) const;
|
||||
void buildCellSearchTree() const;
|
||||
void buildCellSearchTreeOptimized( size_t cellsPerBoundingBox ) const;
|
||||
|
||||
private:
|
||||
std::vector<cvf::Vec3d> m_nodes; ///< Global vertex table
|
||||
std::vector<RigCell> m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's)
|
||||
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
|
||||
@@ -149,9 +151,8 @@ protected:
|
||||
cvf::ref<RigNNCData> m_nncData;
|
||||
cvf::ref<RigFaultsPrCellAccumulator> m_faultsPrCellAcc;
|
||||
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
cvf::ref<cvf::BoundingBoxTree> m_cellSearchTree;
|
||||
cvf::BoundingBox m_boundingBox;
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
cvf::BoundingBox m_boundingBox;
|
||||
|
||||
bool m_flipXAxis;
|
||||
bool m_flipYAxis;
|
||||
@@ -161,6 +162,7 @@ protected:
|
||||
|
||||
bool m_dualPorosity;
|
||||
|
||||
mutable bool m_isFaceNormalsOutwards;
|
||||
mutable bool m_isFaceNormalsOutwardsComputed;
|
||||
mutable bool m_isFaceNormalsOutwards;
|
||||
mutable bool m_isFaceNormalsOutwardsComputed;
|
||||
mutable cvf::ref<cvf::BoundingBoxTree> m_cellSearchTree;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user