Add method RegionCache::wells()

The method RegionCache::wells() will output the wells with the first connection
in region region_id.
This commit is contained in:
Joakim Hove 2020-11-20 09:57:37 +01:00
parent 44d9261258
commit 3bc490b693
4 changed files with 50 additions and 15 deletions

View File

@ -36,9 +36,12 @@ namespace out {
RegionCache(const std::set<std::string>& fip_regions, const FieldPropsManager& fp, const EclipseGrid& grid, const Schedule& schedule);
const std::vector<std::pair<std::string,size_t>>& connections( const std::string& region_name, int region_id ) const;
// A well is assigned to the region_id where the first connection is
std::vector<std::string> wells(const std::string& region_name, int region_id) const;
private:
std::vector<std::pair<std::string,size_t>> connections_empty;
std::map<std::pair<std::string, int> , std::vector<std::pair<std::string,size_t>>> connection_map;
std::map<std::pair<std::string, int>, std::vector<std::string>> well_map;
};
}
}

View File

@ -36,6 +36,9 @@ RegionCache::RegionCache(const std::set<std::string>& fip_regions, const FieldPr
const auto& wells = schedule.getWellsatEnd();
for (const auto& well : wells) {
const auto& connections = well.getConnections( );
if (connections.empty())
continue;
for (const auto& c : connections) {
if (grid.cellActive(c.getI(), c.getJ(), c.getK())) {
size_t active_index = grid.activeIndex(c.getI(), c.getJ(), c.getK());
@ -45,6 +48,11 @@ RegionCache::RegionCache(const std::set<std::string>& fip_regions, const FieldPr
well_index_list.push_back( { well.name() , active_index } );
}
}
const auto& conn0 = connections[0];
auto region_id = fip_region[grid.activeIndex(conn0.global_index())];
auto key = std::make_pair(fip_name, region_id);
this->well_map[ key ].push_back(well.name());
}
}
}
@ -59,6 +67,16 @@ RegionCache::RegionCache(const std::set<std::string>& fip_regions, const FieldPr
return iter->second;
}
std::vector<std::string> RegionCache::wells(const std::string& region_name, int region_id) const {
auto key = std::make_pair(region_name, region_id);
const auto iter = this->well_map.find( key );
if (iter == this->well_map.end())
return {};
else
return iter->second;
}
}
}

View File

@ -63,17 +63,17 @@ PERMZ
REGIONS
FIPNUM
100*1
100*2
100*3
100*4
100*5
100*6
100*7
100*8
100*9
100*10 /
50*1 50*11
50*2 50*12
50*3 50*13
50*4 50*14
50*5 50*15
50*6 50*16
50*7 50*17
50*8 50*18
50*9 50*19
50*10 50*20
/
SUMMARY
DATE
@ -839,7 +839,7 @@ WELSPECS
'W_2' 'G_1' 2 1 3.33 'OIL' 7* /
'W_3' 'G_2' 3 1 3.92 'WATER' 7* /
'W_6' 'G_2' 8 8 3.92 'GAS' 7* /
'W_5' 'G_3' 4 1 3.92 'OIL' 7* /
'W_5' 'G_3' 6 6 3.92 'OIL' 7* /
/
-- Completion data.
@ -850,7 +850,7 @@ COMPDAT
W_2 0 0 1 1 2* 1* 5 20 0.5 / -- Active index: 1
W_2 0 0 2 2 2* 1* 5 10 0.2 / -- Active index: 101
W_3 0 0 1 1 2* 1* 2* 0.7 / -- Active index: 2
W_6 0 0 2 2 2* 1* 2* 0.7 / -- Active index: 2
W_6 0 0 1 1 2* 1* 2* 0.7 / -- Active index: 2
/
COMPLUMP
@ -905,7 +905,7 @@ WELSPECS
/
COMPDAT
W_4 1 1 3 3 /
W_4 1 1 1 3 /
/
WPIMULT

View File

@ -23,6 +23,7 @@
#include <boost/test/unit_test.hpp>
#include <stdexcept>
#include <unordered_set>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
@ -38,6 +39,13 @@ using namespace Opm;
const char* path = "summary_deck.DATA";
bool cmp_list(const std::vector<std::string>& l1, const std::vector<std::string>& l2) {
std::unordered_set<std::string> s1(l1.begin(), l1.end());
std::unordered_set<std::string> s2(l2.begin(), l2.end());
return s1 == s2;
}
BOOST_AUTO_TEST_CASE(create) {
auto python = std::make_shared<Python>();
@ -54,11 +62,17 @@ BOOST_AUTO_TEST_CASE(create) {
{
const auto& top_layer = rc.connections( "FIPNUM", 1 );
BOOST_CHECK_EQUAL( top_layer.size() , 3U );
BOOST_CHECK_EQUAL( top_layer.size() , 4U );
{
auto pair = top_layer[0];
BOOST_CHECK_EQUAL( pair.first , "W_1");
BOOST_CHECK_EQUAL( pair.second , grid.activeIndex( 0,0,0));
}
}
BOOST_CHECK( rc.wells("FIPXYZ", 100).empty() );
BOOST_CHECK( rc.wells("FIPXYZ", 1).empty() );
BOOST_CHECK( rc.wells("FIPNUM", 100).empty() );
BOOST_CHECK( cmp_list(rc.wells("FIPNUM", 1), {"W_1", "W_2", "W_3", "W_4"}));
BOOST_CHECK( cmp_list(rc.wells("FIPNUM", 11), {"W_6"}));
}