Produce valid K when invalid K for wells is detected

When an invalid K index is detected, use K-index of the lowest active cell for given IJ location. Invalid K are seen for both well heads and well cells.
p4#: 20254
This commit is contained in:
Magne Sjaastad 2013-01-25 15:20:41 +01:00
parent 571da22931
commit 715e42b10b
2 changed files with 64 additions and 8 deletions

View File

@ -562,11 +562,28 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, static_cast<int>(gridNr));
if (ert_wellhead)
{
int cellI = well_conn_get_i( ert_wellhead );
int cellJ = well_conn_get_j( ert_wellhead );
int cellK = CVF_MAX(0, well_conn_get_k(ert_wellhead)); // Why this ?
if (!grids[gridNr]->isCellValid(cellI, cellJ, cellK))
{
int candidateCellK = findSmallestActiveCellIndexK(grids[gridNr], cellI, cellJ);
if (candidateCellK >= 0)
{
cellK = candidateCellK;
}
else
{
CVF_ASSERT(false);
cellK = 0;
}
}
CVF_ASSERT(grids[gridNr]->isCellValid(cellI, cellJ, cellK));
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
wellResFrame.m_wellHead.m_gridIndex = gridNr;
int gridK = CVF_MAX(0, well_conn_get_k(ert_wellhead)); // Why this ?
int gridI = well_conn_get_i( ert_wellhead );
int gridJ = well_conn_get_j( ert_wellhead );
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(gridI, gridJ, gridK);
}
@ -596,14 +613,31 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
RigWellResultCell& data = wellSegment.m_wellCells[existingConnCount + connIdx];
data.m_gridIndex = gridNr;
{
int connI = well_conn_get_i( ert_connection );
int connJ = well_conn_get_j( ert_connection );
int connK = well_conn_get_k( ert_connection );
int cellI = well_conn_get_i( ert_connection );
int cellJ = well_conn_get_j( ert_connection );
int cellK = well_conn_get_k( ert_connection );
bool open = well_conn_open( ert_connection );
int branch = well_conn_get_branch( ert_connection );
int segment = well_conn_get_segment( ert_connection );
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(connI , connJ , connK);
if (!grids[gridNr]->isCellValid(cellI, cellJ, cellK))
{
int candidateCellK = findSmallestActiveCellIndexK(grids[gridNr], cellI, cellJ);
if (candidateCellK >= 0)
{
cellK = candidateCellK;
}
else
{
CVF_ASSERT(false);
cellK = 0;
}
}
CVF_ASSERT(grids[gridNr]->isCellValid(cellI, cellJ, cellK));
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI , cellJ , cellK);
data.m_isOpen = open;
data.m_branchId = branch;
@ -626,3 +660,22 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
reservoir->setWellResults(wells);
}
//--------------------------------------------------------------------------------------------------
// For case DUALPORO, the well K index is reported outside the grid. If this happens,
// for the given IJ position, search from K=0 and upwards for first active cell.
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseOutput::findSmallestActiveCellIndexK(const RigGridBase* grid, int cellI, int cellJ)
{
if (!grid) return -1;
for (int candidateCellK = 0; candidateCellK < grid->cellCountK(); candidateCellK++ )
{
if (grid->isCellActive(cellI, cellJ, candidateCellK))
{
return candidateCellK;
}
}
return -1;
}

View File

@ -24,6 +24,7 @@
class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
class RigGridBase;
typedef struct ecl_grid_struct ecl_grid_type;
@ -53,6 +54,8 @@ private:
bool buildMetaData(RigReservoir* reservoir);
void readWellCells(RigReservoir* reservoir);
int findSmallestActiveCellIndexK( const RigGridBase* grid, int cellI, int cellJ);
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);