23#include <opm/input/eclipse/Schedule/UDQ/UDQAssign.hpp>
24#include <opm/input/eclipse/Schedule/UDQ/UDQDefine.hpp>
25#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
26#include <opm/input/eclipse/Schedule/UDQ/UDQFunctionTable.hpp>
27#include <opm/input/eclipse/Schedule/UDQ/UDQInput.hpp>
28#include <opm/input/eclipse/Schedule/UDQ/UDQParams.hpp>
29#include <opm/input/eclipse/Schedule/UDQ/UDT.hpp>
31#include <opm/input/eclipse/EclipseState/Util/OrderedMap.hpp>
32#include <opm/input/eclipse/EclipseState/Util/IOrderSet.hpp>
41#include <unordered_map>
42#include <unordered_set>
51 class RegionSetMatcher;
60namespace Opm::RestartIO {
88 using Iter = std::vector<std::string>::const_iterator;
109 auto begin()
const {
return this->first_; }
112 auto end()
const {
return this->last_; }
119 return { this->
begin(), this->
end() };
144 std::vector<std::string>::const_iterator last)
146 this->wells_.emplace(first, last);
157 this->wells_.emplace(srange);
164 const std::optional<StringRange>
wells()
const
173 std::optional<StringRange> wells_{};
212 const std::string&
unit(
const std::string& key)
const;
222 bool has_unit(
const std::string& keyword)
const;
230 bool has_keyword(
const std::string& keyword)
const;
248 std::optional<std::string>
252 std::size_t report_step,
253 const std::optional<DynamicSelector>& dynamic_selector = std::nullopt);
263 void add_unit(
const std::string& keyword,
264 const std::string&
unit);
281 std::size_t report_step,
283 const std::vector<std::string>& data);
309 const std::vector<std::string>& selector,
311 std::size_t report_step,
312 const std::optional<DynamicSelector>& dynamic_selector = std::nullopt);
332 const std::vector<std::string>& expression,
333 std::size_t report_step);
419 void eval(std::size_t report_step,
420 const WellMatcher& wm,
459 std::vector<UDQDefine>
definitions(UDQVarType var_type)
const;
464 std::vector<UDQInput>
input()
const;
470 void exportTypeCount(std::array<
int,
static_cast<std::size_t
>(UDQVarType::NumTypes)>& count)
const;
475 std::size_t
size()
const;
507 std::vector<UDQAssign>
assignments(UDQVarType var_type)
const;
516 const std::unordered_map<std::string, UDT>&
tables()
const;
540 template<
class Serializer>
543 serializer(udq_params);
544 serializer(m_definitions);
545 serializer(m_assignments);
546 serializer(m_tables);
548 serializer(define_order);
549 serializer(input_index);
550 serializer(type_count);
551 serializer(pending_assignments_);
580 std::unordered_map<std::string, UDQDefine> m_definitions{};
585 std::unordered_map<std::string, UDQAssign> m_assignments{};
590 std::unordered_map<std::string, UDT> m_tables{};
598 std::unordered_map<std::string, std::string> units{};
603 IOrderSet<std::string> define_order;
606 OrderedMap<UDQIndex> input_index;
609 std::map<UDQVarType, std::size_t> type_count{};
616 mutable std::vector<std::string> pending_assignments_{};
626 void add_node(
const std::string& quantity, UDQAction action);
634 void add_assign(
const RestartIO::RstUDQ& udq,
const std::size_t report_step);
643 void add_define(
const RestartIO::RstUDQ& udq,
const std::size_t report_step);
664 void eval_define(std::size_t report_step,
665 const UDQState& udq_state,
666 UDQContext& context)
const;
685 void add_enumerated_assign(
const std::string& quantity,
687 const std::vector<std::string>& selector,
689 std::size_t report_step);
709 void add_assign_wellvar(
const std::string& quantity,
710 const std::vector<std::string>& selector,
712 std::size_t report_step,
713 const std::optional<DynamicSelector>& dynamic_selector);
724 template <
typename... Args>
725 void add_assign_impl(
const std::string& quantity,
731 const auto& [asgnPos, inserted] =
732 this->m_assignments.try_emplace(quantity, quantity, args...);
737 asgnPos->second.add_record(std::forward<Args>(args)...);
Definition DeckRecord.hpp:32
Collection of group names with built-in ordering.
Definition NameOrder.hpp:69
Definition KeywordLocation.hpp:27
Definition Schedule.hpp:101
Class for (de-)serializing.
Definition Serializer.hpp:94
bool isSerializing() const
Returns true if we are currently doing a serialization operation.
Definition Serializer.hpp:207
Definition SummaryState.hpp:73
Representation of a UDQ ASSIGN statement.
Definition UDQAssign.hpp:41
Random access range of string values.
Definition UDQConfig.hpp:82
StringRange(Iter first, Iter last)
Constructor.
Definition UDQConfig.hpp:103
StringRange()=default
Default constructor.
auto end() const
End of range's elements.
Definition UDQConfig.hpp:112
std::vector< std::string > asVector() const
Convert value range to a std::vector.
Definition UDQConfig.hpp:117
std::vector< std::string >::const_iterator Iter
Random access iterator.
Definition UDQConfig.hpp:88
auto begin() const
Beginning of range's elements.
Definition UDQConfig.hpp:109
DynamicSelector & wells(const StringRange &srange)
Include a range of well names into the dynamic selector.
Definition UDQConfig.hpp:155
const std::optional< StringRange > wells() const
Retrieve current dynamic well set.
Definition UDQConfig.hpp:164
DynamicSelector & wells(std::vector< std::string >::const_iterator first, std::vector< std::string >::const_iterator last)
Include a range of well names into the dynamic selector.
Definition UDQConfig.hpp:143
DynamicSelector()=default
Default constructor.
std::size_t size() const
Total number of active DEFINE and ASSIGN statements.
Definition UDQConfig.cpp:552
const UDQDefine & define(const std::string &key) const
Retrieve defining expression and evaluation object for a single UDQ.
Definition UDQConfig.cpp:485
const UDQParams & params() const
Retrieve run's active UDQ parameters.
Definition UDQConfig.cpp:641
void add_assign(const std::string &quantity, SegmentMatcherFactory create_segment_matcher, const std::vector< std::string > &selector, double value, std::size_t report_step, const std::optional< DynamicSelector > &dynamic_selector=std::nullopt)
Incorporate a UDQ assignment.
Definition UDQConfig.cpp:370
void eval_assign(const WellMatcher &wm, const GroupOrder &go, SegmentMatcherFactory create_segment_matcher, SummaryState &st, UDQState &udq_state) const
Apply all pending assignments.
Definition UDQConfig.cpp:447
static UDQConfig serializationTestObject()
Create a serialisation test object.
Definition UDQConfig.cpp:247
void eval(std::size_t report_step, const WellMatcher &wm, const GroupOrder &go, SegmentMatcherFactory create_segment_matcher, RegionSetMatcherFactory create_region_matcher, SummaryState &st, UDQState &udq_state) const
Compute new values for all UDQs.
Definition UDQConfig.cpp:464
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQConfig.hpp:541
const std::unordered_map< std::string, UDT > & tables() const
Retrieve run's active user defined tables.
Definition UDQConfig.cpp:651
void add_define(const std::string &quantity, const KeywordLocation &location, const std::vector< std::string > &expression, std::size_t report_step)
Incorporate a UDQ defining expressions.
Definition UDQConfig.cpp:402
UDQConfig()=default
Default constructor.
void exportTypeCount(std::array< int, static_cast< std::size_t >(UDQVarType::NumTypes)> &count) const
Export count of all known UDQ categories in the current run.
Definition UDQConfig.cpp:543
bool clear_update_next_for_new_report_step()
Clear "UPDATE NEXT" flags for all pertinent UDQ definitions.
Definition UDQConfig.cpp:435
void add_unit(const std::string &keyword, const std::string &unit)
Incorporate a unit string for a UDQ.
Definition UDQConfig.cpp:325
bool has_keyword(const std::string &keyword) const
Query whether or not a particular UDQ exists in the collection.
Definition UDQConfig.cpp:278
std::optional< std::string > add_record(SegmentMatcherFactory create_segment_matcher, const DeckRecord &record, const KeywordLocation &location, std::size_t report_step, const std::optional< DynamicSelector > &dynamic_selector=std::nullopt)
Incorporate a single UDQ record into the known collection.
Definition UDQConfig.cpp:285
std::vector< UDQDefine > definitions() const
Retrieve defining expressions and evaluation objects for all known UDQs.
Definition UDQConfig.cpp:495
std::function< std::unique_ptr< RegionSetMatcher >()> RegionSetMatcherFactory
Factory function for constructing region set matchers.
Definition UDQConfig.hpp:177
std::vector< UDQAssign > assignments() const
Retrieve pending assignment objects for all known UDQs.
Definition UDQConfig.cpp:612
bool clear_pending_assignments()
Clear all pending assignments.
Definition UDQConfig.cpp:426
bool has_unit(const std::string &keyword) const
Query whether or not a particular UDQ has an associated unit string.
Definition UDQConfig.cpp:273
void add_update(const std::string &keyword, std::size_t report_step, const KeywordLocation &location, const std::vector< std::string > &data)
Incorporate update status change for a UDQ.
Definition UDQConfig.cpp:340
void add_table(const std::string &name, UDT udt)
Incorporate a user defined table.
Definition UDQConfig.cpp:421
const UDQAssign & assign(const std::string &key) const
Retrieve any pending assignment object for a single UDQ.
Definition UDQConfig.cpp:490
UDQInput operator[](const std::string &keyword) const
Unprocessed input object for named quantity.
Definition UDQConfig.cpp:564
const std::string & unit(const std::string &key) const
Retrieve unit string for a particular UDQ.
Definition UDQConfig.cpp:263
std::function< std::unique_ptr< SegmentMatcher >()> SegmentMatcherFactory
Factory function for constructing segment set matchers.
Definition UDQConfig.hpp:180
std::vector< UDQInput > input() const
Retrieve unprocessed input objects for all UDQs.
Definition UDQConfig.cpp:524
void required_summary(std::unordered_set< std::string > &summary_keys) const
Export all summary vectors needed to compute values for the current collection of user defined quanti...
Definition UDQConfig.cpp:671
bool operator==(const UDQConfig &config) const
Equality predicate.
Definition UDQConfig.cpp:656
const UDQFunctionTable & function_table() const
Retrieve run's active UDQ function table.
Definition UDQConfig.cpp:646
Definition UDQDefine.hpp:51
Definition UDQFunctionTable.hpp:32
Definition UDQParams.hpp:31
Definition UDQState.hpp:40
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30