diff --git a/opm/input/eclipse/Schedule/Well/Well.hpp b/opm/input/eclipse/Schedule/Well/Well.hpp index 260b078336f..9c2d179766b 100644 --- a/opm/input/eclipse/Schedule/Well/Well.hpp +++ b/opm/input/eclipse/Schedule/Well/Well.hpp @@ -230,6 +230,7 @@ class Well { void handleWTMULT(Well::WELTARGCMode cmode, double factor); void setGasInjComposition(const std::vector& composition); + const std::vector& gasInjComposition() const; template void serializeOp(Serializer& serializer) @@ -569,7 +570,6 @@ class Well { double inj_temperature() const; bool hasInjTemperature() const; void setWellInjTemperature(const double temp); - void setGasInjComposition(const std::vector& composition); bool hasInjected( ) const; bool hasProduced( ) const; bool updateHasInjected( ); diff --git a/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp b/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp index 7bd1c0e4a40..efd74f92d90 100644 --- a/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp +++ b/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp @@ -509,5 +509,11 @@ namespace Opm { gas_inj_composition = composition; } + const std::vector& Well::WellInjectionProperties::gasInjComposition() const { + if (!gas_inj_composition.has_value()) { + throw std::invalid_argument("Gas injection composition not set"); + } + return gas_inj_composition.value(); + } } diff --git a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp index 1516631f276..ae30ac34167 100644 --- a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp +++ b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp @@ -525,29 +525,29 @@ void handleWELOPEN(HandlerContext& handlerContext) } } -void handleWINJGAS(HandlerContext& HandlerContext) +void handleWINJGAS(HandlerContext& handlerContext) { - for (const auto& record : HandlerContext.keyword) { + for (const auto& record : handlerContext.keyword) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - const auto well_names = HandlerContext.wellNames(wellNamePattern, false); + const auto well_names = handlerContext.wellNames(wellNamePattern, false); const std::string& fluid_nature = record.getItem("FLUID").getTrimmedString(0); // TODO: technically, only the firt two characters are significant // TODO: we need to test it out whether only the first two characters matter if (fluid_nature != "STREAM") { std::string msg = fmt::format("The fluid nature '{}' is not supported in WINJGAS keyword.", fluid_nature); - throw OpmInputError(msg, HandlerContext.keyword.location()); + throw OpmInputError(msg, handlerContext.keyword.location()); } const std::string& stream_name = record.getItem("STREAM").getTrimmedString(0); // TODO: we do not handle other records for now // we make sure the stream is defined in WELLSTRE keyword - const auto& inj_streams = HandlerContext.state().inj_streams; + const auto& inj_streams = handlerContext.state().inj_streams; if (!inj_streams.has(stream_name)) { std::string msg = fmt::format("The stream '{}' is not defined in WELLSTRE keyword.", stream_name); - throw OpmInputError(msg, HandlerContext.keyword.location()); + throw OpmInputError(msg, handlerContext.keyword.location()); } - auto well2 = HandlerContext.state().wells.get(well_names[0]); + auto well2 = handlerContext.state().wells.get(well_names[0]); // if (well2.isProducer()) { // std::string msg = fmt::format("The well '{}' is a producer, not an injector.", well_names[0]); // throw OpmInputError(msg, HandlerContext.keyword.location()); @@ -557,6 +557,10 @@ void handleWINJGAS(HandlerContext& HandlerContext) // TODO: should we make it a injection event? const auto& inj_stream = inj_streams.get(stream_name); injection->setGasInjComposition(inj_stream); + + if (well2.updateInjection(injection)) { + handlerContext.state().wells.update( std::move(well2) ); + } } }