Fix of GH#43 Assertion Fail for localGridIndex

The grid number associated with an ert grid was an ID and not an index.
In addition: Fixed unrobustness handling wells with no data.
Now the /Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID file loads( Have tested only two timesteps ).
p4#: 22321
This commit is contained in:
Jacob Støren 2013-09-05 13:03:53 +02:00
parent 3cf18d91fd
commit 97bb848b1d
7 changed files with 49 additions and 10 deletions

View File

@ -154,9 +154,9 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, localCellIdx);
if (subGrid != NULL)
{
int subGridFileIndex = ecl_grid_get_lgr_nr(subGrid);
CVF_ASSERT(subGridFileIndex > 0);
cell.setSubGrid(static_cast<RigLocalGrid*>(mainGrid->gridByIndex(subGridFileIndex)));
int subGridId = ecl_grid_get_lgr_nr(subGrid);
CVF_ASSERT(subGridId > 0);
cell.setSubGrid(static_cast<RigLocalGrid*>(mainGrid->gridById(subGridId)));
}
// Mark inactive long pyramid looking cells as invalid
@ -260,12 +260,15 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
std::string lgrName = ecl_grid_get_name(localEclGrid);
int lgrId = ecl_grid_get_lgr_nr(localEclGrid);
cvf::Vec3st gridPointDim(0,0,0);
gridPointDim.x() = ecl_grid_get_nx(localEclGrid) + 1;
gridPointDim.y() = ecl_grid_get_ny(localEclGrid) + 1;
gridPointDim.z() = ecl_grid_get_nz(localEclGrid) + 1;
RigLocalGrid* localGrid = new RigLocalGrid(mainGrid);
localGrid->setGridId(lgrId);
mainGrid->addLocalGrid(localGrid);
localGrid->setIndexToStartOfCells(totalCellCount);

View File

@ -188,10 +188,13 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex)
size_t gridIndex = wrsf.m_wellHead.m_gridIndex;
size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T)
{
return true;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
{
return true;
}
}
// Then check the rest of the well, with all the branches

View File

@ -164,9 +164,11 @@ void RigCaseData::computeWellCellsPrGrid()
size_t gridIndex = wellCells.m_wellHead.m_gridIndex;
size_t gridCellIndex = wellCells.m_wellHead.m_gridCellIndex;
CVF_ASSERT(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size());
m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true);
m_gridCellToWellIndex[gridIndex]->set(gridCellIndex, static_cast<cvf::uint>(wIdx));
if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T)
{
m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true);
m_gridCellToWellIndex[gridIndex]->set(gridCellIndex, static_cast<cvf::uint>(wIdx));
}
size_t sIdx;
for (sIdx = 0; sIdx < wellCells.m_wellResultBranches.size(); ++sIdx)

View File

@ -33,10 +33,12 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid):
if (mainGrid == NULL)
{
m_gridIndex = 0;
m_gridId = 0;
}
else
{
m_gridIndex = cvf::UNDEFINED_SIZE_T;
m_gridId = cvf::UNDEFINED_INT;
}
}

View File

@ -57,6 +57,9 @@ public:
void setGridIndex(size_t index) { m_gridIndex = index; }
size_t gridIndex() const { return m_gridIndex; }
void setGridId(int id) { m_gridId = id; }
int gridId() const { return m_gridId; }
double characteristicIJCellSize();
std::string gridName() const;
@ -108,6 +111,7 @@ private:
cvf::Vec3st m_gridPointDimensions;
size_t m_indexToStartOfCells; ///< Index into the global cell array stored in main-grid where this grids cells starts.
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
int m_gridId; ///< The LGR id of this grid. Main grid has id 0.
RigMainGrid* m_mainGrid;
cvf::BoundingBox m_boundingBox;

View File

@ -26,6 +26,9 @@ RigMainGrid::RigMainGrid(void)
m_displayModelOffset = cvf::Vec3d::ZERO;
m_gridIndex = 0;
m_gridId = 0;
m_gridIdToIndexMapping.push_back(0);
m_flipXAxis = false;
m_flipYAxis = false;
}
@ -40,8 +43,19 @@ RigMainGrid::~RigMainGrid(void)
//--------------------------------------------------------------------------------------------------
void RigMainGrid::addLocalGrid(RigLocalGrid* localGrid)
{
CVF_ASSERT(localGrid && localGrid->gridId() != cvf::UNDEFINED_INT); // The grid ID must be set.
CVF_ASSERT(localGrid->gridId() >= 0); // We cant handle negative ID's if they exist.
m_localGrids.push_back(localGrid);
localGrid->setGridIndex(m_localGrids.size()); // Maingrid itself has grid index 0
if (m_gridIdToIndexMapping.size() <= localGrid->gridId())
{
m_gridIdToIndexMapping.resize(localGrid->gridId() + 1, cvf::UNDEFINED_SIZE_T);
}
m_gridIdToIndexMapping[localGrid->gridId()] = localGrid->gridIndex();
}
//--------------------------------------------------------------------------------------------------
@ -156,3 +170,12 @@ void RigMainGrid::setFlipAxis(bool flipXAxis, bool flipYAxis)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGridBase* RigMainGrid::gridById(int localGridId)
{
CVF_ASSERT (localGridId >= 0 && localGridId < m_gridIdToIndexMapping.size());
return this->gridByIndex(m_gridIdToIndexMapping[localGridId]);
}

View File

@ -44,7 +44,8 @@ public:
size_t gridCount() const { return m_localGrids.size() + 1; }
RigGridBase* gridByIndex(size_t localGridIndex);
const RigGridBase* gridByIndex(size_t localGridIndex) const;
RigGridBase* gridById(int localGridId);
void computeCachedData();
// Overrides
@ -62,6 +63,7 @@ private:
std::vector<cvf::Vec3d> m_nodes; ///< Global vertex table
std::vector<RigCell> m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's)
cvf::Collection<RigLocalGrid> m_localGrids; ///< List of all the LGR's in this reservoir
std::vector<size_t> m_gridIdToIndexMapping; ///< Mapping from LGR Id to index.
cvf::Vec3d m_displayModelOffset;