diff --git a/opm/output/eclipse/RegionCache.hpp b/opm/output/eclipse/RegionCache.hpp index ec0198cd2..58be3a6c0 100644 --- a/opm/output/eclipse/RegionCache.hpp +++ b/opm/output/eclipse/RegionCache.hpp @@ -32,10 +32,14 @@ namespace out { RegionCache() = default; RegionCache(const EclipseState& state, const EclipseGrid& grid); const std::vector& cells( int region_id ) const; + const std::vector>& completions( int region_id ) const; private: - std::vector empty; + std::vector cells_empty; + std::vector> completions_empty; + std::map > cell_map; + std::map>> completion_map; }; } } diff --git a/src/opm/output/eclipse/EclipseWriter.cpp b/src/opm/output/eclipse/EclipseWriter.cpp index 400508669..15718d2b5 100644 --- a/src/opm/output/eclipse/EclipseWriter.cpp +++ b/src/opm/output/eclipse/EclipseWriter.cpp @@ -417,7 +417,7 @@ EclipseWriter::Impl::Impl( const EclipseState& eclipseState, EclipseGrid grid_) : es( eclipseState ) , grid( std::move( grid_ ) ) - , regionCache( *es , grid ) + , regionCache( es , grid ) , outputDir( eclipseState.getIOConfig().getOutputDir() ) , baseName( uppercase( eclipseState.getIOConfig().getBaseName() ) ) , summary( eclipseState, eclipseState.getSummaryConfig() ) diff --git a/src/opm/output/eclipse/RegionCache.cpp b/src/opm/output/eclipse/RegionCache.cpp index 43b0e92ca..e6c01def5 100644 --- a/src/opm/output/eclipse/RegionCache.cpp +++ b/src/opm/output/eclipse/RegionCache.cpp @@ -18,6 +18,10 @@ */ #include +#include +#include +#include +#include #include #include #include @@ -34,13 +38,39 @@ namespace out { for (auto region_id : region_values) this->cell_map.emplace( region_id , fipnum.cellsEqual( region_id , grid )); + + + { + const auto& schedule = state.getSchedule(); + const auto& wells = schedule.getWells(); + for (const auto& well : wells) { + const auto& completions = well->getCompletions( ); + for (const auto& c : completions) { + size_t global_index = grid.getGlobalIndex( c.getI() , c.getJ() , c.getK()); + size_t active_index = grid.activeIndex( global_index ); + int region_id =fipnum.iget( global_index ); + auto& well_index_list = this->completion_map[ region_id ]; + well_index_list.push_back( { well->name() , active_index } ); + } + } + } } const std::vector& RegionCache::cells( int region_id ) const { const auto iter = this->cell_map.find( region_id ); if (iter == this->cell_map.end()) - return this->empty; + return this->cells_empty; + else + return iter->second; + } + + + + const std::vector>& RegionCache::completions( int region_id ) const { + const auto iter = this->completion_map.find( region_id ); + if (iter == this->completion_map.end()) + return this->completions_empty; else return iter->second; } diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index 8f8c44c2d..4f41d8b96 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -182,7 +182,7 @@ struct setup { ta( ERT::TestArea("test_summary") ), solution( make_solution( es.getInputGrid() ) ) { - solution = make_solution( *es.getInputGrid()); + solution = make_solution( es.getInputGrid()); } }; diff --git a/tests/test_regionCache.cpp b/tests/test_regionCache.cpp index 90eb90cd7..36317d69a 100644 --- a/tests/test_regionCache.cpp +++ b/tests/test_regionCache.cpp @@ -44,9 +44,9 @@ const char* path = "summary_deck.DATA"; BOOST_AUTO_TEST_CASE(create) { ParseContext parseContext; Parser parser; - std::shared_ptr deck( parser.parseFile( path, parseContext )); - EclipseState es(*deck , parseContext ); - const EclipseGrid& grid = *es.getInputGrid(); + Deck deck( parser.parseFile( path, parseContext )); + EclipseState es(deck , parseContext ); + const EclipseGrid& grid = es.getInputGrid(); out::RegionCache rc(es , grid);