Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Oct 25, 2024
1 parent be61328 commit 19bf09d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 247 deletions.
92 changes: 0 additions & 92 deletions ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,98 +227,6 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips

return true;
}
//
////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// void RifReaderOpmCommonActive::transferActiveGeometry( Opm::EclIO::EGrid& opmMainGrid,
// RigActiveCellGrid* activeGrid,
// RigEclipseCaseData* eclipseCaseData )
//{
// int cellCount = opmMainGrid.totalActiveCells();
//
// RigCell defaultCell;
// defaultCell.setHostGrid( activeGrid );
// for ( size_t i = 0; i < 8; i++ )
// defaultCell.cornerIndices()[i] = 0;
//
// activeGrid->reservoirCells().resize( cellCount + 1, defaultCell );
// activeGrid->reservoirCells()[cellCount].setInvalid( true );
//
// activeGrid->nodes().resize( ( cellCount + 1 ) * 8, cvf::Vec3d( 0, 0, 0 ) );
//
// auto& riNodes = activeGrid->nodes();
//
// opmMainGrid.loadData();
// opmMainGrid.load_grid_data();
//
// const bool isRadialGrid = opmMainGrid.is_radial();
// const auto& activeMatIndexes = opmMainGrid.active_indexes();
// const auto& activeFracIndexes = opmMainGrid.active_frac_indexes();
//
// // Compute the center of the LGR radial grid cells for each K layer
// auto radialGridCenterTopLayerOpm = isRadialGrid
// ? RifOpmRadialGridTools::computeXyCenterForTopOfCells( opmMainGrid, opmMainGrid, activeGrid )
// : std::map<int, std::pair<double, double>>();
//
// const bool invalidateLongPyramidCells = invalidateLongThinCells();
//
// // use same mapping as resdata
// const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
//
// #pragma omp parallel for
// for ( int opmCellIndex = 0; opmCellIndex < static_cast<int>( opmMainGrid.totalNumberOfCells() ); opmCellIndex++ )
// {
// if ( ( activeMatIndexes[opmCellIndex] < 0 ) && ( activeFracIndexes[opmCellIndex] < 0 ) ) continue;
//
// auto opmIJK = opmMainGrid.ijk_from_global_index( opmCellIndex );
//
// double xCenterCoordOpm = 0.0;
// double yCenterCoordOpm = 0.0;
//
// if ( isRadialGrid && radialGridCenterTopLayerOpm.contains( opmIJK[2] ) )
// {
// const auto& [xCenter, yCenter] = radialGridCenterTopLayerOpm[opmIJK[2]];
// xCenterCoordOpm = xCenter;
// yCenterCoordOpm = yCenter;
// }
//
// auto nativeIndex = activeGrid->cellIndexFromIJK( opmIJK[0], opmIJK[1], opmIJK[2] );
// RigCell& cell = activeGrid->nativeCell( nativeIndex );
// // auto globalIndex = activeGrid->nativeCellIndexToGlobal( nativeIndex );
// cell.setGridLocalCellIndex( nativeIndex );
// cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T );
//
// // corner coordinates
// std::array<double, 8> opmX{};
// std::array<double, 8> opmY{};
// std::array<double, 8> opmZ{};
// opmMainGrid.getCellCorners( opmCellIndex, opmX, opmY, opmZ );
//
// // Each cell has 8 nodes, use active cell index and multiply to find first node index for cell
// auto riNodeStartIndex = nativeIndex * 8;
//
// for ( size_t opmNodeIndex = 0; opmNodeIndex < 8; opmNodeIndex++ )
// {
// auto riCornerIndex = cellMappingECLRi[opmNodeIndex];
// size_t riNodeIndex = riNodeStartIndex + riCornerIndex;
//
// auto& riNode = riNodes[riNodeIndex];
// riNode.x() = opmX[opmNodeIndex] + xCenterCoordOpm;
// riNode.y() = opmY[opmNodeIndex] + yCenterCoordOpm;
// riNode.z() = -opmZ[opmNodeIndex];
//
// cell.cornerIndices()[riCornerIndex] = riNodeIndex;
// }
//
// if ( invalidateLongPyramidCells )
// {
// cell.setInvalid( cell.isLongPyramidCell() );
// }
// }
//
// if ( riNodes.size() > 1 ) riNodes[riNodes.size() - 1] = riNodes[0];
// }

