Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b698f08

Browse files
GitPaeanwmboon
authored andcommittedMar 17, 2025
addressing reviewing comments for OPM#4334
1 parent f76f7ae commit b698f08

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed
 

‎opm/input/eclipse/Schedule/ScheduleState.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,9 @@ namespace Opm {
203203
}
204204

205205
void update(const K& key, std::shared_ptr<T> value) {
206-
this->m_data[key] = value;
206+
this->m_data.insert_or_assign(key, std::move(value));
207207
}
208208

209-
210209
void update(T object) {
211210
auto key = object.name();
212211
this->m_data[key] = std::make_shared<T>( std::move(object) );

‎opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ void handleWELLSTRE(HandlerContext& handlerContext)
449449
{
450450
auto& inj_streams = handlerContext.state().inj_streams;
451451
for (const auto& record : handlerContext.keyword) {
452-
const std::string& stream_name = record.getItem("STREAM").getTrimmedString(0);
453-
const auto& composition = record.getItem("COMPOSITIONS").getData<double>();
452+
const auto stream_name = record.getItem<ParserKeywords::WELLSTRE::STREAM>().getTrimmedString(0);
453+
const auto& composition = record.getItem<ParserKeywords::WELLSTRE::COMPOSITIONS>().getSIDoubleData();
454454
const std::size_t num_comps = handlerContext.static_schedule().m_runspec.numComps();
455455
if (composition.size() != num_comps) {
456456
const std::string msg = fmt::format("The number of the composition values for stream '{}' is not the same as the number of components.", stream_name);
@@ -462,8 +462,8 @@ void handleWELLSTRE(HandlerContext& handlerContext)
462462
const std::string msg = fmt::format("The sum of the composition values for stream '{}' is not 1.0, but {}.", stream_name, sum);
463463
throw OpmInputError(msg, handlerContext.keyword.location());
464464
}
465-
auto composition_ptr = std::make_shared<std::vector<double>>(std::move(composition));
466-
inj_streams.update(stream_name, composition_ptr);
465+
auto composition_ptr = std::make_shared<std::vector<double>>(composition);
466+
inj_streams.update(stream_name, std::move(composition_ptr));
467467
}
468468

469469
}
@@ -554,9 +554,7 @@ void handleWINJGAS(HandlerContext& handlerContext)
554554
{
555555
// \Note: we do not support the item 4 MAKEUPGAS and item 5 STAGE in WINJGAS keyword yet
556556
for (const auto& record : handlerContext.keyword) {
557-
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
558-
const auto well_names = handlerContext.wellNames(wellNamePattern, false);
559-
const std::string fluid_nature = record.getItem("FLUID").getTrimmedString(0);
557+
const std::string fluid_nature = record.getItem<ParserKeywords::WINJGAS::FLUID>().getTrimmedString(0);
560558

561559
// \Note: technically, only the first two characters are significant
562560
// with some testing, we can determine whether we want to enforce this.
@@ -565,15 +563,17 @@ void handleWINJGAS(HandlerContext& handlerContext)
565563
const std::string msg = fmt::format("The fluid nature '{}' is not supported in WINJGAS keyword.", fluid_nature);
566564
throw OpmInputError(msg, handlerContext.keyword.location());
567565
}
568-
const std::string stream_name = record.getItem("STREAM").getTrimmedString(0);
569566

567+
const std::string stream_name = record.getItem<ParserKeywords::WINJGAS::STREAM>().getTrimmedString(0);
570568
// we make sure the stream is defined in WELLSTRE keyword
571569
const auto& inj_streams = handlerContext.state().inj_streams;
572570
if (!inj_streams.has(stream_name)) {
573571
const std::string msg = fmt::format("The stream '{}' is not defined in WELLSTRE keyword.", stream_name);
574572
throw OpmInputError(msg, handlerContext.keyword.location());
575573
}
576574

575+
const std::string wellNamePattern = record.getItem<ParserKeywords::WINJGAS::WELL>().getTrimmedString(0);
576+
const auto well_names = handlerContext.wellNames(wellNamePattern, false);
577577
for (const auto& well_name : well_names) {
578578
auto well2 = handlerContext.state().wells.get(well_name);
579579
auto injection = std::make_shared<Well::WellInjectionProperties>(well2.getInjectionProperties());

0 commit comments

Comments
 (0)
Please sign in to comment.