Report a compositional well with no control mode

A well can be open without having been given a control mode, e.g. when
WELOPEN opens one before any WCONPROD or WCONINJE record. The state
update asserted on this, which aborts a debug build and is silently
ignored in a release build. Report it the same way the black-oil model
does in WellAssemble instead, so the two agree on the same deck.
This commit is contained in:
Kai Bao committed 2026-08-11 18:06:35 +02:00
1 parent e03d8433a5
commit 22a88ecb26
2 files changed
+16 -6

No files matched your search

@@ -20,9 +20,12 @@
#ifndef OPM_SINGLE_COMP_WELL_STATE_HPP
#define OPM_SINGLE_COMP_WELL_STATE_HPP
#include <opm/common/ErrorMacros.hpp>
#include <opm/input/eclipse/Schedule/Well/WellEnums.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <stdexcept>
#include <string>
#include <vector>
@@ -74,11 +74,16 @@ update_injector_targets(const Well& well,
{
const auto& inj_controls = well.injectionControls(st);
const auto& injection_properties = well.getInjectionProperties();
// Report this the way the black-oil model does in WellAssemble.
if (inj_controls.cmode == Well::InjectorCMode::CMODE_UNDEFINED) {
OPM_THROW(std::runtime_error,
"Well control must be specified for well " + this->name);
}
const auto& inj_composition = injection_properties.gasInjComposition();
#ifndef NDEBUG
assert(this->total_molar_fractions.size() == inj_composition.size());
const bool cmode_is_undefined = (inj_controls.cmode == Well::InjectorCMode::CMODE_UNDEFINED);
assert(!cmode_is_undefined && "control types should be specified");
const auto injection_type = injection_properties.injectorType;
const bool is_gas_injecting = (injection_type == InjectorType::GAS);
assert(is_gas_injecting && "Only gas injection is supported for now");
@@ -120,10 +125,12 @@ update_producer_targets(const Well& well,
const SummaryState& st)
{
const auto& prod_controls = well.productionControls(st);
#ifndef NDEBUG
const auto cmode_is_undefined = (prod_controls.cmode == Well::ProducerCMode::CMODE_UNDEFINED);
assert(!cmode_is_undefined && "control types should be specified");
#endif
// Report this the way the black-oil model does in WellAssemble.
if (prod_controls.cmode == Well::ProducerCMode::CMODE_UNDEFINED) {
OPM_THROW(std::runtime_error,
"Well control must be specified for well " + this->name);
}
this->total_molar_fractions = cell_mole_fractions[this->connection_data.ecl_index[0]];