//--------------------------------------------------------------------------------------------------
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
{
for ( size_t j = 0; j < grid->cellCountJ(); j++ )
{
size_t cellIdx = grid->cellIndexFromIJK( i, j, K );
size_t cellIdx = grid->cellIndexFromIJKUnguarded( i, j, K );
const RigCell& cell = grid->cell( cellIdx );
// valid cell?
if ( cell.isInvalid() ) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void RigIndexIjkResultCalculator::calculate( const RigEclipseResultAddress& resV
for ( long long cellIdx = 0; cellIdx < numCells; cellIdx++ )
{
const RigCell& cell = mainGrid->cell( cellIdx );
if ( cell.isInvalid() ) continue;

size_t resultIndex = cellIdx;
if ( resultIndex == cvf::UNDEFINED_SIZE_T ) continue;
Expand Down
123 changes: 5 additions & 118 deletions ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ RigActiveCellGrid::RigActiveCellGrid()
, m_totalActiveCellCount( 0 )
{
m_invalidCell.setInvalid( true );
for ( size_t i = 0; i < 8; i++ )
m_invalidCell.cornerIndices()[i] = 0;
m_invalidCell.setHostGrid( this );
m_invalidCell.setSubGrid( nullptr );

for ( size_t i = 0; i < 8; i++ )
{
m_invalidCell.cornerIndices()[i] = 0;
}
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -42,122 +45,6 @@ RigActiveCellGrid::~RigActiveCellGrid()
{
}

////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// size_t RigActiveCellGrid::transferActiveInformation( int gridIndex,
// RigEclipseCaseData* eclipseCaseData,
// size_t totalActiveCells,
// size_t matrixActiveCells,
// size_t fractureActiveCells,
// const std::vector<int>& activeMatrixIndexes,
// const std::vector<int>& activeFracIndexes,
// size_t inactiveCellIndex )
//{
// if ( gridIndex == 0 )
// {
// m_globalToNativeMap.clear();
// inactiveCellIndex = 0;
// }
//
// const auto totalCells = activeMatrixIndexes.size();
//
// const auto cellStartIndex = m_globalToNativeMap.size();
//
// m_globalToNativeMap.resize( cellStartIndex + totalCells );
// size_t activeCells = cellStartIndex;
// size_t anInactiveCellIdx = inactiveCellIndex;
//
// for ( size_t i = 0; i < totalCells; i++ )
// {
// const auto globalCellIndex = cellStartIndex + i;
// if ( ( activeMatrixIndexes[i] < 0 ) && ( activeFracIndexes[i] < 0 ) )
// {
// m_globalToNativeMap[globalCellIndex] = totalActiveCells;
// anInactiveCellIdx = globalCellIndex;
// continue;
// }
// m_nativeToGlobalMap.push_back( globalCellIndex );
// m_globalToNativeMap[i] = activeCells++;
// }
// m_nativeToGlobalMap.push_back( anInactiveCellIdx );
//
// RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
// RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );
//
// activeCellInfo->setReservoirCellCount( activeCellInfo->reservoirCellCount() + totalActiveCells + 1 );
// fractureActiveCellInfo->setReservoirCellCount( fractureActiveCellInfo->reservoirCellCount() + totalActiveCells + 1 );
//
// activeCellInfo->setGridCount( gridIndex + 1 );
// fractureActiveCellInfo->setGridCount( gridIndex + 1 );
//
// activeCellInfo->setGridActiveCellCounts( gridIndex, matrixActiveCells );
// fractureActiveCellInfo->setGridActiveCellCounts( gridIndex, fractureActiveCells );
//
// // TODO - update indexes here
//
// #pragma omp parallel for
// for ( int opmCellIndex = 0; opmCellIndex < (int)totalCells; opmCellIndex++ )
// {
// auto activeCellIndex = m_globalToNativeMap[cellStartIndex + opmCellIndex];
//
// // active cell index
// int matrixActiveIndex = activeMatrixIndexes[opmCellIndex];
// if ( matrixActiveIndex != -1 )
// {
// activeCellInfo->setCellResultIndex( activeCellIndex, matrixActiveIndex );
// }
//
// int fractureActiveIndex = activeFracIndexes[opmCellIndex];
// if ( fractureActiveIndex != -1 )
// {
// fractureActiveCellInfo->setCellResultIndex( activeCellIndex, fractureActiveIndex );
// }
// }
//
// return anInactiveCellIdx;
// }

////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// size_t RigActiveCellGrid::cellIndexFromIJK( size_t i, size_t j, size_t k ) const
//{
// auto index = RigGridBase::cellIndexFromIJK( i, j, k );
// return m_globalToActiveMap[index];
// }
//
////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// size_t RigActiveCellGrid::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const
//{
// auto index = RigGridBase::cellIndexFromIJKUnguarded( i, j, k );
// return m_globalToActiveMap[index];
// }
//
////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// bool RigActiveCellGrid::ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const
//{
// if ( cellIndex >= m_activeToGlobalMap.size() )
// {
// return false;
// }
// auto index = m_activeToGlobalMap[cellIndex];
// return RigGridBase::ijkFromCellIndex( index, i, j, k );
// }
//
////--------------------------------------------------------------------------------------------------
/////
////--------------------------------------------------------------------------------------------------
// void RigActiveCellGrid::ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const
//{
// auto index = m_activeToGlobalMap[cellIndex];
// RigGridBase::ijkFromCellIndexUnguarded( index, i, j, k );
// }

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
17 changes: 0 additions & 17 deletions ApplicationLibCode/ReservoirDataModel/RigActiveCellGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,8 @@ class RigActiveCellGrid : public RigMainGrid
RigActiveCellGrid();
~RigActiveCellGrid() override;

// size_t transferActiveInformation( int gridIndex,
// RigEclipseCaseData* eclipseCaseData,
// size_t totalActiveCells,
// size_t matrixActiveCells,
// size_t fractureActiveCells,
// const std::vector<int>& activeMatrixIndexes,
// const std::vector<int>& activeFracIndexes,
// size_t inactiveCellIndex );

// size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override;
// size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const override;
// bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override;
// void ijkFromCellIndexUnguarded( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override;

RigCell& cell( size_t gridLocalCellIndex ) override;
const RigCell& cell( size_t gridLocalCellIndex ) const override;
// size_t cellCount() const override;

size_t totalCellCount() const override;
size_t totalActiveCellCount() const;
Expand All @@ -56,8 +41,6 @@ class RigActiveCellGrid : public RigMainGrid
void setTotalActiveCellCount( size_t totalActiveCellCount );

private:
// std::vector<size_t> m_globalToNativeMap;
// std::vector<size_t> m_nativeToGlobalMap;
size_t m_totalCellCount;
size_t m_totalActiveCellCount;
RigCell m_invalidCell;
Expand Down
6 changes: 3 additions & 3 deletions ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ std::string RigGridBase::gridName() const
//--------------------------------------------------------------------------------------------------
RigCell& RigGridBase::cell( size_t gridLocalCellIndex )
{
CVF_ASSERT( m_mainGrid );
CVF_TIGHT_ASSERT( m_mainGrid );

CVF_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->reservoirCells().size() );
CVF_TIGHT_ASSERT( m_indexToStartOfCells + gridLocalCellIndex < m_mainGrid->reservoirCells().size() );

return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex];
}
Expand All @@ -94,7 +94,7 @@ RigCell& RigGridBase::cell( size_t gridLocalCellIndex )
//--------------------------------------------------------------------------------------------------
const RigCell& RigGridBase::cell( size_t gridLocalCellIndex ) const
{
CVF_ASSERT( m_mainGrid );
CVF_TIGHT_ASSERT( m_mainGrid );

return m_mainGrid->reservoirCells()[m_indexToStartOfCells + gridLocalCellIndex];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,27 @@ std::vector<size_t> RigWellTargetCandidatesGenerator::findCandidates( const RimE
std::vector<size_t> candidates;
auto resultsData = eclipseCase.results( RiaDefines::PorosityModelType::MATRIX_MODEL );

const std::vector<cvf::StructGridInterface::FaceType> faces = {
cvf::StructGridInterface::FaceType::POS_I,
cvf::StructGridInterface::FaceType::NEG_I,
cvf::StructGridInterface::FaceType::POS_J,
cvf::StructGridInterface::FaceType::NEG_J,
cvf::StructGridInterface::FaceType::POS_K,
cvf::StructGridInterface::FaceType::NEG_K,
};

for ( size_t cellIdx : previousCells )
{
std::vector<cvf::StructGridInterface::FaceType> faces = {
cvf::StructGridInterface::FaceType::POS_I,
cvf::StructGridInterface::FaceType::NEG_I,
cvf::StructGridInterface::FaceType::POS_J,
cvf::StructGridInterface::FaceType::NEG_J,
cvf::StructGridInterface::FaceType::POS_K,
cvf::StructGridInterface::FaceType::NEG_K,
};

size_t resultIndex = resultsData->activeCellInfo()->cellResultIndex( cellIdx );
const RigCell& nativeCell = eclipseCase.mainGrid()->cell( cellIdx );
RigGridBase* grid = nativeCell.hostGrid();
size_t gridLocalNativeCellIndex = nativeCell.gridLocalCellIndex();
const RigCell& cell = eclipseCase.mainGrid()->cell( cellIdx );
if ( cell.isInvalid() ) continue;

RigGridBase* grid = cell.hostGrid();
size_t gridLocalCellIndex = cell.gridLocalCellIndex();
size_t resultIndex = resultsData->activeCellInfo()->cellResultIndex( cellIdx );

size_t i, j, k;

grid->ijkFromCellIndex( gridLocalNativeCellIndex, &i, &j, &k );
grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k );

for ( cvf::StructGridInterface::FaceType face : faces )
{
Expand Down
2 changes: 0 additions & 2 deletions ApplicationLibCode/SocketInterface/RiaCaseInfoCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ class RiaGetActiveCellInfo : public RiaSocketCommand
hostCellK.reserve( numMatrixModelActiveCells );
globalCoarseningBoxIdx.reserve( numMatrixModelActiveCells );

// const std::vector<RigCell>& reservoirCells = reservoirCase->eclipseCaseData()->mainGrid()->globalCellArray();

auto mainGrid = reservoirCase->eclipseCaseData()->mainGrid();

std::vector<size_t> globalCoarseningBoxIndexStart;
Expand Down

0 comments on commit 19bf09d

Please sign in to comment.