#2195 First step in making higher LGR level connections not beeing hidden

This commit is contained in:
Jacob Støren 2017-12-04 11:42:10 +01:00
parent a460124055
commit fcd9d0f3e6
3 changed files with 120 additions and 6 deletions

View File

@ -343,6 +343,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
progInfo.setProgress(3 + lgrIdx); progInfo.setProgress(3 + lgrIdx);
} }
mainGrid->initAllSubGridsParentGridPointer();
activeCellInfo->computeDerivedData(); activeCellInfo->computeDerivedData();
fractureActiveCellInfo->computeDerivedData(); fractureActiveCellInfo->computeDerivedData();
@ -1291,6 +1292,49 @@ void propagatePosContribDownwards(std::map<int, std::vector<SegmentPositionContr
} }
} }
//--------------------------------------------------------------------------------------------------
/// Helper class to determine whether a well connection is present in a sub cell
// for a specific well. Connections must be tested from innermost lgr to outermost since
// it accumulates the outer cells having subcell connections as it goes.
//--------------------------------------------------------------------------------------------------
class WellResultPointHasSubCellConnectionCalculator
{
public:
explicit WellResultPointHasSubCellConnectionCalculator(const RigMainGrid* mainGrid): m_mainGrid(mainGrid) {}
bool hasSubCellConnection(const RigWellResultPoint& wellResultPoint)
{
if (!wellResultPoint.isCell()) return false;
size_t gridIndex = wellResultPoint.m_gridIndex;
size_t gridCellIndex = wellResultPoint.m_gridCellIndex;
size_t reservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex(gridIndex, gridCellIndex);
if ( m_gridCellsWithSubCellWellConnections.count(reservoirCellIdx) ) return true;
// Traverse parent gridcells, and add them to the map
while ( gridIndex > 0 ) // is lgr
{
const RigCell& connectionCell = m_mainGrid->cellByGridAndGridLocalCellIdx(gridIndex, gridCellIndex);
RigGridBase* hostGrid = connectionCell.hostGrid();
RigLocalGrid* lgrHost = static_cast<RigLocalGrid*> (hostGrid);
gridIndex = lgrHost->parentGrid()->gridIndex();
gridCellIndex = connectionCell.parentCellIndex();
size_t parentReservoirCellIdx = m_mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex(gridIndex, gridCellIndex);
m_gridCellsWithSubCellWellConnections.insert(parentReservoirCellIdx);
}
return false;
}
private:
std::set<size_t> m_gridCellsWithSubCellWellConnections;
const RigMainGrid* m_mainGrid;
};
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1742,7 +1786,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
} }
} // End of the MSW section } // End of the MSW section
else else if ( false )
{ {
// Code handling None-MSW Wells ... Normal wells that is. // Code handling None-MSW Wells ... Normal wells that is.
@ -1810,6 +1854,54 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
} }
} }
} }
else
{
// Code handling None-MSW Wells ... Normal wells that is.
WellResultPointHasSubCellConnectionCalculator subCellConnCalc(m_eclipseCase->mainGrid());
int lastGridNr = static_cast<int>(grids.size()) - 1;
for ( int gridNr = lastGridNr; gridNr >= 0; --gridNr )
{
const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, static_cast<int>(gridNr));
if ( ert_wellhead )
{
RigWellResultPoint wellHeadRp = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1, wellName);
// HACK: Ert returns open as "this is equally wrong as closed for well heads".
// Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016
wellHeadRp.m_isOpen = false;
if (!subCellConnCalc.hasSubCellConnection(wellHeadRp)) wellResFrame.m_wellHead = wellHeadRp;
}
const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, this->ertGridName(gridNr).data());
// Import all well result cells for all connections
if ( connections )
{
int connectionCount = well_conn_collection_get_size(connections);
if ( connectionCount )
{
wellResFrame.m_wellResultBranches.push_back(RigWellResultBranch());
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back();
wellResultBranch.m_ertBranchId = 0; // Normal wells have only one branch
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount);
for ( int connIdx = 0; connIdx < connectionCount; connIdx++ )
{
well_conn_type* ert_connection = well_conn_collection_iget(connections, connIdx);
RigWellResultPoint wellRp = createWellResultPoint(grids[gridNr], ert_connection, -1, -1, wellName);
if (!subCellConnCalc.hasSubCellConnection(wellRp)){
wellResultBranch.m_branchResultPoints[existingCellCount + connIdx] = wellRp;
}
}
}
}
}
}
} }

View File

@ -47,6 +47,22 @@ RigMainGrid::~RigMainGrid(void)
{ {
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCell& RigMainGrid::cellByGridAndGridLocalCellIdx(size_t gridIdx, size_t gridLocalCellIdx) const
{
return gridByIndex(gridIdx)->cell(gridLocalCellIdx);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigMainGrid::reservoirCellIndexByGridAndGridLocalCellIndex(size_t gridIdx, size_t gridLocalCellIdx) const
{
return gridByIndex(gridIdx)->reservoirCellIndex(gridLocalCellIdx);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -72,11 +88,14 @@ void RigMainGrid::addLocalGrid(RigLocalGrid* localGrid)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigMainGrid::initAllSubGridsParentGridPointer() void RigMainGrid::initAllSubGridsParentGridPointer()
{ {
initSubGridParentPointer(); if ( m_localGrids.size() && m_localGrids[0]->parentGrid() == nullptr )
size_t i;
for (i = 0; i < m_localGrids.size(); ++i)
{ {
m_localGrids[i]->initSubGridParentPointer(); initSubGridParentPointer();
size_t i;
for ( i = 0; i < m_localGrids.size(); ++i )
{
m_localGrids[i]->initSubGridParentPointer();
}
} }
} }

View File

@ -51,6 +51,9 @@ public:
std::vector<RigCell>& globalCellArray() {return m_cells;} std::vector<RigCell>& globalCellArray() {return m_cells;}
const std::vector<RigCell>& globalCellArray() const {return m_cells;} const std::vector<RigCell>& globalCellArray() const {return m_cells;}
const RigCell& cellByGridAndGridLocalCellIdx(size_t gridIdx, size_t gridLocalCellIdx) const;
size_t reservoirCellIndexByGridAndGridLocalCellIndex(size_t gridIdx, size_t gridLocalCellIdx) const;
void addLocalGrid(RigLocalGrid* localGrid); void addLocalGrid(RigLocalGrid* localGrid);
size_t gridCount() const { return m_localGrids.size() + 1; } size_t gridCount() const { return m_localGrids.size() + 1; }
RigGridBase* gridByIndex(size_t localGridIndex); RigGridBase* gridByIndex(size_t localGridIndex);
@ -68,6 +71,7 @@ public:
bool isFaceNormalsOutwards() const; bool isFaceNormalsOutwards() const;
void computeCachedData(); void computeCachedData();
void initAllSubGridsParentGridPointer();
// Overrides // Overrides
virtual cvf::Vec3d displayModelOffset() const; virtual cvf::Vec3d displayModelOffset() const;
@ -78,7 +82,6 @@ public:
cvf::BoundingBox boundingBox() const; cvf::BoundingBox boundingBox() const;
private: private:
void initAllSubGridsParentGridPointer();
void initAllSubCellsMainGridCellIndex(); void initAllSubCellsMainGridCellIndex();
void buildCellSearchTree(); void buildCellSearchTree();
bool hasFaultWithName(const QString& name) const; bool hasFaultWithName(const QString& name) const;