Add function Schedule::changed_wells() to use in WELSPECS reporting

This commit is contained in:
Joakim Hove
2020-04-21 10:40:34 +02:00
parent ca508663b2
commit d37aa1116d
3 changed files with 72 additions and 7 deletions

View File

@@ -202,6 +202,7 @@ namespace Opm
std::vector<std::string> groupNames() const;
void updateWell(std::shared_ptr<Well> well, size_t reportStep);
std::vector<std::string> changed_wells(size_t reportStep) const;
const Well& getWell(const std::string& wellName, size_t timeStep) const;
const Well& getWellatEnd(const std::string& well_name) const;
std::vector<Well> getWells(size_t timeStep) const;

View File

@@ -2418,6 +2418,31 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t
}
}
/*
This function will return a list of wells which have changed
*structurally* in the last report_step; wells where only production
settings have changed will not be included.
*/
std::vector<std::string> Schedule::changed_wells(std::size_t report_step) const {
std::vector<std::string> wells;
for (const auto& dynamic_pair : this->wells_static) {
const auto& well_ptr = dynamic_pair.second.get(report_step);
if (well_ptr) {
if (report_step > 0) {
const auto& prev = dynamic_pair.second.get(report_step - 1);
if (prev) {
if (!well_ptr->cmp_structure( *prev ))
wells.push_back( well_ptr->name() );
} else
wells.push_back( well_ptr->name() );
} else
wells.push_back( well_ptr->name() );
}
}
return wells;
}
std::vector<Well> Schedule::getWells(size_t timeStep) const {

View File

@@ -3623,10 +3623,22 @@ DATES -- 4
/
DATES -- 4
DATES -- 5
10 NOV 2007 /
/
WELSPECS
'W4' 'G1' 1 2 3.33 'OIL' 7*/
/
DATES -- 6
10 DEC 2007 /
/
COMPDAT
'W4' 1 1 1 1 'OPEN' 1* 1.168 0.311 107.872 1* 1* 'Z' 21.925 /
/
)";
auto deck = parser.parseString(input);
@@ -3662,13 +3674,40 @@ DATES -- 4
BOOST_CHECK(!grc.has_group("G2"));
}
GuideRate gr(schedule);
{
GuideRate gr(schedule);
double oil_pot = 1;
double gas_pot = 1;
double wat_pot = 1;
double oil_pot = 1;
double gas_pot = 1;
double wat_pot = 1;
gr.compute("XYZ",1, 1.0, oil_pot, gas_pot, wat_pot);
gr.compute("XYZ",1, 1.0, oil_pot, gas_pot, wat_pot);
}
{
const auto& changed_wells = schedule.changed_wells(0);
BOOST_CHECK_EQUAL( changed_wells.size() , 3);
for (const auto& wname : {"W1", "W2", "W2"}) {
auto find_well = std::find(changed_wells.begin(), changed_wells.end(), wname);
BOOST_CHECK(find_well != changed_wells.end());
}
}
{
const auto& changed_wells = schedule.changed_wells(2);
BOOST_CHECK_EQUAL( changed_wells.size(), 0);
}
{
const auto& changed_wells = schedule.changed_wells(4);
BOOST_CHECK_EQUAL( changed_wells.size(), 0);
}
{
const auto& changed_wells = schedule.changed_wells(5);
BOOST_CHECK_EQUAL( changed_wells.size(), 1);
BOOST_CHECK_EQUAL( changed_wells[0], "W4");
}
{
const auto& changed_wells = schedule.changed_wells(6);
BOOST_CHECK_EQUAL( changed_wells.size(), 1);
BOOST_CHECK_EQUAL( changed_wells[0], "W4");
}
}
BOOST_AUTO_TEST_CASE(Injection_Control_Mode_From_Well) {