RegionCache object can manage multiple fip regions
This commit is contained in:
parent
d5a21427b4
commit
dad067835c
@ -20,23 +20,25 @@
|
|||||||
#ifndef OPM_REGION_CACHE_HPP
|
#ifndef OPM_REGION_CACHE_HPP
|
||||||
#define OPM_REGION_CACHE_HPP
|
#define OPM_REGION_CACHE_HPP
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
class Schedule;
|
class Schedule;
|
||||||
class EclipseGrid;
|
class EclipseGrid;
|
||||||
|
class FieldPropsManager;
|
||||||
|
|
||||||
namespace out {
|
namespace out {
|
||||||
class RegionCache {
|
class RegionCache {
|
||||||
public:
|
public:
|
||||||
RegionCache() = default;
|
RegionCache() = default;
|
||||||
RegionCache(const std::vector<int>& fipnum, const EclipseGrid& grid, const Schedule& schedule);
|
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( int region_id ) const;
|
const std::vector<std::pair<std::string,size_t>>& connections( const std::string& region_name, int region_id ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<std::string,size_t>> connections_empty;
|
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<int , std::vector<std::pair<std::string,size_t>>> connection_map;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,7 @@ namespace Opm {
|
|||||||
is required to calculate the summary variables.
|
is required to calculate the summary variables.
|
||||||
*/
|
*/
|
||||||
bool require3DField( const std::string& keyword) const;
|
bool require3DField( const std::string& keyword) const;
|
||||||
|
std::set<std::string> fip_regions() const;
|
||||||
|
|
||||||
bool operator==(const SummaryConfig& data) const;
|
bool operator==(const SummaryConfig& data) const;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp>
|
||||||
@ -28,7 +29,9 @@
|
|||||||
namespace Opm {
|
namespace Opm {
|
||||||
namespace out {
|
namespace out {
|
||||||
|
|
||||||
RegionCache::RegionCache(const std::vector<int>& fipnum, const EclipseGrid& grid, const Schedule& schedule) {
|
RegionCache::RegionCache(const std::set<std::string>& fip_regions, const FieldPropsManager& fp, const EclipseGrid& grid, const Schedule& schedule) {
|
||||||
|
for (const auto& fip_name : fip_regions) {
|
||||||
|
const auto& fip_region = fp.get_int(fip_name);
|
||||||
|
|
||||||
const auto& wells = schedule.getWellsatEnd();
|
const auto& wells = schedule.getWellsatEnd();
|
||||||
for (const auto& well : wells) {
|
for (const auto& well : wells) {
|
||||||
@ -36,17 +39,20 @@ RegionCache::RegionCache(const std::vector<int>& fipnum, const EclipseGrid& grid
|
|||||||
for (const auto& c : connections) {
|
for (const auto& c : connections) {
|
||||||
if (grid.cellActive(c.getI(), c.getJ(), c.getK())) {
|
if (grid.cellActive(c.getI(), c.getJ(), c.getK())) {
|
||||||
size_t active_index = grid.activeIndex(c.getI(), c.getJ(), c.getK());
|
size_t active_index = grid.activeIndex(c.getI(), c.getJ(), c.getK());
|
||||||
int region_id = fipnum[active_index];
|
int region_id = fip_region[active_index];
|
||||||
auto& well_index_list = this->connection_map[ region_id ];
|
auto key = std::make_pair(fip_name, region_id);
|
||||||
|
auto& well_index_list = this->connection_map[ key ];
|
||||||
well_index_list.push_back( { well.name() , active_index } );
|
well_index_list.push_back( { well.name() , active_index } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::pair<std::string,size_t>>& RegionCache::connections( int region_id ) const {
|
const std::vector<std::pair<std::string,size_t>>& RegionCache::connections( const std::string& region_name, int region_id ) const {
|
||||||
const auto iter = this->connection_map.find( region_id );
|
auto key = std::make_pair(region_name, region_id);
|
||||||
|
const auto iter = this->connection_map.find( key );
|
||||||
if (iter == this->connection_map.end())
|
if (iter == this->connection_map.end())
|
||||||
return this->connections_empty;
|
return this->connections_empty;
|
||||||
else
|
else
|
||||||
|
@ -717,7 +717,7 @@ inline quantity duration( const fn_args& args ) {
|
|||||||
template<rt phase , bool injection>
|
template<rt phase , bool injection>
|
||||||
quantity region_rate( const fn_args& args ) {
|
quantity region_rate( const fn_args& args ) {
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
const auto& well_connections = args.regionCache.connections( args.num );
|
const auto& well_connections = args.regionCache.connections( args.fip_region, args.num );
|
||||||
|
|
||||||
for (const auto& pair : well_connections) {
|
for (const auto& pair : well_connections) {
|
||||||
|
|
||||||
@ -1438,7 +1438,7 @@ inline std::vector<Opm::Well> find_wells( const Opm::Schedule& schedule,
|
|||||||
|
|
||||||
const auto region = node.number;
|
const auto region = node.number;
|
||||||
|
|
||||||
for ( const auto& connection : regionCache.connections( region ) ){
|
for ( const auto& connection : regionCache.connections( node.fip_region, region ) ){
|
||||||
const auto& w_name = connection.first;
|
const auto& w_name = connection.first;
|
||||||
if (schedule.hasWell(w_name, sim_step)) {
|
if (schedule.hasWell(w_name, sim_step)) {
|
||||||
const auto& well = schedule.getWell( w_name, sim_step );
|
const auto& well = schedule.getWell( w_name, sim_step );
|
||||||
@ -2393,7 +2393,7 @@ SummaryImplementation(const EclipseState& es,
|
|||||||
const Schedule& sched,
|
const Schedule& sched,
|
||||||
const std::string& basename)
|
const std::string& basename)
|
||||||
: grid_ (std::cref(grid))
|
: grid_ (std::cref(grid))
|
||||||
, regCache_ (es.globalFieldProps().get_int("FIPNUM"), grid, sched)
|
, regCache_ (sumcfg.fip_regions(), es.globalFieldProps(), grid, sched)
|
||||||
, deferredSMSpec_(makeDeferredSMSpecCreation(es, grid, sched))
|
, deferredSMSpec_(makeDeferredSMSpecCreation(es, grid, sched))
|
||||||
, rset_ (makeResultSet(es.cfg().io(), basename))
|
, rset_ (makeResultSet(es.cfg().io(), basename))
|
||||||
, fmt_ { es.cfg().io().getFMTOUT() }
|
, fmt_ { es.cfg().io().getFMTOUT() }
|
||||||
|
@ -1161,6 +1161,18 @@ bool SummaryConfig::require3DField( const std::string& keyword ) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::set<std::string> SummaryConfig::fip_regions() const {
|
||||||
|
std::set<std::string> reg_set;
|
||||||
|
for (const auto& node : this->keywords) {
|
||||||
|
const auto& fip_region = node.fip_region();
|
||||||
|
if (fip_region.size() > 0)
|
||||||
|
reg_set.insert( fip_region );
|
||||||
|
}
|
||||||
|
return reg_set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SummaryConfig::operator==(const Opm::SummaryConfig& data) const {
|
bool SummaryConfig::operator==(const Opm::SummaryConfig& data) const {
|
||||||
return this->keywords == data.keywords &&
|
return this->keywords == data.keywords &&
|
||||||
this->short_keywords == data.short_keywords &&
|
this->short_keywords == data.short_keywords &&
|
||||||
|
@ -35,14 +35,14 @@ BOOST_AUTO_TEST_CASE(UniqueKey) {
|
|||||||
using Category = Opm::EclIO::SummaryNode::Category;
|
using Category = Opm::EclIO::SummaryNode::Category;
|
||||||
using Type = Opm::EclIO::SummaryNode::Type;
|
using Type = Opm::EclIO::SummaryNode::Type;
|
||||||
|
|
||||||
expect_key( { "KEYW", Category::Well, Type::Rate, "NORA", 1 }, "KEYW:NORA" );
|
expect_key( { "KEYW", Category::Well, Type::Rate, "NORA", 1 ,""}, "KEYW:NORA" );
|
||||||
expect_key( { "KEYW", Category::Group, Type::Rate, "NORA", 2 }, "KEYW:NORA" );
|
expect_key( { "KEYW", Category::Group, Type::Rate, "NORA", 2 ,""}, "KEYW:NORA" );
|
||||||
expect_key( { "KEYW", Category::Field, Type::Rate, "NORA", 3 }, "KEYW" );
|
expect_key( { "KEYW", Category::Field, Type::Rate, "NORA", 3 ,""}, "KEYW" );
|
||||||
expect_key( { "KEYW", Category::Region, Type::Rate, "NORA", 4 }, "KEYW:4" );
|
expect_key( { "KEYW", Category::Region, Type::Rate, "NORA", 4 ,""}, "KEYW:4" );
|
||||||
expect_key( { "KEYW", Category::Block, Type::Rate, "NORA", 5 }, "KEYW:5" );
|
expect_key( { "KEYW", Category::Block, Type::Rate, "NORA", 5 ,""}, "KEYW:5" );
|
||||||
expect_key( { "KEYW", Category::Connection, Type::Rate, "NORA", 6 }, "KEYW:NORA:6" );
|
expect_key( { "KEYW", Category::Connection, Type::Rate, "NORA", 6 ,""}, "KEYW:NORA:6" );
|
||||||
expect_key( { "KEYW", Category::Segment, Type::Rate, "NORA", 7 }, "KEYW:NORA:7" );
|
expect_key( { "KEYW", Category::Segment, Type::Rate, "NORA", 7 ,""}, "KEYW:NORA:7" );
|
||||||
expect_key( { "KEYW", Category::Miscellaneous, Type::Rate, "NORA", 8 }, "KEYW" );
|
expect_key( { "KEYW", Category::Miscellaneous, Type::Rate, "NORA", 8 ,""}, "KEYW" );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(InjectedNumberRenderer) {
|
BOOST_AUTO_TEST_CASE(InjectedNumberRenderer) {
|
||||||
@ -54,7 +54,8 @@ BOOST_AUTO_TEST_CASE(InjectedNumberRenderer) {
|
|||||||
Category::Region,
|
Category::Region,
|
||||||
Type::Undefined,
|
Type::Undefined,
|
||||||
"-",
|
"-",
|
||||||
2
|
2,
|
||||||
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
Opm::EclIO::SummaryNode negativeNode {
|
Opm::EclIO::SummaryNode negativeNode {
|
||||||
@ -62,7 +63,8 @@ BOOST_AUTO_TEST_CASE(InjectedNumberRenderer) {
|
|||||||
Category::Region,
|
Category::Region,
|
||||||
Type::Undefined,
|
Type::Undefined,
|
||||||
"-",
|
"-",
|
||||||
-2
|
-2,
|
||||||
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
auto chooseSign = [](const Opm::EclIO::SummaryNode& node) -> std::string {
|
auto chooseSign = [](const Opm::EclIO::SummaryNode& node) -> std::string {
|
||||||
@ -74,7 +76,7 @@ BOOST_AUTO_TEST_CASE(InjectedNumberRenderer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_defined) {
|
BOOST_AUTO_TEST_CASE(user_defined) {
|
||||||
auto summary_node = Opm::EclIO::SummaryNode{"FU_VAR1", Opm::EclIO::SummaryNode::Category::Field, Opm::EclIO::SummaryNode::Type::Undefined, "", -1 };
|
auto summary_node = Opm::EclIO::SummaryNode{"FU_VAR1", Opm::EclIO::SummaryNode::Category::Field, Opm::EclIO::SummaryNode::Type::Undefined, "", -1 , ""};
|
||||||
BOOST_CHECK( summary_node.is_user_defined() );
|
BOOST_CHECK( summary_node.is_user_defined() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +46,14 @@ BOOST_AUTO_TEST_CASE(create) {
|
|||||||
EclipseState es(deck);
|
EclipseState es(deck);
|
||||||
const EclipseGrid& grid = es.getInputGrid();
|
const EclipseGrid& grid = es.getInputGrid();
|
||||||
Schedule schedule( deck, es, python);
|
Schedule schedule( deck, es, python);
|
||||||
out::RegionCache rc(es.fieldProps().get_int("FIPNUM"), grid, schedule);
|
out::RegionCache rc({"FIPNUM"}, es.fieldProps(), grid, schedule);
|
||||||
{
|
{
|
||||||
const auto& empty = rc.connections( 4 );
|
const auto& empty = rc.connections( "FIPNUM", 4 );
|
||||||
BOOST_CHECK_EQUAL( empty.size() , 0 );
|
BOOST_CHECK_EQUAL( empty.size() , 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto& top_layer = rc.connections( 1 );
|
const auto& top_layer = rc.connections( "FIPNUM", 1 );
|
||||||
BOOST_CHECK_EQUAL( top_layer.size() , 3 );
|
BOOST_CHECK_EQUAL( top_layer.size() , 3 );
|
||||||
{
|
{
|
||||||
auto pair = top_layer[0];
|
auto pair = top_layer[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user