diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelFeature.cpp index 62ee5d3bc5..9bd838f328 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelFeature.cpp @@ -99,17 +99,7 @@ void RicExportSectorModelFeature::doExport( RicExportSectorModelUi* exportSettin RigSimulationInputSettings settings; settings.setMin( exportSettings->min() ); settings.setMax( exportSettings->max() ); - settings.setRefinement( exportSettings->refinement() ); - - if ( exportSettings->hasNonUniformRefinement() ) - { - auto nonUniform = exportSettings->nonUniformRefinement(); - RiaLogging::info( QString( "Sector model export: non-uniform refinement enabled, refined grid dimensions [%1, %2, %3]" ) - .arg( nonUniform.totalRefinedCount( RigNonUniformRefinement::DimI ) ) - .arg( nonUniform.totalRefinedCount( RigNonUniformRefinement::DimJ ) ) - .arg( nonUniform.totalRefinedCount( RigNonUniformRefinement::DimK ) ) ); - settings.setNonUniformRefinement( nonUniform ); - } + settings.setEffectiveRefinement( exportSettings->effectiveRefinement() ); std::vector keywordsToRemove; for ( auto& s : exportSettings->keywordsToRemove() ) diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.cpp b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.cpp index 8094a4ee5a..eb92a3eace 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.cpp @@ -457,6 +457,15 @@ RicRefinementSettings* RicExportSectorModelUi::refinementSettings() const return m_refinementSettings(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigNonUniformRefinement RicExportSectorModelUi::effectiveRefinement() const +{ + m_refinementSettings->setSectorBounds( min(), max() ); + return m_refinementSettings->effectiveRefinement(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.h b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.h index 3a8a88d0ed..23e4d0adad 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicExportSectorModelUi.h @@ -66,6 +66,7 @@ public: RicRefinementSettings* refinementSettings() const; + RigNonUniformRefinement effectiveRefinement() const; cvf::Vec3st refinement() const; RigNonUniformRefinement nonUniformRefinement() const; bool hasNonUniformRefinement() const; diff --git a/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.cpp b/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.cpp index 1a73b6129e..f8131466a2 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.cpp @@ -125,6 +125,27 @@ void RicRefinementSettings::setSectorBounds( const caf::VecIjk0& min, const caf: m_sectorMaxK = static_cast( max.z() ) + 1; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigNonUniformRefinement RicRefinementSettings::effectiveRefinement() const +{ + size_t sectorSizeI = m_sectorMaxI - m_sectorMinI + 1; + size_t sectorSizeJ = m_sectorMaxJ - m_sectorMinJ + 1; + size_t sectorSizeK = m_sectorMaxK - m_sectorMinK + 1; + + cvf::Vec3st sectorSize( sectorSizeI, sectorSizeJ, sectorSizeK ); + + if ( !m_refineGrid() ) return RigNonUniformRefinement( sectorSize ); + + if ( m_refinementMode() == UNIFORM ) + { + return RigNonUniformRefinement::fromUniform( cvf::Vec3st( m_refinementCountI(), m_refinementCountJ(), m_refinementCountK() ), sectorSize ); + } + + return nonUniformRefinement(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.h b/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.h index f1f344254a..f1d4e0bf5a 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.h +++ b/ApplicationLibCode/Commands/ExportCommands/RicRefinementSettings.h @@ -59,6 +59,7 @@ public: void setSectorBounds( const caf::VecIjk0& min, const caf::VecIjk0& max ); // Data access + RigNonUniformRefinement effectiveRefinement() const; cvf::Vec3st refinement() const; RefinementMode refinementMode() const; RigNonUniformRefinement nonUniformRefinement() const; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp index 369aa0916e..cbe557bc7e 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcEclipseCase.cpp @@ -30,6 +30,7 @@ #include "RigEclipseResultAddress.h" #include "RigGridExportAdapter.h" #include "RigMainGrid.h" +#include "RigNonUniformRefinement.h" #include "RigResdataGridConverter.h" #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" @@ -247,7 +248,9 @@ std::expected RimcEclipseCase_exportCornerPointG // Use RigGridExportAdapter to handle full grid export // Export the full grid (no min/max bounds, no refinement, no visibility override) - RigGridExportAdapter gridAdapter( eclipseCaseData, cvf::Vec3st::ZERO, cvf::Vec3st::UNDEFINED, cvf::Vec3st( 1, 1, 1 ), nullptr ); + const auto* mainGrid = eclipseCaseData->mainGrid(); + cvf::Vec3st fullSize( mainGrid->cellCountI(), mainGrid->cellCountJ(), mainGrid->cellCountK() ); + RigGridExportAdapter gridAdapter( eclipseCaseData, cvf::Vec3st::ZERO, cvf::Vec3st::UNDEFINED, RigNonUniformRefinement( fullSize ), nullptr ); // Use the existing conversion utility to get the arrays in the correct format std::vector coordArray; diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseResultTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseResultTools.cpp index db2909f624..2a2627cd63 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseResultTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseResultTools.cpp @@ -237,27 +237,28 @@ std::pair, int> generateOperNumResult( RimEclipseCase* auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); if ( mainGrid ) { - cvf::Vec3st originalMin = gridAdapter.originalMin(); - cvf::Vec3st refinement = gridAdapter.refinement(); + cvf::Vec3st originalMin = gridAdapter.originalMin(); + const RigNonUniformRefinement& ref = gridAdapter.nonUniformRefinement(); // Refine the OPERNUM data to match the refined grid - // Each original cell is subdivided into refinement.x * refinement.y * refinement.z subcells size_t refinedNI = gridAdapter.cellCountI(); size_t refinedNJ = gridAdapter.cellCountJ(); size_t refinedNK = gridAdapter.cellCountK(); for ( size_t rk = 0; rk < refinedNK; ++rk ) { + auto [sectorK, subK] = ref.mapRefinedToOriginal( RigNonUniformRefinement::DimK, rk ); for ( size_t rj = 0; rj < refinedNJ; ++rj ) { + auto [sectorJ, subJ] = ref.mapRefinedToOriginal( RigNonUniformRefinement::DimJ, rj ); for ( size_t ri = 0; ri < refinedNI; ++ri ) { - // Calculate which original cell this refined cell belongs to - size_t origI = originalMin.x() + ri / refinement.x(); - size_t origJ = originalMin.y() + rj / refinement.y(); - size_t origK = originalMin.z() + rk / refinement.z(); + auto [sectorI, subI] = ref.mapRefinedToOriginal( RigNonUniformRefinement::DimI, ri ); // Get the OPERNUM value from the original grid + size_t origI = originalMin.x() + sectorI; + size_t origJ = originalMin.y() + sectorJ; + size_t origK = originalMin.z() + sectorK; size_t origCellIdx = mainGrid->cellIndexFromIJK( origI, origJ, origK ); if ( origCellIdx < resultValues.size() ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.cpp index c64d802ca9..8911b5dca6 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.cpp @@ -34,37 +34,6 @@ #include -//-------------------------------------------------------------------------------------------------- -/// Generate refined cell corners using trilinear interpolation within the original cell -/// This ensures refined cells are strictly contained within the original cell bounds -//-------------------------------------------------------------------------------------------------- -static std::array generateRefinedCellCorners( const std::array& originalCorners, - size_t refinementI, - size_t refinementJ, - size_t refinementK, - size_t subI, - size_t subJ, - size_t subK ) -{ - // Use ResInsight's proven face-based refinement approach - auto allRefinedCorners = RiaCellDividingTools::createHexCornerCoords( originalCorners, refinementI, refinementJ, refinementK ); - - // Calculate the linear index of the specific subcell we want - // createHexCornerCoords uses for(z) for(y) for(x) loops, so X is fastest changing (X-major) - // Linear index = z * (nx * ny) + y * nx + x - size_t subcellIndex = subK * ( refinementI * refinementJ ) + subJ * refinementI + subI; - size_t cornerStartIndex = subcellIndex * 8; - - // Extract the 8 corners for this specific subcell - std::array refinedCorners; - for ( size_t i = 0; i < 8; ++i ) - { - refinedCorners[i] = allRefinedCorners[cornerStartIndex + i]; - } - - return refinedCorners; -} - //-------------------------------------------------------------------------------------------------- /// Generate refined cell corners using non-uniform cumulative fractions //-------------------------------------------------------------------------------------------------- @@ -94,62 +63,20 @@ static std::array generateRefinedCellCornersNonUniform( const std return refinedCorners; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigGridExportAdapter::RigGridExportAdapter( RigEclipseCaseData* eclipseCase, - const cvf::Vec3st& min, - const cvf::Vec3st& max, - const cvf::Vec3st& refinement, - const cvf::UByteArray* cellVisibilityOverrideForActnum ) - : m_mainGrid( nullptr ) - , m_activeCellInfo( nullptr ) - , m_cellVisibilityOverride( cellVisibilityOverrideForActnum ) - , m_min( min ) - , m_max( max ) - , m_refinement( refinement ) - , m_refinedNI( 0 ) - , m_refinedNJ( 0 ) - , m_refinedNK( 0 ) -{ - CVF_ASSERT( eclipseCase ); - - m_mainGrid = eclipseCase->mainGrid(); - m_activeCellInfo = eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); - - CVF_ASSERT( m_mainGrid ); - CVF_ASSERT( m_activeCellInfo ); - - // Calculate actual max if undefined - cvf::Vec3st maxActual = - max.isUndefined() ? cvf::Vec3st( m_mainGrid->cellCountI() - 1, m_mainGrid->cellCountJ() - 1, m_mainGrid->cellCountK() - 1 ) : max; - m_max = maxActual; - - // Calculate refined grid dimensions - m_refinedNI = ( maxActual.x() - min.x() + 1 ) * refinement.x(); - m_refinedNJ = ( maxActual.y() - min.y() + 1 ) * refinement.y(); - m_refinedNK = ( maxActual.z() - min.z() + 1 ) * refinement.z(); - - // Create equivalent non-uniform refinement for internal use - cvf::Vec3st sectorSize( maxActual.x() - min.x() + 1, maxActual.y() - min.y() + 1, maxActual.z() - min.z() + 1 ); - m_nonUniformRefinement = RigNonUniformRefinement::fromUniform( refinement, sectorSize ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigGridExportAdapter::RigGridExportAdapter( RigEclipseCaseData* eclipseCase, const cvf::Vec3st& min, const cvf::Vec3st& max, - const RigNonUniformRefinement& nonUniformRefinement, + const RigNonUniformRefinement& refinement, const cvf::UByteArray* cellVisibilityOverrideForActnum ) : m_mainGrid( nullptr ) , m_activeCellInfo( nullptr ) , m_cellVisibilityOverride( cellVisibilityOverrideForActnum ) , m_min( min ) , m_max( max ) - , m_refinement( 1, 1, 1 ) - , m_nonUniformRefinement( nonUniformRefinement ) + , m_nonUniformRefinement( refinement ) , m_refinedNI( 0 ) , m_refinedNJ( 0 ) , m_refinedNK( 0 ) @@ -384,22 +311,17 @@ std::array RigGridExportAdapter::computeRefinedCorners( const std size_t subJ, size_t subK ) const { - if ( m_nonUniformRefinement.hasNonUniformRefinement() ) - { - size_t sectorI = origI - m_min.x(); - size_t sectorJ = origJ - m_min.y(); - size_t sectorK = origK - m_min.z(); + size_t sectorI = origI - m_min.x(); + size_t sectorJ = origJ - m_min.y(); + size_t sectorK = origK - m_min.z(); - return generateRefinedCellCornersNonUniform( originalCorners, - m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimI, sectorI ), - m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimJ, sectorJ ), - m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimK, sectorK ), - subI, - subJ, - subK ); - } - - return generateRefinedCellCorners( originalCorners, m_refinement.x(), m_refinement.y(), m_refinement.z(), subI, subJ, subK ); + return generateRefinedCellCornersNonUniform( originalCorners, + m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimI, sectorI ), + m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimJ, sectorJ ), + m_nonUniformRefinement.cumulativeFractions( RigNonUniformRefinement::DimK, sectorK ), + subI, + subJ, + subK ); } //-------------------------------------------------------------------------------------------------- @@ -439,29 +361,16 @@ RigGridExportAdapter::CellMapping RigGridExportAdapter::mapRefinedToOriginal( si { CellMapping mapping; - if ( m_nonUniformRefinement.hasNonUniformRefinement() ) - { - auto [origI, subI] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimI, refinedI ); - auto [origJ, subJ] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimJ, refinedJ ); - auto [origK, subK] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimK, refinedK ); + auto [origI, subI] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimI, refinedI ); + auto [origJ, subJ] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimJ, refinedJ ); + auto [origK, subK] = m_nonUniformRefinement.mapRefinedToOriginal( RigNonUniformRefinement::DimK, refinedK ); - mapping.originalI = m_min.x() + origI; - mapping.originalJ = m_min.y() + origJ; - mapping.originalK = m_min.z() + origK; - mapping.subI = subI; - mapping.subJ = subJ; - mapping.subK = subK; - } - else - { - mapping.originalI = m_min.x() + refinedI / m_refinement.x(); - mapping.originalJ = m_min.y() + refinedJ / m_refinement.y(); - mapping.originalK = m_min.z() + refinedK / m_refinement.z(); - - mapping.subI = refinedI % m_refinement.x(); - mapping.subJ = refinedJ % m_refinement.y(); - mapping.subK = refinedK % m_refinement.z(); - } + mapping.originalI = m_min.x() + origI; + mapping.originalJ = m_min.y() + origJ; + mapping.originalK = m_min.z() + origK; + mapping.subI = subI; + mapping.subJ = subJ; + mapping.subK = subK; return mapping; } @@ -482,20 +391,12 @@ cvf::Vec3st RigGridExportAdapter::originalMax() const return m_max; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec3st RigGridExportAdapter::refinement() const -{ - return m_refinement; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigGridExportAdapter::hasRefinement() const { - return m_refinement.x() > 1 || m_refinement.y() > 1 || m_refinement.z() > 1 || m_nonUniformRefinement.hasNonUniformRefinement(); + return m_nonUniformRefinement.hasNonUniformRefinement(); } //-------------------------------------------------------------------------------------------------- @@ -530,54 +431,6 @@ size_t RigGridExportAdapter::totalCells() const return m_refinedNI * m_refinedNJ * m_refinedNK; } -//-------------------------------------------------------------------------------------------------- -/// Transform IJK coordinates from global grid space to sector-relative space with refinement -/// Returns 0-based coordinates -//-------------------------------------------------------------------------------------------------- -std::expected RigGridExportAdapter::transformIjkToSectorCoordinates( const caf::VecIjk0& ijk, - const caf::VecIjk0& min, - const caf::VecIjk0& max, - const cvf::Vec3st& refinement, - bool applyRefinementCentering, - bool isBoxMaxCoordinate ) -{ - // Check if original IJK is within the sector bounds - RigBoundingBoxIjk sectorBox( min, max ); - if ( !sectorBox.contains( ijk ) ) - { - return std::unexpected( QString( "IJK coordinates (%1) are outside sector bounds [(%2), (%3)]" ) - .arg( QString::fromStdString( ijk.toString() ) ) - .arg( QString::fromStdString( min.toString() ) ) - .arg( QString::fromStdString( max.toString() ) ) ); - } - - // Transform to sector-relative coordinates with refinement - // Returns 0-based coordinates - if ( applyRefinementCentering ) - { - // Center the coordinate in the refined cell block (for point coordinates like WELSPECS) - return caf::VecIjk0( ( ijk.x() - min.x() ) * refinement.x() + ( refinement.x() + 1 ) / 2 - 1, - ( ijk.y() - min.y() ) * refinement.y() + ( refinement.y() + 1 ) / 2 - 1, - ( ijk.z() - min.z() ) * refinement.z() + ( refinement.z() + 1 ) / 2 - 1 ); - } - else if ( isBoxMaxCoordinate ) - { - // Box maximum coordinate: map to end of last refined cell - // For a cell at index i (0-based), after refinement it becomes cells [i*r, i*r+r-1] - // So the max index of a box [min, max] becomes: (max-sector_min+1)*r - 1 (0-based) - return caf::VecIjk0( ( ijk.x() - min.x() + 1 ) * refinement.x() - 1, - ( ijk.y() - min.y() + 1 ) * refinement.y() - 1, - ( ijk.z() - min.z() + 1 ) * refinement.z() - 1 ); - } - else - { - // Box minimum coordinate: map to start of first refined cell - return caf::VecIjk0( ( ijk.x() - min.x() ) * refinement.x(), - ( ijk.y() - min.y() ) * refinement.y(), - ( ijk.z() - min.z() ) * refinement.z() ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -587,7 +440,7 @@ const RigNonUniformRefinement& RigGridExportAdapter::nonUniformRefinement() cons } //-------------------------------------------------------------------------------------------------- -/// Transform IJK coordinates from global grid space to sector-relative space with non-uniform refinement +/// Transform IJK coordinates from global grid space to sector-relative space with refinement //-------------------------------------------------------------------------------------------------- std::expected RigGridExportAdapter::transformIjkToSectorCoordinates( const caf::VecIjk0& ijk, const caf::VecIjk0& min, diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.h b/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.h index 077e67a6cc..203d606989 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridExportAdapter.h @@ -62,16 +62,10 @@ class QString; class RigGridExportAdapter { public: - RigGridExportAdapter( RigEclipseCaseData* eclipseCase, - const cvf::Vec3st& min, - const cvf::Vec3st& max, - const cvf::Vec3st& refinement, - const cvf::UByteArray* cellVisibilityOverrideForActnum = nullptr ); - RigGridExportAdapter( RigEclipseCaseData* eclipseCase, const cvf::Vec3st& min, const cvf::Vec3st& max, - const RigNonUniformRefinement& nonUniformRefinement, + const RigNonUniformRefinement& refinement, const cvf::UByteArray* cellVisibilityOverrideForActnum = nullptr ); // Grid dimensions (after refinement) @@ -93,24 +87,16 @@ public: // Grid bounds and refinement info cvf::Vec3st originalMin() const; cvf::Vec3st originalMax() const; - cvf::Vec3st refinement() const; bool hasRefinement() const; - // Non-uniform refinement accessor + // Refinement accessor const RigNonUniformRefinement& nonUniformRefinement() const; - // Coordinate transformation utilities - static std::expected transformIjkToSectorCoordinates( const caf::VecIjk0& originalIjk, - const caf::VecIjk0& min, - const caf::VecIjk0& max, - const cvf::Vec3st& refinement, - bool applyRefinementCentering = false, - bool isBoxMaxCoordinate = false ); - + // Coordinate transformation utility static std::expected transformIjkToSectorCoordinates( const caf::VecIjk0& originalIjk, const caf::VecIjk0& min, const caf::VecIjk0& max, - const RigNonUniformRefinement& nonUniformRefinement, + const RigNonUniformRefinement& refinement, bool applyRefinementCentering = false, bool isBoxMaxCoordinate = false ); @@ -142,7 +128,6 @@ private: cvf::Vec3st m_min; cvf::Vec3st m_max; - cvf::Vec3st m_refinement; RigNonUniformRefinement m_nonUniformRefinement; diff --git a/ApplicationLibCode/ReservoirDataModel/RigResdataGridConverter.cpp b/ApplicationLibCode/ReservoirDataModel/RigResdataGridConverter.cpp index 904dd6be98..af801f29e0 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigResdataGridConverter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigResdataGridConverter.cpp @@ -23,6 +23,7 @@ #include "RigEclipseCaseData.h" #include "RigGridExportAdapter.h" #include "RigMainGrid.h" +#include "RigNonUniformRefinement.h" #include "RifReaderEclipseOutput.h" @@ -50,7 +51,12 @@ bool RigResdataGridConverter::exportGrid( const QString& resultFileName, if ( !eclipseCase ) return false; // Create grid export adapter that handles all the complexity - RigGridExportAdapter gridAdapter( eclipseCase, min, max, refinement, cellVisibilityOverrideForActnum ); + // Compute sector size for creating non-uniform refinement (adapter resolves UNDEFINED max internally) + const auto* mainGrid = eclipseCase->mainGrid(); + cvf::Vec3st resolvedMax = + max.isUndefined() ? cvf::Vec3st( mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1 ) : max; + cvf::Vec3st sectorSize( resolvedMax.x() - min.x() + 1, resolvedMax.y() - min.y() + 1, resolvedMax.z() - min.z() + 1 ); + RigGridExportAdapter gridAdapter( eclipseCase, min, max, RigNonUniformRefinement::fromUniform( refinement, sectorSize ), cellVisibilityOverrideForActnum ); size_t ni = gridAdapter.cellCountI(); size_t nj = gridAdapter.cellCountJ(); diff --git a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.cpp b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.cpp index 8dffdb589d..7301f0837d 100644 --- a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.cpp +++ b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.cpp @@ -77,6 +77,39 @@ std::expected RigSimulationInputSettings::validateBox() const return {}; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigNonUniformRefinement RigSimulationInputSettings::effectiveRefinement() const +{ + if ( hasNonUniformRefinement() ) return m_nonUniformRefinement; + + auto sectorSize = + cvf::Vec3st( m_max.x() - m_min.x() + 1, m_max.y() - m_min.y() + 1, m_max.z() - m_min.z() + 1 ); + + if ( m_refinement.x() > 1 || m_refinement.y() > 1 || m_refinement.z() > 1 ) + return RigNonUniformRefinement::fromUniform( m_refinement, sectorSize ); + + return RigNonUniformRefinement( sectorSize ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigSimulationInputSettings::setEffectiveRefinement( const RigNonUniformRefinement& refinement ) +{ + m_nonUniformRefinement = refinement; + m_refinement = cvf::Vec3st( 1, 1, 1 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigSimulationInputSettings::hasRefinement() const +{ + return ( m_refinement.x() > 1 || m_refinement.y() > 1 || m_refinement.z() > 1 ) || hasNonUniformRefinement(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.h b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.h index 819477488c..c139e01316 100644 --- a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.h +++ b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputSettings.h @@ -57,11 +57,16 @@ public: std::expected validateBox() const; - // Grid refinement + // Unified refinement interface + RigNonUniformRefinement effectiveRefinement() const; + void setEffectiveRefinement( const RigNonUniformRefinement& refinement ); + bool hasRefinement() const; + + // Grid refinement (legacy) cvf::Vec3st refinement() const; void setRefinement( const cvf::Vec3st& refinement ); - // Non-uniform refinement + // Non-uniform refinement (legacy) const RigNonUniformRefinement& nonUniformRefinement() const; void setNonUniformRefinement( const RigNonUniformRefinement& refinement ); bool hasNonUniformRefinement() const; diff --git a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.cpp b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.cpp index 8e2d8e6d83..d6822fed92 100644 --- a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.cpp +++ b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.cpp @@ -194,16 +194,7 @@ std::expected RigSimulationInputTool::updateCornerPointGridInDeck RifOpmFlowDeckFile& deckFile ) { // Get grid bounds for extraction - auto createGridAdapter = [&]() - { - if ( settings.hasNonUniformRefinement() ) - { - return RigGridExportAdapter( eclipseCase->eclipseCaseData(), settings.min(), settings.max(), settings.nonUniformRefinement() ); - } - return RigGridExportAdapter( eclipseCase->eclipseCaseData(), settings.min(), settings.max(), settings.refinement() ); - }; - - RigGridExportAdapter gridAdapter = createGridAdapter(); + RigGridExportAdapter gridAdapter( eclipseCase->eclipseCaseData(), settings.min(), settings.max(), settings.effectiveRefinement() ); std::vector coordArray; std::vector zcornArray; @@ -302,16 +293,11 @@ std::expected RigSimulationInputTool::replaceKeywordValuesInDeckF } // Try to extract keyword data - auto result = settings.hasNonUniformRefinement() ? RifEclipseInputFileTools::extractKeywordData( eclipseCase->eclipseCaseData(), - keyword, - settings.min(), - settings.max(), - settings.nonUniformRefinement() ) - : RifEclipseInputFileTools::extractKeywordData( eclipseCase->eclipseCaseData(), - keyword, - settings.min(), - settings.max(), - settings.refinement() ); + auto result = RifEclipseInputFileTools::extractKeywordData( eclipseCase->eclipseCaseData(), + keyword, + settings.min(), + settings.max(), + settings.effectiveRefinement() ); if ( result ) { // Replace keyword values in deck with extracted data @@ -347,17 +333,9 @@ std::set RigSimulationInputTool::cropDataKeywordsInDeckFile( RimEcl const size_t fullNz = mainGrid->cellCountK(); const size_t fullCellCount = fullNx * fullNy * fullNz; - const auto min = settings.min(); - const auto max = settings.max(); - const auto refinement = settings.refinement(); - - // Build non-uniform refinement for cropping (handles both uniform and non-uniform cases) - const bool hasNonUniform = settings.hasNonUniformRefinement(); - const auto nonUniformRef = - hasNonUniform - ? settings.nonUniformRefinement() - : RigNonUniformRefinement::fromUniform( refinement, - cvf::Vec3st( max.x() - min.x() + 1, max.y() - min.y() + 1, max.z() - min.z() + 1 ) ); + const auto min = settings.min(); + const auto max = settings.max(); + const auto nonUniformRef = settings.effectiveRefinement(); auto keywords = deckFile.keywords( false ); @@ -456,19 +434,11 @@ std::expected RigSimulationInputTool::addBorderBoundaryConditions } // Create grid adapter for refined grid operations - auto createBorderGridAdapter = [&]() - { - if ( settings.hasNonUniformRefinement() ) - { - return RigGridExportAdapter( eclipseCase->eclipseCaseData(), - settings.min(), - settings.max(), - settings.nonUniformRefinement(), - visibility.p() ); - } - return RigGridExportAdapter( eclipseCase->eclipseCaseData(), settings.min(), settings.max(), settings.refinement(), visibility.p() ); - }; - RigGridExportAdapter gridAdapter = createBorderGridAdapter(); + RigGridExportAdapter gridAdapter( eclipseCase->eclipseCaseData(), + settings.min(), + settings.max(), + settings.effectiveRefinement(), + visibility.p() ); // Create refined visibility array matching refined grid dimensions std::vector refinedVisibility = createRefinedVisibility( gridAdapter ); @@ -641,11 +611,11 @@ struct Modification /// Process a BOX keyword entry: update box state and return a modification for the BOX keyword. /// Returns std::unexpected on fatal exception. //-------------------------------------------------------------------------------------------------- -static std::expected processBoxKeywordEntry( const Opm::DeckKeyword& kw, - const Opm::FileDeck::Index& index, - const caf::VecIjk0& sectorMin, - const caf::VecIjk0& sectorMax, - const cvf::Vec3st& refinement, +static std::expected processBoxKeywordEntry( const Opm::DeckKeyword& kw, + const Opm::FileDeck::Index& index, + const caf::VecIjk0& sectorMin, + const caf::VecIjk0& sectorMax, + const RigNonUniformRefinement& refinement, bool& insideBox, std::array& activeBoxIndices, caf::VecIjk0& boxMin, @@ -712,8 +682,7 @@ static std::optional cropDataKeywordInBoxContext( const Opm::DeckK const caf::VecIjk0& boxMax, const caf::VecIjk0& sectorMin, const caf::VecIjk0& sectorMax, - const cvf::Vec3st& refinement, - const RigNonUniformRefinement* nonUniformRef = nullptr ) + const RigNonUniformRefinement& refinement ) { const std::string& name = kw.name(); @@ -741,14 +710,12 @@ static std::optional cropDataKeywordInBoxContext( const Opm::DeckK for ( size_t k = intMin.z(); k <= static_cast( intMax.z() ); ++k ) { - size_t subCountK = nonUniformRef ? nonUniformRef->subcellCount( RigNonUniformRefinement::DimK, k - sectorMin.z() ) - : refinement.z(); + size_t subCountK = refinement.subcellCount( RigNonUniformRefinement::DimK, k - sectorMin.z() ); for ( size_t rk = 0; rk < subCountK; ++rk ) { for ( size_t j = intMin.y(); j <= static_cast( intMax.y() ); ++j ) { - size_t subCountJ = nonUniformRef ? nonUniformRef->subcellCount( RigNonUniformRefinement::DimJ, j - sectorMin.y() ) - : refinement.y(); + size_t subCountJ = refinement.subcellCount( RigNonUniformRefinement::DimJ, j - sectorMin.y() ); for ( size_t rj = 0; rj < subCountJ; ++rj ) { for ( size_t i = intMin.x(); i <= static_cast( intMax.x() ); ++i ) @@ -758,8 +725,7 @@ static std::optional cropDataKeywordInBoxContext( const Opm::DeckK size_t boxRelK = k - boxMin.z(); size_t srcIdx = boxRelI + boxRelJ * boxNi + boxRelK * boxNi * boxNj; - size_t subCountI = nonUniformRef ? nonUniformRef->subcellCount( RigNonUniformRefinement::DimI, i - sectorMin.x() ) - : refinement.x(); + size_t subCountI = refinement.subcellCount( RigNonUniformRefinement::DimI, i - sectorMin.x() ); for ( size_t ri = 0; ri < subCountI; ++ri ) { croppedData.push_back( sourceData[srcIdx] ); @@ -816,14 +782,14 @@ static std::optional cropDataKeywordInBoxContext( const Opm::DeckK /// Process an EQUALS/COPY/ADD/MULTIPLY keyword: transform all records. /// Returns std::unexpected on fatal exception. //-------------------------------------------------------------------------------------------------- -static std::expected processRecordBasedKeyword( const Opm::DeckKeyword& kw, - const Opm::FileDeck::Index& index, - const RecordProcessorFunc& processorFunc, - bool insideBox, - const std::array& activeBoxIndices, - const caf::VecIjk0& sectorMin, - const caf::VecIjk0& sectorMax, - const cvf::Vec3st& refinement ) +static std::expected processRecordBasedKeyword( const Opm::DeckKeyword& kw, + const Opm::FileDeck::Index& index, + const RecordProcessorFunc& processorFunc, + bool insideBox, + const std::array& activeBoxIndices, + const caf::VecIjk0& sectorMin, + const caf::VecIjk0& sectorMax, + const RigNonUniformRefinement& refinement ) { const std::string& name = kw.name(); @@ -897,10 +863,7 @@ std::expected RigSimulationInputTool::transformKeywordsInDeckFile const auto sectorMin = settings.min(); const auto sectorMax = settings.max(); - const auto refinement = settings.refinement(); - - // Build non-uniform refinement pointer for functions that support it - const RigNonUniformRefinement* nonUniformRefPtr = settings.hasNonUniformRefinement() ? &settings.nonUniformRefinement() : nullptr; + const auto refinement = settings.effectiveRefinement(); // Map keyword names to their record processor functions const std::map recordProcessors = { @@ -937,7 +900,7 @@ std::expected RigSimulationInputTool::transformKeywordsInDeckFile } else if ( insideBox && kw.isDataKeyword() ) { - auto result = cropDataKeywordInBoxContext( kw, it, boxMin, boxMax, sectorMin, sectorMax, refinement, nonUniformRefPtr ); + auto result = cropDataKeywordInBoxContext( kw, it, boxMin, boxMax, sectorMin, sectorMax, refinement ); if ( result ) modifications.push_back( std::move( result.value() ) ); } else if ( auto procIt = recordProcessors.find( name ); procIt != recordProcessors.end() ) @@ -997,7 +960,7 @@ std::expected RigSimulationInputTool::replaceKeywordWithBoxIndice for ( size_t recordIdx = 0; recordIdx < kw.size(); ++recordIdx ) { const auto& record = kw.getRecord( recordIdx ); - auto result = processorFunc( record, settings.min(), settings.max(), settings.refinement() ); + auto result = processorFunc( record, settings.min(), settings.max(), settings.effectiveRefinement() ); if ( result ) { @@ -1072,27 +1035,18 @@ std::expected RigSimulationInputTool::updateWelldimsKeyword( RimE if ( wellDims.empty() ) return std::unexpected( QString( "Missing WELLDIMS keyword" ) ); // Scale the max connections with the refinement - int refinementProduct = 1; - if ( settings.hasNonUniformRefinement() ) + const auto& ref = settings.effectiveRefinement(); + size_t maxProduct = 1; + for ( auto dim : { RigNonUniformRefinement::DimI, RigNonUniformRefinement::DimJ, RigNonUniformRefinement::DimK } ) { - const auto& nuRef = settings.nonUniformRefinement(); - // Use the maximum subcell product across all cell combinations - size_t maxProduct = 1; - for ( auto dim : { RigNonUniformRefinement::DimI, RigNonUniformRefinement::DimJ, RigNonUniformRefinement::DimK } ) + size_t maxSubcells = 1; + for ( size_t idx = 0; idx < ref.sectorSize( dim ); ++idx ) { - size_t maxSubcells = 1; - for ( size_t idx = 0; idx < nuRef.sectorSize( dim ); ++idx ) - { - maxSubcells = std::max( maxSubcells, nuRef.subcellCount( dim, idx ) ); - } - maxProduct *= maxSubcells; + maxSubcells = std::max( maxSubcells, ref.subcellCount( dim, idx ) ); } - refinementProduct = static_cast( maxProduct ); - } - else - { - refinementProduct = static_cast( settings.refinement().x() * settings.refinement().y() * settings.refinement().z() ); + maxProduct *= maxSubcells; } + int refinementProduct = static_cast( maxProduct ); int newMaxConnections = wellDims[1] * refinementProduct; deckFile.setWelldims( wellDims[0], newMaxConnections, wellDims[2], wellDims[3] ); @@ -1213,22 +1167,13 @@ std::expected RigSimulationInputTool::processWelspecsR // Transform with clamped coordinates (this will always succeed) // Center the coordinate in the refined cell block - size_t sectorI, sectorJ; - if ( settings.hasNonUniformRefinement() ) - { - const auto& nuRef = settings.nonUniformRefinement(); - size_t relI = clampedI - settings.min().x(); - size_t relJ = clampedJ - settings.min().y(); - sectorI = - nuRef.cumulativeOffset( RigNonUniformRefinement::DimI, relI ) + ( nuRef.subcellCount( RigNonUniformRefinement::DimI, relI ) + 1 ) / 2; - sectorJ = - nuRef.cumulativeOffset( RigNonUniformRefinement::DimJ, relJ ) + ( nuRef.subcellCount( RigNonUniformRefinement::DimJ, relJ ) + 1 ) / 2; - } - else - { - sectorI = ( clampedI - settings.min().x() ) * settings.refinement().x() + ( settings.refinement().x() + 1 ) / 2; - sectorJ = ( clampedJ - settings.min().y() ) * settings.refinement().y() + ( settings.refinement().y() + 1 ) / 2; - } + const auto& effRef = settings.effectiveRefinement(); + size_t relI = clampedI - settings.min().x(); + size_t relJ = clampedJ - settings.min().y(); + size_t sectorI = + effRef.cumulativeOffset( RigNonUniformRefinement::DimI, relI ) + ( effRef.subcellCount( RigNonUniformRefinement::DimI, relI ) + 1 ) / 2; + size_t sectorJ = + effRef.cumulativeOffset( RigNonUniformRefinement::DimJ, relJ ) + ( effRef.subcellCount( RigNonUniformRefinement::DimJ, relJ ) + 1 ) / 2; if ( origI < static_cast( settings.min().x() ) || origI > static_cast( settings.max().x() ) || origJ < static_cast( settings.min().y() ) || origJ > static_cast( settings.max().y() ) ) @@ -1283,17 +1228,13 @@ std::expected RigSimulationInputTool::processCompdatRe // Transform K1 caf::VecIjk0 origIjkK1( origI, origJ, origK1 ); - auto transformResultK1 = - settings.hasNonUniformRefinement() - ? RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK1, settings.min(), settings.max(), settings.nonUniformRefinement(), true ) - : RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK1, settings.min(), settings.max(), settings.refinement(), true ); + auto transformResultK1 = + RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK1, settings.min(), settings.max(), settings.effectiveRefinement(), true ); // Transform K2 caf::VecIjk0 origIjkK2( origI, origJ, origK2 ); - auto transformResultK2 = - settings.hasNonUniformRefinement() - ? RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK2, settings.min(), settings.max(), settings.nonUniformRefinement(), true ) - : RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK2, settings.min(), settings.max(), settings.refinement(), true ); + auto transformResultK2 = + RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK2, settings.min(), settings.max(), settings.effectiveRefinement(), true ); if ( !transformResultK1 ) { @@ -1351,17 +1292,11 @@ std::expected RigSimulationInputTool::processCompsegsR // Transform I, J, K (first three items) caf::VecIjk1 origIjk = extractIjk( record, 0, 1, 2 ); - auto transformResult = settings.hasNonUniformRefinement() - ? RigGridExportAdapter::transformIjkToSectorCoordinates( origIjk.toZeroBased(), - settings.min(), - settings.max(), - settings.nonUniformRefinement(), - true ) - : RigGridExportAdapter::transformIjkToSectorCoordinates( origIjk.toZeroBased(), - settings.min(), - settings.max(), - settings.refinement(), - true ); + auto transformResult = RigGridExportAdapter::transformIjkToSectorCoordinates( origIjk.toZeroBased(), + settings.min(), + settings.max(), + settings.effectiveRefinement(), + true ); if ( !transformResult ) { @@ -1401,7 +1336,7 @@ std::expected, QString> RigSimulationInputTool::transformBoxToSectorCoordinates( const RigBoundingBoxIjk& inputBox, const caf::VecIjk0& sectorMin, const caf::VecIjk0& sectorMax, - const cvf::Vec3st& refinement, + const RigNonUniformRefinement& refinement, const QString& keywordName, const QString& recordIdentifier ) { @@ -1475,10 +1410,10 @@ std::expected, QString> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::expected RigSimulationInputTool::processEqualsRecord( const Opm::DeckRecord& record, - const caf::VecIjk0& min, - const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) +std::expected RigSimulationInputTool::processEqualsRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ) { // EQUALS format: FIELD VALUE I1 I2 J1 J2 K1 K2 // Items: 0=FIELD, 1=VALUE, 2=I1, 3=I2, 4=J1, 5=J2, 6=K1, 7=K2 @@ -1533,7 +1468,7 @@ std::expected RigSimulationInputTool::processEqualsRec std::expected RigSimulationInputTool::processMultiplyRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // MULTIPLY format: FIELD FACTOR I1 I2 J1 J2 K1 K2 // Items: 0=FIELD, 1=FACTOR, 2=I1, 3=I2, 4=J1, 5=J2, 6=K1, 7=K2 @@ -1588,7 +1523,7 @@ std::expected RigSimulationInputTool::processMultiplyR std::expected RigSimulationInputTool::processAddRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // ADD format: FIELD SHIFT I1 I2 J1 J2 K1 K2 // Items: 0=FIELD, 1=SHIFT, 2=I1, 3=I2, 4=J1, 5=J2, 6=K1, 7=K2 @@ -1643,7 +1578,7 @@ std::expected RigSimulationInputTool::processAddRecord std::expected RigSimulationInputTool::processAquconRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // AQUCON format: ID I1 I2 J1 J2 K1 K2 CONNECT_FACE ... // Items: 0=ID, 1=I1, 2=I2, 3=J1, 4=J2, 5=K1, 6=K2, 7+=other parameters @@ -1713,7 +1648,7 @@ std::expected RigSimulationInputTool::processAquconRec std::expected RigSimulationInputTool::processAquanconRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // AQUANCON format: ID I1 I2 J1 J2 K1 K2 AQU_FACE ... // Items: 0=ID, 1=I1, 2=I2, 3=J1, 4=J2, 5=K1, 6=K2, 7+=other parameters @@ -1783,7 +1718,7 @@ std::expected RigSimulationInputTool::processAquanconR std::expected RigSimulationInputTool::processAqunumRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // AQUNUM format: ID I J K AREA ... // Items: 0=ID, 1=I, 2=J, 3=K, 4+=other parameters @@ -1848,7 +1783,7 @@ std::expected RigSimulationInputTool::processAqunumRec std::expected RigSimulationInputTool::processCopyRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // COPY format: SRC_ARRAY TARGET_ARRAY I1 I2 J1 J2 K1 K2 // Items: 0=SRC_ARRAY, 1=TARGET_ARRAY, 2=I1, 3=I2, 4=J1, 5=J2, 6=K1, 7=K2 @@ -1914,7 +1849,7 @@ std::expected RigSimulationInputTool::processCopyRecor std::expected RigSimulationInputTool::processBoxRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, - const cvf::Vec3st& refinement ) + const RigNonUniformRefinement& refinement ) { // BOX format: I1 I2 J1 J2 K1 K2 // Items: 0=I1, 1=I2, 2=J1, 3=J2, 4=K1, 5=K2 @@ -2420,26 +2355,29 @@ std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::VecIjk0 RigSimulationInputTool::transformToSectorCoordinates( const caf::VecIjk0& globalIjk, - const caf::VecIjk0& min, - const cvf::Vec3st& refinement ) +caf::VecIjk0 RigSimulationInputTool::transformToSectorCoordinates( const caf::VecIjk0& globalIjk, + const caf::VecIjk0& min, + const RigNonUniformRefinement& refinement ) { // Transform global IJK to sector-relative coordinates with refinement - // Formula matches RigGridExportAdapter::transformIjkToSectorCoordinates for box minimum coordinates // Returns 0-based sector coordinates - return caf::VecIjk0( ( globalIjk.i() - min.i() ) * refinement.x(), - ( globalIjk.j() - min.j() ) * refinement.y(), - ( globalIjk.k() - min.k() ) * refinement.z() ); + size_t sectorI = globalIjk.i() - min.i(); + size_t sectorJ = globalIjk.j() - min.j(); + size_t sectorK = globalIjk.k() - min.k(); + + return caf::VecIjk0( refinement.cumulativeOffset( RigNonUniformRefinement::DimI, sectorI ), + refinement.cumulativeOffset( RigNonUniformRefinement::DimJ, sectorJ ), + refinement.cumulativeOffset( RigNonUniformRefinement::DimK, sectorK ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::expected - RigSimulationInputTool::transformNNCToSectorCoordinates( const NNCConnection& connection, - const RigMainGrid& mainGrid, - const caf::VecIjk0& min, - const cvf::Vec3st& refinement ) + RigSimulationInputTool::transformNNCToSectorCoordinates( const NNCConnection& connection, + const RigMainGrid& mainGrid, + const caf::VecIjk0& min, + const RigNonUniformRefinement& refinement ) { // Get global IJK for both cells auto gijk1 = mainGrid.ijkFromCellIndex( connection.c1GlobIdx ); @@ -2466,10 +2404,10 @@ std::expected //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigSimulationInputTool::refineEditNncConnection( const NNCConnection& connection, - const RigMainGrid& mainGrid, - const caf::VecIjk0& min, - const cvf::Vec3st& refinement ) +std::vector RigSimulationInputTool::refineEditNncConnection( const NNCConnection& connection, + const RigMainGrid& mainGrid, + const caf::VecIjk0& min, + const RigNonUniformRefinement& refinement ) { // Get global IJK for both cells auto gijk1 = mainGrid.ijkFromCellIndex( connection.c1GlobIdx ); @@ -2492,12 +2430,21 @@ std::vector RigSimulationInput caf::VecIjk0 baseCell1 = transformToSectorCoordinates( *gijk1, min, refinement ); caf::VecIjk0 baseCell2 = transformToSectorCoordinates( *gijk2, min, refinement ); + // Get subcell counts for each cell + size_t rel1I = gijk1->i() - min.i(); + size_t rel1J = gijk1->j() - min.j(); + size_t rel1K = gijk1->k() - min.k(); + + size_t subcellsI = refinement.subcellCount( RigNonUniformRefinement::DimI, rel1I ); + size_t subcellsJ = refinement.subcellCount( RigNonUniformRefinement::DimJ, rel1J ); + size_t subcellsK = refinement.subcellCount( RigNonUniformRefinement::DimK, rel1K ); + std::vector refined; - for ( size_t subI = 0; subI < refinement.x(); ++subI ) + for ( size_t subI = 0; subI < subcellsI; ++subI ) { - for ( size_t subJ = 0; subJ < refinement.y(); ++subJ ) + for ( size_t subJ = 0; subJ < subcellsJ; ++subJ ) { - for ( size_t subK = 0; subK < refinement.z(); ++subK ) + for ( size_t subK = 0; subK < subcellsK; ++subK ) { // Add subcell offset to base coordinates TransformedNNCConnection conn; @@ -2547,8 +2494,7 @@ std::expected RigSimulationInputTool::exportEditNncKeyword( RimEc QString( "Found %1 internal EDITNNC connections in sector (out of %2 total)" ).arg( sectorConnections.size() ).arg( allConnections.size() ) ); // Step 3: Transform and refine - bool hasRef = ( settings.refinement().x() != 1 || settings.refinement().y() != 1 || settings.refinement().z() != 1 ) || - settings.hasNonUniformRefinement(); + bool hasRef = settings.hasRefinement(); std::vector transformedConnections; @@ -2557,7 +2503,7 @@ std::expected RigSimulationInputTool::exportEditNncKeyword( RimEc // Refine to subcells with corresponding positions for ( const auto& conn : sectorConnections ) { - auto refined = refineEditNncConnection( conn, *mainGrid, settings.min(), settings.refinement() ); + auto refined = refineEditNncConnection( conn, *mainGrid, settings.min(), settings.effectiveRefinement() ); transformedConnections.insert( transformedConnections.end(), refined.begin(), refined.end() ); } } @@ -2566,7 +2512,7 @@ std::expected RigSimulationInputTool::exportEditNncKeyword( RimEc // Simple coordinate transformation, no refinement for ( const auto& conn : sectorConnections ) { - auto result = transformNNCToSectorCoordinates( conn, *mainGrid, settings.min(), settings.refinement() ); + auto result = transformNNCToSectorCoordinates( conn, *mainGrid, settings.min(), settings.effectiveRefinement() ); if ( result ) { transformedConnections.push_back( *result ); diff --git a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.h b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.h index 525c947884..cbea26aac6 100644 --- a/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.h +++ b/ApplicationLibCode/ReservoirDataModel/SimulationFile/RigSimulationInputTool.h @@ -18,6 +18,8 @@ #pragma once +#include "RigNonUniformRefinement.h" + #include "cafVecIjk.h" #include "cvfArray.h" #include "cvfVector3.h" @@ -77,29 +79,45 @@ public: static std::expected exportSimulationInput( RimEclipseCase& eclipseCase, const RigSimulationInputSettings& settings, cvf::UByteArray* visibility ); - static std::expected - processEqualsRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processEqualsRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processMultiplyRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processMultiplyRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processBoxRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processBoxRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processCopyRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processCopyRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processAddRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processAddRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processAquconRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processAquconRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processAquanconRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processAquanconRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); - static std::expected - processAqunumRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement ); + static std::expected processAqunumRecord( const Opm::DeckRecord& record, + const caf::VecIjk0& min, + const caf::VecIjk0& max, + const RigNonUniformRefinement& refinement ); static std::vector createRefinedVisibility( const RigGridExportAdapter& gridAdapter ); @@ -112,18 +130,18 @@ public: const RigMainGrid& mainGrid, const caf::VecIjk0& min, const caf::VecIjk0& max ); - static std::expected transformNNCToSectorCoordinates( const NNCConnection& connection, - const RigMainGrid& mainGrid, - const caf::VecIjk0& min, - const cvf::Vec3st& refinement ); - static std::vector refineEditNncConnection( const NNCConnection& connection, - const RigMainGrid& mainGrid, - const caf::VecIjk0& min, - const cvf::Vec3st& refinement ); + static std::expected transformNNCToSectorCoordinates( const NNCConnection& connection, + const RigMainGrid& mainGrid, + const caf::VecIjk0& min, + const RigNonUniformRefinement& refinement ); + static std::vector refineEditNncConnection( const NNCConnection& connection, + const RigMainGrid& mainGrid, + const caf::VecIjk0& min, + const RigNonUniformRefinement& refinement ); // Generic helper for processing keywords with box indices using RecordProcessorFunc = - std::function( const Opm::DeckRecord&, const caf::VecIjk0&, const caf::VecIjk0&, const cvf::Vec3st& )>; + std::function( const Opm::DeckRecord&, const caf::VecIjk0&, const caf::VecIjk0&, const RigNonUniformRefinement& )>; private: static std::expected updateCornerPointGridInDeckFile( RimEclipseCase* eclipseCase, @@ -174,7 +192,7 @@ private: static std::expected applyModelPadding( RifOpmFlowDeckFile& deckFile, const RigModelPaddingSettings& paddingSettings ); // Utility: Transform global IJK to sector-relative coordinates with refinement - static caf::VecIjk0 transformToSectorCoordinates( const caf::VecIjk0& globalIjk, const caf::VecIjk0& min, const cvf::Vec3st& refinement ); + static caf::VecIjk0 transformToSectorCoordinates( const caf::VecIjk0& globalIjk, const caf::VecIjk0& min, const RigNonUniformRefinement& refinement ); static std::expected addOperNumRegionAndOperater( RifOpmFlowDeckFile& deckFile, const RigGridExportAdapter& gridAdapter, @@ -207,7 +225,7 @@ private: transformBoxToSectorCoordinates( const RigBoundingBoxIjk& inputBox, const caf::VecIjk0& sectorMin, const caf::VecIjk0& sectorMax, - const cvf::Vec3st& refinement, + const RigNonUniformRefinement& refinement, const QString& keywordName, const QString& recordIdentifier ); diff --git a/ApplicationLibCode/UnitTests/RigEclipseCaseDataTools-Test.cpp b/ApplicationLibCode/UnitTests/RigEclipseCaseDataTools-Test.cpp index 0833ed9c7f..5c907bb534 100644 --- a/ApplicationLibCode/UnitTests/RigEclipseCaseDataTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigEclipseCaseDataTools-Test.cpp @@ -35,6 +35,7 @@ #include "RigEclipseResultTools.h" #include "RigGridExportAdapter.h" #include "RigMainGrid.h" +#include "RigNonUniformRefinement.h" #include "RigSimulationInputTool.h" #include "Well/RigSimWellData.h" @@ -463,7 +464,7 @@ TEST( RigEclipseCaseDataToolsTest, GenerateBorderResultFromIjkBounds ) ASSERT_FALSE( visibility.isNull() ) << "Visibility should be created successfully"; // Generate border result using refined methods (no refinement: 1,1,1) - cvf::Vec3st refinement( 1, 1, 1 ); + RigNonUniformRefinement refinement( cvf::Vec3st( maxIjk.i() - minIjk.i() + 1, maxIjk.j() - minIjk.j() + 1, maxIjk.k() - minIjk.k() + 1 ) ); RigGridExportAdapter gridAdapter( eclipseCase.p(), minIjk, maxIjk, refinement, visibility.p() ); // Create refined visibility @@ -552,7 +553,7 @@ TEST( RigEclipseCaseDataToolsTest, GenerateOperNumResultFromBorderResult ) ASSERT_FALSE( visibility.isNull() ) << "Visibility should be created successfully"; // Generate border result using refined methods (no refinement: 1,1,1) - cvf::Vec3st refinement( 1, 1, 1 ); + RigNonUniformRefinement refinement( cvf::Vec3st( maxIjk.i() - minIjk.i() + 1, maxIjk.j() - minIjk.j() + 1, maxIjk.k() - minIjk.k() + 1 ) ); RigGridExportAdapter gridAdapter( eclipseCase.p(), minIjk, maxIjk, refinement, visibility.p() ); // Create refined visibility diff --git a/ApplicationLibCode/UnitTests/RigEclipseResultTools-Test.cpp b/ApplicationLibCode/UnitTests/RigEclipseResultTools-Test.cpp index 71cbcb0d6d..ef1fd0401b 100644 --- a/ApplicationLibCode/UnitTests/RigEclipseResultTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigEclipseResultTools-Test.cpp @@ -31,6 +31,7 @@ #include "RigEclipseCaseData.h" #include "RigGridExportAdapter.h" #include "RigMainGrid.h" +#include "RigNonUniformRefinement.h" #include "RigSimulationInputTool.h" #include "RimEclipseResultCase.h" @@ -115,7 +116,7 @@ TEST( RigEclipseResultToolsTest, BorderCellBcconGeneration ) // Step 3: Create grid adapter and generate refined border result caf::VecIjk0 min( startI, startJ, startK ); caf::VecIjk0 max( endI - 1, endJ - 1, endK - 1 ); - cvf::Vec3st refinement( 1, 1, 1 ); // No refinement for this test + RigNonUniformRefinement refinement( cvf::Vec3st( max.i() - min.i() + 1, max.j() - min.j() + 1, max.k() - min.k() + 1 ) ); RigGridExportAdapter gridAdapter( caseData.p(), min, max, refinement, customVisibility.p() ); // Create refined visibility (same as original since refinement=1) @@ -287,7 +288,7 @@ TEST( RigEclipseResultToolsTest, BcconResultWithFaceNumbering ) } // Step 3: Create grid adapter and generate refined border result - cvf::Vec3st refinement( 1, 1, 1 ); // No refinement for this test + RigNonUniformRefinement refinement( cvf::Vec3st( max.i() - min.i() + 1, max.j() - min.j() + 1, max.k() - min.k() + 1 ) ); RigGridExportAdapter gridAdapter( caseData.p(), min, max, refinement, customVisibility.p() ); // Create refined visibility (same as original since refinement=1) diff --git a/ApplicationLibCode/UnitTests/RigGridExportAdapter-Test.cpp b/ApplicationLibCode/UnitTests/RigGridExportAdapter-Test.cpp index a5815daa9a..573a7152e3 100644 --- a/ApplicationLibCode/UnitTests/RigGridExportAdapter-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigGridExportAdapter-Test.cpp @@ -25,6 +25,7 @@ #include "RigEclipseCaseData.h" #include "RigGridExportAdapter.h" #include "RigMainGrid.h" +#include "RigNonUniformRefinement.h" #include "RimEclipseResultCase.h" @@ -35,6 +36,23 @@ #include +//-------------------------------------------------------------------------------------------------- +/// Helper: convert uniform refinement (Vec3st) to RigNonUniformRefinement given bounds. +/// For UNDEFINED max, pass the mainGrid pointer to resolve actual dimensions. +//-------------------------------------------------------------------------------------------------- +static RigNonUniformRefinement makeUniformRef( const cvf::Vec3st& min, + const cvf::Vec3st& max, + const cvf::Vec3st& refCounts, + const RigMainGrid* mainGrid = nullptr ) +{ + cvf::Vec3st resolvedMax = max; + if ( max.isUndefined() && mainGrid ) + resolvedMax = cvf::Vec3st( mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1 ); + + cvf::Vec3st sectorSize( resolvedMax.x() - min.x() + 1, resolvedMax.y() - min.y() + 1, resolvedMax.z() - min.z() + 1 ); + return RigNonUniformRefinement::fromUniform( refCounts, sectorSize ); +} + //-------------------------------------------------------------------------------------------------- /// Helper function to load test grid //-------------------------------------------------------------------------------------------------- @@ -73,7 +91,7 @@ TEST( RigGridExportAdapterTest, BasicConstruction ) cvf::Vec3st max( 2, 2, 2 ); // Small 3x3x3 subset cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement ) ); EXPECT_EQ( 3, adapter.cellCountI() ); EXPECT_EQ( 3, adapter.cellCountJ() ); @@ -82,7 +100,6 @@ TEST( RigGridExportAdapterTest, BasicConstruction ) EXPECT_FALSE( adapter.hasRefinement() ); EXPECT_EQ( min, adapter.originalMin() ); EXPECT_EQ( max, adapter.originalMax() ); - EXPECT_EQ( refinement, adapter.refinement() ); } //-------------------------------------------------------------------------------------------------- @@ -99,7 +116,7 @@ TEST( RigGridExportAdapterTest, UndefinedMax ) cvf::Vec3st max = cvf::Vec3st::UNDEFINED; cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, mainGrid ) ); EXPECT_EQ( mainGrid->cellCountI(), adapter.cellCountI() ); EXPECT_EQ( mainGrid->cellCountJ(), adapter.cellCountJ() ); @@ -119,7 +136,7 @@ TEST( RigGridExportAdapterTest, RefinementConstruction ) cvf::Vec3st max( 1, 1, 1 ); // 2x2x2 original cells cvf::Vec3st refinement( 2, 2, 2 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); EXPECT_EQ( 4, adapter.cellCountI() ); // 2 * 2 EXPECT_EQ( 4, adapter.cellCountJ() ); // 2 * 2 @@ -142,7 +159,7 @@ TEST( RigGridExportAdapterTest, CellCornersNoRefinement ) cvf::Vec3st max( 0, 0, 0 ); // Just first cell cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); EXPECT_EQ( 1, adapter.cellCountI() ); EXPECT_EQ( 1, adapter.cellCountJ() ); @@ -189,7 +206,7 @@ TEST( RigGridExportAdapterTest, CellActivity ) cvf::Vec3st max( 2, 2, 2 ); // Small 3x3x3 subset cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); // Test a few cells for ( size_t k = 0; k < adapter.cellCountK(); ++k ) @@ -232,7 +249,7 @@ TEST( RigGridExportAdapterTest, CellActivityWithOverride ) cvf::Vec3st max( 1, 1, 1 ); // 2x2x2 subset cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement, &visibilityOverride ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ), &visibilityOverride ); // All cells should be inactive due to override for ( size_t k = 0; k < adapter.cellCountK(); ++k ) @@ -262,7 +279,7 @@ TEST( RigGridExportAdapterTest, RefinedCellCorners ) cvf::Vec3st max( 0, 0, 0 ); // Just first cell cvf::Vec3st refinement( 2, 2, 2 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); EXPECT_EQ( 2, adapter.cellCountI() ); EXPECT_EQ( 2, adapter.cellCountJ() ); @@ -340,7 +357,7 @@ TEST( RigGridExportAdapterTest, ReasonableCornerValues ) cvf::Vec3st max( 1, 1, 1 ); cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); bool hasNonZeroValues = false; @@ -384,7 +401,7 @@ TEST( RigGridExportAdapterTest, MapAxes ) cvf::Vec3st max( 1, 1, 1 ); cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); // Should match main grid MAPAXES settings EXPECT_EQ( mainGrid->useMapAxes(), adapter.useMapAxes() ); @@ -428,7 +445,7 @@ TEST( RigGridExportAdapterTest, FaceCornersNoRefinement ) cvf::Vec3st max( 0, 0, 0 ); // Just first cell cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); // Get face corners from adapter auto adapterTopFace = adapter.getFaceCorners( 0, 0, 0, cvf::StructGridInterface::NEG_K ); @@ -484,8 +501,8 @@ TEST( RigGridExportAdapterTest, FaceCornersRefinedConsistency ) cvf::Vec3st refinement( 2, 2, 2 ); cvf::Vec3st noRefinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); - RigGridExportAdapter adapterNoRefinement( caseData.p(), min, max, noRefinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); + RigGridExportAdapter adapterNoRefinement( caseData.p(), min, max, makeUniformRef( min, max, noRefinement, caseData->mainGrid() ) ); auto makeVector = []( const std::array& input1, const std::array& input2 ) { @@ -553,7 +570,7 @@ TEST( RigGridExportAdapterTest, AllFaceTypes ) cvf::Vec3st max( 0, 0, 0 ); // Just first cell cvf::Vec3st refinement( 1, 1, 1 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); // Test all face types std::vector faceTypes = { cvf::StructGridInterface::NEG_K, @@ -593,7 +610,7 @@ TEST( RigGridExportAdapterTest, RefinedCellsContainOriginalCorners ) cvf::Vec3st max = cvf::Vec3st::UNDEFINED; //( 1, 0, 0 ); cvf::Vec3st refinement( 2, 2, 2 ); - RigGridExportAdapter adapter( caseData.p(), min, max, refinement ); + RigGridExportAdapter adapter( caseData.p(), min, max, makeUniformRef( min, max, refinement, caseData->mainGrid() ) ); // Get the original cell corners const RigMainGrid* mainGrid = caseData->mainGrid(); @@ -670,7 +687,9 @@ TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_NoRefinement ) { caf::VecIjk0 min( 3, 3, 1 ); caf::VecIjk0 max( 10, 10, 5 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( + cvf::Vec3st( 1, 1, 1 ), + cvf::Vec3st( max.i() - min.i() + 1, max.j() - min.j() + 1, max.k() - min.k() + 1 ) ); // Point at sector min should transform to (0,0,0) auto result1 = RigGridExportAdapter::transformIjkToSectorCoordinates( min, min, max, refinement ); @@ -702,7 +721,9 @@ TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_OutOfBounds ) { caf::VecIjk0 min( 3, 3, 1 ); caf::VecIjk0 max( 10, 10, 5 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( + cvf::Vec3st( 1, 1, 1 ), + cvf::Vec3st( max.i() - min.i() + 1, max.j() - min.j() + 1, max.k() - min.k() + 1 ) ); // Point before sector min (X too small) caf::VecIjk0 point1( 2, 5, 3 ); @@ -734,7 +755,11 @@ TEST( RigGridExportAdapter, BoxTransformation_NoRefinement ) { caf::VecIjk0 sectorMin( 3, 3, 1 ); caf::VecIjk0 sectorMax( 10, 10, 5 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( + cvf::Vec3st( 1, 1, 1 ), + cvf::Vec3st( sectorMax.i() - sectorMin.i() + 1, + sectorMax.j() - sectorMin.j() + 1, + sectorMax.k() - sectorMin.k() + 1 ) ); // Test box from (5,5,2) to (7,7,3) in global coordinates // Expected in sector coordinates: (3,3,2) to (5,5,3) @@ -773,7 +798,11 @@ TEST( RigGridExportAdapter, SingleCellBox_NoRefinement ) { caf::VecIjk0 sectorMin( 3, 3, 1 ); caf::VecIjk0 sectorMax( 10, 10, 5 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( + cvf::Vec3st( 1, 1, 1 ), + cvf::Vec3st( sectorMax.i() - sectorMin.i() + 1, + sectorMax.j() - sectorMin.j() + 1, + sectorMax.k() - sectorMin.k() + 1 ) ); // Single cell box at global position (5,5,2) caf::VecIjk0 singleCell( 5, 5, 2 ); @@ -797,7 +826,11 @@ TEST( RigGridExportAdapter, BoxAtSectorBoundaries_NoRefinement ) { caf::VecIjk0 sectorMin( 3, 3, 1 ); caf::VecIjk0 sectorMax( 10, 10, 5 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( + cvf::Vec3st( 1, 1, 1 ), + cvf::Vec3st( sectorMax.i() - sectorMin.i() + 1, + sectorMax.j() - sectorMin.j() + 1, + sectorMax.k() - sectorMin.k() + 1 ) ); // Box spanning entire sector auto minResult = RigGridExportAdapter::transformIjkToSectorCoordinates( sectorMin, sectorMin, sectorMax, refinement ); diff --git a/ApplicationLibCode/UnitTests/RigResdataGridConverter-Test.cpp b/ApplicationLibCode/UnitTests/RigResdataGridConverter-Test.cpp index 9408f5b8f9..4cb24a7003 100644 --- a/ApplicationLibCode/UnitTests/RigResdataGridConverter-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigResdataGridConverter-Test.cpp @@ -21,6 +21,7 @@ #include "RiaTestDataDirectory.h" #include "RifEclipseInputFileTools.h" #include "RigGridExportAdapter.h" +#include "RigNonUniformRefinement.h" #include "RigResdataGridConverter.h" #include "RigActiveCellInfo.h" @@ -681,11 +682,11 @@ TEST( RigResdataGridConverterTest, CornerPointArrayConversion ) // Test conversion for a small subset (first 2x2x2 cells) cvf::Vec3st min( 0, 0, 0 ); cvf::Vec3st max( 1, 1, 1 ); - cvf::Vec3st refinement( 1, 1, 1 ); cvf::Mat4d mapAxisTransform = grid->mapAxisTransform(); - // Create grid adapter with the test parameters + // Create grid adapter with the test parameters (no refinement: 1 subcell per cell) + RigNonUniformRefinement refinement( cvf::Vec3st( max.x() - min.x() + 1, max.y() - min.y() + 1, max.z() - min.z() + 1 ) ); RigGridExportAdapter gridAdapter( testCaseData.p(), min, max, refinement, nullptr ); RigResdataGridConverter::convertGridToCornerPointArrays( gridAdapter, coordArray, zcornArray, actnumArray ); diff --git a/ApplicationLibCode/UnitTests/RigSimulationInputTool-Test.cpp b/ApplicationLibCode/UnitTests/RigSimulationInputTool-Test.cpp index 25bd94a25e..f31d8f0a20 100644 --- a/ApplicationLibCode/UnitTests/RigSimulationInputTool-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigSimulationInputTool-Test.cpp @@ -28,6 +28,7 @@ #include "RigEclipseCaseDataTools.h" #include "RigMainGrid.h" #include "RigModelPaddingSettings.h" +#include "RigNonUniformRefinement.h" #include "RigSimulationInputSettings.h" #include "RimEclipseResultCase.h" @@ -42,6 +43,12 @@ #include #include +static RigNonUniformRefinement makeRef( const caf::VecIjk0& sectorMin, const caf::VecIjk0& sectorMax, const cvf::Vec3st& refCounts ) +{ + cvf::Vec3st sectorSize( sectorMax.i() - sectorMin.i() + 1, sectorMax.j() - sectorMin.j() + 1, sectorMax.k() - sectorMin.k() + 1 ); + return RigNonUniformRefinement::fromUniform( refCounts, sectorSize ); +} + //-------------------------------------------------------------------------------------------------- /// Helper to create an EQUALS DeckRecord /// EQUALS format: FIELD VALUE I1 I2 J1 J2 K1 K2 (1-based Eclipse coordinates) @@ -69,7 +76,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_NoOverlap ) // Sector: sectorMin=(0, 15, 0), sectorMax=(19, 29, 9) (inclusive, cells [0-19, 15-29, 0-9]) caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // EQUALS record: FIPNUM 1 1 20 1 14 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[0-13], K[0-9] @@ -90,7 +97,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_PartialOverlapWithClamping ) // Sector: sectorMin=(0, 15, 0), sectorMax=(19, 29, 9) (inclusive, cells [0-19, 15-29, 0-9]) caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // EQUALS record: FIPNUM 2 1 20 15 30 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[14-29], K[0-9] @@ -128,7 +135,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_CompletelyInside ) // Sector: min=(0, 0, 0), max=(19, 19, 9) (inclusive, cells [0-19, 0-19, 0-9]) caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 19, 19, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // EQUALS record completely inside: FIPNUM 3 5 15 5 15 2 8 (1-based Eclipse) // Converts to 0-based: I[4-14], J[4-14], K[1-7] @@ -158,7 +165,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_CompletelyOutside ) // Sector: min=(0, 0, 0), max=(9, 9, 9) (inclusive, cells [0-9, 0-9, 0-9]) caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 9, 9, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // EQUALS record outside: FIPNUM 4 20 30 20 30 1 10 (1-based Eclipse) // Converts to 0-based: I[19-29], J[19-29], K[0-9] @@ -178,7 +185,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_InvalidRecord ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 9, 9, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // Create a record with only 1 item (field name, missing value) std::vector items; @@ -200,7 +207,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_NoBoxDefinition ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 9, 9, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // Create a record with only field name and value (no box coordinates) std::vector items; @@ -225,7 +232,7 @@ TEST( RigSimulationInputTool, ProcessEqualsRecord_AtBoundary ) // Sector: min=(5, 5, 5), max=(14, 14, 14) (inclusive, cells [5-14, 5-14, 5-14]) caf::VecIjk0 sectorMin( 5, 5, 5 ); caf::VecIjk0 sectorMax( 14, 14, 14 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // EQUALS record exactly matching sector: 6 15 6 15 6 15 (1-based Eclipse) // Converts to 0-based: I[5-14], J[5-14], K[5-14] @@ -273,7 +280,7 @@ TEST( RigSimulationInputTool, ProcessAquconRecord_PartialOverlap ) // This corresponds to a sector with cells [40-100, 27-72, 21-58] caf::VecIjk0 sectorMin( 40, 27, 21 ); caf::VecIjk0 sectorMax( 100, 72, 58 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // AQUCON record from user data: 1 57 57 28 36 46 58 'I+' (1-based Eclipse) // Converts to 0-based: I[56-56], J[27-35], K[45-57] @@ -309,7 +316,7 @@ TEST( RigSimulationInputTool, ProcessAquconRecord_PartialOverlapWithClamping ) // Sector: min=(40, 27, 21), max=(100, 72, 58) (inclusive, 0-based) caf::VecIjk0 sectorMin( 40, 27, 21 ); caf::VecIjk0 sectorMax( 100, 72, 58 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // AQUCON record: 1 79 79 41 67 5 11 'I+' (1-based Eclipse) // Converts to 0-based: I[78-78], J[40-66], K[4-10] @@ -331,7 +338,7 @@ TEST( RigSimulationInputTool, ProcessAquconRecord_CompletelyInside ) // Sector: min=(40, 27, 21), max=(100, 72, 58) (inclusive, 0-based) caf::VecIjk0 sectorMin( 40, 27, 21 ); caf::VecIjk0 sectorMax( 100, 72, 58 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // AQUCON record: 1 61 61 48 72 12 17 'I+' (1-based Eclipse) // Converts to 0-based: I[60-60], J[47-71], K[11-16] @@ -350,7 +357,7 @@ TEST( RigSimulationInputTool, ProcessAquconRecord_NoBoxDefinition ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 9, 9, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // Create a record with only aquifer ID (no box coordinates) std::vector items; @@ -815,7 +822,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_LargeBox ) // This means the sector spans exactly the same range as the BOX keyword caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 45, 111, 21 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // BOX record: 1 46 1 112 1 22 (1-based Eclipse) // Converts to 0-based: I[0-45], J[0-111], K[0-21] @@ -847,7 +854,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_LargeBoxWithRefinement ) // BOX will be clamped to this sector and then refined caf::VecIjk0 sectorMin( 19, 59, 0 ); caf::VecIjk0 sectorMax( 45, 111, 21 ); - cvf::Vec3st refinement( 3, 3, 1 ); // Refinement: I=3, J=3, K=1 + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 3, 3, 1 ) ); // Refinement: I=3, J=3, K=1 // BOX record: 1 46 1 112 1 22 (1-based Eclipse) // Converts to 0-based: I[0-45], J[0-111], K[0-21] @@ -883,7 +890,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_PartialOverlapWithClamping ) // Sector: min=(10, 20, 5), max=(39, 99, 19) (inclusive, 0-based) caf::VecIjk0 sectorMin( 10, 20, 5 ); caf::VecIjk0 sectorMax( 39, 99, 19 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // BOX record: 1 46 1 112 1 22 (1-based Eclipse) // Converts to 0-based: I[0-45], J[0-111], K[0-21] @@ -917,7 +924,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_CompletelyInside ) // Sector: min=(0, 0, 0), max=(49, 119, 29) (inclusive, 0-based) caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 49, 119, 29 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // BOX record: 5 20 10 50 5 15 (1-based Eclipse) // Converts to 0-based: I[4-19], J[9-49], K[4-14] @@ -948,7 +955,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_NoOverlap ) // Sector: min=(0, 0, 0), max=(19, 29, 9) (inclusive, 0-based) caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // BOX record: 30 50 40 60 1 10 (1-based Eclipse) // Converts to 0-based: I[29-49], J[39-59], K[0-9] @@ -968,7 +975,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_InvalidRecord ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 9, 9, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // Create a record with only 3 items (missing J2, K1, K2) std::vector items; @@ -992,7 +999,7 @@ TEST( RigSimulationInputTool, ProcessBoxRecord_AtBoundary ) // Sector: min=(5, 10, 3), max=(24, 39, 12) (inclusive, 0-based) caf::VecIjk0 sectorMin( 5, 10, 3 ); caf::VecIjk0 sectorMax( 24, 39, 12 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // BOX record exactly matching sector: 6 25 11 40 4 13 (1-based Eclipse) // Converts to 0-based: I[5-24], J[10-39], K[3-12] @@ -1468,9 +1475,9 @@ TEST( RigSimulationInputTool, TransformNNCToSectorCoordinates_NoRefinement ) RigSimulationInputTool::NNCConnection connection{ c1Idx, c2Idx, 4.5 }; - // Sector starts at (5,10,2) + // Sector starts at (5,10,2), grid is 20x30x10 caf::VecIjk0 sectorMin( 5, 10, 2 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = RigNonUniformRefinement::fromUniform( cvf::Vec3st( 1, 1, 1 ), cvf::Vec3st( 20, 30, 10 ) ); auto result = RigSimulationInputTool::transformNNCToSectorCoordinates( connection, *mainGrid, sectorMin, refinement ); @@ -1506,7 +1513,7 @@ TEST( RigSimulationInputTool, RefineEDITNNCConnection_CorrespondingSubcells ) RigSimulationInputTool::NNCConnection connection{ c1Idx, c2Idx, 2.5 }; // TRAN_MULT = 2.5 caf::VecIjk0 sectorMin( 0, 0, 0 ); - cvf::Vec3st refinement( 2, 2, 1 ); // Refine by 2x2x1 + auto refinement = RigNonUniformRefinement::fromUniform( cvf::Vec3st( 2, 2, 1 ), cvf::Vec3st( 20, 30, 10 ) ); // Refine by 2x2x1, grid is 20x30x10 auto refined = RigSimulationInputTool::refineEditNncConnection( connection, *mainGrid, sectorMin, refinement ); @@ -1730,7 +1737,7 @@ TEST( RigSimulationInputTool, ProcessAddRecord_NoBoxIndices ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); auto record = createAddRecordNoBox( "PORO", 0.1 ); @@ -1751,7 +1758,7 @@ TEST( RigSimulationInputTool, ProcessAddRecord_WithBoxIndices ) // Sector: sectorMin=(0, 15, 0), sectorMax=(19, 29, 9) caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // ADD record with box fully inside sector (1-based Eclipse coords) auto record = createAddRecord( "PORO", 0.05, 1, 20, 16, 30, 1, 10 ); @@ -1779,7 +1786,7 @@ TEST( RigSimulationInputTool, ProcessMultiplyRecord_NoBoxIndices ) { caf::VecIjk0 sectorMin( 0, 0, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); auto record = createMultiplyRecordNoBox( "PERMX", 2.0 ); @@ -1800,7 +1807,7 @@ TEST( RigSimulationInputTool, ProcessMultiplyRecord_WithBoxIndices ) // Sector: sectorMin=(0, 15, 0), sectorMax=(19, 29, 9) caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // MULTIPLY record with box fully inside sector auto record = createMultiplyRecord( "PERMX", 3.0, 1, 20, 16, 30, 1, 10 ); @@ -2193,7 +2200,7 @@ TEST( RigSimulationInputTool, ProcessMultiplyRecord_NoOverlap ) { caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // MULTIPLY record: PERMX 2.0 1 20 1 14 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[0-13], K[0-9] @@ -2213,7 +2220,7 @@ TEST( RigSimulationInputTool, ProcessMultiplyRecord_PartialOverlapWithClamping ) { caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // MULTIPLY record: PERMX 3.5 1 20 15 30 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[14-29], K[0-9] @@ -2243,7 +2250,7 @@ TEST( RigSimulationInputTool, ProcessMultiplyRecord_CompletelyInsideSector ) { caf::VecIjk0 sectorMin( 2, 2, 1 ); caf::VecIjk0 sectorMax( 7, 7, 4 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // MULTIPLY record: PORV 0.5 4 6 4 6 2 4 (1-based Eclipse) // Converts to 0-based: I[3-5], J[3-5], K[1-3] — inside sector @@ -2272,7 +2279,7 @@ TEST( RigSimulationInputTool, ProcessAddRecord_NoOverlap ) { caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // ADD record: PRESSURE 100.0 1 20 1 14 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[0-13], K[0-9] @@ -2292,7 +2299,7 @@ TEST( RigSimulationInputTool, ProcessAddRecord_PartialOverlapWithClamping ) { caf::VecIjk0 sectorMin( 0, 15, 0 ); caf::VecIjk0 sectorMax( 19, 29, 9 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // ADD record: PRESSURE -50.0 1 20 15 30 1 10 (1-based Eclipse) // Converts to 0-based: I[0-19], J[14-29], K[0-9] @@ -2322,7 +2329,7 @@ TEST( RigSimulationInputTool, ProcessAddRecord_CompletelyInsideSector ) { caf::VecIjk0 sectorMin( 2, 2, 1 ); caf::VecIjk0 sectorMax( 7, 7, 4 ); - cvf::Vec3st refinement( 1, 1, 1 ); + auto refinement = makeRef( sectorMin, sectorMax, cvf::Vec3st( 1, 1, 1 ) ); // ADD record: PORO 0.01 4 6 4 6 2 4 (1-based Eclipse) // Converts to 0-based: I[3-5], J[3-5], K[1-3] — inside sector