diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index 1374c10f8c..3886b7bc3a 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->totalCellCount() ) continue; size_t localGridCellIndex = 0u; const RigGridBase* localGrid = diff --git a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp index b8ddfe58c2..1c9a376eca 100644 --- a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -190,7 +190,7 @@ void RicCreateTemporaryLgrFeature::setupActionLook( QAction* actionToSetup ) void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGrid* mainGrid ) { int lgrId = lgrInfo.id; - size_t totalCellCount = mainGrid->globalCellArray().size(); + size_t totalCellCount = mainGrid->totalCellCount(); size_t lgrCellCount = lgrInfo.cellCount(); // Create local grid and set properties @@ -203,14 +203,14 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri localGrid->setGridPointDimensions( cvf::Vec3st( lgrInfo.sizes.i() + 1, lgrInfo.sizes.j() + 1, lgrInfo.sizes.k() + 1 ) ); mainGrid->addLocalGrid( localGrid ); - size_t cellStartIndex = mainGrid->globalCellArray().size(); + size_t cellStartIndex = mainGrid->totalCellCount(); size_t nodeStartIndex = mainGrid->nodes().size(); // Resize global cell and node arrays { RigCell defaultCell; defaultCell.setHostGrid( localGrid ); - mainGrid->globalCellArray().resize( cellStartIndex + lgrCellCount, defaultCell ); + mainGrid->reservoirCells().resize( cellStartIndex + lgrCellCount, defaultCell ); mainGrid->nodes().resize( nodeStartIndex + lgrCellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); } @@ -231,10 +231,10 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri size_t mainI = lgrInfo.mainGridStartCell.i() + lgrI / lgrSizePerMainCell.i(); size_t mainCellIndex = mainGrid->cellIndexFromIJK( mainI, mainJ, mainK ); - auto& mainGridCell = mainGrid->globalCellArray()[mainCellIndex]; + auto& mainGridCell = mainGrid->cell( mainCellIndex ); mainGridCell.setSubGrid( localGrid ); - RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex]; + RigCell& cell = mainGrid->cell( cellStartIndex + gridLocalCellIndex ); cell.setGridLocalCellIndex( gridLocalCellIndex ); cell.setParentCellIndex( mainCellIndex ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp index fe49ffb81d..94aa48d653 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -668,7 +668,7 @@ bool RifEclipseOutputFileTools::assignActiveCellData( std::vectormainGrid()->globalCellArray().size() != reservoirCellCount ) + if ( eclipseCaseData->mainGrid()->reservoirCells().size() != reservoirCellCount ) { return false; } diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp index 5f69945f3a..c31c4ef443 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseOutput.cpp @@ -161,12 +161,12 @@ bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid CVF_ASSERT( activeCellInfo && fractureActiveCellInfo ); int cellCount = ecl_grid_get_global_size( localEclGrid ); - size_t cellStartIndex = mainGrid->globalCellArray().size(); + size_t cellStartIndex = mainGrid->reservoirCells().size(); size_t nodeStartIndex = mainGrid->nodes().size(); RigCell defaultCell; defaultCell.setHostGrid( localGrid ); - mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); + mainGrid->reservoirCells().resize( cellStartIndex + cellCount, defaultCell ); mainGrid->nodes().resize( nodeStartIndex + cellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); @@ -175,7 +175,7 @@ bool RifReaderEclipseOutput::transferGridCellData( RigMainGrid* mainGrid #pragma omp parallel for for ( int gridLocalCellIndex = 0; gridLocalCellIndex < cellCount; ++gridLocalCellIndex ) { - RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex]; + RigCell& cell = mainGrid->cell( cellStartIndex + gridLocalCellIndex ); cell.setGridLocalCellIndex( gridLocalCellIndex ); @@ -303,7 +303,7 @@ bool RifReaderEclipseOutput::transferGeometry( const ecl_grid_type* mainEclGrid, // Reserve room for the cells and nodes and fill them with data - mainGrid->globalCellArray().reserve( totalCellCount ); + mainGrid->reservoirCells().reserve( totalCellCount ); mainGrid->nodes().reserve( 8 * totalCellCount ); caf::ProgressInfo progInfo( 3 + numLGRs, "" ); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp index dd9ba7c4c9..b8b1b106f5 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp @@ -197,7 +197,7 @@ bool RifReaderOpmCommon::importGrid( RigMainGrid* mainGrid, RigEclipseCaseData* activeCellInfo->setReservoirCellCount( totalCellCount ); fractureActiveCellInfo->setReservoirCellCount( totalCellCount ); - mainGrid->globalCellArray().reserve( (size_t)totalCellCount ); + mainGrid->reservoirCells().reserve( (size_t)totalCellCount ); mainGrid->nodes().reserve( (size_t)totalCellCount * 8 ); activeCellInfo->setGridCount( 1 + numLGRs ); @@ -411,7 +411,7 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, RigEclipseCaseData* eclipseCaseData ) { int cellCount = opmGrid.totalNumberOfCells(); - size_t cellStartIndex = mainGrid->globalCellArray().size(); + size_t cellStartIndex = mainGrid->reservoirCells().size(); size_t nodeStartIndex = mainGrid->nodes().size(); const bool invalidateLongPyramidCells = invalidateLongThinCells(); @@ -419,7 +419,7 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, RigCell defaultCell; defaultCell.setHostGrid( localGrid ); - mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); + mainGrid->reservoirCells().resize( cellStartIndex + cellCount, defaultCell ); mainGrid->nodes().resize( nodeStartIndex + cellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); @@ -456,7 +456,7 @@ void RifReaderOpmCommon::transferGeometry( Opm::EclIO::EGrid& opmMainGrid, } auto riReservoirIndex = localGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); - RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + riReservoirIndex]; + RigCell& cell = mainGrid->cell( cellStartIndex + riReservoirIndex ); cell.setGridLocalCellIndex( riReservoirIndex ); // parent cell index diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index a68a123e7d..e0dcd10436 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -99,15 +99,25 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips localGrid->setGridPointDimensions( cvf::Vec3st( lgrDims[0] + 1, lgrDims[1] + 1, lgrDims[2] + 1 ) ); localGrid->setGridId( lgrIdx + 1 ); localGrid->setGridName( lgr_names[lgrIdx] ); - localGrid->setIndexToGlobalStartOfCells( totalCellCount ); + localGrid->setIndexToStartOfCells( totalCellCount ); activeGrid->addLocalGrid( localGrid ); totalCellCount += lgrGrids[lgrIdx].totalNumberOfCells(); totalNativeCellCount += lgrGrids[lgrIdx].totalActiveCells() + 1; } + activeGrid->setTotalCellCount( totalCellCount ); + // active cell information { + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); + + activeCellInfo->setReservoirCellCount( totalCellCount ); + fractureActiveCellInfo->setReservoirCellCount( totalCellCount ); + activeCellInfo->setGridCount( 1 + numLGRs ); + fractureActiveCellInfo->setGridCount( 1 + numLGRs ); + auto task = progInfo.task( "Getting Active Cell Information", 1 ); for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) @@ -122,29 +132,28 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips updateActiveCellInfo( eclipseCaseData, opmGrid, lgrGrids, activeGrid ); } - size_t anInactiveCellIndex = activeGrid->transferActiveInformation( 0, - eclipseCaseData, - opmGrid.totalActiveCells(), - opmGrid.activeCells(), - opmGrid.activeFracCells(), - opmGrid.active_indexes(), - opmGrid.active_frac_indexes(), - 0 ); + globalMatrixActiveSize = opmGrid.activeCells(); + globalFractureActiveSize = opmGrid.activeFracCells(); + + activeCellInfo->setGridActiveCellCounts( 0, globalMatrixActiveSize ); + fractureActiveCellInfo->setGridActiveCellCounts( 0, globalFractureActiveSize ); + + transferActiveCells( opmGrid, 0, eclipseCaseData, 0, 0 ); + size_t cellCount = opmGrid.totalNumberOfCells(); for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) { - activeGrid->transferActiveInformation( lgrIdx + 1, - eclipseCaseData, - lgrGrids[lgrIdx].totalActiveCells(), - lgrGrids[lgrIdx].activeCells(), - lgrGrids[lgrIdx].activeFracCells(), - lgrGrids[lgrIdx].active_indexes(), - lgrGrids[lgrIdx].active_frac_indexes(), - anInactiveCellIndex ); + auto& lgrGrid = lgrGrids[lgrIdx]; + transferActiveCells( lgrGrid, cellCount, eclipseCaseData, globalMatrixActiveSize, globalFractureActiveSize ); + cellCount += lgrGrid.totalNumberOfCells(); + globalMatrixActiveSize += lgrGrid.activeCells(); + globalFractureActiveSize += lgrGrid.activeFracCells(); + activeCellInfo->setGridActiveCellCounts( lgrIdx + 1, lgrGrid.activeCells() ); + fractureActiveCellInfo->setGridActiveCellCounts( lgrIdx + 1, lgrGrid.activeFracCells() ); } - eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeDerivedData(); - eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL )->computeDerivedData(); + activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); } // grid geometry @@ -158,7 +167,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips bool hasParentInfo = ( lgr_parent_names.size() >= (size_t)numLGRs ); - auto task = progInfo.task( "Loading Active Cell LGR Grid Geometry ", 1 ); + auto task2 = progInfo.task( "Loading Active Cell LGR Grid Geometry ", 1 ); for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) { @@ -328,12 +337,11 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa for ( size_t i = 0; i < 8; i++ ) defaultCell.cornerIndices()[i] = 0; - 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 ) ); + const auto newNodeCount = nodeStartIndex + 8 * cellCount; + activeGrid->nodes().resize( newNodeCount, cvf::Vec3d( 0, 0, 0 ) ); auto& riNodes = activeGrid->nodes(); + auto& riCells = activeGrid->nativeCells(); opmGrid.loadData(); opmGrid.load_grid_data(); @@ -351,6 +359,20 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa // use same mapping as resdata const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; + std::map activeCellMap; + int nativeIdx = 0; + + // non-parallell loop to set up and initialize things so that we can run in parallell later + for ( int opmCellIndex = 0; opmCellIndex < static_cast( opmGrid.totalNumberOfCells() ); opmCellIndex++ ) + { + if ( ( activeMatIndexes[opmCellIndex] < 0 ) && ( activeFracIndexes[opmCellIndex] < 0 ) ) continue; + + auto opmIJK = opmGrid.ijk_from_global_index( opmCellIndex ); + auto localIndex = localGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); + riCells[cellStartIndex + localIndex] = defaultCell; + activeCellMap[opmCellIndex] = nativeIdx++; + } + #pragma omp parallel for for ( int opmCellIndex = 0; opmCellIndex < static_cast( opmGrid.totalNumberOfCells() ); opmCellIndex++ ) { @@ -368,9 +390,9 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa yCenterCoordOpm = yCenter; } - auto nativeIndex = activeGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); - RigCell& cell = activeGrid->nativeCell( cellStartIndex + nativeIndex ); - cell.setGridLocalCellIndex( nativeIndex ); + auto localIndex = localGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] ); + RigCell& cell = riCells[cellStartIndex + localIndex]; + cell.setGridLocalCellIndex( localIndex ); // parent cell index if ( ( hostCellGlobalIndices.size() > (size_t)opmCellIndex ) && hostCellGlobalIndices[opmCellIndex] >= 0 ) @@ -389,7 +411,8 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa opmGrid.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 = nodeStartIndex + nativeIndex * 8; + auto localNodeIndex = activeCellMap[opmCellIndex] * 8; + auto riNodeStartIndex = nodeStartIndex + localNodeIndex; for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ ) { @@ -425,6 +448,4 @@ void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMa cell.setInvalid( cell.isLongPyramidCell() ); } } - - if ( riNodes.size() > 1 ) riNodes[riNodes.size() - 1] = riNodes[0]; } diff --git a/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp b/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp index 624e80f5bb..249225ba3c 100644 --- a/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp @@ -188,19 +188,19 @@ bool RifRoffFileTools::openGridFile( const QString& fileName, RigEclipseCaseData fractureActiveCellInfo->setReservoirCellCount( totalCellCount ); // Reserve room for the cells and nodes and fill them with data - mainGrid->globalCellArray().reserve( totalCellCount ); + mainGrid->reservoirCells().reserve( totalCellCount ); mainGrid->nodes().reserve( 8 * totalCellCount ); int progTicks = 100; caf::ProgressInfo progInfo( progTicks, "" ); int cellCount = static_cast( totalCellCount ); - size_t cellStartIndex = mainGrid->globalCellArray().size(); + size_t cellStartIndex = mainGrid->reservoirCells().size(); size_t nodeStartIndex = mainGrid->nodes().size(); RigCell defaultCell; defaultCell.setHostGrid( mainGrid ); - mainGrid->globalCellArray().resize( cellStartIndex + cellCount, defaultCell ); + mainGrid->reservoirCells().resize( cellStartIndex + cellCount, defaultCell ); mainGrid->nodes().resize( nodeStartIndex + static_cast( cellCount ) * 8, cvf::Vec3d( 0, 0, 0 ) ); @@ -220,7 +220,7 @@ bool RifRoffFileTools::openGridFile( const QString& fileName, RigEclipseCaseData #pragma omp for for ( int gridLocalCellIndex = 0; gridLocalCellIndex < cellCount; ++gridLocalCellIndex ) { - RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex]; + RigCell& cell = mainGrid->cell( cellStartIndex + gridLocalCellIndex ); cell.setGridLocalCellIndex( gridLocalCellIndex ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp index 04c9d8ebed..84dc54deb2 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp @@ -66,7 +66,7 @@ bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const if ( m_intervalTool.isNumberIncluded( k ) ) { - const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex]; + const RigCell& cell = m_mainGrid->cell( cellIndex ); if ( m_showInactiveCells ) return !cell.isInvalid() && ( cell.subGrid() == nullptr ); else @@ -88,7 +88,7 @@ void RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3 //-------------------------------------------------------------------------------------------------- void RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const { - const std::array& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices(); + const std::array& cornerIndicesSource = m_mainGrid->cell( cellIndex ).cornerIndices(); for ( size_t i = 0; i < 8; i++ ) { diff --git a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp index 7fe212b818..6d1ae6347f 100644 --- a/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivElementVectorResultPartMgr.cpp @@ -150,24 +150,25 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - const std::vector& cells = eclipseCase->mainGrid()->globalCellArray(); + const auto mainGrid = eclipseCase->mainGrid(); - auto getFaceCenterAndNormal = [cells, arrowScaling, displayCordXf]( size_t globalCellIdx, - cvf::StructGridInterface::FaceType faceType, - cvf::Vec3d& faceCenter, - cvf::Vec3d& faceNormal ) + auto getFaceCenterAndNormal = [arrowScaling, displayCordXf, mainGrid]( size_t globalCellIdx, + cvf::StructGridInterface::FaceType faceType, + cvf::Vec3d& faceCenter, + cvf::Vec3d& faceNormal ) { - faceCenter = displayCordXf->transformToDisplayCoord( cells[globalCellIdx].faceCenter( faceType ) ); - cvf::Vec3d cellCenter = displayCordXf->transformToDisplayCoord( cells[globalCellIdx].center() ); + faceCenter = displayCordXf->transformToDisplayCoord( mainGrid->cell( globalCellIdx ).faceCenter( faceType ) ); + cvf::Vec3d cellCenter = displayCordXf->transformToDisplayCoord( mainGrid->cell( globalCellIdx ).center() ); faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling; }; if ( !resultAddresses.empty() && !directions.empty() ) { #pragma omp parallel for - for ( int gcIdx = 0; gcIdx < static_cast( cells.size() ); ++gcIdx ) + for ( int gcIdx = 0; gcIdx < static_cast( mainGrid->totalCellCount() ); ++gcIdx ) { - if ( !cells[gcIdx].isInvalid() && activeCellInfo->isActive( gcIdx ) ) + auto& cell = mainGrid->cell( gcIdx ); + if ( !cell.isInvalid() && activeCellInfo->isActive( gcIdx ) ) { size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx ); if ( result->vectorView() == RimElementVectorResult::VectorView::PER_FACE ) @@ -198,7 +199,7 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode tensorVisualizations.push_back( ElementVectorResultVisualization( faceCenter, faceNormal, resultValue, - std::cbrt( cells[gcIdx].volume() / 3.0 ), + std::cbrt( cell.volume() / 3.0 ), centerArrow ) ); } } @@ -233,10 +234,10 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode #pragma omp critical( critical_section_RivElementVectorResultPartMgr_add_2 ) tensorVisualizations.push_back( - ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( cells[gcIdx].center() ), + ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( cell.center() ), aggregatedVector, aggregatedResult.length(), - std::cbrt( cells[gcIdx].volume() / 3.0 ), + std::cbrt( cell.volume() / 3.0 ), centerArrow ) ); } } @@ -300,11 +301,12 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode } #pragma omp critical( critical_section_RivElementVectorResultPartMgr_add_nnc ) - tensorVisualizations.push_back( ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( connCenter ), - connNormal, - resultValue, - std::cbrt( cells[conn.c1GlobIdx()].volume() / 3.0 ), - centerArrow ) ); + tensorVisualizations.push_back( + ElementVectorResultVisualization( displayCordXf->transformToDisplayCoord( connCenter ), + connNormal, + resultValue, + std::cbrt( mainGrid->cell( conn.c1GlobIdx() ).volume() / 3.0 ), + centerArrow ) ); } } } diff --git a/ApplicationLibCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/RivNNCGeometryGenerator.cpp index 8dd25a6999..e4fb7a8f82 100644 --- a/ApplicationLibCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -77,11 +77,11 @@ void RivNNCGeometryGenerator::computeArrays() const cvf::Vec3f offset( m_offset ); long long numConnections = static_cast( m_nncIndexes.empty() ? m_nncData->allConnections().size() : m_nncIndexes.size() ); - bool isVisibilityCalcActive = m_cellVisibility.notNull() && m_grid.notNull(); - std::vector* allCells = nullptr; + bool isVisibilityCalcActive = m_cellVisibility.notNull() && m_grid.notNull(); + RigMainGrid* mainGrid = nullptr; if ( isVisibilityCalcActive ) { - allCells = &( m_grid->mainGrid()->globalCellArray() ); + mainGrid = m_grid->mainGrid(); } #pragma omp parallel for ordered @@ -104,15 +104,15 @@ void RivNNCGeometryGenerator::computeArrays() bool cell1Visible = false; bool cell2Visible = false; - if ( ( *allCells )[conn.c1GlobIdx()].hostGrid() == m_grid.p() ) + if ( mainGrid->cell( conn.c1GlobIdx() ).hostGrid() == m_grid.p() ) { - size_t cell1GridLocalIdx = ( *allCells )[conn.c1GlobIdx()].gridLocalCellIndex(); + size_t cell1GridLocalIdx = mainGrid->cell( conn.c1GlobIdx() ).gridLocalCellIndex(); cell1Visible = ( *m_cellVisibility )[cell1GridLocalIdx]; } - if ( ( *allCells )[conn.c2GlobIdx()].hostGrid() == m_grid.p() ) + if ( mainGrid->cell( conn.c2GlobIdx() ).hostGrid() == m_grid.p() ) { - size_t cell2GridLocalIdx = ( *allCells )[conn.c2GlobIdx()].gridLocalCellIndex(); + size_t cell2GridLocalIdx = mainGrid->cell( conn.c2GlobIdx() ).gridLocalCellIndex(); cell2Visible = ( *m_cellVisibility )[cell2GridLocalIdx]; } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp index 9301801c52..4a1277ee84 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -93,9 +93,11 @@ bool RimFractureContainment::isEclipseCellOpenForFlow( const RigMainGrid* m { CVF_ASSERT( mainGrid ); - if ( globalCellIndex >= mainGrid->globalCellArray().size() ) return false; + if ( globalCellIndex >= mainGrid->totalCellCount() ) return false; + + auto& cell = mainGrid->cell( globalCellIndex ); + if ( cell.isInvalid() ) return false; - auto cell = mainGrid->globalCellArray()[globalCellIndex]; auto mainGridCellIndex = cell.mainGridCellIndex(); size_t i, j, k; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 7a3c08ed59..7c201ab607 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -332,8 +332,7 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView ) } else if ( eclipseView->mainGrid() ) { - QString totCellCount = - localeWithSpaceAsGroupSeparator.toString( static_cast( eclipseView->mainGrid()->globalCellArray().size() ) ); + QString totCellCount = localeWithSpaceAsGroupSeparator.toString( static_cast( eclipseView->mainGrid()->totalCellCount() ) ); size_t mxActCellCount = eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->reservoirActiveCellCount(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index 71d76103c8..4346ab9c18 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -389,7 +389,7 @@ std::vector RimEclipseContourMapProjection::findIntersectingCells( const //-------------------------------------------------------------------------------------------------- size_t RimEclipseContourMapProjection::kLayer( size_t globalCellIdx ) const { - const RigCell& cell = m_mainGrid->globalCellArray()[globalCellIdx]; + const RigCell& cell = m_mainGrid->cell( globalCellIdx ); size_t mainGridCellIdx = cell.mainGridCellIndex(); size_t i, j, k; m_mainGrid->ijkFromCellIndex( mainGridCellIdx, &i, &j, &k ); @@ -411,7 +411,7 @@ double RimEclipseContourMapProjection::calculateOverlapVolume( size_t globalCell { std::array hexCorners; - const RigCell& cell = m_mainGrid->globalCellArray()[globalCellIdx]; + const RigCell& cell = m_mainGrid->cell( globalCellIdx ); size_t localCellIdx = cell.gridLocalCellIndex(); RigGridBase* localGrid = cell.hostGrid(); @@ -437,7 +437,7 @@ double RimEclipseContourMapProjection::calculateRayLengthInCell( size_t { std::array hexCorners; - RigCell cell = m_mainGrid->globalCellArray()[globalCellIdx]; + RigCell cell = m_mainGrid->cell( globalCellIdx ); size_t localCellIdx = cell.gridLocalCellIndex(); RigGridBase* localGrid = cell.hostGrid(); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 23339631e6..bee9035cfd 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -401,7 +401,7 @@ RimEclipseStatisticsCaseEvaluator::RimEclipseStatisticsCaseEvaluator( const std: { if ( !sourceCases.empty() ) { - m_reservoirCellCount = sourceCases[0]->eclipseCaseData()->mainGrid()->globalCellArray().size(); + m_reservoirCellCount = sourceCases[0]->eclipseCaseData()->mainGrid()->totalCellCount(); } CVF_ASSERT( m_destinationCase ); diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 1d3a94a9cc..85adec918a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -2345,7 +2345,7 @@ void RimEclipseView::setOverridePropertyFilterCollection( RimEclipsePropertyFilt //-------------------------------------------------------------------------------------------------- void RimEclipseView::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) { - size_t cellCount = mainGrid()->globalCellArray().size(); + size_t cellCount = mainGrid()->totalCellCount(); totalVisibility->resize( cellCount ); totalVisibility->setAll( false ); @@ -2376,7 +2376,7 @@ void RimEclipseView::calculateCellVisibility( cvf::UByteArray* visibility, std:: { if ( !mainGrid() ) return; - size_t cellCount = mainGrid()->globalCellArray().size(); + size_t cellCount = mainGrid()->totalCellCount(); visibility->resize( cellCount ); visibility->setAll( false ); diff --git a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 8fce6f1add..b945e5f3e4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -267,8 +267,8 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() return; } - m_unionOfMatrixActiveCells->setReservoirCellCount( m_mainGrid->globalCellArray().size() ); - m_unionOfFractureActiveCells->setReservoirCellCount( m_mainGrid->globalCellArray().size() ); + m_unionOfMatrixActiveCells->setReservoirCellCount( m_mainGrid->totalCellCount() ); + m_unionOfFractureActiveCells->setReservoirCellCount( m_mainGrid->totalCellCount() ); m_unionOfMatrixActiveCells->setGridCount( m_mainGrid->gridCount() ); m_unionOfFractureActiveCells->setGridCount( m_mainGrid->gridCount() ); diff --git a/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp index e4a6fc7742..499e6eb14a 100644 --- a/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp @@ -276,7 +276,7 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM { // Use main grid cell to evaluate if a cell is active or not. // All cells in temporary grids are active - const RigCell& cell = mainGrid->globalCellArray()[reservoirCellIndex]; + const RigCell& cell = mainGrid->cell( reservoirCellIndex ); size_t mainGridReservoirIndex = cell.mainGridCellIndex(); if ( !activeCellInfo->isActive( mainGridReservoirIndex ) ) @@ -358,7 +358,8 @@ std::vector std::vector cellIndicesToLeafCells; for ( const size_t& index : cellIndices ) { - const RigCell& cell = mainGrid->globalCellArray()[index]; + const RigCell& cell = mainGrid->cell( index ); + if ( cell.isInvalid() ) continue; if ( !cell.subGrid() ) { cellIndicesToLeafCells.push_back( index ); diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp index 99ba1fcbb2..9880ee2982 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp @@ -73,13 +73,13 @@ void RigCellVolumeResultCalculator::calculate( const RigEclipseResultAddress& re cellVolumeResults.resize( cellResultCount, std::numeric_limits::infinity() ); #pragma omp parallel for - for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->globalCellArray().size() ); + for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->totalCellCount() ); nativeResvCellIndex++ ) { size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex ); if ( resultIndex != cvf::UNDEFINED_SIZE_T ) { - const RigCell& cell = m_resultsData->m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; + const RigCell& cell = m_resultsData->m_ownerMainGrid->cell( nativeResvCellIndex ); if ( !cell.subGrid() ) { cellVolumeResults[resultIndex] = cell.volume(); diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp index dda128be9d..3d7aa28b64 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigFaultDistanceResultCalculator.cpp @@ -78,9 +78,8 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& if ( !shouldCompute ) return; - const std::vector& globalCellArray = m_resultsData->m_ownerMainGrid->globalCellArray(); - - long long numCells = static_cast( globalCellArray.size() ); + const auto mainGrid = m_resultsData->m_ownerMainGrid; + long long numCells = static_cast( mainGrid->totalCellCount() ); std::vector faceTypes = cvf::StructGridInterface::validFaceTypes(); @@ -90,7 +89,8 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& { if ( m_resultsData->activeCellInfo()->isActive( cellIdx ) ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = mainGrid->cell( cellIdx ); + if ( cell.isInvalid() ) continue; for ( auto faceType : faceTypes ) { if ( m_resultsData->m_ownerMainGrid->findFaultFromCellIndexAndCellFace( cellIdx, faceType ) ) @@ -124,7 +124,8 @@ void RigFaultDistanceResultCalculator::calculate( const RigEclipseResultAddress& #pragma omp parallel for for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = mainGrid->cell( cellIdx ); + if ( cell.isInvalid() ) continue; 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..76b3650ce9 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigIndexIjkResultCalculator.cpp @@ -98,12 +98,13 @@ 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() ); + const auto mainGrid = m_resultsData->m_ownerMainGrid; + long long numCells = static_cast( mainGrid->totalCellCount() ); + #pragma omp parallel for for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ ) { - const RigCell& cell = globalCellArray[cellIdx]; + const RigCell& cell = mainGrid->cell( cellIdx ); size_t resultIndex = cellIdx; if ( resultIndex == cvf::UNDEFINED_SIZE_T ) continue; diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp index 676104b3e3..1797755221 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigOilVolumeResultCalculator.cpp @@ -74,7 +74,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() ); + for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->totalCellCount() ); nativeResvCellIndex++ ) { size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex ); diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigPorvSoilSgasResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigPorvSoilSgasResultCalculator.cpp index 579f4814d6..64895f8284 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigPorvSoilSgasResultCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigPorvSoilSgasResultCalculator.cpp @@ -124,7 +124,7 @@ void RigPorvSoilSgasResultCalculator::calculate( const RigEclipseResultAddress& bool res2ActiveOnly = in2Results.size() == activeCellCount; #pragma omp parallel for - for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->globalCellArray().size() ); + for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->totalCellCount() ); nativeResvCellIndex++ ) { size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp index f1c7e36617..8148c1ed06 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp @@ -26,6 +26,10 @@ //-------------------------------------------------------------------------------------------------- RigActiveCellGrid::RigActiveCellGrid() { + m_invalidCell.setInvalid( true ); + for ( size_t i = 0; i < 8; i++ ) + m_invalidCell.cornerIndices()[i] = 0; + m_invalidCell.setHostGrid( this ); } //-------------------------------------------------------------------------------------------------- @@ -35,116 +39,129 @@ RigActiveCellGrid::~RigActiveCellGrid() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellGrid::transferActiveInformation( RigEclipseCaseData* eclipseCaseData, - size_t totalActiveCells, - size_t matrixActiveCells, - size_t fractureActiveCells, - const std::vector& activeMatrixIndexes, - const std::vector& activeFracIndexes ) -{ - const auto totalCells = activeMatrixIndexes.size(); +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +// size_t RigActiveCellGrid::transferActiveInformation( int gridIndex, +// RigEclipseCaseData* eclipseCaseData, +// size_t totalActiveCells, +// size_t matrixActiveCells, +// size_t fractureActiveCells, +// const std::vector& activeMatrixIndexes, +// const std::vector& activeFracIndexes, +// size_t inactiveCellIndex ) +//{ +// if ( gridIndex == 0 ) +// { +// m_globalToNativeMap.clear(); +// inactiveCellIndex = 0; +// } +// +// const auto totalCells = activeMatrixIndexes.size(); +// +// const auto cellStartIndex = m_globalToNativeMap.size(); +// +// m_globalToNativeMap.resize( cellStartIndex + totalCells ); +// size_t activeCells = cellStartIndex; +// size_t anInactiveCellIdx = inactiveCellIndex; +// +// for ( size_t i = 0; i < totalCells; i++ ) +// { +// const auto globalCellIndex = cellStartIndex + i; +// if ( ( activeMatrixIndexes[i] < 0 ) && ( activeFracIndexes[i] < 0 ) ) +// { +// m_globalToNativeMap[globalCellIndex] = totalActiveCells; +// anInactiveCellIdx = globalCellIndex; +// continue; +// } +// m_nativeToGlobalMap.push_back( globalCellIndex ); +// m_globalToNativeMap[i] = activeCells++; +// } +// m_nativeToGlobalMap.push_back( anInactiveCellIdx ); +// +// RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); +// RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); +// +// activeCellInfo->setReservoirCellCount( activeCellInfo->reservoirCellCount() + totalActiveCells + 1 ); +// fractureActiveCellInfo->setReservoirCellCount( fractureActiveCellInfo->reservoirCellCount() + totalActiveCells + 1 ); +// +// activeCellInfo->setGridCount( gridIndex + 1 ); +// fractureActiveCellInfo->setGridCount( gridIndex + 1 ); +// +// activeCellInfo->setGridActiveCellCounts( gridIndex, matrixActiveCells ); +// fractureActiveCellInfo->setGridActiveCellCounts( gridIndex, fractureActiveCells ); +// +// // TODO - update indexes here +// +// #pragma omp parallel for +// for ( int opmCellIndex = 0; opmCellIndex < (int)totalCells; opmCellIndex++ ) +// { +// auto activeCellIndex = m_globalToNativeMap[cellStartIndex + opmCellIndex]; +// +// // active cell index +// int matrixActiveIndex = activeMatrixIndexes[opmCellIndex]; +// if ( matrixActiveIndex != -1 ) +// { +// activeCellInfo->setCellResultIndex( activeCellIndex, matrixActiveIndex ); +// } +// +// int fractureActiveIndex = activeFracIndexes[opmCellIndex]; +// if ( fractureActiveIndex != -1 ) +// { +// fractureActiveCellInfo->setCellResultIndex( activeCellIndex, fractureActiveIndex ); +// } +// } +// +// return anInactiveCellIdx; +// } - m_globalToActiveMap.resize( totalCells ); - size_t activeCells = 0; - size_t anInactiveCellIdx = 0; - - for ( size_t i = 0; i < totalCells; i++ ) - { - if ( ( activeMatrixIndexes[i] < 0 ) && ( activeFracIndexes[i] < 0 ) ) - { - m_globalToActiveMap[i] = totalActiveCells; - anInactiveCellIdx = i; - continue; - } - m_activeToGlobalMap.push_back( i ); - m_globalToActiveMap[i] = activeCells++; - } - m_activeToGlobalMap.push_back( anInactiveCellIdx ); - - RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - - activeCellInfo->setReservoirCellCount( totalActiveCells + 1 ); - fractureActiveCellInfo->setReservoirCellCount( totalActiveCells + 1 ); - - activeCellInfo->setGridCount( 1 ); - fractureActiveCellInfo->setGridCount( 1 ); - - activeCellInfo->setGridActiveCellCounts( 0, matrixActiveCells ); - fractureActiveCellInfo->setGridActiveCellCounts( 0, fractureActiveCells ); - -#pragma omp parallel for - for ( int opmCellIndex = 0; opmCellIndex < (int)totalCells; opmCellIndex++ ) - { - auto activeCellIndex = m_globalToActiveMap[opmCellIndex]; - - // active cell index - int matrixActiveIndex = activeMatrixIndexes[opmCellIndex]; - if ( matrixActiveIndex != -1 ) - { - activeCellInfo->setCellResultIndex( activeCellIndex, matrixActiveIndex ); - } - - int fractureActiveIndex = activeFracIndexes[opmCellIndex]; - if ( fractureActiveIndex != -1 ) - { - fractureActiveCellInfo->setCellResultIndex( activeCellIndex, fractureActiveIndex ); - } - } - - activeCellInfo->computeDerivedData(); - fractureActiveCellInfo->computeDerivedData(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigActiveCellGrid::cellIndexFromIJK( size_t i, size_t j, size_t k ) const -{ - auto index = RigGridBase::cellIndexFromIJK( i, j, k ); - return m_globalToActiveMap[index]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigActiveCellGrid::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const -{ - auto index = RigGridBase::cellIndexFromIJKUnguarded( i, j, k ); - return m_globalToActiveMap[index]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const -{ - if ( cellIndex >= m_activeToGlobalMap.size() ) - { - return false; - } - auto index = m_activeToGlobalMap[cellIndex]; - return RigGridBase::ijkFromCellIndex( index, i, j, k ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellGrid::ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const -{ - auto index = m_activeToGlobalMap[cellIndex]; - RigGridBase::ijkFromCellIndexUnguarded( index, i, j, k ); -} +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +// size_t RigActiveCellGrid::cellIndexFromIJK( size_t i, size_t j, size_t k ) const +//{ +// auto index = RigGridBase::cellIndexFromIJK( i, j, k ); +// return m_globalToActiveMap[index]; +// } +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +// size_t RigActiveCellGrid::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const +//{ +// auto index = RigGridBase::cellIndexFromIJKUnguarded( i, j, k ); +// return m_globalToActiveMap[index]; +// } +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +// bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const +//{ +// if ( cellIndex >= m_activeToGlobalMap.size() ) +// { +// return false; +// } +// auto index = m_activeToGlobalMap[cellIndex]; +// return RigGridBase::ijkFromCellIndex( index, i, j, k ); +// } +// +////-------------------------------------------------------------------------------------------------- +///// +////-------------------------------------------------------------------------------------------------- +// void RigActiveCellGrid::ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const +//{ +// auto index = m_activeToGlobalMap[cellIndex]; +// RigGridBase::ijkFromCellIndexUnguarded( index, i, j, k ); +// } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) { - return m_cells[gridLocalCellIndex]; + if ( m_nativeCells.contains( gridLocalCellIndex ) ) return m_nativeCells[gridLocalCellIndex]; + return m_invalidCell; } //-------------------------------------------------------------------------------------------------- @@ -152,13 +169,38 @@ RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) //-------------------------------------------------------------------------------------------------- const RigCell& RigActiveCellGrid::cell( size_t gridLocalCellIndex ) const { - return m_cells[gridLocalCellIndex]; + if ( m_nativeCells.contains( gridLocalCellIndex ) ) return m_nativeCells.at( gridLocalCellIndex ); + return m_invalidCell; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellGrid::cellCount() const +std::map& RigActiveCellGrid::nativeCells() { - return m_cells.size(); + return m_nativeCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map& RigActiveCellGrid::nativeCells() const +{ + return m_nativeCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellGrid::totalCellCount() const +{ + return m_totalCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellGrid::setTotalCellCount( size_t totalCellCount ) +{ + m_totalCellCount = totalCellCount; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h index c1fda83d89..26ad0464e0 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h @@ -28,25 +28,35 @@ public: RigActiveCellGrid(); ~RigActiveCellGrid() override; - void transferActiveInformation( RigEclipseCaseData* eclipseCaseData, - size_t totalActiveCells, - size_t matrixActiveCells, - size_t fractureActiveCells, - const std::vector& activeMatrixIndexes, - const std::vector& activeFracIndexes ); + // size_t transferActiveInformation( int gridIndex, + // RigEclipseCaseData* eclipseCaseData, + // size_t totalActiveCells, + // size_t matrixActiveCells, + // size_t fractureActiveCells, + // const std::vector& activeMatrixIndexes, + // const std::vector& activeFracIndexes, + // size_t inactiveCellIndex ); - size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; - size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const override; - bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; - void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; + // size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; + // size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const override; + // bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; + // void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; RigCell& cell( size_t gridLocalCellIndex ) override; const RigCell& cell( size_t gridLocalCellIndex ) const override; - size_t cellCount() const override; + // size_t cellCount() const override; + + size_t totalCellCount() const override; + +public: // only for use by file readers! + std::map& nativeCells(); + const std::map& nativeCells() const; + void setTotalCellCount( size_t totalCellCount ); private: - std::vector m_globalToActiveMap; - std::vector m_activeToGlobalMap; - RigCell m_invalidCell; - std::map m_cells; + // std::vector m_globalToNativeMap; + // std::vector m_nativeToGlobalMap; + size_t m_totalCellCount; + RigCell m_invalidCell; + std::map m_nativeCells; }; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 699df7819c..9dcd532981 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -514,7 +514,7 @@ bool RigCaseCellResultsData::isUsingGlobalActiveIndex( const RigEclipseResultAdd if ( m_cellScalarResults[scalarResultIndex].empty() ) return true; size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size(); - return firstTimeStepResultValueCount != m_ownerMainGrid->globalCellArray().size(); + return firstTimeStepResultValueCount != m_ownerMainGrid->totalCellCount(); } //-------------------------------------------------------------------------------------------------- @@ -1895,9 +1895,9 @@ void RigCaseCellResultsData::computeDepthRelatedResults() } #pragma omp parallel for - for ( long cellIdx = 0; cellIdx < static_cast( m_ownerMainGrid->globalCellArray().size() ); cellIdx++ ) + for ( long cellIdx = 0; cellIdx < static_cast( m_ownerMainGrid->totalCellCount() ); cellIdx++ ) { - const RigCell& cell = m_ownerMainGrid->globalCellArray()[cellIdx]; + const RigCell& cell = m_ownerMainGrid->cell( cellIdx ); size_t resultIndex = activeCellInfo()->cellResultIndex( cellIdx ); if ( resultIndex == cvf::UNDEFINED_SIZE_T ) continue; @@ -2160,14 +2160,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->totalCellCount(); 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->cell( nativeResvCellIndex ); RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -2179,7 +2179,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 ); @@ -2351,8 +2351,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->cell( nativeResvCellIndex ); + const RigCell& neighborCell = m_ownerMainGrid->cell( neighborResvCellIdx ); // Connection geometry @@ -2595,14 +2595,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->totalCellCount(); 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->cell( nativeResvCellIndex ); RigGridBase* grid = nativeCell.hostGrid(); size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); @@ -2614,7 +2614,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 @@ -2690,7 +2690,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->totalCellCount(); if ( completionTypeResult.size() == resultValues ) { @@ -2831,7 +2831,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF return; } - size_t totalGlobCellCount = m_ownerMainGrid->globalCellArray().size(); + size_t totalGlobCellCount = m_ownerMainGrid->totalCellCount(); addStaticScalarResult( RiaDefines::ResultCatType::FORMATION_NAMES, RiaResultNames::activeFormationNamesResultName(), false, totalGlobCellCount ); std::vector* fnData = modifiableCellScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::FORMATION_NAMES, @@ -2867,7 +2867,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->cell( 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..dda55cbab5 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->totalCellCount(), 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->totalCellCount(), 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..ab46f6fda0 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]] ); @@ -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 19d88793b8..601633f735 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->reservoirCells().size() ); - return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex]; + return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex]; } //-------------------------------------------------------------------------------------------------- @@ -96,7 +96,7 @@ const RigCell& RigGridBase::cell( size_t gridLocalCellIndex ) const { CVF_ASSERT( m_mainGrid ); - return m_mainGrid->globalCellArray()[m_indexToStartOfCells + gridLocalCellIndex]; + return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex]; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp index 62a351de75..b8fbf88406 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp @@ -74,7 +74,15 @@ const std::vector& RigMainGrid::nodes() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector& RigMainGrid::globalCellArray() +size_t RigMainGrid::totalCellCount() const +{ + return m_cells.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector& RigMainGrid::reservoirCells() { return m_cells; } @@ -82,7 +90,7 @@ std::vector& RigMainGrid::globalCellArray() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigMainGrid::globalCellArray() const +const std::vector& RigMainGrid::reservoirCells() const { return m_cells; } @@ -92,9 +100,9 @@ const std::vector& RigMainGrid::globalCellArray() const //-------------------------------------------------------------------------------------------------- RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ) { - CVF_ASSERT( globalCellIdx < m_cells.size() ); + CVF_ASSERT( globalCellIdx < totalCellCount() ); - const RigCell& cell = m_cells[globalCellIdx]; + const RigCell& cell = this->cell( globalCellIdx ); RigGridBase* hostGrid = cell.hostGrid(); CVF_ASSERT( hostGrid ); @@ -111,9 +119,9 @@ RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCel //-------------------------------------------------------------------------------------------------- const RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx( size_t globalCellIdx, size_t* gridLocalCellIdx ) const { - CVF_ASSERT( globalCellIdx < m_cells.size() ); + CVF_ASSERT( globalCellIdx < totalCellCount() ); - const RigCell& cell = m_cells[globalCellIdx]; + const RigCell& cell = this->cell( globalCellIdx ); const RigGridBase* hostGrid = cell.hostGrid(); CVF_ASSERT( hostGrid ); @@ -492,7 +500,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) return; } - m_faultsPrCellAcc = new RigFaultsPrCellAccumulator( m_cells.size() ); + m_faultsPrCellAcc = new RigFaultsPrCellAccumulator( totalCellCount() ); // Spread fault idx'es on the cells from the faults for ( size_t fIdx = 0; fIdx < m_faults.size(); ++fIdx ) @@ -517,7 +525,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) std::vector& unNamedFaultFaces = unNamedFault->faultFaces(); std::vector& unNamedFaultFacesInactive = unNamedFaultWithInactive->faultFaces(); - for ( int gcIdx = 0; gcIdx < static_cast( m_cells.size() ); ++gcIdx ) + for ( int gcIdx = 0; gcIdx < static_cast( totalCellCount() ); ++gcIdx ) { addUnNamedFaultFaces( gcIdx, activeCellInfo, @@ -542,7 +550,7 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx, std::vector& unNamedFaultFacesInactive, RigFaultsPrCellAccumulator* faultsPrCellAcc ) const { - if ( m_cells[gcIdx].isInvalid() ) + if ( cell( gcIdx ).isInvalid() ) { return; } @@ -586,7 +594,7 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx, } neighborReservoirCellIdx = hostGrid->reservoirCellIndex( neighborGridCellIdx ); - if ( m_cells[neighborReservoirCellIdx].isInvalid() ) + if ( cell( neighborReservoirCellIdx ).isInvalid() ) { continue; } @@ -596,9 +604,9 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx, double tolerance = 1e-6; std::array faceIdxs; - m_cells[gcIdx].faceIndices( face, &faceIdxs ); + cell( gcIdx ).faceIndices( face, &faceIdxs ); std::array nbFaceIdxs; - m_cells[neighborReservoirCellIdx].faceIndices( StructGridInterface::oppositeFace( face ), &nbFaceIdxs ); + cell( neighborReservoirCellIdx ).faceIndices( StructGridInterface::oppositeFace( face ), &nbFaceIdxs ); bool sharedFaceVertices = true; if ( sharedFaceVertices && vxs[faceIdxs[0]].pointDistance( vxs[nbFaceIdxs[0]] ) > tolerance ) sharedFaceVertices = false; @@ -664,7 +672,7 @@ void RigMainGrid::distributeNNCsToFaults() if ( fIdx1 < 0 && fIdx2 < 0 ) { cvf::String lgrString( "Same Grid" ); - if ( m_cells[conn.c1GlobIdx()].hostGrid() != m_cells[conn.c2GlobIdx()].hostGrid() ) + if ( cell( conn.c1GlobIdx() ).hostGrid() != cell( conn.c2GlobIdx() ).hostGrid() ) { lgrString = "Different Grid"; } @@ -698,7 +706,7 @@ bool RigMainGrid::isFaceNormalsOutwards() const if ( !m_isFaceNormalsOutwardsComputed ) { std::vector reservoirCellIndices; - reservoirCellIndices.resize( cellCount() ); + reservoirCellIndices.resize( totalCellCount() ); std::iota( reservoirCellIndices.begin(), reservoirCellIndices.end(), 0 ); computeFaceNormalsDirection( reservoirCellIndices ); @@ -741,7 +749,7 @@ void RigMainGrid::computeFaceNormalsDirection( const std::vector& reserv for ( const auto& index : reservoirCellIndices ) { - const auto& cell = m_cells[index]; + const auto& cell = this->cell( index ); if ( !cell.isInvalid() ) { // Some cells can be very twisted and distorted. Use a volume criteria to find a reasonably regular cell. @@ -843,7 +851,7 @@ void RigMainGrid::buildCellSearchTree() { // build tree - size_t cellCount = m_cells.size(); + size_t cellCount = totalCellCount(); std::vector cellIndicesForBoundingBoxes; std::vector cellBoundingBoxes; @@ -862,9 +870,10 @@ void RigMainGrid::buildCellSearchTree() #pragma omp for for ( int cIdx = 0; cIdx < (int)cellCount; ++cIdx ) { - if ( m_cells[cIdx].isInvalid() ) continue; + auto& cell = this->cell( cIdx ); + if ( cell.isInvalid() ) continue; - const std::array& cellIndices = m_cells[cIdx].cornerIndices(); + const std::array& cellIndices = cell.cornerIndices(); cvf::BoundingBox cellBB; for ( size_t i : cellIndices ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h index 821f7fde94..88ac93e79f 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h @@ -43,12 +43,11 @@ public: RigMainGrid(); ~RigMainGrid() override; + virtual size_t totalCellCount() const; + std::vector& nodes(); const std::vector& nodes() 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; @@ -114,6 +113,10 @@ public: bool isDualPorosity() const; void setDualPorosity( bool enable ); +public: // only for use by file readers! + std::vector& reservoirCells(); + const std::vector& reservoirCells() const; + protected: void initAllSubCellsMainGridCellIndex(); void buildCellSearchTree(); 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..a31e6475e7 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -330,11 +330,11 @@ 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 globalCellIndex = 0; globalCellIndex < mainGrid->totalCellCount(); globalCellIndex++ ) { if ( !actCellInfo->isActive( globalCellIndex ) ) continue; - const RigCell& cell = mainGrid->globalCellArray()[globalCellIndex]; + const RigCell& cell = mainGrid->cell( globalCellIndex ); RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilder.cpp index 0fa052bb9e..2cd54ed601 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()->totalCellCount() ); + for ( size_t i = 0; i < eclipseCase->mainGrid()->totalCellCount(); i++ ) { activeCellInfo->setCellResultIndex( i, i ); } activeCellInfo->setGridCount( 1 ); - activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->globalCellArray().size() ); + activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->totalCellCount() ); 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 222a9ddd03..5a0d7f7d5d 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -116,7 +116,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()->totalCellCount(); k++ ) { values->push_back( k * iSecret ); } @@ -129,12 +129,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()->totalCellCount() ); #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()->totalCellCount() ); k++ ) { - values->at( k ) = ( k * 2 ) % eclipseCase->mainGrid()->globalCellArray().size(); + values->at( k ) = ( k * 2 ) % eclipseCase->mainGrid()->totalCellCount(); } return false; @@ -157,12 +157,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()->totalCellCount() ); #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()->totalCellCount() ); k++ ) { - double val = offsetValue + scaleValue * ( ( stepIndex * 1000 + k ) % eclipseCase->mainGrid()->globalCellArray().size() ); + double val = offsetValue + scaleValue * ( ( stepIndex * 1000 + k ) % eclipseCase->mainGrid()->totalCellCount() ); 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/ReservoirDataModel/RigWellTargetCandidatesGenerator.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellTargetCandidatesGenerator.cpp index 24baaeaaa5..e6354d1f9e 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellTargetCandidatesGenerator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellTargetCandidatesGenerator.cpp @@ -316,19 +316,18 @@ std::vector RigWellTargetCandidatesGenerator::findCandidates( const RimE cvf::StructGridInterface::FaceType::NEG_K, }; - size_t resultIndex = resultsData->activeCellInfo()->cellResultIndex( cellIdx ); + size_t resultIndex = resultsData->activeCellInfo()->cellResultIndex( cellIdx ); + const RigCell& nativeCell = eclipseCase.mainGrid()->cell( cellIdx ); + RigGridBase* grid = nativeCell.hostGrid(); + size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); + + size_t i, j, k; + + grid->ijkFromCellIndex( gridLocalNativeCellIndex, &i, &j, &k ); for ( cvf::StructGridInterface::FaceType face : faces ) { - const RigCell& nativeCell = eclipseCase.mainGrid()->globalCellArray()[cellIdx]; - RigGridBase* grid = nativeCell.hostGrid(); - - size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex(); - - size_t i, j, k, gridLocalNeighborCellIdx; - - grid->ijkFromCellIndex( gridLocalNativeCellIndex, &i, &j, &k ); - + size_t gridLocalNeighborCellIdx; if ( grid->cellIJKNeighbor( i, j, k, face, &gridLocalNeighborCellIdx ) ) { size_t neighborResvCellIdx = grid->reservoirCellIndex( gridLocalNeighborCellIdx ); diff --git a/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp index 2b7b272ec4..58863e51bf 100644 --- a/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -189,7 +189,9 @@ public: hostCellK.reserve( numMatrixModelActiveCells ); globalCoarseningBoxIdx.reserve( numMatrixModelActiveCells ); - const std::vector& reservoirCells = reservoirCase->eclipseCaseData()->mainGrid()->globalCellArray(); + // const std::vector& reservoirCells = reservoirCase->eclipseCaseData()->mainGrid()->globalCellArray(); + + auto mainGrid = reservoirCase->eclipseCaseData()->mainGrid(); std::vector globalCoarseningBoxIndexStart; { @@ -206,13 +208,14 @@ public: } } - for ( size_t cIdx = 0; cIdx < reservoirCells.size(); ++cIdx ) + for ( size_t cIdx = 0; cIdx < mainGrid->totalCellCount(); ++cIdx ) { if ( actCellInfo->isActive( cIdx ) ) { - RigGridBase* grid = reservoirCells[cIdx].hostGrid(); + auto& cell = mainGrid->cell( cIdx ); + RigGridBase* grid = cell.hostGrid(); CVF_ASSERT( grid != nullptr ); - size_t cellIndex = reservoirCells[cIdx].gridLocalCellIndex(); + size_t cellIndex = cell.gridLocalCellIndex(); size_t i, j, k; grid->ijkFromCellIndex( cellIndex, &i, &j, &k ); @@ -229,7 +232,7 @@ public: } else { - size_t parentCellIdx = reservoirCells[cIdx].parentCellIndex(); + size_t parentCellIdx = cell.parentCellIndex(); parentGrid = ( static_cast( grid ) )->parentGrid(); CVF_ASSERT( parentGrid != nullptr ); parentGrid->ijkFromCellIndex( parentCellIdx, &pi, &pj, &pk ); @@ -245,7 +248,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 = cell.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..eb14dec4e1 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 reservoirCellIndex = 0; reservoirCellIndex < mainGrid->totalCellCount(); reservoirCellIndex++ ) { if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue; - cvf::Vec3d center = mainGrid->globalCellArray()[reservoirCellIndex].center(); + cvf::Vec3d center = mainGrid->cell( reservoirCellIndex ).center(); convertVec3dToPositiveDepth( ¢er ); @@ -377,7 +377,7 @@ public: quint64 valueIndex = 0; - for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->globalCellArray().size(); reservoirCellIndex++ ) + for ( size_t reservoirCellIndex = 0; reservoirCellIndex < mainGrid->totalCellCount(); reservoirCellIndex++ ) { if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue; 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..9aee4762ac 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()->totalCellCount(); m_scalarResultsToAdd->at( tsId ).resize( totalNumberOfCellsIncludingLgrCells, HUGE_VAL ); } diff --git a/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp b/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp index 33a172addc..0182543f6e 100644 --- a/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigWellLogExtractor-Test.cpp @@ -45,10 +45,9 @@ TEST( RigEclipseWellLogExtractor, ShortWellPathInsideOneCell ) reservoir->mainGrid()->computeCachedData(); } - auto cells = reservoir->mainGrid()->globalCellArray(); - EXPECT_FALSE( cells.empty() ); + EXPECT_FALSE( reservoir->mainGrid()->totalCellCount() == 0 ); - 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..646d0271bd 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->totalCellCount() ); + 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->totalCellCount() ); + 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/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..181d3b3dda 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()->totalCellCount(); resultValues->resize( totalCellCount ); }