From 99fa28f284a8511f4c4e348d3ce8353f65a4a671 Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Wed, 11 Sep 2024 18:18:07 +0200 Subject: [PATCH] Work in progress --- .../RicWellPathExportMswCompletionsImpl.cpp | 2 +- .../RifReaderOpmCommonActive.cpp | 4 +-- .../Completions/RimFractureContainment.cpp | 6 ++-- .../RigFaultDistanceResultCalculator.cpp | 13 ++++--- .../RigIndexIjkResultCalculator.cpp | 10 +++--- .../RigOilVolumeResultCalculator.cpp | 5 +-- .../ReservoirDataModel/RigActiveCellGrid.cpp | 36 +++++++++++++++++-- .../ReservoirDataModel/RigActiveCellGrid.h | 7 ++-- .../RigCaseCellResultsData.cpp | 35 +++++++++--------- .../RigCaseToCaseCellMapper.cpp | 4 +-- .../RigCaseToCaseCellMapperTools.cpp | 2 +- .../RigCaseToCaseRangeFilterMapper.cpp | 4 +-- .../RigCellFaceGeometryTools.cpp | 12 +++---- .../RigEclipseWellLogExtractor.cpp | 4 +-- .../ReservoirDataModel/RigGridBase.cpp | 33 ++++++++--------- .../ReservoirDataModel/RigGridBase.h | 21 ++++++++--- .../ReservoirDataModel/RigMainGrid.cpp | 20 ++--------- .../ReservoirDataModel/RigMainGrid.h | 2 -- .../ReservoirDataModel/RigNNCData.cpp | 4 +-- ...igNumberOfFloodedPoreVolumesCalculator.cpp | 9 +++-- .../RigReservoirBuilder.cpp | 12 +++---- .../RigReservoirBuilderMock.cpp | 14 ++++---- .../RigStimPlanModelTools.cpp | 4 +-- .../SocketInterface/RiaCaseInfoCommands.cpp | 14 ++++---- .../SocketInterface/RiaGeometryCommands.cpp | 12 +++---- .../SocketInterface/RiaNNCCommands.cpp | 4 +-- .../RiaPropertyDataCommands.cpp | 2 +- .../UnitTests/RigWellLogExtractor-Test.cpp | 4 +-- .../UserInterface/RiuResultTextBuilder.cpp | 10 +++--- .../UserInterface/RiuViewerCommands.cpp | 2 +- .../cvfStructGridGeometryGenerator.cpp | 1 + GrpcInterface/RiaGrpcCaseService.cpp | 8 ++--- GrpcInterface/RiaGrpcNNCPropertiesService.cpp | 4 +-- GrpcInterface/RiaGrpcPropertiesService.cpp | 2 +- 34 files changed, 174 insertions(+), 152 deletions(-) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 07578d8a8c..201006edd4 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -694,7 +694,7 @@ void RicWellPathExportMswCompletionsImpl::generateFishbonesMswExportInfo( const for ( auto intersectionIndex : indices ) { auto intersection = filteredIntersections[intersectionIndex]; - // if ( intersection.globCellIndex >= mainGrid->globalCellArray().size() ) continue; + if ( intersection.globCellIndex >= mainGrid->globalCellCount() ) continue; size_t localGridCellIndex = 0u; const RigGridBase* localGrid = diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index 953c4a6090..29668c2d1f 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -238,7 +238,7 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa auto riReservoirIndex = activeGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); RigCell& cell = activeGrid->cell( riReservoirIndex ); - auto actualIndex = activeGrid->globalToActualCellIndex( riReservoirIndex ); + auto nativeIndex = activeGrid->globalCellIndexToNative( riReservoirIndex ); cell.setGridLocalCellIndex( riReservoirIndex ); cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T ); @@ -249,7 +249,7 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa opmMainGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ ); // Each cell has 8 nodes, use active cell index and multiply to find first node index for cell - auto riNodeStartIndex = actualIndex * 8; + auto riNodeStartIndex = nativeIndex * 8; for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ ) { diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp index 11cd103de0..a280312c56 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -93,10 +93,10 @@ bool RimFractureContainment::isEclipseCellOpenForFlow( const RigMainGrid* m { CVF_ASSERT( mainGrid ); - // if ( globalCellIndex >= mainGrid->globalCellArray().size() ) return false; + if ( globalCellIndex >= mainGrid->globalCellCount() ) return false; - auto cell = mainGrid->cell( globalCellIndex ); - auto mainGridCellIndex = cell.mainGridCellIndex(); + auto& cell = mainGrid->cell( globalCellIndex ); + auto mainGridCellIndex = cell.mainGridCellIndex(); size_t i, j, k; mainGrid->ijkFromCellIndex( mainGridCellIndex, &i, &j, &k ); diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp index c0f6832a2a..9b28ae145d 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp @@ -78,10 +78,9 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& if ( !shouldCompute ) return; - const std::vector& globalCellArray = m_resultsData->m_ownerMainGrid->globalCellArray(); - const auto grid = m_resultsData->m_ownerMainGrid; + const auto grid = m_resultsData->m_ownerMainGrid; - long long numCells = static_cast( m_resultsData->m_ownerMainGrid->cellCount() ); + long long numCells = static_cast( grid->cellCount() ); std::vector faceTypes = cvf::StructGridInterface::validFaceTypes(); @@ -91,7 +90,7 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& { if ( m_resultsData->activeCellInfo()->isActive( cellIdx ) ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = grid->cell( cellIdx ); for ( auto faceType : faceTypes ) { if ( m_resultsData->m_ownerMainGrid->findFaultFromCellIndexAndCellFace( cellIdx, faceType ) ) @@ -119,13 +118,13 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& searchTree->buildTreeFromBoundingBoxes( faceBBs, &faceIndicesForBoundingBoxes ); } - const auto nodes = m_resultsData->m_ownerMainGrid->nodes(); - const auto mainGridBB = m_resultsData->m_ownerMainGrid->boundingBox(); + const auto& nodes = m_resultsData->m_ownerMainGrid->nodes(); + const auto mainGridBB = m_resultsData->m_ownerMainGrid->boundingBox(); #pragma omp parallel for for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = grid->nativeCell( cellIdx ); size_t resultIndex = cellIdx; if ( resultIndex == cvf::UNDEFINED_SIZE_T || !m_resultsData->activeCellInfo()->isActive( cellIdx ) ) continue; diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp index 149acb395f..e97961263a 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp @@ -98,14 +98,14 @@ void RigIndexIjkResultCalculator::calculate( const RigEclipseResultAddress& resV if ( !( computeIndexI || computeIndexJ || computeIndexK ) ) return; - const std::vector& globalCellArray = m_resultsData->m_ownerMainGrid->globalCellArray(); - long long numCells = static_cast( globalCellArray.size() ); + auto mainGrid = m_resultsData->m_ownerMainGrid; + long long numCells = mainGrid->cellCount(); #pragma omp parallel for - for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ ) + for ( long long nativeCellIdx = 0; nativeCellIdx < numCells; nativeCellIdx++ ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = mainGrid->nativeCell( nativeCellIdx ); - size_t resultIndex = cellIdx; + size_t resultIndex = nativeCellIdx; if ( resultIndex == cvf::UNDEFINED_SIZE_T ) continue; bool isTemporaryGrid = cell.hostGrid()->isTempGrid(); diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp index 676104b3e3..dce4dfbc3b 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp @@ -66,6 +66,8 @@ void RigOilVolumeResultCalculator::calculate( const RigEclipseResultAddress& res false ); m_resultsData->m_cellScalarResults[oilVolIdx].resize( m_resultsData->maxTimeStepCount() ); + auto mainGrid = m_resultsData->m_ownerMainGrid; + size_t cellResultCount = m_resultsData->m_activeCellInfo->reservoirActiveCellCount(); for ( size_t timeStepIdx = 0; timeStepIdx < m_resultsData->maxTimeStepCount(); timeStepIdx++ ) { @@ -74,8 +76,7 @@ void RigOilVolumeResultCalculator::calculate( const RigEclipseResultAddress& res oilVolumeResults.resize( cellResultCount, 0u ); #pragma omp parallel for - for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->globalCellArray().size() ); - nativeResvCellIndex++ ) + for ( int nativeResvCellIndex = 0; nativeResvCellIndex < (int)mainGrid->cellCount(); nativeResvCellIndex++ ) { size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex ); if ( resultIndex != cvf::UNDEFINED_SIZE_T ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp index c6f6f27052..e008b03766 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp @@ -21,6 +21,8 @@ #include "RigActiveCellInfo.h" #include "RigEclipseCaseData.h" +#include "cvfAssert.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -155,6 +157,8 @@ void RigActiveCellGrid::transferActiveInformation( int gridI //-------------------------------------------------------------------------------------------------- RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) { + CVF_ASSERT( gridLocalCellIndex < m_globalToActiveMap.size() ); + const auto index = m_globalToActiveMap[gridLocalCellIndex]; return m_cells[index]; } @@ -164,6 +168,8 @@ RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) //-------------------------------------------------------------------------------------------------- const RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) const { + CVF_ASSERT( gridLocalCellIndex < m_globalToActiveMap.size() ); + const auto index = m_globalToActiveMap[gridLocalCellIndex]; return m_cells[index]; } @@ -171,17 +177,41 @@ const RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellGrid::globalToActualCellIndex( size_t globalCellIndex ) const +RigCell& RigActiveCellGrid::nativeCell( size_t nativeCellIndex ) { + CVF_ASSERT( nativeCellIndex < m_cells.size() ); + + return m_cells[nativeCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigCell& RigActiveCellGrid::nativeCell( size_t nativeCellIndex ) const +{ + CVF_ASSERT( nativeCellIndex < m_cells.size() ); + + return m_cells[nativeCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellGrid::globalCellIndexToNative( size_t globalCellIndex ) const +{ + CVF_ASSERT( globalCellIndex < m_globalToActiveMap.size() ); + return m_globalToActiveMap[globalCellIndex]; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellGrid::actualToGlobalCellIndex( size_t actualCellIndex ) const +size_t RigActiveCellGrid::nativeCellIndexToGlobal( size_t nativeCellIndex ) const { - return m_activeToGlobalMap[actualCellIndex]; + CVF_ASSERT( nativeCellIndex < m_globalToActiveMap.size() ); + + return m_activeToGlobalMap[nativeCellIndex]; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h index a497a0c32f..16d95f46f9 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h @@ -44,8 +44,11 @@ public: RigCell& cell( size_t gridLocalCellIndex ) override; const RigCell& cell( size_t gridLocalCellIndex ) const override; - size_t globalToActualCellIndex( size_t globalCellIndex ) const override; - size_t actualToGlobalCellIndex( size_t actualCellIndex ) const override; + RigCell& nativeCell( size_t nativeCellIndex ) override; + const RigCell& nativeCell( size_t nativeCellIndex ) const override; + + size_t globalCellIndexToNative( size_t globalCellIndex ) const override; + size_t nativeCellIndexToGlobal( size_t nativeCellIndex ) const override; size_t cellCount() const override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index cb2f55eec1..7e074c5170 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -512,8 +512,9 @@ bool RigCaseCellResultsData::isUsingGlobalActiveIndex( const RigEclipseResultAdd if ( m_cellScalarResults[scalarResultIndex].empty() ) return true; + // TODO - handle that some timesteps (in this case step 0) might be missing data! size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size(); - return firstTimeStepResultValueCount != m_ownerMainGrid->globalCellArray().size(); + return firstTimeStepResultValueCount != m_ownerMainGrid->cellCount(); } //-------------------------------------------------------------------------------------------------- @@ -1865,11 +1866,11 @@ void RigCaseCellResultsData::computeDepthRelatedResults() } #pragma omp parallel for - for ( long cellIdx = 0; cellIdx < static_cast( m_ownerMainGrid->globalCellArray().size() ); cellIdx++ ) + for ( int nativeCellIdx = 0; nativeCellIdx < (int)m_ownerMainGrid->cellCount(); nativeCellIdx++ ) { - const RigCell& cell = m_ownerMainGrid->globalCellArray()[cellIdx]; + const RigCell& cell = m_ownerMainGrid->nativeCell( nativeCellIdx ); - size_t resultIndex = activeCellInfo()->cellResultIndex( cellIdx ); + size_t resultIndex = activeCellInfo()->cellResultIndex( nativeCellIdx ); if ( resultIndex == cvf::UNDEFINED_SIZE_T ) continue; bool isTemporaryGrid = cell.hostGrid()->isTempGrid(); @@ -2130,14 +2131,14 @@ void RigCaseCellResultsData::computeRiTransComponent( const QString& riTransComp const std::vector& nodes = m_ownerMainGrid->nodes(); bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); - for ( size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->globalCellArray().size(); nativeResvCellIndex++ ) + for ( size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cellCount(); nativeResvCellIndex++ ) { // Do nothing if we are only dealing with active cells, and this cell is not active: size_t tranResIdx = ( *riTranIdxFunc )( activeCellInfo, nativeResvCellIndex ); if ( tranResIdx == cvf::UNDEFINED_SIZE_T ) continue; - const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; + const RigCell& nativeCell = m_ownerMainGrid->nativeCell( nativeResvCellIndex ); RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -2149,7 +2150,7 @@ void RigCaseCellResultsData::computeRiTransComponent( const QString& riTransComp if ( grid->cellIJKNeighbor( i, j, k, faceId, &gridLocalNeighborCellIdx ) ) { size_t neighborResvCellIdx = grid->reservoirCellIndex( gridLocalNeighborCellIdx ); - const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; + const RigCell& neighborCell = m_ownerMainGrid->cell( neighborResvCellIdx ); // Do nothing if neighbor cell has no results size_t neighborCellPermResIdx = ( *permIdxFunc )( activeCellInfo, neighborResvCellIdx ); @@ -2283,8 +2284,8 @@ void RigCaseCellResultsData::computeNncCombRiTrans() const RigConnectionContainer& nncConnections = m_ownerMainGrid->nncData()->allConnections(); for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ ) { - size_t nativeResvCellIndex = nncConnections[connIdx].c1GlobIdx(); - size_t neighborResvCellIdx = nncConnections[connIdx].c2GlobIdx(); + size_t nativeResvCellIndex = m_ownerMainGrid->globalCellIndexToNative( nncConnections[connIdx].c1GlobIdx() ); + size_t neighborResvCellIdx = m_ownerMainGrid->globalCellIndexToNative( nncConnections[connIdx].c2GlobIdx() ); cvf::StructGridInterface::FaceType faceId = static_cast( nncConnections[connIdx].face() ); ResultIndexFunction permIdxFunc = nullptr; @@ -2321,8 +2322,8 @@ void RigCaseCellResultsData::computeNncCombRiTrans() size_t neighborCellPermResIdx = ( *permIdxFunc )( activeCellInfo, neighborResvCellIdx ); if ( neighborCellPermResIdx == cvf::UNDEFINED_SIZE_T ) continue; - const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; - const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; + const RigCell& nativeCell = m_ownerMainGrid->nativeCell( nativeResvCellIndex ); + const RigCell& neighborCell = m_ownerMainGrid->nativeCell( neighborResvCellIdx ); // Connection geometry @@ -2565,14 +2566,14 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent( const QString& riTra const RigActiveCellInfo* activeCellInfo = this->activeCellInfo(); const std::vector& nodes = m_ownerMainGrid->nodes(); - for ( size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->globalCellArray().size(); nativeResvCellIndex++ ) + for ( size_t nativeResvCellIndex = 0; nativeResvCellIndex < m_ownerMainGrid->cellCount(); nativeResvCellIndex++ ) { // Do nothing if we are only dealing with active cells, and this cell is not active: size_t nativeCellResValIdx = ( *resValIdxFunc )( activeCellInfo, nativeResvCellIndex ); if ( nativeCellResValIdx == cvf::UNDEFINED_SIZE_T ) continue; - const RigCell& nativeCell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; + const RigCell& nativeCell = m_ownerMainGrid->nativeCell( nativeResvCellIndex ); RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -2584,7 +2585,7 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent( const QString& riTra if ( grid->cellIJKNeighbor( i, j, k, faceId, &gridLocalNeighborCellIdx ) ) { size_t neighborResvCellIdx = grid->reservoirCellIndex( gridLocalNeighborCellIdx ); - const RigCell& neighborCell = m_ownerMainGrid->globalCellArray()[neighborResvCellIdx]; + const RigCell& neighborCell = m_ownerMainGrid->cell( neighborResvCellIdx ); // Connection geometry @@ -2660,7 +2661,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep( size_t timeStep ) std::vector& completionTypeResult = m_cellScalarResults[completionTypeResultIndex][timeStep]; - size_t resultValues = m_ownerMainGrid->globalCellArray().size(); + size_t resultValues = m_ownerMainGrid->cellCount(); if ( completionTypeResult.size() == resultValues ) { @@ -2783,7 +2784,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF return; } - size_t totalGlobCellCount = m_ownerMainGrid->globalCellArray().size(); + size_t totalGlobCellCount = m_ownerMainGrid->cellCount(); addStaticScalarResult( RiaDefines::ResultCatType::FORMATION_NAMES, RiaResultNames::activeFormationNamesResultName(), false, totalGlobCellCount ); std::vector* fnData = modifiableCellScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::FORMATION_NAMES, @@ -2819,7 +2820,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF for ( size_t cIdx = localCellCount; cIdx < totalGlobCellCount; ++cIdx ) { - size_t mgrdCellIdx = m_ownerMainGrid->globalCellArray()[cIdx].mainGridCellIndex(); + size_t mgrdCellIdx = m_ownerMainGrid->nativeCell( cIdx ).mainGridCellIndex(); size_t i( cvf::UNDEFINED_SIZE_T ), j( cvf::UNDEFINED_SIZE_T ), k( cvf::UNDEFINED_SIZE_T ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp index 356651abce..9542baefe7 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp @@ -33,7 +33,7 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigMainGrid* masterEclGrid, Ri , m_masterFemPart( nullptr ) , m_dependentFemPart( nullptr ) { - m_masterCellOrIntervalIndex.resize( dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT ); + m_masterCellOrIntervalIndex.resize( dependentEclGrid->cellCount(), cvf::UNDEFINED_INT ); } //-------------------------------------------------------------------------------------------------- @@ -45,7 +45,7 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper( RigFemPart* masterFemPart, Rig , m_masterFemPart( masterFemPart ) , m_dependentFemPart( nullptr ) { - m_masterCellOrIntervalIndex.resize( dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT ); + m_masterCellOrIntervalIndex.resize( dependentEclGrid->cellCount(), cvf::UNDEFINED_INT ); calculateEclToGeomCellMapping( dependentEclGrid, masterFemPart, false ); } diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp index 7c334efb48..902895420f 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp @@ -51,7 +51,7 @@ public: if ( offsetK > 0 && m_baseK == m_mainGrid->cellCountK() - 1 ) return nullptr; size_t gridLocalCellIndex = m_mainGrid->cellIndexFromIJK( m_baseI + offsetI, m_baseJ + offsetJ, m_baseK + offsetK ); - const RigCell& cell = m_mainGrid->globalCellArray()[gridLocalCellIndex]; + const RigCell& cell = m_mainGrid->cell( gridLocalCellIndex ); return &( cell.cornerIndices() ); } diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp index f69eaa0933..cf123bddee 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp @@ -373,7 +373,7 @@ RigCaseToCaseRangeFilterMapper::CellMatchType RigCaseToCaseRangeFilterMapper::fi size_t cellIdx = masterEclGrid->cellIndexFromIJK( ei, ej, ek ); - bool isCollapsedCell = masterEclGrid->globalCellArray()[cellIdx].isCollapsedCell(); + bool isCollapsedCell = masterEclGrid->cell( cellIdx ).isCollapsedCell(); cvf::Vec3d geoMechConvertedEclCell[8]; RigCaseToCaseCellMapperTools::estimatedFemCellFromEclCell( masterEclGrid, cellIdx, geoMechConvertedEclCell ); @@ -512,7 +512,7 @@ RigCaseToCaseRangeFilterMapper::CellMatchType RigCaseToCaseRangeFilterMapper::fi if ( globCellIdxToBestMatch != cvf::UNDEFINED_SIZE_T ) { masterEclGrid->ijkFromCellIndex( globCellIdxToBestMatch, ei, ej, ek ); - isCollapsedCell = masterEclGrid->globalCellArray()[globCellIdxToBestMatch].isCollapsedCell(); + isCollapsedCell = masterEclGrid->cell( globCellIdxToBestMatch ).isCollapsedCell(); } else { diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index e01fc78421..445f4e2b2e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -229,7 +229,7 @@ void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultF cvf::BoundingBox bb; std::array sourceFaceIndices; - mainGrid->globalCellArray()[sourceReservoirCellIndex].faceIndices( sourceCellFace, &sourceFaceIndices ); + mainGrid->cell( sourceReservoirCellIndex ).faceIndices( sourceCellFace, &sourceFaceIndices ); bb.add( mainGridNodes[sourceFaceIndices[0]] ); bb.add( mainGridNodes[sourceFaceIndices[1]] ); @@ -267,10 +267,10 @@ void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultF continue; } - if ( candidateCellIndex >= mainGrid->cellCount() ) - { - continue; - } + // if ( candidateCellIndex >= mainGrid->cellCount() ) + //{ + // continue; + // } if ( candidateCellIndex == neighborCellIndex ) { @@ -333,7 +333,7 @@ void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultF std::vector intersections; std::array candidateFaceIndices; - mainGrid->globalCellArray()[candidateCellIndex].faceIndices( candidateFace, &candidateFaceIndices ); + mainGrid->cell( candidateCellIndex ).faceIndices( candidateFace, &candidateFaceIndices ); bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &intersections, diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index 88d02f9312..9f74e09437 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -77,7 +77,7 @@ void RigEclipseWellLogExtractor::calculateIntersection() cvf::Vec3d hexCorners[8]; for ( const auto& globalCellIndex : closeCellIndices ) { - const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; + const RigCell& cell = m_caseData->mainGrid()->cell( globalCellIndex ); if ( cell.isInvalid() || cell.subGrid() != nullptr ) continue; @@ -123,7 +123,7 @@ void RigEclipseWellLogExtractor::calculateIntersection() cvf::Vec3d hexCorners[8]; for ( const auto& globalCellIndex : closeCellIndices ) { - const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; + const RigCell& cell = m_caseData->mainGrid()->cell( globalCellIndex ); if ( cell.isInvalid() ) continue; diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index 0e013ca9bb..ac036bd27c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -84,9 +84,9 @@ RigCell& RigGridBase::cell( size_t gridLocalCellIndex ) { CVF_ASSERT( m_mainGrid ); - CVF_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->globalCellArray().size() ); + CVF_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->globalCellCount() ); - return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex]; + return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex]; } //-------------------------------------------------------------------------------------------------- @@ -96,23 +96,9 @@ const RigCell& RigGridBase::cell( size_t gridLocalCellIndex ) const { CVF_ASSERT( m_mainGrid ); - return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex]; -} + CVF_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->globalCellCount() ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigGridBase::globalToActualCellIndex( size_t globalCellIndex ) const -{ - return globalCellIndex; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigGridBase::actualToGlobalCellIndex( size_t actualCellIndex ) const -{ - return actualCellIndex; + return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex]; } //-------------------------------------------------------------------------------------------------- @@ -563,6 +549,14 @@ size_t RigGridBase::cellCountK() const /// //-------------------------------------------------------------------------------------------------- size_t RigGridBase::cellCount() const +{ + return globalCellCount(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigGridBase::globalCellCount() const { return cellCountI() * cellCountJ() * cellCountK(); } @@ -612,8 +606,9 @@ bool RigGridCellFaceVisibilityFilter::isFaceVisible( size_t return false; } + auto nativeCellIndex = m_grid->globalCellIndexToNative( neighborCellIndex ); // If the neighbour cell is invisible, we need to draw the face - if ( ( cellVisibility != nullptr ) && !( *cellVisibility )[neighborCellIndex] ) + if ( ( cellVisibility != nullptr ) && !( *cellVisibility )[nativeCellIndex] ) { return true; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index 17fcea64ca..8ad74e9a0c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -52,12 +52,23 @@ public: size_t cellCountJ() const override; size_t cellCountK() const override; - virtual size_t cellCount() const; - virtual RigCell& cell( size_t actualCellIndex ); - virtual const RigCell& cell( size_t actualCellIndex ) const; + virtual size_t cellCount() const; // number of cells in the cell array, could be different from countI x countJ x countK - virtual size_t globalToActualCellIndex( size_t globalCellIndex ) const; - virtual size_t actualToGlobalCellIndex( size_t actualCellIndex ) const; + virtual size_t globalCellCount() const; // number of cells in the global grid (countI x countJ x countK) + + // Cell index naming: + // - global cell index is the cell index in the IJK global grid + // - native cell index is the cell index in the cell array, which is the same index if all cells are present, + // but could be different if i.e. only active cells are loaded + + virtual RigCell& cell( size_t globalCellIndex ); + virtual const RigCell& cell( size_t globalCellIndex ) const; + + virtual RigCell& nativeCell( size_t nativeCellIndex ) { return cell( nativeCellIndex ); }; + virtual const RigCell& nativeCell( size_t nativeCellIndex ) const { return cell( nativeCellIndex ); }; + + virtual size_t globalCellIndexToNative( size_t globalCellIndex ) const { return globalCellIndex; }; + virtual size_t nativeCellIndexToGlobal( size_t nativeIndex ) const { return nativeIndex; }; void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp index 8c6f20ca16..0e19af0a9b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp @@ -87,22 +87,6 @@ const std::vector& RigMainGrid::reservoirCells() const return m_cells; } -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -// std::vector& RigMainGrid::globalCellArray() -//{ -// return m_cells; -// } -// -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -// const std::vector& RigMainGrid::globalCellArray() const -//{ -// return m_cells; -// } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -535,7 +519,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) std::vector& unNamedFaultFacesInactive = unNamedFaultWithInactive->faultFaces(); for ( size_t i = 0; i < cellCount(); i++ ) { - const auto globIndex = actualToGlobalCellIndex( i ); + const auto globIndex = nativeCellIndexToGlobal( i ); addUnNamedFaultFaces( (int)globIndex, activeCellInfo, vxs, @@ -608,7 +592,7 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx, continue; } - auto activeNeighborCellIndex = hostGrid->globalToActualCellIndex( neighborGridCellIdx ); + auto activeNeighborCellIndex = hostGrid->globalCellIndexToNative( neighborGridCellIdx ); bool isNeighborCellActive = activeCellInfo->isActive( activeNeighborCellIndex ); double tolerance = 1e-6; diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h index 991fbbc237..882604253e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h @@ -48,8 +48,6 @@ public: std::vector& reservoirCells(); const std::vector& reservoirCells() const; - // std::vector& globalCellArray(); - // const std::vector& globalCellArray() const; virtual RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ); virtual const RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ) const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp index ae361e7e0a..e03dddef46 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp @@ -68,8 +68,8 @@ void RigNNCData::buildPolygonsForEclipseConnections() #pragma omp parallel for for ( int cnIdx = 0; cnIdx < static_cast( eclipseConnectionCount() ); ++cnIdx ) { - const RigCell& c1 = m_mainGrid->globalCellArray()[m_connections[cnIdx].c1GlobIdx()]; - const RigCell& c2 = m_mainGrid->globalCellArray()[m_connections[cnIdx].c2GlobIdx()]; + const RigCell& c1 = m_mainGrid->cell( m_connections[cnIdx].c1GlobIdx() ); + const RigCell& c2 = m_mainGrid->cell( m_connections[cnIdx].c2GlobIdx() ); std::vector connectionPolygon; std::vector connectionIntersections; diff --git a/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index abbe9383c7..920bfd6e76 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -197,7 +197,6 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid* std::vector*> flowrateNNCatAllTimeSteps, std::vector> summedTracersAtAllTimesteps ) { - // size_t totalNumberOfCells = mainGrid->globalCellArray().size(); RigActiveCellInfo* actCellInfo = caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); size_t resultCellCount = actCellInfo->reservoirActiveCellCount(); @@ -330,15 +329,15 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow( RigMa { RigActiveCellInfo* actCellInfo = caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - for ( size_t globalCellIndex = 0; globalCellIndex < mainGrid->globalCellArray().size(); globalCellIndex++ ) + for ( size_t nativeCellIndex = 0; nativeCellIndex < mainGrid->cellCount(); nativeCellIndex++ ) { - if ( !actCellInfo->isActive( globalCellIndex ) ) continue; + if ( !actCellInfo->isActive( nativeCellIndex ) ) continue; - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + const RigCell& cell = mainGrid->nativeCell( nativeCellIndex ); RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); - size_t cellResultIndex = actCellInfo->cellResultIndex( globalCellIndex ); + size_t cellResultIndex = actCellInfo->cellResultIndex( nativeCellIndex ); size_t i, j, k; hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp index 0fa052bb9e..a3628833f0 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp @@ -75,7 +75,7 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase ) size_t mainGridCellCount = mainGridNodeCount / 8; // Must create cells in main grid here, as this information is used when creating LGRs - appendCells( 0, mainGridCellCount, eclipseCase->mainGrid(), eclipseCase->mainGrid()->globalCellArray() ); + appendCells( 0, mainGridCellCount, eclipseCase->mainGrid(), eclipseCase->mainGrid()->reservoirCells() ); size_t totalCellCount = mainGridCellCount; @@ -125,7 +125,7 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase ) size_t cellIdx; for ( cellIdx = 0; cellIdx < mainGridIndicesWithSubGrid.size(); cellIdx++ ) { - RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[mainGridIndicesWithSubGrid[cellIdx]]; + RigCell& cell = eclipseCase->mainGrid()->cell( mainGridIndicesWithSubGrid[cellIdx] ); std::array& indices = cell.cornerIndices(); int nodeIdx; @@ -141,7 +141,7 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase ) appendNodes( bb.min(), bb.max(), lgrCellDimensions, mainGridNodes ); size_t subGridCellCount = ( mainGridNodes.size() / 8 ) - totalCellCount; - appendCells( totalCellCount * 8, subGridCellCount, localGrid, eclipseCase->mainGrid()->globalCellArray() ); + appendCells( totalCellCount * 8, subGridCellCount, localGrid, eclipseCase->mainGrid()->reservoirCells() ); totalCellCount += subGridCellCount; } @@ -149,14 +149,14 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase ) // Set all cells active RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - activeCellInfo->setReservoirCellCount( eclipseCase->mainGrid()->globalCellArray().size() ); - for ( size_t i = 0; i < eclipseCase->mainGrid()->globalCellArray().size(); i++ ) + activeCellInfo->setReservoirCellCount( eclipseCase->mainGrid()->cellCount() ); + for ( size_t i = 0; i < eclipseCase->mainGrid()->cellCount(); i++ ) { activeCellInfo->setCellResultIndex( i, i ); } activeCellInfo->setGridCount( 1 ); - activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->globalCellArray().size() ); + activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->cellCount() ); activeCellInfo->computeDerivedData(); bool useOptimizedVersion = false; // workaround, optimized version causes assert in debug builds diff --git a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index e7886c8df8..48ae89aa0a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -114,7 +114,7 @@ bool RigReservoirBuilderMock::inputProperty( RigEclipseCaseData* eclipseCase, co /* generate secret number: */ int iSecret = rand() % 20 + 1; - for ( k = 0; k < eclipseCase->mainGrid()->globalCellArray().size(); k++ ) + for ( k = 0; k < eclipseCase->mainGrid()->cellCount(); k++ ) { values->push_back( k * iSecret ); } @@ -127,12 +127,12 @@ bool RigReservoirBuilderMock::inputProperty( RigEclipseCaseData* eclipseCase, co //-------------------------------------------------------------------------------------------------- bool RigReservoirBuilderMock::staticResult( RigEclipseCaseData* eclipseCase, const QString& result, std::vector* values ) { - values->resize( eclipseCase->mainGrid()->globalCellArray().size() ); + values->resize( eclipseCase->mainGrid()->cellCount() ); #pragma omp parallel for - for ( long long k = 0; k < static_cast( eclipseCase->mainGrid()->globalCellArray().size() ); k++ ) + for ( long long k = 0; k < static_cast( eclipseCase->mainGrid()->cellCount() ); k++ ) { - values->at( k ) = ( k * 2 ) % eclipseCase->mainGrid()->globalCellArray().size(); + values->at( k ) = ( k * 2 ) % eclipseCase->mainGrid()->cellCount(); } return false; @@ -155,12 +155,12 @@ bool RigReservoirBuilderMock::dynamicResult( RigEclipseCaseData* eclipseCase, co double scaleValue = 1.0 + resultIndex * 0.1; double offsetValue = 100 * resultIndex; - values->resize( eclipseCase->mainGrid()->globalCellArray().size() ); + values->resize( eclipseCase->mainGrid()->cellCount() ); #pragma omp parallel for - for ( long long k = 0; k < static_cast( eclipseCase->mainGrid()->globalCellArray().size() ); k++ ) + for ( long long k = 0; k < static_cast( eclipseCase->mainGrid()->cellCount() ); k++ ) { - double val = offsetValue + scaleValue * ( ( stepIndex * 1000 + k ) % eclipseCase->mainGrid()->globalCellArray().size() ); + double val = offsetValue + scaleValue * ( ( stepIndex * 1000 + k ) % eclipseCase->mainGrid()->cellCount() ); values->at( k ) = val; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp index 5c3f423a5b..e31fcfeb14 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp @@ -62,7 +62,7 @@ cvf::Vec3d RigStimPlanModelTools::calculateTSTDirection( RigEclipseCaseData* ecl int numContributingCells = 0; for ( size_t globalCellIndex : closeCells ) { - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + const RigCell& cell = mainGrid->cell( globalCellIndex ); if ( !cell.isInvalid() ) { @@ -128,7 +128,7 @@ std::tuple RigStimPlanModelTools::f shortestDistance = distance; barrierPosition = intersection.startPoint; - const RigCell& cell = mainGrid->globalCellArray()[intersection.globCellIndex]; + const RigCell& cell = mainGrid->cell( intersection.globCellIndex ); cvf::Vec3d faceNormal = cell.faceNormalWithAreaLength( intersection.intersectedCellFaceIn ); barrierDip = RigStimPlanModelTools::calculateFormationDip( faceNormal ); } diff --git a/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp index 2b7b272ec4..bc9029cf73 100644 --- a/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -189,7 +189,7 @@ public: hostCellK.reserve( numMatrixModelActiveCells ); globalCoarseningBoxIdx.reserve( numMatrixModelActiveCells ); - const std::vector& reservoirCells = reservoirCase->eclipseCaseData()->mainGrid()->globalCellArray(); + auto mainGrid = reservoirCase->eclipseCaseData()->mainGrid(); std::vector globalCoarseningBoxIndexStart; { @@ -206,13 +206,13 @@ public: } } - for ( size_t cIdx = 0; cIdx < reservoirCells.size(); ++cIdx ) + for ( size_t ncIdx = 0; ncIdx < mainGrid->cellCount(); ++ncIdx ) { - if ( actCellInfo->isActive( cIdx ) ) + if ( actCellInfo->isActive( ncIdx ) ) { - RigGridBase* grid = reservoirCells[cIdx].hostGrid(); + RigGridBase* grid = mainGrid->nativeCell( ncIdx ).hostGrid(); CVF_ASSERT( grid != nullptr ); - size_t cellIndex = reservoirCells[cIdx].gridLocalCellIndex(); + size_t cellIndex = mainGrid->nativeCell( ncIdx ).gridLocalCellIndex(); size_t i, j, k; grid->ijkFromCellIndex( cellIndex, &i, &j, &k ); @@ -229,7 +229,7 @@ public: } else { - size_t parentCellIdx = reservoirCells[cIdx].parentCellIndex(); + size_t parentCellIdx = mainGrid->nativeCell( ncIdx ).parentCellIndex(); parentGrid = ( static_cast( grid ) )->parentGrid(); CVF_ASSERT( parentGrid != nullptr ); parentGrid->ijkFromCellIndex( parentCellIdx, &pi, &pj, &pk ); @@ -245,7 +245,7 @@ public: hostCellJ.push_back( static_cast( pj + 1 ) ); // NB: 1-based index in Octave hostCellK.push_back( static_cast( pk + 1 ) ); // NB: 1-based index in Octave - size_t coarseningIdx = reservoirCells[cIdx].coarseningBoxIndex(); + size_t coarseningIdx = mainGrid->nativeCell( ncIdx ).coarseningBoxIndex(); if ( coarseningIdx != cvf::UNDEFINED_SIZE_T ) { size_t globalCoarseningIdx = globalCoarseningBoxIndexStart[grid->gridIndex()] + coarseningIdx; diff --git a/ApplicationLibCode/SocketInterface/RiaGeometryCommands.cpp b/ApplicationLibCode/SocketInterface/RiaGeometryCommands.cpp index 6d251c7439..f56df0c8ac 100644 --- a/ApplicationLibCode/SocketInterface/RiaGeometryCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaGeometryCommands.cpp @@ -203,11 +203,11 @@ public: { quint64 valueIndex = 0; - for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size(); reservoirCellIndex++ ) + for ( size_t nativeCellIndex = 0; nativeCellIndex < mainGrid->cellCount(); nativeCellIndex++ ) { - if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue; + if ( !actCellInfo->isActive( nativeCellIndex ) ) continue; - cvf::Vec3d center = mainGrid->globalCellArray()[reservoirCellIndex].center(); + cvf::Vec3d center = mainGrid->nativeCell( nativeCellIndex ).center(); convertVec3dToPositiveDepth( ¢er ); @@ -377,11 +377,11 @@ public: quint64 valueIndex = 0; - for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size(); reservoirCellIndex++ ) + for ( size_t nativeCellIndex = 0; nativeCellIndex < mainGrid->cellCount(); nativeCellIndex++ ) { - if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue; + if ( !actCellInfo->isActive( nativeCellIndex ) ) continue; - mainGrid->cellCornerVertices( reservoirCellIndex, cornerVerts ); + mainGrid->cellCornerVertices( nativeCellIndex, cornerVerts ); doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts, cornerIndexMapping, coordIdx ); } diff --git a/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp index b46b1d114b..8ec94b7898 100644 --- a/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp @@ -73,8 +73,8 @@ public: { RigConnection connection = mainGrid->nncData()->allConnections()[i]; - const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()]; - const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()]; + const RigCell& cell1 = mainGrid->cell( connection.c1GlobIdx() ); + const RigCell& cell2 = mainGrid->cell( connection.c2GlobIdx() ); sendCellInfo( socketStream, cell1 ); sendCellInfo( socketStream, cell2 ); diff --git a/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp index 5f91a374d9..42abe36bf5 100644 --- a/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -933,7 +933,7 @@ public: // The size of this array must match the test in RigCaseCellResultsData::isUsingGlobalActiveIndex(), // as it is used to determine if we have data for active cells or all cells // See RigCaseCellResultsData::isUsingGlobalActiveIndex() - size_t totalNumberOfCellsIncludingLgrCells = grid->mainGrid()->globalCellArray().size(); + size_t totalNumberOfCellsIncludingLgrCells = grid->mainGrid()->cellCount(); m_scalarResultsToAdd->at( tsId ).resize( totalNumberOfCellsIncludingLgrCells, HUGE_VAL ); } diff --git a/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp b/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp index 33a172addc..80b7a178ae 100644 --- a/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp @@ -45,10 +45,10 @@ TEST( RigEclipseWellLogExtractor, ShortWellPathInsideOneCell ) reservoir->mainGrid()->computeCachedData(); } - auto cells = reservoir->mainGrid()->globalCellArray(); + auto cells = reservoir->mainGrid()->reservoirCells(); EXPECT_FALSE( cells.empty() ); - auto firstCell = reservoir->mainGrid()->globalCellArray()[0]; + auto firstCell = reservoir->mainGrid()->cell( 0 ); auto center = firstCell.center(); cvf::ref wellPathGeometry = new RigWellPath; diff --git a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp index 1b6108486f..176ce7bfd4 100644 --- a/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuResultTextBuilder.cpp @@ -96,7 +96,7 @@ RiuResultTextBuilder::RiuResultTextBuilder( RimGridView* settings RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); RigMainGrid* mainGrid = caseData->mainGrid(); - const RigCell& cell = caseData->mainGrid()->globalCellArray()[reservoirCellIndex]; + const RigCell& cell = caseData->mainGrid()->cell( reservoirCellIndex ); for ( size_t i = 0; i < mainGrid->gridCount(); i++ ) { @@ -922,8 +922,8 @@ QString RiuResultTextBuilder::nncDetails() // First cell of NNC { - CVF_ASSERT( conn.c1GlobIdx() < grid->globalCellArray().size() ); - const RigCell& cell = grid->globalCellArray()[conn.c1GlobIdx()]; + CVF_ASSERT( conn.c1GlobIdx() < grid->globalCellCount() ); + const RigCell& cell = grid->cell( conn.c1GlobIdx() ); RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); @@ -944,8 +944,8 @@ QString RiuResultTextBuilder::nncDetails() // Second cell of NNC { - CVF_ASSERT( conn.c2GlobIdx() < grid->globalCellArray().size() ); - const RigCell& cell = grid->globalCellArray()[conn.c2GlobIdx()]; + CVF_ASSERT( conn.c2GlobIdx() < grid->globalCellCount() ); + const RigCell& cell = grid->cell( conn.c2GlobIdx() ); RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index aead16b7a8..b95584dbd0 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -1066,7 +1066,7 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m if ( eclipseCase ) { - const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex]; + const RigCell& cell = eclipseCase->mainGrid()->cell( globalCellIndex ); *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp index 6eef13a527..3ad3860041 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp @@ -390,6 +390,7 @@ void StructGridGeometryGenerator::computeArrays() for ( i = 0; i < m_grid->cellCountI(); i++ ) { size_t cellIndex = m_grid->cellIndexFromIJK( i, j, k ); + if ( m_cellVisibility.notNull() && !( *m_cellVisibility )[cellIndex] ) { continue; diff --git a/GrpcInterface/RiaGrpcCaseService.cpp b/GrpcInterface/RiaGrpcCaseService.cpp index b671c91ce2..1a07f5f773 100644 --- a/GrpcInterface/RiaGrpcCaseService.cpp +++ b/GrpcInterface/RiaGrpcCaseService.cpp @@ -94,7 +94,7 @@ grpc::Status RiaActiveCellInfoStateHandler::init( const rips::CellInfoRequest* r //-------------------------------------------------------------------------------------------------- grpc::Status RiaActiveCellInfoStateHandler::assignNextActiveCellInfoData( rips::CellInfo* cellInfo ) { - const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->globalCellArray(); + const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->reservoirCells(); while ( m_currentCellIdx < reservoirCells.size() ) { @@ -182,7 +182,7 @@ RigActiveCellInfo* RiaActiveCellInfoStateHandler::activeCellInfo() const //-------------------------------------------------------------------------------------------------- const std::vector& RiaActiveCellInfoStateHandler::reservoirCells() const { - const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->globalCellArray(); + const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->reservoirCells(); return reservoirCells; } @@ -223,7 +223,7 @@ grpc::Status RiaActiveCellInfoStateHandler::assignReply( rips::CellInfoArray* re //-------------------------------------------------------------------------------------------------- grpc::Status RiaActiveCellInfoStateHandler::assignNextActiveCellCenter( rips::Vec3d* cellCenter ) { - const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->globalCellArray(); + const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->reservoirCells(); while ( m_currentCellIdx < reservoirCells.size() ) { @@ -288,7 +288,7 @@ grpc::Status RiaActiveCellInfoStateHandler::assignCellCentersReply( rips::CellCe //-------------------------------------------------------------------------------------------------- Status RiaActiveCellInfoStateHandler::assignNextActiveCellCorners( rips::CellCorners* cellCorners ) { - const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->globalCellArray(); + const std::vector& reservoirCells = m_eclipseCase->eclipseCaseData()->mainGrid()->reservoirCells(); while ( m_currentCellIdx < reservoirCells.size() ) { diff --git a/GrpcInterface/RiaGrpcNNCPropertiesService.cpp b/GrpcInterface/RiaGrpcNNCPropertiesService.cpp index ef9075635f..343c7e446e 100644 --- a/GrpcInterface/RiaGrpcNNCPropertiesService.cpp +++ b/GrpcInterface/RiaGrpcNNCPropertiesService.cpp @@ -100,8 +100,8 @@ grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* r for ( ; indexInPackage < packageSize && m_currentIdx < connectionCount; ++indexInPackage ) { const RigConnection& connection = connections[m_currentIdx]; - const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()]; - const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()]; + const RigCell& cell1 = mainGrid->cell( connection.c1GlobIdx() ); + const RigCell& cell2 = mainGrid->cell( connection.c2GlobIdx() ); NNCConnection* nncConnection = reply->add_connections(); nncConnection->set_allocated_cell1( createConnectionVec3i( cell1 ) ); diff --git a/GrpcInterface/RiaGrpcPropertiesService.cpp b/GrpcInterface/RiaGrpcPropertiesService.cpp index 469ab22124..f52e618daf 100644 --- a/GrpcInterface/RiaGrpcPropertiesService.cpp +++ b/GrpcInterface/RiaGrpcPropertiesService.cpp @@ -373,7 +373,7 @@ protected: auto resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex ); if ( resultValues && resultValues->empty() && m_cellCount > 0 ) { - auto totalCellCount = caseData->mainGrid()->globalCellArray().size(); + auto totalCellCount = caseData->mainGrid()->cellCount(); resultValues->resize( totalCellCount ); }