From a6c0146d2933e67f7da03abce7ff0938481c678b Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Thu, 3 Oct 2024 02:18:57 +0200 Subject: [PATCH] Work in progress --- .../FileInterface/RifReaderOpmCommonActive.cpp | 8 +++++++- ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp | 11 +++++++++++ ApplicationLibCode/ReservoirDataModel/RigGridBase.h | 1 + ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp | 6 +++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index e748f0fadf..a68a123e7d 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -162,6 +162,12 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) { + RiaLogging::info( + QString( "Loading %0 active of %1 total cells in LGR grid %2." ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalActiveCells() ) ) ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalNumberOfCells() ) ) ) + .arg( lgrIdx + 1 ) ); + RigGridBase* parentGrid = hasParentInfo ? activeGrid->gridByName( lgr_parent_names[lgrIdx] ) : activeGrid; RigLocalGrid* localGrid = static_cast( activeGrid->gridById( lgrIdx + 1 ) ); @@ -325,7 +331,7 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa const auto newCellCount = cellStartIndex + cellCount + 1; activeGrid->reservoirCells().resize( newCellCount, defaultCell ); activeGrid->reservoirCells()[newCellCount - 1].setInvalid( true ); - activeGrid->nodes().resize( ( newCellCount ) * 8, cvf::Vec3d( 0, 0, 0 ) ); + activeGrid->nodes().resize( (newCellCount)*8, cvf::Vec3d( 0, 0, 0 ) ); auto& riNodes = activeGrid->nodes(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index 00579e1c42..66ef5f6e6c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -448,6 +448,17 @@ size_t RigGridBase::localCellIndexToNative( size_t gridLocalCellIndex ) const return m_indexToGlobalStartOfCells + gridLocalCellIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigGridBase::localNativeCellIndexToNative( size_t nativeLocalCellIndex ) const +{ + if ( !m_mainGrid ) return nativeLocalCellIndex; + + const auto nativeStartIdx = m_mainGrid->globalCellIndexToNative( m_indexToGlobalStartOfCells ); + return nativeStartIdx + nativeLocalCellIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index a512e25230..6f35172464 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -74,6 +74,7 @@ public: void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const override; size_t localCellIndexToNative( size_t gridLocalCellIndex ) const; + size_t localNativeCellIndexToNative( size_t nativeLocalCellIndex ) const; void setIndexToGlobalStartOfCells( size_t indexToGlobalStartOfCells ) { m_indexToGlobalStartOfCells = indexToGlobalStartOfCells; } void setGridIndex( size_t index ) { m_gridIndex = index; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp index 26c3d6c0a3..ead51c149a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp @@ -138,7 +138,7 @@ const RigCell& RigMainGrid::cellByGridAndGridLocalCellIdx( size_t gridIdx, size_ //-------------------------------------------------------------------------------------------------- size_t RigMainGrid::reservoirCellIndexByGridAndGridLocalCellIndex( size_t gridIdx, size_t gridLocalCellIdx ) const { - return gridByIndex( gridIdx )->reservoirCellIndex( gridLocalCellIdx ); + return gridByIndex( gridIdx )->localCellIndexToNative( gridLocalCellIdx ); } //-------------------------------------------------------------------------------------------------- @@ -588,7 +588,7 @@ void RigMainGrid::addUnNamedFaultFaces( int global continue; } - neighborReservoirCellIdx = hostGrid->reservoirCellIndex( nativeNeighborGridCellIdx ); + neighborReservoirCellIdx = hostGrid->localCellIndexToNative( nativeNeighborGridCellIdx ); if ( cell( neighborReservoirCellIdx ).isInvalid() ) { continue; @@ -943,7 +943,7 @@ void RigMainGrid::buildCellSearchTreeOptimized( size_t cellsPerBoundingBox ) const auto& localCell = subGrid->cell( localIdx ); if ( localCell.mainGridCellIndex() == cellIdx ) { - aggregatedCellIndices.push_back( static_cast( subGrid->reservoirCellIndex( localIdx ) ) ); + aggregatedCellIndices.push_back( static_cast( subGrid->localCellIndexToNative( localIdx ) ) ); } } }