From 3ff9ac3336ece16bb22ed42e311d346c9fa881c8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 14 Sep 2025 11:22:04 +0200 Subject: [PATCH] Improve LGR data structures and UI Use term refinement from GUI to export code Improve naming of variables --- .../ExportCommands/RicExportLgrFeature.cpp | 77 ++++++++----------- .../ExportCommands/RicExportLgrFeature.h | 49 +++++++----- .../ExportCommands/RicExportLgrUi.cpp | 28 +++---- .../Commands/ExportCommands/RicExportLgrUi.h | 8 +- .../Commands/RicCreateTemporaryLgrFeature.cpp | 47 +++++------ .../Commands/RicCreateTemporaryLgrFeature.h | 5 +- 6 files changed, 104 insertions(+), 110 deletions(-) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.cpp index 09b3d1d6c4..ebc0333d8d 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.cpp @@ -370,9 +370,9 @@ void RicExportLgrFeature::writeLgrs( QTextStream& stream, const std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ) { std::vector lgrs; - lgrs = buildLgrsForWellPaths( wellPaths, eclipseCase, timeStep, lgrCellCounts, splitType, completionTypes, wellsIntersectingOtherLgrs ); + lgrs = buildLgrsForWellPaths( wellPaths, eclipseCase, timeStep, refinement, splitType, completionTypes, wellsIntersectingOtherLgrs ); for ( const auto& wellPath : wellPaths ) { @@ -441,7 +441,7 @@ void RicExportLgrFeature::exportLgrs( const QString& exportFolder, const QString std::vector RicExportLgrFeature::buildLgrsForWellPaths( std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ) @@ -468,7 +468,7 @@ std::vector RicExportLgrFeature::buildLgrsForWellPaths( std::vectorpush_back( wellPath->name() ); @@ -480,8 +480,7 @@ std::vector RicExportLgrFeature::buildLgrsForWellPaths( std::vector RicExportLgrFeature::buildLgrsForWellPaths( std::vectorname(), intersectingCells, lgrCellCounts ) ); + lgrs.push_back( buildLgr( lgrId, lgrName, wellPath->name(), intersectingCells, refinement ) ); } if ( isIntersectingOtherLgrs ) wellsIntersectingOtherLgrs->push_back( wellPath->name() ); @@ -519,7 +518,7 @@ std::vector RicExportLgrFeature::buildLgrsPerMainCell( int RimEclipseCase* eclipseCase, RimWellPath* wellPath, const std::vector& intersectingCells, - const caf::VecIjk& lgrSizes, + const caf::VecIjk& refinement, LgrNameFactory& lgrNameFactory ) { std::vector lgrs; @@ -527,7 +526,7 @@ std::vector RicExportLgrFeature::buildLgrsPerMainCell( int for ( const auto& intersectionCell : intersectingCells ) { auto lgrName = lgrNameFactory.newName( "", lgrId ); - lgrs.push_back( buildLgr( lgrId++, lgrName, eclipseCase, wellPath->name(), { intersectionCell }, lgrSizes ) ); + lgrs.push_back( buildLgr( lgrId++, lgrName, wellPath->name(), { intersectionCell }, refinement ) ); } return lgrs; } @@ -539,8 +538,8 @@ std::vector RicExportLgrFeature::buildLgrsPerCompletion( int firstLgrId, RimEclipseCase* eclipseCase, const std::map>& completionInfo, - const caf::VecIjk& lgrSizesPerMainGridCell, - LgrNameFactory& lgrNameFactory ) + const caf::VecIjk& refinement, + LgrNameFactory& lgrNameFactory ) { std::vector lgrs; @@ -593,7 +592,7 @@ std::vector for ( auto complInfo : occupiedBbs ) { auto lgrName = lgrNameFactory.newName( complInfo.first.type ); - lgrs.push_back( buildLgr( lgrId++, lgrName, eclipseCase, complInfo.first.wellPathName, complInfo.second, lgrSizesPerMainGridCell ) ); + lgrs.push_back( buildLgr( lgrId++, lgrName, complInfo.first.wellPathName, complInfo.second, refinement ) ); } return lgrs; } @@ -603,31 +602,17 @@ std::vector //-------------------------------------------------------------------------------------------------- LgrInfo RicExportLgrFeature::buildLgr( int lgrId, const QString& lgrName, - RimEclipseCase* eclipseCase, const QString& wellPathName, const std::vector& intersectingCells, - const caf::VecIjk& lgrSizesPerMainGridCell ) + const caf::VecIjk& refinement ) { - // Find min and max IJK - auto iRange = initRange(); - auto jRange = initRange(); - auto kRange = initRange(); - + IjkBoundingBox boundingBox; for ( const auto& cell : intersectingCells ) { - iRange.first = std::min( cell.localCellIndexI(), iRange.first ); - iRange.second = std::max( cell.localCellIndexI(), iRange.second ); - jRange.first = std::min( cell.localCellIndexJ(), jRange.first ); - jRange.second = std::max( cell.localCellIndexJ(), jRange.second ); - kRange.first = std::min( cell.localCellIndexK(), kRange.first ); - kRange.second = std::max( cell.localCellIndexK(), kRange.second ); + boundingBox.addCell( cell.localCellIndexI(), cell.localCellIndexJ(), cell.localCellIndexK() ); } - caf::VecIjk mainGridStartCell( iRange.first, jRange.first, kRange.first ); - caf::VecIjk mainGridEndCell( iRange.second, jRange.second, kRange.second ); - - IjkBoundingBox boundingBox( mainGridStartCell, mainGridEndCell ); - return buildLgr( lgrId, lgrName, eclipseCase, wellPathName, boundingBox, lgrSizesPerMainGridCell ); + return buildLgr( lgrId, lgrName, wellPathName, boundingBox, refinement ); } //-------------------------------------------------------------------------------------------------- @@ -635,16 +620,11 @@ LgrInfo RicExportLgrFeature::buildLgr( int //-------------------------------------------------------------------------------------------------- LgrInfo RicExportLgrFeature::buildLgr( int lgrId, const QString& lgrName, - RimEclipseCase* eclipseCase, const QString& wellPathName, const IjkBoundingBox& boundingBox, - const caf::VecIjk& lgrSizesPerMainGridCell ) + const caf::VecIjk& refinement ) { - caf::VecIjk lgrSizes( ( boundingBox.max().i() - boundingBox.min().i() + 1 ) * lgrSizesPerMainGridCell.i(), - ( boundingBox.max().j() - boundingBox.min().j() + 1 ) * lgrSizesPerMainGridCell.j(), - ( boundingBox.max().k() - boundingBox.min().k() + 1 ) * lgrSizesPerMainGridCell.k() ); - - return LgrInfo( lgrId, lgrName, wellPathName, lgrSizes, boundingBox.min(), boundingBox.max() ); + return LgrInfo( lgrId, lgrName, wellPathName, refinement, boundingBox.min(), boundingBox.max() ); } //-------------------------------------------------------------------------------------------------- @@ -790,7 +770,7 @@ void RicExportLgrFeature::onActionTriggered( bool isChecked ) if ( dialogData ) { auto eclipseCase = dialogData->caseToApply(); - auto lgrCellCounts = dialogData->lgrCellCount(); + auto lgrCellCounts = dialogData->refinement(); size_t timeStep = dialogData->timeStep(); QStringList wellsIntersectingOtherLgrs; @@ -876,7 +856,7 @@ std::pair mainGridCellBoundingBoxFromLgr( const RigGri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::map> RicExportLgrFeature::createLgrInfoListForTemporaryLgrs( const RigMainGrid* mainGrid ) +std::map> RicExportLgrFeature::createLgrInfoListForTemporaryLgrs( const RigMainGrid* mainGrid ) { std::map> lgrInfosPerWell; @@ -885,16 +865,25 @@ std::map> RicExportLgrFeature::create const auto grid = mainGrid->gridByIndex( i ); if ( !grid->isTempGrid() ) continue; - caf::VecIjk lgrSizes( grid->cellCountI(), grid->cellCountJ(), grid->cellCountK() ); std::pair mainGridBoundingBox = mainGridCellBoundingBoxFromLgr( grid ); + size_t mainGridCellCountI = mainGridBoundingBox.second.i() - mainGridBoundingBox.first.i() + 1; + size_t mainGridCellCountJ = mainGridBoundingBox.second.j() - mainGridBoundingBox.first.j() + 1; + size_t mainGridCellCountK = mainGridBoundingBox.second.k() - mainGridBoundingBox.first.k() + 1; + + auto refinementI = mainGridCellCountI > 0 ? std::max( size_t( 1 ), grid->cellCountI() / mainGridCellCountI ) : 1; + auto refinementJ = mainGridCellCountJ > 0 ? std::max( size_t( 1 ), grid->cellCountJ() / mainGridCellCountJ ) : 1; + auto refinementK = mainGridCellCountK > 0 ? std::max( size_t( 1 ), grid->cellCountK() / mainGridCellCountK ) : 1; + + caf::VecIjk refinement( refinementI, refinementJ, refinementK ); + QString wellName = QString::fromStdString( grid->associatedWellPathName() ); auto& item = lgrInfosPerWell[wellName]; item.emplace_back( LgrInfo( grid->gridId(), QString::fromStdString( grid->gridName() ), QString::fromStdString( grid->associatedWellPathName() ), - lgrSizes, + refinement, mainGridBoundingBox.first, mainGridBoundingBox.second ) ); } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.h b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.h index b0ed25ef21..61b1d3e6a3 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrFeature.h @@ -52,31 +52,42 @@ public: LgrInfo( int id, const QString& name, const QString& associatedWellPathName, - const caf::VecIjk& sizes, + const caf::VecIjk& refinement, const caf::VecIjk& mainGridStartCell, const caf::VecIjk& mainGridEndCell ) : id( id ) , name( name ) , associatedWellPathName( associatedWellPathName ) - , sizes( sizes ) + , refinement( refinement ) , mainGridStartCell( mainGridStartCell ) , mainGridEndCell( mainGridEndCell ) { } - caf::VecIjk sizesPerMainGridCell() const + caf::VecIjk lgrCellCounts() const { - return caf::VecIjk( sizes.i() / ( mainGridEndCell.i() - mainGridStartCell.i() + 1 ), - sizes.j() / ( mainGridEndCell.j() - mainGridStartCell.j() + 1 ), - sizes.k() / ( mainGridEndCell.k() - mainGridStartCell.k() + 1 ) ); + auto lgrI = ( mainGridEndCell.i() - mainGridStartCell.i() + 1 ) * refinement.i(); + auto lgrJ = ( mainGridEndCell.j() - mainGridStartCell.j() + 1 ) * refinement.j(); + auto lgrK = ( mainGridEndCell.k() - mainGridStartCell.k() + 1 ) * refinement.k(); + + lgrI = lgrI > 0 ? lgrI : 1; + lgrJ = lgrJ > 0 ? lgrJ : 1; + lgrK = lgrK > 0 ? lgrK : 1; + + return { lgrI, lgrJ, lgrK }; } - size_t cellCount() const { return sizes.i() * sizes.j() * sizes.k(); } + size_t lgrCellCount() const + { + auto size = lgrCellCounts(); + return size.i() * size.j() * size.k(); + } - int id; - QString name; - QString associatedWellPathName; - caf::VecIjk sizes; + int id; + QString name; + QString associatedWellPathName; + + caf::VecIjk refinement; caf::VecIjk mainGridStartCell; caf::VecIjk mainGridEndCell; @@ -158,7 +169,7 @@ class RicExportLgrFeature : public caf::CmdFeature std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ); @@ -168,14 +179,14 @@ class RicExportLgrFeature : public caf::CmdFeature static std::vector buildLgrsForWellPaths( std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ); static std::vector selectedWellPaths(); - static std::map> createLgrInfoListForTemporaryLgrs( const RigMainGrid* mainGrid ); + static std::map> createLgrInfoListForTemporaryLgrs( const RigMainGrid* mainGrid ); protected: bool isCommandEnabled() const override; @@ -189,26 +200,24 @@ private: RimEclipseCase* eclipseCase, RimWellPath* wellPath, const std::vector& intersectingCells, - const caf::VecIjk& lgrSizes, + const caf::VecIjk& refinement, LgrNameFactory& lgrNameFactory ); static std::vector buildLgrsPerCompletion( int firstLgrId, RimEclipseCase* eclipseCase, const std::map>& completionInfo, - const caf::VecIjk& lgrSizesPerMainGridCell, + const caf::VecIjk& refinement, LgrNameFactory& lgrNameFactory ); static LgrInfo buildLgr( int lgrId, const QString& lgrName, - RimEclipseCase* eclipseCase, const QString& wellPathName, const std::vector& intersectingCells, - const caf::VecIjk& lgrSizesPerMainGridCell ); + const caf::VecIjk& refinement ); static LgrInfo buildLgr( int lgrId, const QString& lgrName, - RimEclipseCase* eclipseCase, const QString& wellPathName, const IjkBoundingBox& boundingBox, - const caf::VecIjk& lgrSizesPerMainGridCell ); + const caf::VecIjk& refinement ); static std::vector cellsIntersectingCompletions( RimEclipseCase* eclipseCase, const RimWellPath* wellPath, diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp index afdbcfe1cb..96afe64db0 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.cpp @@ -62,13 +62,13 @@ RicExportLgrUi::RicExportLgrUi() CAF_PDM_InitField( &m_includeFractures, "IncludeFractures", true, "Fractures" ); CAF_PDM_InitField( &m_includeFishbones, "IncludeFishbones", true, "Fishbones" ); - QString ijkLabel = "Cell Count I, J, K"; - CAF_PDM_InitField( &m_cellCountI, "CellCountI", 2, ijkLabel ); - CAF_PDM_InitField( &m_cellCountJ, "CellCountJ", 2, "" ); - CAF_PDM_InitField( &m_cellCountK, "CellCountK", 2, "" ); + QString ijkLabel = "Refinement I, J, K"; + CAF_PDM_InitField( &m_refinementI, "CellCountI", 2, ijkLabel ); + CAF_PDM_InitField( &m_refinementJ, "CellCountJ", 2, "" ); + CAF_PDM_InitField( &m_refinementK, "CellCountK", 2, "" ); - m_cellCountJ.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); - m_cellCountK.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + m_refinementJ.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + m_refinementK.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); CAF_PDM_InitField( &m_splitType, "SplitType", Lgr::SplitTypeEnum(), "Split Type" ); } @@ -104,9 +104,9 @@ void RicExportLgrUi::setTimeStep( int timeStep ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::VecIjk RicExportLgrUi::lgrCellCount() const +caf::VecIjk RicExportLgrUi::refinement() const { - return caf::VecIjk( m_cellCountI, m_cellCountJ, m_cellCountK ); + return caf::VecIjk( m_refinementI, m_refinementJ, m_refinementK ); } //-------------------------------------------------------------------------------------------------- @@ -180,9 +180,9 @@ void RicExportLgrUi::setDefaultValuesFromCase() m_exportFolder = caseFolder; } - m_cellCountI = 2; - m_cellCountJ = 2; - m_cellCountK = 2; + m_refinementI = 2; + m_refinementJ = 2; + m_refinementK = 2; } //-------------------------------------------------------------------------------------------------- @@ -230,9 +230,9 @@ void RicExportLgrUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add( &m_splitType, { .newRow = true, .totalColumnSpan = 6, .leftLabelColumnSpan = 1 } ); caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup( "Grid Refinement" ); - gridRefinement->add( &m_cellCountI, { .newRow = true, .totalColumnSpan = 2, .leftLabelColumnSpan = 1 } ); - gridRefinement->appendToRow( &m_cellCountJ ); - gridRefinement->appendToRow( &m_cellCountK ); + gridRefinement->add( &m_refinementI, { .newRow = true, .totalColumnSpan = 2, .leftLabelColumnSpan = 1 } ); + gridRefinement->appendToRow( &m_refinementJ ); + gridRefinement->appendToRow( &m_refinementK ); // uiOrdering.add(&m_wellPathsInfo); uiOrdering.skipRemainingFields( true ); diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h index b78097d2cf..db9795b220 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportLgrUi.h @@ -53,7 +53,7 @@ public: void setCase( RimEclipseCase* rimCase ); void setTimeStep( int timeStep ); - caf::VecIjk lgrCellCount() const; + caf::VecIjk refinement() const; QString exportFolder() const; RimEclipseCase* caseToApply() const; int timeStep() const; @@ -79,9 +79,9 @@ private: caf::PdmField m_includeFractures; caf::PdmField m_includeFishbones; - caf::PdmField m_cellCountI; - caf::PdmField m_cellCountJ; - caf::PdmField m_cellCountK; + caf::PdmField m_refinementI; + caf::PdmField m_refinementJ; + caf::PdmField m_refinementK; caf::PdmField m_splitType; }; diff --git a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp index c551958c16..2863e01f8b 100644 --- a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -58,7 +58,7 @@ CAF_CMD_SOURCE_INIT( RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature void RicCreateTemporaryLgrFeature::createLgrsForWellPaths( std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ) @@ -67,19 +67,14 @@ void RicCreateTemporaryLgrFeature::createLgrsForWellPaths( std::vectoractiveCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL ); - auto lgrs = RicExportLgrFeature::buildLgrsForWellPaths( wellPaths, - eclipseCase, - timeStep, - lgrCellCounts, - splitType, - completionTypes, - wellsIntersectingOtherLgrs ); + auto lgrs = + RicExportLgrFeature::buildLgrsForWellPaths( wellPaths, eclipseCase, timeStep, refinement, splitType, completionTypes, wellsIntersectingOtherLgrs ); for ( const auto& lgr : lgrs ) { createLgr( lgr, eclipseCase->eclipseCaseData()->mainGrid() ); - size_t lgrCellCount = lgr.cellCount(); + size_t lgrCellCount = lgr.lgrCellCount(); activeCellInfo->addLgr( lgrCellCount ); if ( fractureActiveCellInfo->reservoirActiveCellCount() > 0 ) @@ -153,7 +148,7 @@ void RicCreateTemporaryLgrFeature::onActionTriggered( bool isChecked ) if ( dialogData ) { auto eclipseCase = dialogData->caseToApply(); - auto lgrCellCounts = dialogData->lgrCellCount(); + auto refinement = dialogData->refinement(); size_t timeStep = dialogData->timeStep(); auto splitType = dialogData->splitType(); const auto completionTypes = dialogData->completionTypes(); @@ -162,7 +157,7 @@ void RicCreateTemporaryLgrFeature::onActionTriggered( bool isChecked ) QStringList wellsIntersectingOtherLgrs; - createLgrsForWellPaths( wellPaths, eclipseCase, timeStep, lgrCellCounts, splitType, completionTypes, &wellsIntersectingOtherLgrs ); + createLgrsForWellPaths( wellPaths, eclipseCase, timeStep, refinement, splitType, completionTypes, &wellsIntersectingOtherLgrs ); updateViews( eclipseCase ); @@ -192,7 +187,7 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri { int lgrId = lgrInfo.id; size_t totalCellCount = mainGrid->totalCellCount(); - size_t lgrCellCount = lgrInfo.cellCount(); + size_t lgrCellCount = lgrInfo.lgrCellCount(); // Create local grid and set properties RigLocalGrid* localGrid = new RigLocalGrid( mainGrid ); @@ -201,7 +196,7 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri localGrid->setGridId( lgrId ); localGrid->setIndexToStartOfCells( totalCellCount ); localGrid->setGridName( lgrInfo.name.toStdString() ); - localGrid->setCellCounts( cvf::Vec3st( lgrInfo.sizes.i(), lgrInfo.sizes.j(), lgrInfo.sizes.k() ) ); + localGrid->setCellCounts( cvf::Vec3st( lgrInfo.lgrCellCounts().i(), lgrInfo.lgrCellCounts().j(), lgrInfo.lgrCellCounts().k() ) ); mainGrid->addLocalGrid( localGrid ); size_t cellStartIndex = mainGrid->totalCellCount(); @@ -215,21 +210,21 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri mainGrid->nodes().resize( nodeStartIndex + lgrCellCount * 8, cvf::Vec3d( 0, 0, 0 ) ); } - auto lgrSizePerMainCell = lgrInfo.sizesPerMainGridCell(); + auto refinement = lgrInfo.refinement; size_t gridLocalCellIndex = 0; // Loop through all new LGR cells - for ( size_t lgrK = 0; lgrK < lgrInfo.sizes.k(); lgrK++ ) + for ( size_t lgrK = 0; lgrK < lgrInfo.lgrCellCounts().k(); lgrK++ ) { - size_t mainK = lgrInfo.mainGridStartCell.k() + lgrK / lgrSizePerMainCell.k(); + size_t mainK = lgrInfo.mainGridStartCell.k() + lgrK / refinement.k(); - for ( size_t lgrJ = 0; lgrJ < lgrInfo.sizes.j(); lgrJ++ ) + for ( size_t lgrJ = 0; lgrJ < lgrInfo.lgrCellCounts().j(); lgrJ++ ) { - size_t mainJ = lgrInfo.mainGridStartCell.j() + lgrJ / lgrSizePerMainCell.j(); + size_t mainJ = lgrInfo.mainGridStartCell.j() + lgrJ / refinement.j(); - for ( size_t lgrI = 0; lgrI < lgrInfo.sizes.i(); lgrI++, gridLocalCellIndex++ ) + for ( size_t lgrI = 0; lgrI < lgrInfo.lgrCellCounts().i(); lgrI++, gridLocalCellIndex++ ) { - size_t mainI = lgrInfo.mainGridStartCell.i() + lgrI / lgrSizePerMainCell.i(); + size_t mainI = lgrInfo.mainGridStartCell.i() + lgrI / refinement.i(); size_t mainCellIndex = mainGrid->cellIndexFromIJK( mainI, mainJ, mainK ); auto& mainGridCell = mainGrid->cell( mainCellIndex ); @@ -244,14 +239,14 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri size_t cIdx; std::array vertices = mainGrid->cellCornerVertices( mainCellIndex ); - auto cellCounts = lgrInfo.sizesPerMainGridCell(); - auto lgrCoords = RiaCellDividingTools::createHexCornerCoords( vertices, cellCounts.i(), cellCounts.j(), cellCounts.k() ); + std::vector lgrCoords = + RiaCellDividingTools::createHexCornerCoords( vertices, refinement.i(), refinement.j(), refinement.k() ); - size_t subI = lgrI % lgrSizePerMainCell.i(); - size_t subJ = lgrJ % lgrSizePerMainCell.j(); - size_t subK = lgrK % lgrSizePerMainCell.k(); + size_t subI = lgrI % refinement.i(); + size_t subJ = lgrJ % refinement.j(); + size_t subK = lgrK % refinement.k(); - size_t subIndex = subI + subJ * lgrSizePerMainCell.i() + subK * lgrSizePerMainCell.i() * lgrSizePerMainCell.j(); + size_t subIndex = subI + subJ * refinement.i() + subK * refinement.i() * refinement.j(); for ( cIdx = 0; cIdx < 8; ++cIdx ) { diff --git a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.h b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.h index ae39c9896c..ad8fbcfa55 100644 --- a/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.h +++ b/ApplicationLibCode/Commands/RicCreateTemporaryLgrFeature.h @@ -49,20 +49,21 @@ public: void createLgrsForWellPaths( std::vector wellPaths, RimEclipseCase* eclipseCase, size_t timeStep, - caf::VecIjk lgrCellCounts, + caf::VecIjk refinement, Lgr::SplitType splitType, const std::set& completionTypes, QStringList* wellsIntersectingOtherLgrs ); void updateViews( RimEclipseCase* eclipseCase ); + static void createLgr( const LgrInfo& lgrInfo, RigMainGrid* mainGrid ); + protected: bool isCommandEnabled() const override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; private: - void createLgr( const LgrInfo& lgrInfo, RigMainGrid* mainGrid ); void computeCachedData( RimEclipseCase* eclipseCase ); void deleteAllCachedData( RimEclipseCase* eclipseCase ); };