Skip to content

Commit

Permalink
Some minor fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Aug 28, 2024
1 parent 64298d8 commit a9a29b9
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 15 deletions.
7 changes: 6 additions & 1 deletion ApplicationLibCode/FileInterface/RifReaderEclipseWell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
3 changes: 0 additions & 3 deletions ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const RigGridBase*> grids;
allGrids( &grids );
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/ReservoirDataModel/RigEclipseCaseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t> reservoirCellIndices;
reservoirCellIndices.resize( cellCount() );
std::iota( reservoirCellIndices.begin(), reservoirCellIndices.end(), 0 );

computeCharacteristicCellSize( reservoirCellIndices );
}

*iSize = m_characteristicCellSizeI;
*jSize = m_characteristicCellSizeJ;
*kSize = m_characteristicCellSizeK;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ReservoirDataModel/RigGridBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const
}
}

return m_wellHead; // Nothing else to do
return RigWellResultPoint(); // Nothing else matters
}

//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Fwk/AppFwk/CommonCode/cvfStructGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>& globalCellIndices ) const;
Expand Down Expand Up @@ -123,7 +123,7 @@ class StructGridInterface : public Object
cvf::StructGridInterface::FaceType face2 );
static std::vector<FaceType> validFaceTypes();

private:
protected:
mutable double m_characteristicCellSizeI;
mutable double m_characteristicCellSizeJ;
mutable double m_characteristicCellSizeK;
Expand Down

0 comments on commit a9a29b9

Please sign in to comment.