From a9a29b9e78b707ac97a0efc4e917bdec6d23fa9a Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Wed, 28 Aug 2024 15:35:11 +0200 Subject: [PATCH] Some minor fixes and improvements --- .../FileInterface/RifReaderEclipseWell.cpp | 7 ++++++- .../RifReaderOpmCommonActive.cpp | 5 +++-- .../ReservoirDataModel/RigActiveCellGrid.cpp | 3 --- .../ReservoirDataModel/RigEclipseCaseData.cpp | 8 +++---- .../ReservoirDataModel/RigEclipseCaseData.h | 2 +- .../ReservoirDataModel/RigGridBase.cpp | 21 +++++++++++++++++++ .../ReservoirDataModel/RigGridBase.h | 2 ++ .../RigSimulationWellCenterLineCalculator.cpp | 5 ++++- .../ReservoirDataModel/RigWellResultFrame.cpp | 2 +- Fwk/AppFwk/CommonCode/cvfStructGrid.h | 4 ++-- 10 files changed, 44 insertions(+), 15 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp index 0b34e06504..c6fa2e7212 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp @@ -132,6 +132,11 @@ size_t RifReaderEclipseWell::localGridCellIndexFromErtConnection( const RigGridB return cvf::UNDEFINED_SIZE_T; } + if ( ( cellI < 0 ) || ( cellJ < 0 ) ) + { + return cvf::UNDEFINED_SIZE_T; + } + return grid->cellIndexFromIJK( cellI, cellJ, cellK ); } @@ -158,7 +163,7 @@ RigWellResultPoint RifReaderEclipseWell::createWellResultPoint( const RigEclipse RigWellResultPoint resultPoint; - if ( ( gridCellIndex == cvf::UNDEFINED_SIZE_T ) || ( gridCellIndex > grid->cellCount() - 1 ) ) + if ( ( grid->cellCount() == 0 ) || ( gridCellIndex > grid->cellCount() - 1 ) ) { return resultPoint; } diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index d84f44d8f9..53ea8662ae 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -103,8 +103,9 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips // grid geometry { - RiaLogging::info( - QString( "Loading %0 active of %1 total cells." ).arg( opmGrid.totalActiveCells() ).arg( opmGrid.totalNumberOfCells() ) ); + RiaLogging::info( QString( "Loading %0 active of %1 total cells." ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ) ); auto task = progInfo.task( "Loading Active Cell Main Grid Geometry", 1 ); transferActiveGeometry( opmGrid, activeGrid, eclipseCaseData ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp index 0f2b151a35..f1c7e36617 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp @@ -124,9 +124,6 @@ bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j { if ( cellIndex >= m_activeToGlobalMap.size() ) { - i = 0; - j = 0; - k = 0; return false; } auto index = m_activeToGlobalMap[cellIndex]; diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp index 5918007ac7..839d18da54 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -333,12 +333,12 @@ const cvf::UIntArray* RigEclipseCaseData::gridCellToResultWellIndex( size_t grid //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigCell& RigEclipseCaseData::cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const +const RigCell& RigEclipseCaseData::cellFromWellResultCell( const RigWellResultPoint& wellResultPoint ) const { - CVF_ASSERT( wellResultCell.isCell() ); + CVF_ASSERT( wellResultPoint.isCell() ); - size_t gridIndex = wellResultCell.gridIndex(); - size_t gridCellIndex = wellResultCell.cellIndex(); + size_t gridIndex = wellResultPoint.gridIndex(); + size_t gridCellIndex = wellResultPoint.cellIndex(); std::vector grids; allGrids( &grids ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h index 63416b16cb..b37a9d527b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h @@ -98,7 +98,7 @@ class RigEclipseCaseData : public cvf::Object const cvf::UByteArray* wellCellsInGrid( size_t gridIndex ); const cvf::UIntArray* gridCellToResultWellIndex( size_t gridIndex ); - const RigCell& cellFromWellResultCell( const RigWellResultPoint& wellResultCell ) const; + const RigCell& cellFromWellResultCell( const RigWellResultPoint& wellResultPoint ) const; bool findSharedSourceFace( cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult ) const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index 1933f826a2..19d88793b8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -413,6 +413,27 @@ double RigGridBase::characteristicIJCellSize() const return characteristicCellSize; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridBase::characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const +{ + CVF_ASSERT( iSize && jSize && kSize ); + + if ( !hasValidCharacteristicCellSizes() ) + { + std::vector reservoirCellIndices; + reservoirCellIndices.resize( cellCount() ); + std::iota( reservoirCellIndices.begin(), reservoirCellIndices.end(), 0 ); + + computeCharacteristicCellSize( reservoirCellIndices ); + } + + *iSize = m_characteristicCellSizeI; + *jSize = m_characteristicCellSizeJ; + *kSize = m_characteristicCellSizeK; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index 2bf9da424d..3502e2b72a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -53,6 +53,8 @@ class RigGridBase : public cvf::StructGridInterface virtual RigCell& cell( size_t gridLocalCellIndex ); virtual const RigCell& cell( size_t gridLocalCellIndex ) const; + void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const override; + size_t reservoirCellIndex( size_t gridLocalCellIndex ) const; void setIndexToStartOfCells( size_t indexToStartOfCells ) { m_indexToStartOfCells = indexToStartOfCells; } diff --git a/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 014a96d9ef..7d1e39aeb4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -243,7 +243,10 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineForTimeSt // Well head // Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts() - const RigCell& whCell = eclipseCaseData->cellFromWellResultCell( wellFrame.wellHeadOrStartCell() ); + auto wellPoint = wellFrame.wellHeadOrStartCell(); + if ( !wellPoint.isCell() ) return; + + const RigCell& whCell = eclipseCaseData->cellFromWellResultCell( wellPoint ); cvf::Vec3d whStartPos = whCell.faceCenter( cvf::StructGridInterface::NEG_K ); RigWellResultPoint wellHead = wellFrame.wellHeadOrStartCell(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp index 417b1dc07d..1d5584ac22 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellResultFrame.cpp @@ -101,7 +101,7 @@ RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const } } - return m_wellHead; // Nothing else to do + return RigWellResultPoint(); // Nothing else matters } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.h b/Fwk/AppFwk/CommonCode/cvfStructGrid.h index 7275be352a..94adf0d436 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.h +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.h @@ -85,7 +85,7 @@ class StructGridInterface : public Object virtual cvf::Vec3d minCoordinate() const = 0; virtual cvf::Vec3d maxCoordinate() const = 0; - void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const; + virtual void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const; bool hasValidCharacteristicCellSizes() const; void computeCharacteristicCellSize( const std::vector& globalCellIndices ) const; @@ -123,7 +123,7 @@ class StructGridInterface : public Object cvf::StructGridInterface::FaceType face2 ); static std::vector validFaceTypes(); -private: +protected: mutable double m_characteristicCellSizeI; mutable double m_characteristicCellSizeJ; mutable double m_characteristicCellSizeK;