Merge pull request #2030 from joakim-hove/default-group
Use optional - and default to self - for reinj and voidage groups
This commit is contained in:
commit
85f7380721
@ -84,9 +84,6 @@ struct RstHeader {
|
||||
int nilbrz;
|
||||
int ntfip ;
|
||||
int nmfipr;
|
||||
int nrfreg;
|
||||
int ntfreg;
|
||||
int nplmix;
|
||||
int ngroup;
|
||||
int nwgmax;
|
||||
|
||||
|
@ -79,6 +79,7 @@ enum class InjectionCMode : int {
|
||||
};
|
||||
static const std::string InjectionCMode2String( InjectionCMode enumValue );
|
||||
static InjectionCMode InjectionCModeFromString( const std::string& stringValue );
|
||||
static InjectionCMode InjectionCModeFromInt(int ecl_int);
|
||||
|
||||
|
||||
enum class ProductionCMode : int {
|
||||
@ -94,7 +95,7 @@ enum class ProductionCMode : int {
|
||||
};
|
||||
static const std::string ProductionCMode2String( ProductionCMode enumValue );
|
||||
static ProductionCMode ProductionCModeFromString( const std::string& stringValue );
|
||||
|
||||
static ProductionCMode ProductionCModeFromInt(int ecl_int);
|
||||
|
||||
enum class GuideRateTarget {
|
||||
OIL = 0,
|
||||
@ -121,8 +122,8 @@ struct GroupInjectionProperties {
|
||||
UDAValue resv_max_rate;
|
||||
UDAValue target_reinj_fraction;
|
||||
UDAValue target_void_fraction;
|
||||
std::string reinj_group;
|
||||
std::string voidage_group;
|
||||
std::optional<std::string> reinj_group;
|
||||
std::optional<std::string> voidage_group;
|
||||
bool available_group_control = true;
|
||||
|
||||
static GroupInjectionProperties serializeObject();
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
@ -465,8 +466,8 @@ Group::InjectionControls Group::injectionControls(Phase phase, const SummaryStat
|
||||
ic.resv_max_rate = UDA::eval_group_uda(inj.resv_max_rate, this->m_name, st, this->udq_undefined);
|
||||
ic.target_reinj_fraction = UDA::eval_group_uda(inj.target_reinj_fraction, this->m_name, st, this->udq_undefined);
|
||||
ic.target_void_fraction = UDA::eval_group_uda(inj.target_void_fraction, this->m_name, st, this->udq_undefined);
|
||||
ic.reinj_group = inj.reinj_group;
|
||||
ic.voidage_group = inj.voidage_group;
|
||||
ic.reinj_group = inj.reinj_group.value_or(this->m_name);
|
||||
ic.voidage_group = inj.voidage_group.value_or(this->m_name);
|
||||
|
||||
return ic;
|
||||
}
|
||||
@ -642,6 +643,48 @@ Group::ProductionCMode Group::ProductionCModeFromString( const std::string& stri
|
||||
throw std::invalid_argument("Unknown enum state string: " + stringValue );
|
||||
}
|
||||
|
||||
Group::ProductionCMode Group::ProductionCModeFromInt(int ecl_int) {
|
||||
switch (ecl_int) {
|
||||
case 0:
|
||||
// The inverse function in AggregateGroupData also writes 0
|
||||
// for ProductionCMode::FLD.
|
||||
return ProductionCMode::NONE;
|
||||
case 1:
|
||||
return ProductionCMode::ORAT;
|
||||
case 2:
|
||||
return ProductionCMode::WRAT;
|
||||
case 3:
|
||||
return ProductionCMode::GRAT;
|
||||
case 4:
|
||||
return ProductionCMode::LRAT;
|
||||
case 5:
|
||||
return ProductionCMode::RESV;
|
||||
default:
|
||||
throw std::logic_error(fmt::format("Not recognized value: {} for PRODUCTION CMODE", ecl_int));
|
||||
}
|
||||
}
|
||||
|
||||
Group::InjectionCMode Group::InjectionCModeFromInt(int ecl_int) {
|
||||
switch (ecl_int) {
|
||||
case 0:
|
||||
// The inverse function in AggregateGroupData also writes 0
|
||||
// for InjectionCMode::FLD and InjectionCMode::SALE
|
||||
return InjectionCMode::NONE;
|
||||
case 1:
|
||||
return InjectionCMode::RATE;
|
||||
case 2:
|
||||
return InjectionCMode::RESV;
|
||||
case 3:
|
||||
return InjectionCMode::REIN;
|
||||
case 4:
|
||||
return InjectionCMode::VREP;
|
||||
case 5:
|
||||
return InjectionCMode::RESV;
|
||||
default:
|
||||
throw std::logic_error(fmt::format("Not recognized value: {} for INJECTION CMODE", ecl_int));
|
||||
}
|
||||
}
|
||||
|
||||
Group::GuideRateTarget Group::GuideRateTargetFromString( const std::string& stringValue ) {
|
||||
if (stringValue == "OIL")
|
||||
return GuideRateTarget::OIL;
|
||||
|
@ -270,19 +270,8 @@ namespace {
|
||||
const auto voidage_target = record.getItem("VOIDAGE_TARGET").get<UDAValue>(0);
|
||||
const bool is_free = DeckItem::to_bool(record.getItem("FREE").getTrimmedString(0));
|
||||
|
||||
const std::optional<std::string> reinj_group_name = record.getItem("REINJECT_GROUP").defaultApplied(0)
|
||||
? std::nullopt
|
||||
: std::optional<std::string>(record.getItem("REINJECT_GROUP").getTrimmedString(0));
|
||||
|
||||
const std::optional<std::string> voidage_group_name = record.getItem("VOIDAGE_GROUP").defaultApplied(0)
|
||||
? std::nullopt
|
||||
: std::optional<std::string>(record.getItem("VOIDAGE_GROUP").getTrimmedString(0));
|
||||
|
||||
for (const auto& group_name : group_names) {
|
||||
const bool availableForGroupControl = is_free && (group_name != "FIELD");
|
||||
const std::string reinj_group = reinj_group_name.value_or(group_name);
|
||||
const std::string voidage_group = voidage_group_name.value_or(group_name);
|
||||
|
||||
auto group_ptr = std::make_shared<Group>(this->getGroup(group_name, handlerContext.currentStep));
|
||||
Group::GroupInjectionProperties injection;
|
||||
injection.phase = phase;
|
||||
@ -292,8 +281,6 @@ namespace {
|
||||
injection.target_reinj_fraction = reinj_target;
|
||||
injection.target_void_fraction = voidage_target;
|
||||
injection.injection_controls = 0;
|
||||
injection.reinj_group = reinj_group;
|
||||
injection.voidage_group = voidage_group;
|
||||
injection.available_group_control = availableForGroupControl;
|
||||
|
||||
if (!record.getItem("SURFACE_TARGET").defaultApplied(0))
|
||||
@ -308,6 +295,12 @@ namespace {
|
||||
if (!record.getItem("VOIDAGE_TARGET").defaultApplied(0))
|
||||
injection.injection_controls += static_cast<int>(Group::InjectionCMode::VREP);
|
||||
|
||||
if (record.getItem("REINJECT_GROUP").hasValue(0))
|
||||
injection.reinj_group = record.getItem("REINJECT_GROUP").getTrimmedString(0);
|
||||
|
||||
if (record.getItem("VOIDAGE_GROUP").hasValue(0))
|
||||
injection.voidage_group = record.getItem("VOIDAGE_GROUP").getTrimmedString(0);
|
||||
|
||||
if (group_ptr->updateInjection(injection)) {
|
||||
this->updateGroup(std::move(group_ptr), handlerContext.currentStep);
|
||||
m_events.addEvent( ScheduleEvents::GROUP_INJECTION_UPDATE , handlerContext.currentStep);
|
||||
|
@ -1640,6 +1640,16 @@ namespace {
|
||||
for (const auto& rst_group : rst_state.groups) {
|
||||
auto group = Group{ rst_group, this->groups.size(), static_cast<std::size_t>(report_step), udq_undefined, unit_system };
|
||||
this->addGroup(group, report_step);
|
||||
|
||||
if (group.isProductionGroup()) {
|
||||
this->m_events.addEvent(ScheduleEvents::GROUP_PRODUCTION_UPDATE, report_step + 1);
|
||||
this->addWellGroupEvent(rst_group.name, ScheduleEvents::GROUP_PRODUCTION_UPDATE, report_step + 1);
|
||||
}
|
||||
|
||||
if (group.isInjectionGroup()) {
|
||||
this->m_events.addEvent(ScheduleEvents::GROUP_INJECTION_UPDATE, report_step + 1);
|
||||
this->addWellGroupEvent(rst_group.name, ScheduleEvents::GROUP_INJECTION_UPDATE, report_step + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t group_index = 0; group_index < rst_state.groups.size(); group_index++) {
|
||||
|
@ -190,43 +190,42 @@ Well::Well(const RestartIO::RstWell& rst_well,
|
||||
p->addProductionControl( Well::ProducerCMode::THP );
|
||||
}
|
||||
|
||||
if (this->status == Well::Status::OPEN) {
|
||||
switch (rst_well.active_control) {
|
||||
case CModeVal::Group:
|
||||
p->controlMode = Well::ProducerCMode::GRUP;
|
||||
p->addProductionControl(Well::ProducerCMode::GRUP);
|
||||
break;
|
||||
case CModeVal::OilRate:
|
||||
p->controlMode = Well::ProducerCMode::ORAT;
|
||||
break;
|
||||
case CModeVal::WatRate:
|
||||
p->controlMode = Well::ProducerCMode::WRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::WRAT);
|
||||
break;
|
||||
case CModeVal::GasRate:
|
||||
p->controlMode = Well::ProducerCMode::GRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::GRAT);
|
||||
break;
|
||||
case CModeVal::LiqRate:
|
||||
p->controlMode = Well::ProducerCMode::LRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::LRAT);
|
||||
break;
|
||||
case CModeVal::ResVRate:
|
||||
p->controlMode = Well::ProducerCMode::RESV;
|
||||
p->addProductionControl(Well::ProducerCMode::RESV);
|
||||
break;
|
||||
case CModeVal::THP:
|
||||
p->controlMode = Well::ProducerCMode::THP;
|
||||
p->addProductionControl(Well::ProducerCMode::THP);
|
||||
break;
|
||||
case CModeVal::BHP:
|
||||
p->controlMode = Well::ProducerCMode::BHP;
|
||||
p->addProductionControl(Well::ProducerCMode::BHP);
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument("Can not convert integer value: " + std::to_string(rst_well.active_control)
|
||||
+ " to control type");
|
||||
}
|
||||
switch (rst_well.active_control) {
|
||||
case CModeVal::Group:
|
||||
p->controlMode = Well::ProducerCMode::GRUP;
|
||||
p->addProductionControl(Well::ProducerCMode::GRUP);
|
||||
|
||||
break;
|
||||
case CModeVal::OilRate:
|
||||
p->controlMode = Well::ProducerCMode::ORAT;
|
||||
p->addProductionControl(Well::ProducerCMode::ORAT);
|
||||
break;
|
||||
case CModeVal::WatRate:
|
||||
p->controlMode = Well::ProducerCMode::WRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::WRAT);
|
||||
break;
|
||||
case CModeVal::GasRate:
|
||||
p->controlMode = Well::ProducerCMode::GRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::GRAT);
|
||||
break;
|
||||
case CModeVal::LiqRate:
|
||||
p->controlMode = Well::ProducerCMode::LRAT;
|
||||
p->addProductionControl(Well::ProducerCMode::LRAT);
|
||||
break;
|
||||
case CModeVal::ResVRate:
|
||||
p->controlMode = Well::ProducerCMode::RESV;
|
||||
p->addProductionControl(Well::ProducerCMode::RESV);
|
||||
break;
|
||||
case CModeVal::THP:
|
||||
p->controlMode = Well::ProducerCMode::THP;
|
||||
p->addProductionControl(Well::ProducerCMode::THP);
|
||||
break;
|
||||
case CModeVal::BHP:
|
||||
p->controlMode = Well::ProducerCMode::BHP;
|
||||
p->addProductionControl(Well::ProducerCMode::BHP);
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument(fmt::format("Can not convert integer value:{} to control type", rst_well.active_control));
|
||||
}
|
||||
|
||||
p->addProductionControl(Well::ProducerCMode::BHP);
|
||||
@ -238,33 +237,33 @@ Well::Well(const RestartIO::RstWell& rst_well,
|
||||
i->VFPTableNumber = rst_well.vfp_table;
|
||||
i->predictionMode = this->prediction_mode;
|
||||
|
||||
if (this->status == Well::Status::OPEN) {
|
||||
switch (rst_well.active_control) {
|
||||
case CModeVal::Group:
|
||||
i->controlMode = Well::InjectorCMode::GRUP;
|
||||
break;
|
||||
case CModeVal::OilRate: [[fallthrough]];
|
||||
case CModeVal::WatRate: [[fallthrough]];
|
||||
case CModeVal::GasRate: [[fallthrough]];
|
||||
case CModeVal::LiqRate:
|
||||
i->controlMode = Well::InjectorCMode::RATE;
|
||||
i->addInjectionControl(Well::InjectorCMode::RATE);
|
||||
break;
|
||||
case CModeVal::ResVRate:
|
||||
i->controlMode = Well::InjectorCMode::RESV;
|
||||
i->addInjectionControl(Well::InjectorCMode::RESV);
|
||||
break;
|
||||
case CModeVal::THP:
|
||||
i->controlMode = Well::InjectorCMode::THP;
|
||||
i->addInjectionControl(Well::InjectorCMode::THP);
|
||||
break;
|
||||
case CModeVal::BHP:
|
||||
i->controlMode = Well::InjectorCMode::BHP;
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument(
|
||||
"Could not convert integer value: " + std::to_string(rst_well.active_control) + " to control type");
|
||||
}
|
||||
switch (rst_well.active_control) {
|
||||
case CModeVal::Group:
|
||||
i->controlMode = Well::InjectorCMode::GRUP;
|
||||
break;
|
||||
case CModeVal::OilRate:
|
||||
[[fallthrough]];
|
||||
case CModeVal::WatRate:
|
||||
[[fallthrough]];
|
||||
case CModeVal::GasRate:
|
||||
[[fallthrough]];
|
||||
case CModeVal::LiqRate:
|
||||
i->controlMode = Well::InjectorCMode::RATE;
|
||||
i->addInjectionControl(Well::InjectorCMode::RATE);
|
||||
break;
|
||||
case CModeVal::ResVRate:
|
||||
i->controlMode = Well::InjectorCMode::RESV;
|
||||
i->addInjectionControl(Well::InjectorCMode::RESV);
|
||||
break;
|
||||
case CModeVal::THP:
|
||||
i->controlMode = Well::InjectorCMode::THP;
|
||||
i->addInjectionControl(Well::InjectorCMode::THP);
|
||||
break;
|
||||
case CModeVal::BHP:
|
||||
i->controlMode = Well::InjectorCMode::BHP;
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument(fmt::format("Can not convert integer value:{} to control type", rst_well.active_control));
|
||||
}
|
||||
|
||||
i->injectorType = rst_well.wtype.injector_type();
|
||||
|
Loading…
Reference in New Issue
Block a user