diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index dcaa767c58..bee46a5854 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -343,6 +343,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, progInfo.setProgress(3 + lgrIdx); } + mainGrid->initAllSubGridsParentGridPointer(); activeCellInfo->computeDerivedData(); fractureActiveCellInfo->computeDerivedData(); @@ -1291,6 +1292,49 @@ void propagatePosContribDownwards(std::mapreservoirCellIndexByGridAndGridLocalCellIndex(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 (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 m_gridCellsWithSubCellWellConnections; + const RigMainGrid* m_mainGrid; +}; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1742,7 +1786,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo } } // End of the MSW section - else + else if ( false ) { // 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(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(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; + } + } + } + } + } + } } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 7d199ff674..11b2615fe8 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -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() { - initSubGridParentPointer(); - size_t i; - for (i = 0; i < m_localGrids.size(); ++i) + if ( m_localGrids.size() && m_localGrids[0]->parentGrid() == nullptr ) { - m_localGrids[i]->initSubGridParentPointer(); + initSubGridParentPointer(); + size_t i; + for ( i = 0; i < m_localGrids.size(); ++i ) + { + m_localGrids[i]->initSubGridParentPointer(); + } } } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index 3259a8c67e..2b5b1e431f 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -51,6 +51,9 @@ public: std::vector& globalCellArray() {return m_cells;} const std::vector& 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); size_t gridCount() const { return m_localGrids.size() + 1; } RigGridBase* gridByIndex(size_t localGridIndex); @@ -68,6 +71,7 @@ public: bool isFaceNormalsOutwards() const; void computeCachedData(); + void initAllSubGridsParentGridPointer(); // Overrides virtual cvf::Vec3d displayModelOffset() const; @@ -78,7 +82,6 @@ public: cvf::BoundingBox boundingBox() const; private: - void initAllSubGridsParentGridPointer(); void initAllSubCellsMainGridCellIndex(); void buildCellSearchTree(); bool hasFaultWithName(const QString& name) const;