#11088 Use non-optimized version for old projects to compute active cells BB

The performance to compute geometry BB for active cells has improved. The original code also set displayModelOffset based on the BB of active cells. To make sure that existing project files produce identically the the same, the non-optimized version is used in this case.
This commit is contained in:
Magne Sjaastad committed 2024-01-31 12:43:55 +01:00
1 parent 111eeb64b7
commit 5151717743
8 files changed
+97 -13

No files matched your search

@@ -322,7 +322,7 @@ void RicCreateTemporaryLgrFeature::computeCachedData( RimEclipseCase* eclipseCas
if ( eclipseCaseData )
{
eclipseCaseData->mainGrid()->computeCachedData();
eclipseCaseData->computeActiveCellBoundingBoxes();
eclipseCase->computeActiveCellsBoundingBox();
}
if ( cellResultsDataMatrix )
@@ -626,7 +626,7 @@ void RimEclipseCase::computeCachedData()
{
auto task = pInf.task( "", 1 );
rigEclipseCase->computeActiveCellBoundingBoxes();
computeActiveCellsBoundingBox();
}
{
@@ -771,6 +771,26 @@ void RimEclipseCase::createDisplayModelAndUpdateAllViews()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::computeActiveCellsBoundingBox()
{
if ( !eclipseCaseData() ) return;
bool useOptimizedVersion = true;
if ( auto proj = RimProject::current() )
{
if ( proj->isProjectFileVersionEqualOrOlderThan( "2023.12.0" ) )
{
useOptimizedVersion = false;
}
}
eclipseCaseData()->computeActiveCellBoundingBoxes( useOptimizedVersion );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -122,6 +122,7 @@ public:
void ensureFaultDataIsComputed();
bool ensureNncDataIsComputed();
void createDisplayModelAndUpdateAllViews();
void computeActiveCellsBoundingBox();
void setReaderSettings( std::shared_ptr<RifReaderSettings> readerSettings );
@@ -318,7 +318,7 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc
CVF_ASSERT( eclipseCaseData() );
CVF_ASSERT( readerInterface.notNull() );
eclipseCaseData()->computeActiveCellBoundingBoxes();
computeActiveCellsBoundingBox();
m_activeCellInfoIsReadFromFile = true;
@@ -247,7 +247,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
if ( i == 0 )
{
rimReservoir->eclipseCaseData()->computeActiveCellBoundingBoxes();
rimReservoir->computeActiveCellsBoundingBox();
}
}
}
@@ -375,7 +375,7 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases()
if ( i == 0 )
{
rimStaticsCase->eclipseCaseData()->computeActiveCellBoundingBoxes();
rimStaticsCase->computeActiveCellsBoundingBox();
}
}
}
@@ -432,7 +432,7 @@ RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createStatisticsCase( bool
if ( selectDefaultResults ) newStatisticsCase->populateResultSelectionAfterLoadingGrid();
newStatisticsCase->openEclipseGridFile();
newStatisticsCase->eclipseCaseData()->computeActiveCellBoundingBoxes();
newStatisticsCase->computeActiveCellsBoundingBox();
newStatisticsCase->selectAllTimeSteps();
return newStatisticsCase;
@@ -453,10 +453,14 @@ void RigEclipseCaseData::computeActiveCellIJKBBox()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::computeActiveCellBoundingBoxes()
void RigEclipseCaseData::computeActiveCellBoundingBoxes( bool useOptimizedVersion )
{
computeActiveCellIJKBBox();
computeActiveCellsGeometryBoundingBox();
if ( useOptimizedVersion )
computeActiveCellsGeometryBoundingBoxOptimized();
else
computeActiveCellsGeometryBoundingBoxSlow();
}
//--------------------------------------------------------------------------------------------------
@@ -627,7 +631,7 @@ bool RigEclipseCaseData::hasFractureResults() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxSlow()
{
if ( m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull() )
{
@@ -646,6 +650,60 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
activeInfos[0] = m_fractureActiveCellInfo.p();
activeInfos[1] = m_activeCellInfo.p(); // Last, to make this bb.min become display offset
cvf::BoundingBox bb;
for ( int acIdx = 0; acIdx < 2; ++acIdx )
{
bb.reset();
if ( m_mainGrid->nodes().empty() )
{
bb.add( cvf::Vec3d::ZERO );
}
else
{
std::array<cvf::Vec3d, 8> hexCorners;
for ( size_t i = 0; i < m_mainGrid->cellCount(); i++ )
{
if ( activeInfos[acIdx]->isActive( i ) )
{
m_mainGrid->cellCornerVertices( i, hexCorners.data() );
for ( const auto& corner : hexCorners )
{
bb.add( corner );
}
}
}
}
activeInfos[acIdx]->setGeometryBoundingBox( bb );
}
// This design choice is unfortunate, as the bounding box of active cells can be computed in different ways.
// Must keep the code to make sure existing projects display 3D model at the same location in the scene.
m_mainGrid->setDisplayModelOffset( bb.min() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxOptimized()
{
if ( m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull() )
{
return;
}
if ( m_mainGrid.isNull() )
{
cvf::BoundingBox bb;
m_activeCellInfo->setGeometryBoundingBox( bb );
m_fractureActiveCellInfo->setGeometryBoundingBox( bb );
return;
}
RigActiveCellInfo* activeInfos[2];
activeInfos[0] = m_fractureActiveCellInfo.p();
activeInfos[1] = m_activeCellInfo.p();
cvf::BoundingBox bb;
for ( int acIdx = 0; acIdx < 2; ++acIdx )
{
@@ -682,7 +740,10 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
activeInfos[acIdx]->setGeometryBoundingBox( bb );
}
m_mainGrid->setDisplayModelOffset( bb.min() );
auto bbMainGrid = m_mainGrid->boundingBox();
// Use center of bounding box as display offset. This point will be stable and independent of the active cell bounding box.
m_mainGrid->setDisplayModelOffset( bbMainGrid.center() );
}
//--------------------------------------------------------------------------------------------------
@@ -103,7 +103,7 @@ public:
const RigWellResultPoint& sourceWellCellResult,
const RigWellResultPoint& otherWellCellResult ) const;
void computeActiveCellBoundingBoxes();
void computeActiveCellBoundingBoxes( bool useOptimizedVersion );
RiaDefines::EclipseUnitSystem unitsType() const { return m_unitsType; }
void setUnitsType( RiaDefines::EclipseUnitSystem unitsType ) { m_unitsType = unitsType; }
@@ -126,7 +126,8 @@ public:
private:
void computeActiveCellIJKBBox();
void computeWellCellsPrGrid();
void computeActiveCellsGeometryBoundingBox();
void computeActiveCellsGeometryBoundingBoxSlow();
void computeActiveCellsGeometryBoundingBoxOptimized();
const RigFormationNames* activeFormationNames() const;
@@ -159,7 +159,8 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase )
activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->globalCellArray().size() );
activeCellInfo->computeDerivedData();
eclipseCase->computeActiveCellBoundingBoxes();
bool useOptimizedVersion = true;
eclipseCase->computeActiveCellBoundingBoxes( useOptimizedVersion );
}
//--------------------------------------------------------------------------------------------------