mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-26 21:27:15 -05:00
Refactor: use RigBoundingBoxIjk in RigActiveCellInfo.
This commit is contained in:
@@ -138,8 +138,8 @@ caf::PdmScriptResponse RicfCreateMultipleFractures::execute()
|
||||
if ( feature && ( topLayer < 0 || baseLayer < 0 ) )
|
||||
{
|
||||
auto ijkRange = feature->ijkRangeForGrid( gridCase );
|
||||
if ( topLayer < 0 ) topLayer = static_cast<int>( ijkRange.first.z() );
|
||||
if ( baseLayer < 0 ) baseLayer = static_cast<int>( ijkRange.second.z() );
|
||||
if ( topLayer < 0 ) topLayer = static_cast<int>( ijkRange.min().z() );
|
||||
if ( baseLayer < 0 ) baseLayer = static_cast<int>( ijkRange.max().z() );
|
||||
}
|
||||
options->setValues( topLayer, baseLayer, fractureTemplate, m_spacing );
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ void RicCellRangeUi::setDefaultValues()
|
||||
|
||||
if ( grid == mainGrid && actCellInfo )
|
||||
{
|
||||
auto [min0, max0] = actCellInfo->ijkBoundingBox();
|
||||
const auto& bbox = actCellInfo->ijkBoundingBox();
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
caf::VecIjk1 min1 = min0.toOneBased();
|
||||
caf::VecIjk1 max1 = max0.toOneBased();
|
||||
caf::VecIjk1 min1 = bbox.min().toOneBased();
|
||||
caf::VecIjk1 max1 = bbox.max().toOneBased();
|
||||
|
||||
m_startIndexI = static_cast<int>( min1.x() );
|
||||
m_startIndexJ = static_cast<int>( min1.y() );
|
||||
@@ -267,18 +267,18 @@ void RicCellRangeUi::updateLegendText()
|
||||
|
||||
if ( grid == mainGrid && actCellInfo )
|
||||
{
|
||||
auto [min0, max0] = actCellInfo->ijkBoundingBox();
|
||||
const auto& bbox = actCellInfo->ijkBoundingBox();
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
caf::VecIjk1 min1 = min0.toOneBased();
|
||||
caf::VecIjk1 max1 = max0.toOneBased();
|
||||
auto min = bbox.min().toOneBased();
|
||||
auto max = bbox.max().toOneBased();
|
||||
|
||||
m_startIndexI.uiCapability()->setUiName( QString( "I Start (%1)" ).arg( min1.x() ) );
|
||||
m_startIndexJ.uiCapability()->setUiName( QString( "J Start (%1)" ).arg( min1.y() ) );
|
||||
m_startIndexK.uiCapability()->setUiName( QString( "K Start (%1)" ).arg( min1.z() ) );
|
||||
m_cellCountI.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max1.x() - min1.x() + 1 ) );
|
||||
m_cellCountJ.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max1.y() - min1.y() + 1 ) );
|
||||
m_cellCountK.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max1.z() - min1.z() + 1 ) );
|
||||
m_startIndexI.uiCapability()->setUiName( QString( "I Start (%1)" ).arg( min.x() ) );
|
||||
m_startIndexJ.uiCapability()->setUiName( QString( "J Start (%1)" ).arg( min.y() ) );
|
||||
m_startIndexK.uiCapability()->setUiName( QString( "K Start (%1)" ).arg( min.z() ) );
|
||||
m_cellCountI.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.x() - min.x() + 1 ) );
|
||||
m_cellCountJ.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.y() - min.y() + 1 ) );
|
||||
m_cellCountK.uiCapability()->setUiName( QString( " Width (%1)" ).arg( max.z() - min.z() + 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -515,9 +515,9 @@ void RicExportEclipseSectorModelUi::applyBoundaryDefaults()
|
||||
{
|
||||
if ( exportGridBox == RiaModelExportDefines::ACTIVE_CELLS_BOX )
|
||||
{
|
||||
auto [minActive, maxActive] = m_caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->ijkBoundingBox();
|
||||
setMin( minActive );
|
||||
setMax( maxActive );
|
||||
const auto& bbox = m_caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->ijkBoundingBox();
|
||||
setMin( bbox.min() );
|
||||
setMax( bbox.max() );
|
||||
}
|
||||
else if ( exportGridBox == RiaModelExportDefines::VISIBLE_CELLS_BOX )
|
||||
{
|
||||
|
||||
@@ -504,9 +504,9 @@ void RicExportSectorModelUi::applyBoundaryDefaults()
|
||||
|
||||
if ( m_gridBoxSelection == RiaModelExportDefines::ACTIVE_CELLS_BOX )
|
||||
{
|
||||
auto [minActive, maxActive] = caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->ijkBoundingBox();
|
||||
setMin( minActive );
|
||||
setMax( maxActive );
|
||||
const auto& bbox = caseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->ijkBoundingBox();
|
||||
setMin( bbox.min() );
|
||||
setMax( bbox.max() );
|
||||
}
|
||||
else if ( m_gridBoxSelection == RiaModelExportDefines::VISIBLE_CELLS_BOX )
|
||||
{
|
||||
|
||||
@@ -66,14 +66,14 @@ void RicCreateMultipleFracturesFeature::replaceFractures()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> RicCreateMultipleFracturesFeature::ijkRangeForGrid( RimEclipseCase* gridCase ) const
|
||||
RigBoundingBoxIjk<caf::VecIjk0> RicCreateMultipleFracturesFeature::ijkRangeForGrid( RimEclipseCase* gridCase ) const
|
||||
{
|
||||
if ( gridCase && gridCase->eclipseCaseData() )
|
||||
{
|
||||
return gridCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->ijkBoundingBox();
|
||||
}
|
||||
|
||||
return {};
|
||||
return RigBoundingBoxIjk<caf::VecIjk0>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -182,9 +182,9 @@ void RicCreateMultipleFracturesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
firstSourceCase = proj->eclipseCases().front();
|
||||
|
||||
auto [top, base] = ijkRangeForGrid( firstSourceCase );
|
||||
int topK = static_cast<int>( top.z() );
|
||||
int baseK = static_cast<int>( base.z() );
|
||||
auto ijkRange = ijkRangeForGrid( firstSourceCase );
|
||||
int topK = static_cast<int>( ijkRange.min().z() );
|
||||
int baseK = static_cast<int>( ijkRange.max().z() );
|
||||
|
||||
double minimumDistanceFromTip = 100.0;
|
||||
int maxFractureCount = 100;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include "RigBoundingBoxIjk.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
@@ -44,9 +47,9 @@ class RicCreateMultipleFracturesFeature : public caf::CmdFeature
|
||||
public:
|
||||
RicCreateMultipleFracturesFeature() {}
|
||||
|
||||
void appendFractures();
|
||||
void replaceFractures();
|
||||
std::pair<cvf::Vec3st, cvf::Vec3st> ijkRangeForGrid( RimEclipseCase* gridCase ) const;
|
||||
void appendFractures();
|
||||
void replaceFractures();
|
||||
RigBoundingBoxIjk<caf::VecIjk0> ijkRangeForGrid( RimEclipseCase* gridCase ) const;
|
||||
|
||||
private slots:
|
||||
void slotDeleteAndAppendFractures();
|
||||
|
||||
@@ -231,16 +231,11 @@ void RimCellRangeFilter::setDefaultValues( int sliceDirection, int defaultSlice
|
||||
|
||||
if ( grid == mainGrid && actCellInfo )
|
||||
{
|
||||
auto [min, max] = actCellInfo->ijkBoundingBox();
|
||||
const auto& bbox = actCellInfo->ijkBoundingBox();
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
auto min = bbox.min().toOneBased();
|
||||
auto max = bbox.max().toOneBased();
|
||||
|
||||
startIndexI = static_cast<int>( min.x() );
|
||||
startIndexJ = static_cast<int>( min.y() );
|
||||
@@ -328,16 +323,11 @@ void RimCellRangeFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
|
||||
if ( grid == mainGrid && actCellInfo )
|
||||
{
|
||||
auto [min, max] = actCellInfo->ijkBoundingBox();
|
||||
const auto& bbox = actCellInfo->ijkBoundingBox();
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
auto min = bbox.min().toOneBased();
|
||||
auto max = bbox.max().toOneBased();
|
||||
|
||||
QString label;
|
||||
|
||||
|
||||
@@ -196,16 +196,11 @@ void RimAdvancedSnapshotExportDefinition::fieldChangedByUi( const caf::PdmFieldH
|
||||
|
||||
if ( mainGrid && actCellInfo )
|
||||
{
|
||||
auto [min, max] = actCellInfo->ijkBoundingBox();
|
||||
const auto& bbox = actCellInfo->ijkBoundingBox();
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
auto min = bbox.min().toOneBased();
|
||||
auto max = bbox.max().toOneBased();
|
||||
|
||||
int maxInt = 0;
|
||||
int minInt = 0;
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigActiveCellInfo::RigActiveCellInfo()
|
||||
: m_reservoirActiveCellCount( 0 )
|
||||
, m_activeCellPositionMin( 0, 0, 0 )
|
||||
, m_activeCellPositionMax( 0, 0, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -139,18 +137,17 @@ size_t RigActiveCellInfo::reservoirActiveCellCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigActiveCellInfo::setIjkBoundingBox( const caf::VecIjk0& min, const caf::VecIjk0& max )
|
||||
void RigActiveCellInfo::setIjkBoundingBox( const RigBoundingBoxIjk<caf::VecIjk0>& boundingBox )
|
||||
{
|
||||
m_activeCellPositionMin = min;
|
||||
m_activeCellPositionMax = max;
|
||||
m_ijkBoundingBox = boundingBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> RigActiveCellInfo::ijkBoundingBox() const
|
||||
const RigBoundingBoxIjk<caf::VecIjk0>& RigActiveCellInfo::ijkBoundingBox() const
|
||||
{
|
||||
return std::make_pair( m_activeCellPositionMin, m_activeCellPositionMax );
|
||||
return m_ijkBoundingBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -185,8 +182,7 @@ void RigActiveCellInfo::clear()
|
||||
m_perGridActiveCellInfo.clear();
|
||||
m_cellIndexToResultIndex.clear();
|
||||
m_reservoirActiveCellCount = 0;
|
||||
m_activeCellPositionMin = caf::VecIjk0( 0, 0, 0 );
|
||||
m_activeCellPositionMax = caf::VecIjk0( 0, 0, 0 );
|
||||
m_ijkBoundingBox = RigBoundingBoxIjk<caf::VecIjk0>();
|
||||
m_activeCellsBoundingBox.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigBoundingBoxIjk.h"
|
||||
#include "RigTypeSafeIndex.h"
|
||||
|
||||
#include "cafVecIjk.h"
|
||||
@@ -47,8 +48,8 @@ public:
|
||||
size_t gridActiveCellCounts( size_t gridIndex ) const;
|
||||
void computeDerivedData();
|
||||
|
||||
void setIjkBoundingBox( const caf::VecIjk0& min, const caf::VecIjk0& max );
|
||||
std::pair<caf::VecIjk0, caf::VecIjk0> ijkBoundingBox() const;
|
||||
void setIjkBoundingBox( const RigBoundingBoxIjk<caf::VecIjk0>& boundingBox );
|
||||
const RigBoundingBoxIjk<caf::VecIjk0>& ijkBoundingBox() const;
|
||||
|
||||
cvf::BoundingBox geometryBoundingBox() const;
|
||||
void setGeometryBoundingBox( cvf::BoundingBox bb );
|
||||
@@ -78,8 +79,7 @@ private:
|
||||
|
||||
size_t m_reservoirActiveCellCount;
|
||||
|
||||
caf::VecIjk0 m_activeCellPositionMin;
|
||||
caf::VecIjk0 m_activeCellPositionMax;
|
||||
RigBoundingBoxIjk<caf::VecIjk0> m_ijkBoundingBox;
|
||||
|
||||
cvf::BoundingBox m_activeCellsBoundingBox;
|
||||
};
|
||||
|
||||
@@ -448,8 +448,9 @@ void RigEclipseCaseData::computeActiveCellIJKBBox()
|
||||
fractureModelActiveBB.add( i, j, k );
|
||||
}
|
||||
}
|
||||
m_activeCellInfo->setIjkBoundingBox( matrixModelActiveBB.m_min, matrixModelActiveBB.m_max );
|
||||
m_fractureActiveCellInfo->setIjkBoundingBox( fractureModelActiveBB.m_min, fractureModelActiveBB.m_max );
|
||||
m_activeCellInfo->setIjkBoundingBox( RigBoundingBoxIjk<caf::VecIjk0>( matrixModelActiveBB.m_min, matrixModelActiveBB.m_max ) );
|
||||
m_fractureActiveCellInfo->setIjkBoundingBox(
|
||||
RigBoundingBoxIjk<caf::VecIjk0>( fractureModelActiveBB.m_min, fractureModelActiveBB.m_max ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,7 +719,9 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxOptimized()
|
||||
{
|
||||
// Use the top and bottom layer of active cells to compute the bounding box
|
||||
|
||||
auto [minBB, maxBB] = activeInfos[acIdx]->ijkBoundingBox();
|
||||
const auto& bbox = activeInfos[acIdx]->ijkBoundingBox();
|
||||
const auto& minBB = bbox.min();
|
||||
const auto& maxBB = bbox.max();
|
||||
|
||||
for ( auto k : { minBB.z(), maxBB.z() } )
|
||||
{
|
||||
|
||||
@@ -72,3 +72,29 @@ TEST( RigActiveCellInfo, GridCellCounts )
|
||||
EXPECT_TRUE( rigActiveCellInfo.reservoirActiveCellCount() == 12 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigActiveCellInfo, IJKBoundingBox )
|
||||
{
|
||||
RigActiveCellInfo rigActiveCellInfo;
|
||||
|
||||
// Test initial state
|
||||
const auto& bbox = rigActiveCellInfo.ijkBoundingBox();
|
||||
EXPECT_EQ( caf::VecIjk0( 0, 0, 0 ), bbox.min() );
|
||||
EXPECT_EQ( caf::VecIjk0( 0, 0, 0 ), bbox.max() );
|
||||
EXPECT_TRUE( bbox.isValid() );
|
||||
|
||||
// Test setting bounding box
|
||||
rigActiveCellInfo.setIjkBoundingBox( RigBoundingBoxIjk<caf::VecIjk0>( caf::VecIjk0( 5, 10, 15 ), caf::VecIjk0( 20, 30, 40 ) ) );
|
||||
const auto& bbox2 = rigActiveCellInfo.ijkBoundingBox();
|
||||
EXPECT_EQ( caf::VecIjk0( 5, 10, 15 ), bbox2.min() );
|
||||
EXPECT_EQ( caf::VecIjk0( 20, 30, 40 ), bbox2.max() );
|
||||
|
||||
// Test clear resets bounding box
|
||||
rigActiveCellInfo.clear();
|
||||
const auto& bbox3 = rigActiveCellInfo.ijkBoundingBox();
|
||||
EXPECT_EQ( caf::VecIjk0( 0, 0, 0 ), bbox3.min() );
|
||||
EXPECT_EQ( caf::VecIjk0( 0, 0, 0 ), bbox3.max() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user