mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Refactor: Use VecIjk0 instead of Vec3st.
This commit is contained in:
@@ -534,7 +534,7 @@ std::expected<void, QString> RicExportEclipseSectorModelFeature::addBorderBounda
|
||||
// Update the IJK coordinates to sector-relative (1-based Eclipse coordinates)
|
||||
// Note: RigGridExportAdapter::transformIjkToSectorCoordinates returns 1-based coordinates, but we need to convert back to
|
||||
// 0-based for the BorderCellFace struct
|
||||
face.ijk = cvf::Vec3st( transformResult->x() - 1, transformResult->y() - 1, transformResult->z() - 1 );
|
||||
face.ijk = transformResult->toZeroBased();
|
||||
}
|
||||
|
||||
// Create BCCON keyword using the factory
|
||||
@@ -666,24 +666,26 @@ std::expected<void, QString> RicExportEclipseSectorModelFeature::addFaultsToDeck
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> RicExportEclipseSectorModelFeature::getVisibleCellRange( RimEclipseView* view,
|
||||
const cvf::UByteArray& cellVisibillity )
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> RicExportEclipseSectorModelFeature::getVisibleCellRange( RimEclipseView* view,
|
||||
const cvf::UByteArray& cellVisibillity )
|
||||
{
|
||||
const RigMainGrid* mainGrid = view->eclipseCase()->mainGrid();
|
||||
cvf::Vec3st max = cvf::Vec3st::ZERO;
|
||||
cvf::Vec3st min = cvf::Vec3st( mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1 );
|
||||
caf::VecIjk0 max = caf::VecIjk0::ZERO;
|
||||
caf::VecIjk0 min( mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1 );
|
||||
|
||||
size_t cellCount = mainGrid->cellCount();
|
||||
for ( size_t index = 0; index < cellCount; ++index )
|
||||
{
|
||||
if ( cellVisibillity[index] )
|
||||
{
|
||||
cvf::Vec3st ijk;
|
||||
mainGrid->ijkFromCellIndex( index, &ijk[0], &ijk[1], &ijk[2] );
|
||||
for ( int n = 0; n < 3; ++n )
|
||||
auto ijk = mainGrid->ijkFromCellIndex( index );
|
||||
if ( ijk.has_value() )
|
||||
{
|
||||
min[n] = std::min( min[n], ijk[n] );
|
||||
max[n] = std::max( max[n], ijk[n] );
|
||||
for ( int n = 0; n < 3; ++n )
|
||||
{
|
||||
min[n] = std::min( min[n], ijk.value()[n] );
|
||||
max[n] = std::max( max[n], ijk.value()[n] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -784,8 +786,8 @@ cvf::ref<cvf::UByteArray>
|
||||
// For full grid, create visibility for
|
||||
// all cells
|
||||
const RigMainGrid* mainGrid = caseData->mainGrid();
|
||||
const cvf::Vec3st minIjk = cvf::Vec3st::ZERO;
|
||||
const cvf::Vec3st maxIjk = mainGrid->cellCounts();
|
||||
const caf::VecIjk0 minIjk = caf::VecIjk0::ZERO;
|
||||
const caf::VecIjk0 maxIjk( mainGrid->cellCountI(), mainGrid->cellCountJ(), mainGrid->cellCountK() );
|
||||
return RigEclipseCaseDataTools::createVisibilityFromIjkBounds( caseData, minIjk, maxIjk );
|
||||
}
|
||||
default:
|
||||
@@ -942,15 +944,15 @@ std::expected<Opm::DeckRecord, QString>
|
||||
int origK2 = record.getItem( 4 ).get<int>( 0 ) - 1;
|
||||
|
||||
// Transform K1
|
||||
cvf::Vec3st origIjkK1( origI, origJ, origK1 );
|
||||
auto transformResultK1 = RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK1,
|
||||
caf::VecIjk0 origIjkK1( origI, origJ, origK1 );
|
||||
auto transformResultK1 = RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK1,
|
||||
exportSettings.min(),
|
||||
exportSettings.max(),
|
||||
exportSettings.refinement() );
|
||||
|
||||
// Transform K2
|
||||
cvf::Vec3st origIjkK2( origI, origJ, origK2 );
|
||||
auto transformResultK2 = RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK2,
|
||||
caf::VecIjk0 origIjkK2( origI, origJ, origK2 );
|
||||
auto transformResultK2 = RigGridExportAdapter::transformIjkToSectorCoordinates( origIjkK2,
|
||||
exportSettings.min(),
|
||||
exportSettings.max(),
|
||||
exportSettings.refinement() );
|
||||
@@ -1014,8 +1016,8 @@ std::expected<Opm::DeckRecord, QString>
|
||||
int origJ = record.getItem( 1 ).get<int>( 0 ) - 1;
|
||||
int origK = record.getItem( 2 ).get<int>( 0 ) - 1;
|
||||
|
||||
cvf::Vec3st origIjk( origI, origJ, origK );
|
||||
auto transformResult =
|
||||
caf::VecIjk0 origIjk( origI, origJ, origK );
|
||||
auto transformResult =
|
||||
RigGridExportAdapter::transformIjkToSectorCoordinates( origIjk, exportSettings.min(), exportSettings.max(), exportSettings.refinement() );
|
||||
|
||||
if ( !transformResult )
|
||||
@@ -1042,8 +1044,8 @@ std::expected<Opm::DeckRecord, QString>
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::expected<Opm::DeckRecord, QString> RicExportEclipseSectorModelFeature::processEqualsRecord( const Opm::DeckRecord& record,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const caf::VecIjk0& min,
|
||||
const caf::VecIjk0& max,
|
||||
const cvf::Vec3st& refinement )
|
||||
{
|
||||
// EQUALS format: FIELD VALUE I1 I2 J1 J2 K1 K2
|
||||
@@ -1070,7 +1072,7 @@ std::expected<Opm::DeckRecord, QString> RicExportEclipseSectorModelFeature::proc
|
||||
|
||||
// Create bounding boxes (both use inclusive min/max coordinates)
|
||||
RigBoundingBoxIjk equalsBox( cvf::Vec3st( origI1, origJ1, origK1 ), cvf::Vec3st( origI2, origJ2, origK2 ) );
|
||||
RigBoundingBoxIjk sectorBox( min, max );
|
||||
RigBoundingBoxIjk sectorBox( cvf::Vec3st( min.x(), min.y(), min.z() ), cvf::Vec3st( max.x(), max.y(), max.z() ) );
|
||||
|
||||
// Check if boxes overlap and get intersection
|
||||
auto intersection = equalsBox.intersection( sectorBox );
|
||||
@@ -1116,8 +1118,10 @@ std::expected<Opm::DeckRecord, QString> RicExportEclipseSectorModelFeature::proc
|
||||
.arg( corner2.z() + 1 ) );
|
||||
}
|
||||
|
||||
auto transformResult1 = RigGridExportAdapter::transformIjkToSectorCoordinates( corner1, min, max, refinement );
|
||||
auto transformResult2 = RigGridExportAdapter::transformIjkToSectorCoordinates( corner2, min, max, refinement );
|
||||
auto transformResult1 =
|
||||
RigGridExportAdapter::transformIjkToSectorCoordinates( caf::VecIjk0( corner1.x(), corner1.y(), corner1.z() ), min, max, refinement );
|
||||
auto transformResult2 =
|
||||
RigGridExportAdapter::transformIjkToSectorCoordinates( caf::VecIjk0( corner2.x(), corner2.y(), corner2.z() ), min, max, refinement );
|
||||
|
||||
if ( !transformResult1 )
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
@@ -48,10 +50,10 @@ public:
|
||||
static void openDialogAndExecuteCommand( RimEclipseView* view );
|
||||
static void executeCommand( RimEclipseView* view, const RicExportEclipseSectorModelUi& exportSettings, const QString& logPrefix );
|
||||
|
||||
static std::pair<cvf::Vec3st, cvf::Vec3st> getVisibleCellRange( RimEclipseView* view, const cvf::UByteArray& cellVisibility );
|
||||
static std::pair<caf::VecIjk0, caf::VecIjk0> getVisibleCellRange( RimEclipseView* view, const cvf::UByteArray& cellVisibility );
|
||||
|
||||
static std::expected<Opm::DeckRecord, QString>
|
||||
processEqualsRecord( const Opm::DeckRecord& record, const cvf::Vec3st& min, const cvf::Vec3st& max, const cvf::Vec3st& refinement );
|
||||
processEqualsRecord( const Opm::DeckRecord& record, const caf::VecIjk0& min, const caf::VecIjk0& max, const cvf::Vec3st& refinement );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() const override;
|
||||
|
||||
@@ -93,6 +93,8 @@ void RicExportEclipseSectorModelUi::BoundaryConditionEnum::setUp()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicExportEclipseSectorModelUi::RicExportEclipseSectorModelUi()
|
||||
: m_visibleMin( caf::VecIjk0::ZERO )
|
||||
, m_visibleMax( caf::VecIjk0::ZERO )
|
||||
{
|
||||
CAF_PDM_InitObject( "Export Visible Cells as Eclipse Input Grid" );
|
||||
|
||||
@@ -184,10 +186,10 @@ const QStringList& RicExportEclipseSectorModelUi::tabNames() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportEclipseSectorModelUi::setCaseData( RigEclipseCaseData* caseData /*= nullptr*/,
|
||||
RimEclipseView* eclipseView /*= nullptr*/,
|
||||
const cvf::Vec3st& visibleMin /*= cvf::Vec3st::ZERO*/,
|
||||
const cvf::Vec3st& visibleMax /*= cvf::Vec3st::ZERO*/ )
|
||||
void RicExportEclipseSectorModelUi::setCaseData( RigEclipseCaseData* caseData,
|
||||
RimEclipseView* eclipseView,
|
||||
const caf::VecIjk0& visibleMin,
|
||||
const caf::VecIjk0& visibleMax )
|
||||
{
|
||||
m_caseData = caseData;
|
||||
m_eclipseView = eclipseView;
|
||||
@@ -258,23 +260,23 @@ void RicExportEclipseSectorModelUi::setCaseData( RigEclipseCaseData* caseData /*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3st RicExportEclipseSectorModelUi::min() const
|
||||
caf::VecIjk0 RicExportEclipseSectorModelUi::min() const
|
||||
{
|
||||
return cvf::Vec3st( minI() - 1, minJ() - 1, minK() - 1 );
|
||||
return caf::VecIjk0( minI() - 1, minJ() - 1, minK() - 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3st RicExportEclipseSectorModelUi::max() const
|
||||
caf::VecIjk0 RicExportEclipseSectorModelUi::max() const
|
||||
{
|
||||
return cvf::Vec3st( maxI() - 1, maxJ() - 1, maxK() - 1 );
|
||||
return caf::VecIjk0( maxI() - 1, maxJ() - 1, maxK() - 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportEclipseSectorModelUi::setMin( const cvf::Vec3st& min )
|
||||
void RicExportEclipseSectorModelUi::setMin( const caf::VecIjk0& min )
|
||||
{
|
||||
minI = static_cast<int>( min.x() ) + 1;
|
||||
minJ = static_cast<int>( min.y() ) + 1;
|
||||
@@ -284,7 +286,7 @@ void RicExportEclipseSectorModelUi::setMin( const cvf::Vec3st& min )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportEclipseSectorModelUi::setMax( const cvf::Vec3st& max )
|
||||
void RicExportEclipseSectorModelUi::setMax( const caf::VecIjk0& max )
|
||||
{
|
||||
maxI = static_cast<int>( max.x() ) + 1;
|
||||
maxJ = static_cast<int>( max.y() ) + 1;
|
||||
@@ -646,8 +648,9 @@ void RicExportEclipseSectorModelUi::applyBoundaryDefaults()
|
||||
else if ( exportGridBox == FULL_GRID_BOX )
|
||||
{
|
||||
const RigMainGrid* mainGrid = m_caseData->mainGrid();
|
||||
setMin( cvf::Vec3st::ZERO );
|
||||
setMax( mainGrid->cellCounts() - cvf::Vec3st( 1, 1, 1 ) );
|
||||
setMin( caf::VecIjk0::ZERO );
|
||||
cvf::Vec3st maxCounts = mainGrid->cellCounts() - cvf::Vec3st( 1, 1, 1 );
|
||||
setMax( caf::VecIjk0( maxCounts.x(), maxCounts.y(), maxCounts.z() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -746,7 +749,7 @@ std::vector<const RigSimWellData*> RicExportEclipseSectorModelUi::getVisibleSimu
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st>
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0>
|
||||
RicExportEclipseSectorModelUi::computeVisibleWellCells( RimEclipseView* view, RigEclipseCaseData* caseData, int visibleWellsPadding )
|
||||
{
|
||||
if ( view )
|
||||
@@ -782,6 +785,7 @@ std::pair<cvf::Vec3st, cvf::Vec3st>
|
||||
}
|
||||
|
||||
// No view available, fallback to full grid
|
||||
const RigMainGrid* mainGrid = caseData->mainGrid();
|
||||
return { cvf::Vec3st::ZERO, mainGrid->cellCounts() - cvf::Vec3st( 1, 1, 1 ) };
|
||||
const RigMainGrid* mainGrid = caseData->mainGrid();
|
||||
cvf::Vec3st maxCounts = mainGrid->cellCounts() - cvf::Vec3st( 1, 1, 1 );
|
||||
return { caf::VecIjk0::ZERO, caf::VecIjk0( maxCounts.x(), maxCounts.y(), maxCounts.z() ) };
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafVecIjk.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
@@ -76,16 +77,16 @@ public:
|
||||
|
||||
void setCaseData( RigEclipseCaseData* caseData = nullptr,
|
||||
RimEclipseView* eclipseView = nullptr,
|
||||
const cvf::Vec3st& visibleMin = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& visibleMax = cvf::Vec3st::ZERO );
|
||||
const caf::VecIjk0& visibleMin = caf::VecIjk0::ZERO,
|
||||
const caf::VecIjk0& visibleMax = caf::VecIjk0::ZERO );
|
||||
|
||||
cvf::Vec3st min() const;
|
||||
cvf::Vec3st max() const;
|
||||
void setMin( const cvf::Vec3st& min );
|
||||
void setMax( const cvf::Vec3st& max );
|
||||
void applyBoundaryDefaults();
|
||||
void removeInvalidKeywords();
|
||||
cvf::Vec3st refinement() const;
|
||||
caf::VecIjk0 min() const;
|
||||
caf::VecIjk0 max() const;
|
||||
void setMin( const caf::VecIjk0& min );
|
||||
void setMax( const caf::VecIjk0& max );
|
||||
void applyBoundaryDefaults();
|
||||
void removeInvalidKeywords();
|
||||
cvf::Vec3st refinement() const;
|
||||
|
||||
QString exportFaultsFilename() const;
|
||||
QString exportGridFilename() const;
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
bool writeEchoKeywords() const;
|
||||
|
||||
static std::vector<const RigSimWellData*> getVisibleSimulationWells( RimEclipseView* view );
|
||||
static std::pair<cvf::Vec3st, cvf::Vec3st>
|
||||
static std::pair<caf::VecIjk0, caf::VecIjk0>
|
||||
computeVisibleWellCells( RimEclipseView* view, RigEclipseCaseData* caseData, int visibleWellsPadding );
|
||||
|
||||
caf::PdmField<bool> exportGrid;
|
||||
@@ -150,7 +151,7 @@ private:
|
||||
|
||||
RigEclipseCaseData* m_caseData;
|
||||
RimEclipseView* m_eclipseView;
|
||||
cvf::Vec3st m_visibleMin;
|
||||
cvf::Vec3st m_visibleMax;
|
||||
caf::VecIjk0 m_visibleMin;
|
||||
caf::VecIjk0 m_visibleMax;
|
||||
QStringList m_tabNames;
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "Well/RigSimWellData.h"
|
||||
#include "Well/RigSimulationWellCenterLineCalculator.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
@@ -86,21 +87,21 @@ cvf::BoundingBox RigEclipseCaseDataTools::wellBoundingBoxInDomainCoords( RigEcli
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::wellBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const RigSimWellData* simWellData,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe )
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> RigEclipseCaseDataTools::wellBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const RigSimWellData* simWellData,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe )
|
||||
{
|
||||
if ( !eclipseCaseData || !simWellData ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !eclipseCaseData || !simWellData ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
cvf::BoundingBox domainBB =
|
||||
wellBoundingBoxInDomainCoords( eclipseCaseData, simWellData, timeStepIndex, isAutoDetectingBranches, isUsingCellCenterForPipe );
|
||||
|
||||
if ( !domainBB.isValid() ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !domainBB.isValid() ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
auto mainGrid = eclipseCaseData->mainGrid();
|
||||
if ( !mainGrid ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !mainGrid ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
// Convert domain bounding box min/max to cell indices
|
||||
cvf::Vec3d minPoint = domainBB.min();
|
||||
@@ -110,20 +111,19 @@ std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::wellBoundingBoxIjk(
|
||||
size_t maxCellIndex = mainGrid->findReservoirCellIndexFromPoint( maxPoint );
|
||||
|
||||
if ( minCellIndex == cvf::UNDEFINED_SIZE_T || maxCellIndex == cvf::UNDEFINED_SIZE_T )
|
||||
return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
// Convert cell indices to IJK coordinates
|
||||
auto ijkFromCellIndex = []( RigMainGrid* mainGrid, size_t index )
|
||||
auto ijkFromCellIndex = []( RigMainGrid* mainGrid, size_t index ) -> caf::VecIjk0
|
||||
{
|
||||
if ( auto ijkOpt = mainGrid->ijkFromCellIndex( index ); ijkOpt.has_value() )
|
||||
return cvf::Vec3st( ijkOpt->i(), ijkOpt->j(), ijkOpt->k() );
|
||||
return cvf::Vec3st::UNDEFINED;
|
||||
if ( auto ijkOpt = mainGrid->ijkFromCellIndex( index ); ijkOpt.has_value() ) return ijkOpt.value();
|
||||
return caf::VecIjk0::UNDEFINED;
|
||||
};
|
||||
|
||||
cvf::Vec3st minIjk = ijkFromCellIndex( mainGrid, minCellIndex );
|
||||
cvf::Vec3st maxIjk = ijkFromCellIndex( mainGrid, maxCellIndex );
|
||||
caf::VecIjk0 minIjk = ijkFromCellIndex( mainGrid, minCellIndex );
|
||||
caf::VecIjk0 maxIjk = ijkFromCellIndex( mainGrid, maxCellIndex );
|
||||
|
||||
if ( minIjk.isUndefined() || maxIjk.isUndefined() ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( minIjk.isUndefined() || maxIjk.isUndefined() ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
if ( minIjk.x() > maxIjk.x() || minIjk.y() > maxIjk.y() || minIjk.z() > maxIjk.z() )
|
||||
{
|
||||
@@ -136,16 +136,16 @@ std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::wellBoundingBoxIjk(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::wellsBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<const RigSimWellData*>& simWells,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe )
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> RigEclipseCaseDataTools::wellsBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<const RigSimWellData*>& simWells,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe )
|
||||
{
|
||||
if ( !eclipseCaseData || simWells.empty() ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !eclipseCaseData || simWells.empty() ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
cvf::Vec3st globalMin = cvf::Vec3st::UNDEFINED;
|
||||
cvf::Vec3st globalMax = cvf::Vec3st::UNDEFINED;
|
||||
caf::VecIjk0 globalMin = caf::VecIjk0::UNDEFINED;
|
||||
caf::VecIjk0 globalMax = caf::VecIjk0::UNDEFINED;
|
||||
|
||||
for ( const auto& well : simWells )
|
||||
{
|
||||
@@ -179,15 +179,15 @@ std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::wellsBoundingBoxIjk
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::expandBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const cvf::Vec3st& minIjk,
|
||||
const cvf::Vec3st& maxIjk,
|
||||
size_t numPadding )
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> RigEclipseCaseDataTools::expandBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const caf::VecIjk0& minIjk,
|
||||
const caf::VecIjk0& maxIjk,
|
||||
size_t numPadding )
|
||||
{
|
||||
if ( !eclipseCaseData || minIjk.isUndefined() || maxIjk.isUndefined() ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !eclipseCaseData || minIjk.isUndefined() || maxIjk.isUndefined() ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
auto mainGrid = eclipseCaseData->mainGrid();
|
||||
if ( !mainGrid ) return { cvf::Vec3st::UNDEFINED, cvf::Vec3st::UNDEFINED };
|
||||
if ( !mainGrid ) return { caf::VecIjk0::UNDEFINED, caf::VecIjk0::UNDEFINED };
|
||||
|
||||
// Calculate expanded bounds with padding, ensuring we stay within grid bounds
|
||||
size_t expandedMinI = ( minIjk.x() >= numPadding ) ? ( minIjk.x() - numPadding ) : 0;
|
||||
@@ -198,15 +198,15 @@ std::pair<cvf::Vec3st, cvf::Vec3st> RigEclipseCaseDataTools::expandBoundingBoxIj
|
||||
size_t expandedMaxJ = std::min( maxIjk.y() + numPadding, mainGrid->cellCountJ() - 1 );
|
||||
size_t expandedMaxK = std::min( maxIjk.z() + numPadding, mainGrid->cellCountK() - 1 );
|
||||
|
||||
return { cvf::Vec3st( expandedMinI, expandedMinJ, expandedMinK ), cvf::Vec3st( expandedMaxI, expandedMaxJ, expandedMaxK ) };
|
||||
return { caf::VecIjk0( expandedMinI, expandedMinJ, expandedMinK ), caf::VecIjk0( expandedMaxI, expandedMaxJ, expandedMaxK ) };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::UByteArray> RigEclipseCaseDataTools::createVisibilityFromIjkBounds( RigEclipseCaseData* eclipseCaseData,
|
||||
const cvf::Vec3st& minIjk,
|
||||
const cvf::Vec3st& maxIjk )
|
||||
const caf::VecIjk0& minIjk,
|
||||
const caf::VecIjk0& maxIjk )
|
||||
{
|
||||
if ( !eclipseCaseData || minIjk.isUndefined() || maxIjk.isUndefined() ) return nullptr;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "QString"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
@@ -43,21 +44,21 @@ public:
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe );
|
||||
|
||||
static std::pair<cvf::Vec3st, cvf::Vec3st> wellBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const RigSimWellData* simWellData,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe );
|
||||
static std::pair<caf::VecIjk0, caf::VecIjk0> wellBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const RigSimWellData* simWellData,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe );
|
||||
|
||||
static std::pair<cvf::Vec3st, cvf::Vec3st> wellsBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<const RigSimWellData*>& simWells,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe );
|
||||
static std::pair<caf::VecIjk0, caf::VecIjk0> wellsBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<const RigSimWellData*>& simWells,
|
||||
int timeStepIndex,
|
||||
bool isAutoDetectingBranches,
|
||||
bool isUsingCellCenterForPipe );
|
||||
|
||||
static std::pair<cvf::Vec3st, cvf::Vec3st>
|
||||
expandBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData, const cvf::Vec3st& minIjk, const cvf::Vec3st& maxIjk, size_t numPadding );
|
||||
static std::pair<caf::VecIjk0, caf::VecIjk0>
|
||||
expandBoundingBoxIjk( RigEclipseCaseData* eclipseCaseData, const caf::VecIjk0& minIjk, const caf::VecIjk0& maxIjk, size_t numPadding );
|
||||
|
||||
static cvf::ref<cvf::UByteArray>
|
||||
createVisibilityFromIjkBounds( RigEclipseCaseData* eclipseCaseData, const cvf::Vec3st& minIjk, const cvf::Vec3st& maxIjk );
|
||||
createVisibilityFromIjkBounds( RigEclipseCaseData* eclipseCaseData, const caf::VecIjk0& minIjk, const caf::VecIjk0& maxIjk );
|
||||
};
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
|
||||
namespace RigEclipseResultTools
|
||||
{
|
||||
namespace
|
||||
@@ -260,7 +262,7 @@ int findMaxBcconValue( RimEclipseCase* eclipseCase )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void generateBcconResult( RimEclipseCase* eclipseCase, const cvf::Vec3st& min, const cvf::Vec3st& max )
|
||||
void generateBcconResult( RimEclipseCase* eclipseCase, const caf::VecIjk0& min, const caf::VecIjk0& max )
|
||||
{
|
||||
if ( eclipseCase == nullptr ) return;
|
||||
|
||||
@@ -378,38 +380,39 @@ std::vector<BorderCellFace> generateBorderCellFaces( RimEclipseCase* eclipseCase
|
||||
if ( borderValue != BorderType::BORDER_CELL ) continue;
|
||||
|
||||
// Get IJK indices for this cell
|
||||
size_t i, j, k;
|
||||
if ( !grid->ijkFromCellIndex( activeCellIdx.value(), &i, &j, &k ) ) continue;
|
||||
|
||||
// Check all 6 faces
|
||||
std::vector<cvf::StructGridInterface::FaceType> faces = cvf::StructGridInterface::validFaceTypes();
|
||||
|
||||
for ( auto faceType : faces )
|
||||
if ( auto ijk = grid->ijkFromCellIndex( activeCellIdx.value() ) )
|
||||
{
|
||||
// Get neighbor cell IJK
|
||||
size_t ni, nj, nk;
|
||||
cvf::StructGridInterface::neighborIJKAtCellFace( i, j, k, faceType, &ni, &nj, &nk );
|
||||
// Check all 6 faces
|
||||
std::vector<cvf::StructGridInterface::FaceType> faces = cvf::StructGridInterface::validFaceTypes();
|
||||
|
||||
// Check if neighbor is within bounds
|
||||
if ( ni >= grid->cellCountI() || nj >= grid->cellCountJ() || nk >= grid->cellCountK() ) continue;
|
||||
|
||||
// Get neighbor reservoir cell index
|
||||
size_t neighborReservoirIdx = grid->cellIndexFromIJK( ni, nj, nk );
|
||||
|
||||
// Find active cell index for neighbor
|
||||
auto it = std::find( activeReservoirCellIdxs.begin(), activeReservoirCellIdxs.end(), ReservoirCellIndex( neighborReservoirIdx ) );
|
||||
if ( it == activeReservoirCellIdxs.end() ) continue; // Neighbor not active
|
||||
|
||||
// Check if neighbor is an interior cell
|
||||
int neighborBorderValue = static_cast<int>( bordNumValues[neighborReservoirIdx] );
|
||||
if ( neighborBorderValue == BorderType::INTERIOR_CELL )
|
||||
for ( auto faceType : faces )
|
||||
{
|
||||
// Get boundary condition value from BCCON grid property
|
||||
int boundaryCondition = static_cast<int>( bcconValues[activeCellIdx.value()] );
|
||||
if ( boundaryCondition > 0 )
|
||||
// Get neighbor cell IJK
|
||||
size_t ni, nj, nk;
|
||||
cvf::StructGridInterface::neighborIJKAtCellFace( ijk->i(), ijk->j(), ijk->k(), faceType, &ni, &nj, &nk );
|
||||
|
||||
// Check if neighbor is within bounds
|
||||
if ( ni >= grid->cellCountI() || nj >= grid->cellCountJ() || nk >= grid->cellCountK() ) continue;
|
||||
|
||||
// Get neighbor reservoir cell index
|
||||
size_t neighborReservoirIdx = grid->cellIndexFromIJK( ni, nj, nk );
|
||||
|
||||
// Find active cell index for neighbor
|
||||
auto it =
|
||||
std::find( activeReservoirCellIdxs.begin(), activeReservoirCellIdxs.end(), ReservoirCellIndex( neighborReservoirIdx ) );
|
||||
if ( it == activeReservoirCellIdxs.end() ) continue; // Neighbor not active
|
||||
|
||||
// Check if neighbor is an interior cell
|
||||
int neighborBorderValue = static_cast<int>( bordNumValues[neighborReservoirIdx] );
|
||||
if ( neighborBorderValue == BorderType::INTERIOR_CELL )
|
||||
{
|
||||
// Add this face to the result
|
||||
borderCellFaces.push_back( { cvf::Vec3st( i, j, k ), faceType, boundaryCondition } );
|
||||
// Get boundary condition value from BCCON grid property
|
||||
int boundaryCondition = static_cast<int>( bcconValues[activeCellIdx.value()] );
|
||||
if ( boundaryCondition > 0 )
|
||||
{
|
||||
// Add this face to the result
|
||||
borderCellFaces.push_back( { *ijk, faceType, boundaryCondition } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
@@ -38,7 +39,7 @@ enum BorderType : int
|
||||
|
||||
struct BorderCellFace
|
||||
{
|
||||
cvf::Vec3st ijk; // Cell indices (0-based)
|
||||
caf::VecIjk0 ijk; // Cell indices (0-based)
|
||||
cvf::StructGridInterface::FaceType faceType;
|
||||
int boundaryCondition; // BCCON grid value
|
||||
};
|
||||
@@ -53,7 +54,7 @@ int findMaxOperNumValue( RimEclipseCase* eclipseCase );
|
||||
|
||||
int findMaxBcconValue( RimEclipseCase* eclipseCase );
|
||||
|
||||
void generateBcconResult( RimEclipseCase* eclipseCase, const cvf::Vec3st& min, const cvf::Vec3st& max );
|
||||
void generateBcconResult( RimEclipseCase* eclipseCase, const caf::VecIjk0& min, const caf::VecIjk0& max );
|
||||
|
||||
std::vector<BorderCellFace> generateBorderCellFaces( RimEclipseCase* eclipseCase );
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
@@ -422,10 +423,10 @@ size_t RigGridExportAdapter::totalCells() const
|
||||
/// Transform IJK coordinates from global grid space to sector-relative space with refinement
|
||||
/// Returns 1-based Eclipse coordinates
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::expected<cvf::Vec3st, QString> RigGridExportAdapter::transformIjkToSectorCoordinates( const cvf::Vec3st& originalIjk,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& refinement )
|
||||
std::expected<caf::VecIjk1, QString> RigGridExportAdapter::transformIjkToSectorCoordinates( const caf::VecIjk0& originalIjk,
|
||||
const caf::VecIjk0& min,
|
||||
const caf::VecIjk0& max,
|
||||
const cvf::Vec3st& refinement )
|
||||
{
|
||||
// Check if original IJK is within the sector bounds
|
||||
if ( originalIjk.x() < min.x() || originalIjk.x() > max.x() || originalIjk.y() < min.y() || originalIjk.y() > max.y() ||
|
||||
@@ -445,10 +446,9 @@ std::expected<cvf::Vec3st, QString> RigGridExportAdapter::transformIjkToSectorCo
|
||||
|
||||
// Transform to sector-relative coordinates with refinement
|
||||
// Eclipse uses 1-based indexing, so we'll return 1-based coordinates
|
||||
cvf::Vec3st sectorIjk;
|
||||
sectorIjk.x() = ( originalIjk.x() - min.x() ) * refinement.x() + 1;
|
||||
sectorIjk.y() = ( originalIjk.y() - min.y() ) * refinement.y() + 1;
|
||||
sectorIjk.z() = ( originalIjk.z() - min.z() ) * refinement.z() + 1;
|
||||
size_t sectorI = ( originalIjk.x() - min.x() ) * refinement.x() + 1;
|
||||
size_t sectorJ = ( originalIjk.y() - min.y() ) * refinement.y() + 1;
|
||||
size_t sectorK = ( originalIjk.z() - min.z() ) * refinement.z() + 1;
|
||||
|
||||
return sectorIjk;
|
||||
return caf::VecIjk1( sectorI, sectorJ, sectorK );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfStructGrid.h"
|
||||
@@ -87,10 +89,10 @@ public:
|
||||
bool hasRefinement() const;
|
||||
|
||||
// Coordinate transformation utilities
|
||||
static std::expected<cvf::Vec3st, QString> transformIjkToSectorCoordinates( const cvf::Vec3st& originalIjk,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& refinement );
|
||||
static std::expected<caf::VecIjk1, QString> transformIjkToSectorCoordinates( const caf::VecIjk0& originalIjk,
|
||||
const caf::VecIjk0& min,
|
||||
const caf::VecIjk0& max,
|
||||
const cvf::Vec3st& refinement );
|
||||
|
||||
private:
|
||||
// Internal methods to handle original vs refined cell access
|
||||
|
||||
@@ -52,17 +52,17 @@ static Opm::DeckRecord createEqualsRecord( const std::string& fieldName, int val
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_NoOverlap )
|
||||
{
|
||||
// Sector: min=(0, 15, 0), max=(19, 29, 9) (inclusive, cells [0-19, 15-29, 0-9])
|
||||
cvf::Vec3st min( 0, 15, 0 );
|
||||
cvf::Vec3st max( 19, 29, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
// 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 );
|
||||
|
||||
// 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]
|
||||
// Sector J is [15-29], so no overlap in J dimension
|
||||
auto record = createEqualsRecord( "FIPNUM", 1, 1, 20, 1, 14, 1, 10 );
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
EXPECT_FALSE( result.has_value() );
|
||||
EXPECT_TRUE( result.error().contains( "does not overlap" ) );
|
||||
@@ -73,10 +73,10 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_NoOverlap )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_PartialOverlapWithClamping )
|
||||
{
|
||||
// Sector: min=(0, 15, 0), max=(19, 29, 9) (inclusive, cells [0-19, 15-29, 0-9])
|
||||
cvf::Vec3st min( 0, 15, 0 );
|
||||
cvf::Vec3st max( 19, 29, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
// 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 );
|
||||
|
||||
// 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]
|
||||
@@ -84,7 +84,7 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_PartialOverlapWith
|
||||
// Intersection (clamped): I[0-19], J[15-29], K[0-9]
|
||||
auto record = createEqualsRecord( "FIPNUM", 2, 1, 20, 15, 30, 1, 10 );
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
ASSERT_TRUE( result.has_value() );
|
||||
|
||||
@@ -112,15 +112,15 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_PartialOverlapWith
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_CompletelyInside )
|
||||
{
|
||||
// Sector: min=(0, 0, 0), max=(19, 19, 9) (inclusive, cells [0-19, 0-19, 0-9])
|
||||
cvf::Vec3st min( 0, 0, 0 );
|
||||
cvf::Vec3st max( 19, 19, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 0, 0, 0 );
|
||||
caf::VecIjk0 sectorMax( 19, 19, 9 );
|
||||
cvf::Vec3st refinement( 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]
|
||||
auto record = createEqualsRecord( "FIPNUM", 3, 5, 15, 5, 15, 2, 8 );
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
ASSERT_TRUE( result.has_value() );
|
||||
|
||||
@@ -142,16 +142,16 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_CompletelyInside )
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_CompletelyOutside )
|
||||
{
|
||||
// Sector: min=(0, 0, 0), max=(9, 9, 9) (inclusive, cells [0-9, 0-9, 0-9])
|
||||
cvf::Vec3st min( 0, 0, 0 );
|
||||
cvf::Vec3st max( 9, 9, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 0, 0, 0 );
|
||||
caf::VecIjk0 sectorMax( 9, 9, 9 );
|
||||
cvf::Vec3st refinement( 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]
|
||||
// No overlap with sector
|
||||
auto record = createEqualsRecord( "FIPNUM", 4, 20, 30, 20, 30, 1, 10 );
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
EXPECT_FALSE( result.has_value() );
|
||||
EXPECT_TRUE( result.error().contains( "does not overlap" ) );
|
||||
@@ -162,9 +162,9 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_CompletelyOutside
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_InvalidRecord )
|
||||
{
|
||||
cvf::Vec3st min( 0, 0, 0 );
|
||||
cvf::Vec3st max( 9, 9, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 0, 0, 0 );
|
||||
caf::VecIjk0 sectorMax( 9, 9, 9 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
|
||||
// Create a record with only 5 items (insufficient)
|
||||
std::vector<Opm::DeckItem> items;
|
||||
@@ -177,7 +177,7 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_InvalidRecord )
|
||||
|
||||
Opm::DeckRecord record{ std::move( items ) };
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
EXPECT_FALSE( result.has_value() );
|
||||
EXPECT_TRUE( result.error().contains( "insufficient items" ) );
|
||||
@@ -189,15 +189,15 @@ TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_InvalidRecord )
|
||||
TEST( RicExportEclipseSectorModelFeature, ProcessEqualsRecord_AtBoundary )
|
||||
{
|
||||
// Sector: min=(5, 5, 5), max=(14, 14, 14) (inclusive, cells [5-14, 5-14, 5-14])
|
||||
cvf::Vec3st min( 5, 5, 5 );
|
||||
cvf::Vec3st max( 14, 14, 14 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 5, 5, 5 );
|
||||
caf::VecIjk0 sectorMax( 14, 14, 14 );
|
||||
cvf::Vec3st refinement( 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]
|
||||
auto record = createEqualsRecord( "FIPNUM", 5, 6, 15, 6, 15, 6, 15 );
|
||||
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, min, max, refinement );
|
||||
auto result = RicExportEclipseSectorModelFeature::processEqualsRecord( record, sectorMin, sectorMax, refinement );
|
||||
|
||||
ASSERT_TRUE( result.has_value() );
|
||||
|
||||
|
||||
@@ -372,10 +372,10 @@ TEST( RifOpmFlowDeckFileTest, BcpropKeyword )
|
||||
|
||||
// Create boundary conditions with different indices
|
||||
std::vector<RigEclipseResultTools::BorderCellFace> boundaryConditions;
|
||||
boundaryConditions.push_back( { cvf::Vec3st( 5, 5, 2 ), cvf::StructGridInterface::POS_I, 1 } );
|
||||
boundaryConditions.push_back( { cvf::Vec3st( 5, 6, 2 ), cvf::StructGridInterface::POS_J, 1 } );
|
||||
boundaryConditions.push_back( { cvf::Vec3st( 6, 5, 2 ), cvf::StructGridInterface::NEG_I, 2 } );
|
||||
boundaryConditions.push_back( { cvf::Vec3st( 7, 5, 2 ), cvf::StructGridInterface::POS_K, 2 } );
|
||||
boundaryConditions.push_back( { caf::VecIjk0( 5, 5, 2 ), cvf::StructGridInterface::POS_I, 1 } );
|
||||
boundaryConditions.push_back( { caf::VecIjk0( 5, 6, 2 ), cvf::StructGridInterface::POS_J, 1 } );
|
||||
boundaryConditions.push_back( { caf::VecIjk0( 6, 5, 2 ), cvf::StructGridInterface::NEG_I, 2 } );
|
||||
boundaryConditions.push_back( { caf::VecIjk0( 7, 5, 2 ), cvf::StructGridInterface::POS_K, 2 } );
|
||||
|
||||
// Create boundary condition properties
|
||||
// BC 1: Free flow boundary with specified pressure
|
||||
|
||||
@@ -109,8 +109,8 @@ TEST( RigEclipseCaseDataToolsTest, WellBoundingBoxWithBruggeModel )
|
||||
auto [minIjk, maxIjk] =
|
||||
RigEclipseCaseDataTools::wellBoundingBoxIjk( eclipseCase.p(), testWell, timeStep, isAutoDetectingBranches, isUsingCellCenterForPipe );
|
||||
|
||||
ASSERT_NE( minIjk, cvf::Vec3st::UNDEFINED ) << "Min IJK should be valid";
|
||||
ASSERT_NE( maxIjk, cvf::Vec3st::UNDEFINED ) << "Max IJK should be valid";
|
||||
ASSERT_NE( minIjk, caf::VecIjk0::UNDEFINED ) << "Min IJK should be valid";
|
||||
ASSERT_NE( maxIjk, caf::VecIjk0::UNDEFINED ) << "Max IJK should be valid";
|
||||
|
||||
// Sanity checks
|
||||
ASSERT_LE( minIjk.x(), maxIjk.x() ) << "Min I should be <= Max I";
|
||||
@@ -180,8 +180,8 @@ TEST( RigEclipseCaseDataToolsTest, MultipleWellsBoundingBoxWithBruggeModel )
|
||||
auto [minIjk, maxIjk] =
|
||||
RigEclipseCaseDataTools::wellsBoundingBoxIjk( eclipseCase.p(), testWells, timeStep, isAutoDetectingBranches, isUsingCellCenterForPipe );
|
||||
|
||||
ASSERT_NE( minIjk, cvf::Vec3st::UNDEFINED ) << "Min IJK should be valid";
|
||||
ASSERT_NE( maxIjk, cvf::Vec3st::UNDEFINED ) << "Max IJK should be valid";
|
||||
ASSERT_NE( minIjk, caf::VecIjk0::UNDEFINED ) << "Min IJK should be valid";
|
||||
ASSERT_NE( maxIjk, caf::VecIjk0::UNDEFINED ) << "Max IJK should be valid";
|
||||
|
||||
// Expected values from visual inspection
|
||||
ASSERT_EQ( minIjk.x(), 44 );
|
||||
@@ -234,14 +234,14 @@ TEST( RigEclipseCaseDataToolsTest, ExpandBoundingBoxIjkWithPadding )
|
||||
size_t gridCellCountK = mainGrid->cellCountK();
|
||||
|
||||
// Test case 1: Normal expansion with padding (using safe values that won't hit grid boundaries)
|
||||
cvf::Vec3st originalMin( 20, 20, 3 );
|
||||
cvf::Vec3st originalMax( 22, 22, 4 );
|
||||
size_t padding = 3;
|
||||
caf::VecIjk0 originalMin( 20, 20, 3 );
|
||||
caf::VecIjk0 originalMax( 22, 22, 4 );
|
||||
size_t padding = 3;
|
||||
|
||||
auto [expandedMin1, expandedMax1] = RigEclipseCaseDataTools::expandBoundingBoxIjk( eclipseCase.p(), originalMin, originalMax, padding );
|
||||
|
||||
ASSERT_NE( expandedMin1, cvf::Vec3st::UNDEFINED ) << "Expanded min should be valid";
|
||||
ASSERT_NE( expandedMax1, cvf::Vec3st::UNDEFINED ) << "Expanded max should be valid";
|
||||
ASSERT_NE( expandedMin1, caf::VecIjk0::UNDEFINED ) << "Expanded min should be valid";
|
||||
ASSERT_NE( expandedMax1, caf::VecIjk0::UNDEFINED ) << "Expanded max should be valid";
|
||||
|
||||
// Check expansion worked correctly (these values should not hit grid boundaries)
|
||||
ASSERT_EQ( expandedMin1.x(), originalMin.x() - padding ) << "Min I should be reduced by padding";
|
||||
@@ -253,15 +253,15 @@ TEST( RigEclipseCaseDataToolsTest, ExpandBoundingBoxIjkWithPadding )
|
||||
ASSERT_EQ( expandedMax1.z(), originalMax.z() + padding ) << "Max K should be increased by padding";
|
||||
|
||||
// Test case 2: Expansion at grid boundary - ensure min never goes below 0
|
||||
cvf::Vec3st boundaryMin( 1, 1, 1 );
|
||||
cvf::Vec3st boundaryMax( 3, 3, 3 );
|
||||
size_t largePadding = 5;
|
||||
caf::VecIjk0 boundaryMin( 1, 1, 1 );
|
||||
caf::VecIjk0 boundaryMax( 3, 3, 3 );
|
||||
size_t largePadding = 5;
|
||||
|
||||
auto [expandedMin2, expandedMax2] =
|
||||
RigEclipseCaseDataTools::expandBoundingBoxIjk( eclipseCase.p(), boundaryMin, boundaryMax, largePadding );
|
||||
|
||||
ASSERT_NE( expandedMin2, cvf::Vec3st::UNDEFINED ) << "Boundary expanded min should be valid";
|
||||
ASSERT_NE( expandedMax2, cvf::Vec3st::UNDEFINED ) << "Boundary expanded max should be valid";
|
||||
ASSERT_NE( expandedMin2, caf::VecIjk0::UNDEFINED ) << "Boundary expanded min should be valid";
|
||||
ASSERT_NE( expandedMax2, caf::VecIjk0::UNDEFINED ) << "Boundary expanded max should be valid";
|
||||
|
||||
// Ensure min coordinates never go negative (should be clamped to 0)
|
||||
ASSERT_EQ( expandedMin2.x(), 0 ) << "Min I should be clamped to 0";
|
||||
@@ -269,14 +269,14 @@ TEST( RigEclipseCaseDataToolsTest, ExpandBoundingBoxIjkWithPadding )
|
||||
ASSERT_EQ( expandedMin2.z(), 0 ) << "Min K should be clamped to 0";
|
||||
|
||||
// Test case 3: Expansion at grid upper boundary - ensure max never exceeds grid dimensions
|
||||
cvf::Vec3st upperBoundaryMin( gridCellCountI - 3, gridCellCountJ - 3, gridCellCountK - 3 );
|
||||
cvf::Vec3st upperBoundaryMax( gridCellCountI - 1, gridCellCountJ - 1, gridCellCountK - 1 );
|
||||
caf::VecIjk0 upperBoundaryMin( gridCellCountI - 3, gridCellCountJ - 3, gridCellCountK - 3 );
|
||||
caf::VecIjk0 upperBoundaryMax( gridCellCountI - 1, gridCellCountJ - 1, gridCellCountK - 1 );
|
||||
|
||||
auto [expandedMin3, expandedMax3] =
|
||||
RigEclipseCaseDataTools::expandBoundingBoxIjk( eclipseCase.p(), upperBoundaryMin, upperBoundaryMax, largePadding );
|
||||
|
||||
ASSERT_NE( expandedMin3, cvf::Vec3st::UNDEFINED ) << "Upper boundary expanded min should be valid";
|
||||
ASSERT_NE( expandedMax3, cvf::Vec3st::UNDEFINED ) << "Upper boundary expanded max should be valid";
|
||||
ASSERT_NE( expandedMin3, caf::VecIjk0::UNDEFINED ) << "Upper boundary expanded min should be valid";
|
||||
ASSERT_NE( expandedMax3, caf::VecIjk0::UNDEFINED ) << "Upper boundary expanded max should be valid";
|
||||
|
||||
// Ensure max coordinates never exceed grid dimensions (should be clamped to grid size - 1)
|
||||
ASSERT_EQ( expandedMax3.x(), gridCellCountI - 1 ) << "Max I should be clamped to grid size - 1";
|
||||
@@ -328,8 +328,8 @@ TEST( RigEclipseCaseDataToolsTest, CreateVisibilityFromIjkBounds )
|
||||
size_t totalCellCount = eclipseCase->mainGrid()->cellCount();
|
||||
|
||||
// Test case 1: Basic visibility generation with small bounds
|
||||
cvf::Vec3st minIjk( 5, 5, 5 );
|
||||
cvf::Vec3st maxIjk( 10, 10, 8 );
|
||||
caf::VecIjk0 minIjk( 5, 5, 5 );
|
||||
caf::VecIjk0 maxIjk( 10, 10, 8 );
|
||||
|
||||
auto visibility = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), minIjk, maxIjk );
|
||||
|
||||
@@ -377,8 +377,8 @@ TEST( RigEclipseCaseDataToolsTest, CreateVisibilityFromIjkBounds )
|
||||
}
|
||||
|
||||
// Test case 4: Edge case - single cell bounds
|
||||
cvf::Vec3st singleCellMin( 2, 2, 2 );
|
||||
cvf::Vec3st singleCellMax( 2, 2, 2 );
|
||||
caf::VecIjk0 singleCellMin( 2, 2, 2 );
|
||||
caf::VecIjk0 singleCellMax( 2, 2, 2 );
|
||||
|
||||
auto singleCellVisibility = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), singleCellMin, singleCellMax );
|
||||
|
||||
@@ -403,15 +403,15 @@ TEST( RigEclipseCaseDataToolsTest, CreateVisibilityFromIjkBounds )
|
||||
auto invalidVisibility1 = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( nullptr, minIjk, maxIjk );
|
||||
ASSERT_TRUE( invalidVisibility1.isNull() ) << "Null case data should return null visibility";
|
||||
|
||||
auto invalidVisibility2 = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), cvf::Vec3st::UNDEFINED, maxIjk );
|
||||
auto invalidVisibility2 = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), caf::VecIjk0::UNDEFINED, maxIjk );
|
||||
ASSERT_TRUE( invalidVisibility2.isNull() ) << "Undefined minIjk should return null visibility";
|
||||
|
||||
auto invalidVisibility3 = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), minIjk, cvf::Vec3st::UNDEFINED );
|
||||
auto invalidVisibility3 = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), minIjk, caf::VecIjk0::UNDEFINED );
|
||||
ASSERT_TRUE( invalidVisibility3.isNull() ) << "Undefined maxIjk should return null visibility";
|
||||
|
||||
// Test case 6: Boundary conditions - bounds at grid limits
|
||||
cvf::Vec3st gridMinBounds( 0, 0, 0 );
|
||||
cvf::Vec3st gridMaxBounds( gridCellCountI - 1, gridCellCountJ - 1, gridCellCountK - 1 );
|
||||
caf::VecIjk0 gridMinBounds( 0, 0, 0 );
|
||||
caf::VecIjk0 gridMaxBounds( gridCellCountI - 1, gridCellCountJ - 1, gridCellCountK - 1 );
|
||||
|
||||
auto fullGridVisibility = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), gridMinBounds, gridMaxBounds );
|
||||
|
||||
@@ -453,8 +453,8 @@ TEST( RigEclipseCaseDataToolsTest, GenerateBorderResultFromIjkBounds )
|
||||
resultCase->setReservoirData( eclipseCase.p() );
|
||||
|
||||
// Define IJK bounds for testing
|
||||
cvf::Vec3st minIjk( 20, 20, 5 );
|
||||
cvf::Vec3st maxIjk( 30, 30, 8 );
|
||||
caf::VecIjk0 minIjk( 20, 20, 5 );
|
||||
caf::VecIjk0 maxIjk( 30, 30, 8 );
|
||||
|
||||
// Create visibility from IJK bounds
|
||||
auto visibility = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), minIjk, maxIjk );
|
||||
@@ -524,8 +524,8 @@ TEST( RigEclipseCaseDataToolsTest, GenerateOperNumResultFromBorderResult )
|
||||
resultCase->setReservoirData( eclipseCase.p() );
|
||||
|
||||
// Define IJK bounds for testing
|
||||
cvf::Vec3st minIjk( 20, 20, 5 );
|
||||
cvf::Vec3st maxIjk( 30, 30, 8 );
|
||||
caf::VecIjk0 minIjk( 20, 20, 5 );
|
||||
caf::VecIjk0 maxIjk( 30, 30, 8 );
|
||||
|
||||
// Create visibility from IJK bounds
|
||||
auto visibility = RigEclipseCaseDataTools::createVisibilityFromIjkBounds( eclipseCase.p(), minIjk, maxIjk );
|
||||
|
||||
@@ -260,8 +260,8 @@ TEST( RigEclipseResultToolsTest, BcconResultWithFaceNumbering )
|
||||
size_t startK = grid->cellCountK() / 4;
|
||||
size_t endK = 3 * grid->cellCountK() / 4;
|
||||
|
||||
cvf::Vec3st min( startI, startJ, startK );
|
||||
cvf::Vec3st max( endI - 1, endJ - 1, endK - 1 );
|
||||
caf::VecIjk0 min( startI, startJ, startK );
|
||||
caf::VecIjk0 max( endI - 1, endJ - 1, endK - 1 );
|
||||
|
||||
// Make the box visible
|
||||
for ( size_t i = startI; i < endI; ++i )
|
||||
|
||||
@@ -668,31 +668,31 @@ TEST( RigGridExportAdapterTest, RefinedCellsContainOriginalCorners )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_NoRefinement )
|
||||
{
|
||||
cvf::Vec3st min( 3, 3, 1 );
|
||||
cvf::Vec3st max( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 min( 3, 3, 1 );
|
||||
caf::VecIjk0 max( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
|
||||
// Point at sector min should transform to (1,1,1)
|
||||
auto result1 = RigGridExportAdapter::transformIjkToSectorCoordinates( min, min, max, refinement );
|
||||
EXPECT_TRUE( result1.has_value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 1, 1, 1 ), result1.value() );
|
||||
EXPECT_EQ( caf::VecIjk1( 1, 1, 1 ), result1.value() );
|
||||
|
||||
// Point at sector max should transform correctly
|
||||
auto result2 = RigGridExportAdapter::transformIjkToSectorCoordinates( max, min, max, refinement );
|
||||
EXPECT_TRUE( result2.has_value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 8, 8, 5 ), result2.value() ); // (10-3)*1+1 = 8
|
||||
EXPECT_EQ( caf::VecIjk1( 8, 8, 5 ), result2.value() ); // (10-3)*1+1 = 8
|
||||
|
||||
// Point in middle of sector
|
||||
cvf::Vec3st middle( 5, 5, 3 );
|
||||
auto result3 = RigGridExportAdapter::transformIjkToSectorCoordinates( middle, min, max, refinement );
|
||||
caf::VecIjk0 middle( 5, 5, 3 );
|
||||
auto result3 = RigGridExportAdapter::transformIjkToSectorCoordinates( middle, min, max, refinement );
|
||||
EXPECT_TRUE( result3.has_value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 3, 3, 3 ), result3.value() ); // (5-3)*1+1 = 3
|
||||
EXPECT_EQ( caf::VecIjk1( 3, 3, 3 ), result3.value() ); // (5-3)*1+1 = 3
|
||||
|
||||
// Test different point
|
||||
cvf::Vec3st point( 7, 6, 2 );
|
||||
auto result4 = RigGridExportAdapter::transformIjkToSectorCoordinates( point, min, max, refinement );
|
||||
caf::VecIjk0 point( 7, 6, 2 );
|
||||
auto result4 = RigGridExportAdapter::transformIjkToSectorCoordinates( point, min, max, refinement );
|
||||
EXPECT_TRUE( result4.has_value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 5, 4, 2 ), result4.value() ); // (7-3)*1+1=5, (6-3)*1+1=4, (2-1)*1+1=2
|
||||
EXPECT_EQ( caf::VecIjk1( 5, 4, 2 ), result4.value() ); // (7-3)*1+1=5, (6-3)*1+1=4, (2-1)*1+1=2
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -700,29 +700,29 @@ TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_NoRefinement )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_OutOfBounds )
|
||||
{
|
||||
cvf::Vec3st min( 3, 3, 1 );
|
||||
cvf::Vec3st max( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 min( 3, 3, 1 );
|
||||
caf::VecIjk0 max( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
|
||||
// Point before sector min (X too small)
|
||||
cvf::Vec3st point1( 2, 5, 3 );
|
||||
auto result1 = RigGridExportAdapter::transformIjkToSectorCoordinates( point1, min, max, refinement );
|
||||
caf::VecIjk0 point1( 2, 5, 3 );
|
||||
auto result1 = RigGridExportAdapter::transformIjkToSectorCoordinates( point1, min, max, refinement );
|
||||
EXPECT_FALSE( result1.has_value() );
|
||||
EXPECT_TRUE( result1.error().contains( "outside sector bounds" ) );
|
||||
|
||||
// Point after sector max (X too large)
|
||||
cvf::Vec3st point2( 11, 5, 3 );
|
||||
auto result2 = RigGridExportAdapter::transformIjkToSectorCoordinates( point2, min, max, refinement );
|
||||
caf::VecIjk0 point2( 11, 5, 3 );
|
||||
auto result2 = RigGridExportAdapter::transformIjkToSectorCoordinates( point2, min, max, refinement );
|
||||
EXPECT_FALSE( result2.has_value() );
|
||||
|
||||
// Point after sector max (Y too large)
|
||||
cvf::Vec3st point3( 5, 11, 3 );
|
||||
auto result3 = RigGridExportAdapter::transformIjkToSectorCoordinates( point3, min, max, refinement );
|
||||
caf::VecIjk0 point3( 5, 11, 3 );
|
||||
auto result3 = RigGridExportAdapter::transformIjkToSectorCoordinates( point3, min, max, refinement );
|
||||
EXPECT_FALSE( result3.has_value() );
|
||||
|
||||
// Point after sector max (Z too large)
|
||||
cvf::Vec3st point4( 5, 5, 6 );
|
||||
auto result4 = RigGridExportAdapter::transformIjkToSectorCoordinates( point4, min, max, refinement );
|
||||
caf::VecIjk0 point4( 5, 5, 6 );
|
||||
auto result4 = RigGridExportAdapter::transformIjkToSectorCoordinates( point4, min, max, refinement );
|
||||
EXPECT_FALSE( result4.has_value() );
|
||||
}
|
||||
|
||||
@@ -732,14 +732,14 @@ TEST( RigGridExportAdapter, TransformIjkToSectorCoordinates_OutOfBounds )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigGridExportAdapter, BoxTransformation_NoRefinement )
|
||||
{
|
||||
cvf::Vec3st sectorMin( 3, 3, 1 );
|
||||
cvf::Vec3st sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 3, 3, 1 );
|
||||
caf::VecIjk0 sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 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)
|
||||
cvf::Vec3st boxStart( 5, 5, 2 );
|
||||
cvf::Vec3st boxEnd( 7, 7, 3 );
|
||||
caf::VecIjk0 boxStart( 5, 5, 2 );
|
||||
caf::VecIjk0 boxEnd( 7, 7, 3 );
|
||||
|
||||
auto startResult = RigGridExportAdapter::transformIjkToSectorCoordinates( boxStart, sectorMin, sectorMax, refinement );
|
||||
auto endResult = RigGridExportAdapter::transformIjkToSectorCoordinates( boxEnd, sectorMin, sectorMax, refinement );
|
||||
@@ -748,10 +748,10 @@ TEST( RigGridExportAdapter, BoxTransformation_NoRefinement )
|
||||
EXPECT_TRUE( endResult.has_value() );
|
||||
|
||||
// Start: (5-3)*1+1 = 3 for each dimension
|
||||
EXPECT_EQ( cvf::Vec3st( 3, 3, 2 ), startResult.value() );
|
||||
EXPECT_EQ( caf::VecIjk1( 3, 3, 2 ), startResult.value() );
|
||||
|
||||
// End: (7-3)*1+1 = 5 for each dimension
|
||||
EXPECT_EQ( cvf::Vec3st( 5, 5, 3 ), endResult.value() );
|
||||
EXPECT_EQ( caf::VecIjk1( 5, 5, 3 ), endResult.value() );
|
||||
|
||||
// Verify box contains expected number of cells
|
||||
// In X: 5-3+1 = 3 cells (sector cells 3,4,5)
|
||||
@@ -771,17 +771,17 @@ TEST( RigGridExportAdapter, BoxTransformation_NoRefinement )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigGridExportAdapter, SingleCellBox_NoRefinement )
|
||||
{
|
||||
cvf::Vec3st sectorMin( 3, 3, 1 );
|
||||
cvf::Vec3st sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 3, 3, 1 );
|
||||
caf::VecIjk0 sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
|
||||
// Single cell box at global position (5,5,2)
|
||||
cvf::Vec3st singleCell( 5, 5, 2 );
|
||||
caf::VecIjk0 singleCell( 5, 5, 2 );
|
||||
|
||||
auto result = RigGridExportAdapter::transformIjkToSectorCoordinates( singleCell, sectorMin, sectorMax, refinement );
|
||||
|
||||
EXPECT_TRUE( result.has_value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 3, 3, 2 ), result.value() );
|
||||
EXPECT_EQ( caf::VecIjk1( 3, 3, 2 ), result.value() );
|
||||
|
||||
// For a single-cell box, start and end are the same
|
||||
auto startResult = RigGridExportAdapter::transformIjkToSectorCoordinates( singleCell, sectorMin, sectorMax, refinement );
|
||||
@@ -795,9 +795,9 @@ TEST( RigGridExportAdapter, SingleCellBox_NoRefinement )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigGridExportAdapter, BoxAtSectorBoundaries_NoRefinement )
|
||||
{
|
||||
cvf::Vec3st sectorMin( 3, 3, 1 );
|
||||
cvf::Vec3st sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
caf::VecIjk0 sectorMin( 3, 3, 1 );
|
||||
caf::VecIjk0 sectorMax( 10, 10, 5 );
|
||||
cvf::Vec3st refinement( 1, 1, 1 );
|
||||
|
||||
// Box spanning entire sector
|
||||
auto minResult = RigGridExportAdapter::transformIjkToSectorCoordinates( sectorMin, sectorMin, sectorMax, refinement );
|
||||
@@ -806,8 +806,8 @@ TEST( RigGridExportAdapter, BoxAtSectorBoundaries_NoRefinement )
|
||||
EXPECT_TRUE( minResult.has_value() );
|
||||
EXPECT_TRUE( maxResult.has_value() );
|
||||
|
||||
EXPECT_EQ( cvf::Vec3st( 1, 1, 1 ), minResult.value() );
|
||||
EXPECT_EQ( cvf::Vec3st( 8, 8, 5 ), maxResult.value() ); // (10-3)*1+1 = 8
|
||||
EXPECT_EQ( caf::VecIjk1( 1, 1, 1 ), minResult.value() );
|
||||
EXPECT_EQ( caf::VecIjk1( 8, 8, 5 ), maxResult.value() ); // (10-3)*1+1 = 8
|
||||
|
||||
// Verify sector dimensions
|
||||
size_t sectorSizeX = sectorMax.x() - sectorMin.x() + 1; // 10-3+1 = 8
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
#include "cafAssert.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -72,6 +74,13 @@ VecIjk1 VecIjk0::toOneBased() const
|
||||
return VecIjk1( i() + 1, j() + 1, k() + 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const VecIjk0 VecIjk0::ZERO( 0, 0, 0 );
|
||||
|
||||
const VecIjk0 VecIjk0::UNDEFINED( cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,9 @@ class VecIjk0 : public VecIjk
|
||||
public:
|
||||
VecIjk0( size_t i, size_t j, size_t k );
|
||||
VecIjk1 toOneBased() const;
|
||||
|
||||
static const VecIjk0 ZERO;
|
||||
static const VecIjk0 UNDEFINED;
|
||||
};
|
||||
|
||||
class VecIjk1 : public VecIjk
|
||||
|
||||
Reference in New Issue
Block a user