Always compute bounding box of main grid and use OpenMP

This commit is contained in:
Magne Sjaastad 2024-01-31 12:58:03 +01:00
parent 5151717743
commit 661840f425
2 changed files with 33 additions and 8 deletions

View File

@ -288,6 +288,8 @@ void RigMainGrid::computeCachedData( std::string* aabbTreeInfo )
*aabbTreeInfo += "Cells per bounding box : " + std::to_string( cellsPerBoundingBox ) + "\n";
*aabbTreeInfo += m_cellSearchTree->info();
}
computeBoundingBox();
}
//--------------------------------------------------------------------------------------------------
@ -433,6 +435,35 @@ bool RigMainGrid::hasFaultWithName( const QString& name ) const
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMainGrid::computeBoundingBox()
{
m_boundingBox.reset();
const int numberOfThreads = RiaOpenMPTools::availableThreadCount();
std::vector<cvf::BoundingBox> threadBoundingBoxes( numberOfThreads );
#pragma omp parallel
{
int myThread = RiaOpenMPTools::currentThreadIndex();
// NB! We are inside a parallel section, do not use "parallel for" here
#pragma omp for
for ( long i = 0; i < static_cast<long>( m_nodes.size() ); i++ )
{
threadBoundingBoxes[myThread].add( m_nodes[i] );
}
}
for ( int i = 0; i < numberOfThreads; i++ )
{
m_boundingBox.add( threadBoundingBoxes[i] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -943,13 +974,6 @@ void RigMainGrid::buildCellSearchTreeOptimized( size_t cellsPerBoundingBox )
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigMainGrid::boundingBox() const
{
if ( m_boundingBox.isValid() ) return m_boundingBox;
for ( const auto& node : m_nodes )
{
m_boundingBox.add( node );
}
return m_boundingBox;
}

View File

@ -118,6 +118,7 @@ private:
void buildCellSearchTree();
void buildCellSearchTreeOptimized( size_t cellsPerBoundingBox );
bool hasFaultWithName( const QString& name ) const;
void computeBoundingBox();
static std::array<double, 6> defaultMapAxes();
@ -133,7 +134,7 @@ private:
cvf::Vec3d m_displayModelOffset;
cvf::ref<cvf::BoundingBoxTree> m_cellSearchTree;
mutable cvf::BoundingBox m_boundingBox;
cvf::BoundingBox m_boundingBox;
bool m_flipXAxis;
bool m_flipYAxis;