@@ -430,12 +430,13 @@ namespace Opm {
430430 const std::unordered_map<std::string, double >* target_wellpi,
431431 std::unordered_map<std::string, double >& wpimult_global_factor,
432432 WelSegsSet* welsegs_wells,
433- std::set<std::string>* compsegs_wells)
433+ std::set<std::string>* compsegs_wells,
434+ std::set<std::string>* comptraj_wells)
434435 {
435436 HandlerContext handlerContext { *this , block, keyword, grid, currentStep,
436437 matches, action_mode,
437438 parseContext, errors, sim_update, target_wellpi,
438- wpimult_global_factor, welsegs_wells, compsegs_wells};
439+ wpimult_global_factor, welsegs_wells, compsegs_wells, comptraj_wells };
439440
440441 if (!KeywordHandlers::getInstance ().handleKeyword (handlerContext)) {
441442 OpmLog::warning (fmt::format (" No handler registered for keyword {} "
@@ -580,30 +581,47 @@ class ScheduleLogger
580581
581582namespace
582583{
583- // / \brief Check whether each MS well has COMPSEGS entry andissue error if not.
584- // / \param welsegs All wells with a WELSEGS entry together with the location.
585- // / \param compsegs All wells with a COMPSEGS entry
586- void check_compsegs_consistency (const Opm::WelSegsSet& welsegs,
587- const std::set<std::string>& compsegs,
588- const std::vector<::Opm::Well>& wells)
589- {
590- const auto difference = welsegs.difference (compsegs, wells);
591584
592- if (!difference.empty ()) {
585+ void report_welsegs_error (const std::vector<Opm::WelSegsSet::Entry>& segments, std::string format_str)
586+ {
587+ if (!segments.empty ()) {
593588 std::string well_str = " well" ;
594- if (difference .size () > 1 ) {
589+ if (segments .size () > 1 ) {
595590 well_str.append (" s" );
596591 }
597592 well_str.append (" :" );
598593
599- for (const auto & [name, location] : difference ) {
594+ for (const auto & [name, location] : segments ) {
600595 well_str.append (fmt::format (" \n {} in {} at line {}" ,
601596 name, location.filename , location.lineno ));
602597 }
603- auto msg = fmt::format (" Missing COMPSEGS keyword for the following multisegment {}. " , well_str);
604- throw Opm::OpmInputError (msg, std::get<1 >(difference [0 ]));
598+ auto msg = fmt::format (format_str , well_str);
599+ throw Opm::OpmInputError (msg, std::get<1 >(segments [0 ]));
605600 }
606601}
602+
603+ // / \brief Check whether each MS well has COMPSEGS entry andissue error if not.
604+ // / \param welsegs All wells with a WELSEGS entry together with the location.
605+ // / \param compsegs All wells with a COMPSEGS entry
606+ // / \param comptraj All wells with a COMPTRAJ entry
607+ void check_compsegs_and_comptraj_consistency (const Opm::WelSegsSet& welsegs,
608+ const std::set<std::string>& compsegs,
609+ const std::set<std::string>& comptraj,
610+ const std::vector<::Opm::Well>& wells)
611+ {
612+ std::set<std::string> comp = compsegs;
613+ comp.insert (comptraj.begin (), comptraj.end ());
614+ const auto difference = welsegs.difference (comp, wells);
615+ report_welsegs_error (
616+ difference," Missing COMPSEGS keyword for the following multisegment {}."
617+ );
618+
619+ const auto intersection = welsegs.intersection (compsegs, comptraj);
620+ report_welsegs_error (
621+ intersection, " Overlapping COMPSEGS and COMPTRAJ keywords for the following multisegment {}."
622+ );
623+ }
624+
607625}// end anonymous namespace
608626
609627namespace Opm
@@ -666,6 +684,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
666684 }
667685
668686 std::set<std::string> compsegs_wells;
687+ std::set<std::string> comptraj_wells;
669688 WelSegsSet welsegs_wells;
670689
671690 const auto matches = Action::Result { false }.matches ();
@@ -759,12 +778,13 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
759778 target_wellpi,
760779 wpimult_global_factor,
761780 &welsegs_wells,
762- &compsegs_wells);
781+ &compsegs_wells,
782+ &comptraj_wells);
763783 keyword_index++;
764784 }
765785
766786 this ->updateICDScalingFactors ();
767- check_compsegs_consistency (welsegs_wells, compsegs_wells, this ->getWells (report_step));
787+ check_compsegs_and_comptraj_consistency (welsegs_wells, compsegs_wells, comptraj_wells , this ->getWells (report_step));
768788 this ->applyGlobalWPIMULT (wpimult_global_factor);
769789 this ->end_report (report_step);
770790
0 commit comments