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>
49 class KeywordLocation;
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;
251 std::size_t report_step,
252 const std::optional<DynamicSelector>& dynamic_selector = std::nullopt);
262 void add_unit(
const std::string& keyword,
263 const std::string& unit);
280 std::size_t report_step,
282 const std::vector<std::string>& data);
308 const std::vector<std::string>& selector,
310 std::size_t report_step,
311 const std::optional<DynamicSelector>& dynamic_selector = std::nullopt);
331 const std::vector<std::string>& expression,
332 std::size_t report_step);
402 void eval(std::size_t report_step,
403 const WellMatcher& wm,
442 std::vector<UDQDefine>
definitions(UDQVarType var_type)
const;
447 std::vector<UDQInput>
input()
const;
453 void exportTypeCount(std::array<
int,
static_cast<std::size_t
>(UDQVarType::NumTypes)>& count)
const;
458 std::size_t
size()
const;
490 std::vector<UDQAssign>
assignments(UDQVarType var_type)
const;
499 const std::unordered_map<std::string, UDT>&
tables()
const;
523 template<
class Serializer>
526 serializer(udq_params);
527 serializer(m_definitions);
528 serializer(m_assignments);
529 serializer(m_tables);
531 serializer(define_order);
532 serializer(input_index);
533 serializer(type_count);
534 serializer(pending_assignments_);
563 std::unordered_map<std::string, UDQDefine> m_definitions{};
568 std::unordered_map<std::string, UDQAssign> m_assignments{};
573 std::unordered_map<std::string, UDT> m_tables{};
581 std::unordered_map<std::string, std::string> units{};
586 IOrderSet<std::string> define_order;
589 OrderedMap<UDQIndex> input_index;
592 std::map<UDQVarType, std::size_t> type_count{};
599 mutable std::vector<std::string> pending_assignments_{};
609 void add_node(
const std::string& quantity, UDQAction action);
617 void add_assign(
const RestartIO::RstUDQ& udq,
const std::size_t report_step);
626 void add_define(
const RestartIO::RstUDQ& udq,
const std::size_t report_step);
647 void eval_define(std::size_t report_step,
648 const UDQState& udq_state,
649 UDQContext& context)
const;
668 void add_enumerated_assign(
const std::string& quantity,
670 const std::vector<std::string>& selector,
672 std::size_t report_step);
692 void add_assign_wellvar(
const std::string& quantity,
693 const std::vector<std::string>& selector,
695 std::size_t report_step,
696 const std::optional<DynamicSelector>& dynamic_selector);
707 template <
typename... Args>
708 void add_assign_impl(
const std::string& quantity,
714 const auto& [asgnPos, inserted] =
715 this->m_assignments.try_emplace(quantity, quantity, args...);
720 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
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:72
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
Container of entities from a dynamic context.
Definition UDQConfig.hpp:76
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.
Collection of all user-defined quantities in the current simulation run.
Definition UDQConfig.hpp:69
std::size_t size() const
Total number of active DEFINE and ASSIGN statements.
Definition UDQConfig.cpp:535
const UDQDefine & define(const std::string &key) const
Retrieve defining expression and evaluation object for a single UDQ.
Definition UDQConfig.cpp:468
const UDQParams & params() const
Retrieve run's active UDQ parameters.
Definition UDQConfig.cpp:625
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:365
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:430
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:447
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQConfig.hpp:524
const std::unordered_map< std::string, UDT > & tables() const
Retrieve run's active user defined tables.
Definition UDQConfig.cpp:635
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:397
UDQConfig()=default
Default constructor.
void 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:284
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:526
void add_unit(const std::string &keyword, const std::string &unit)
Incorporate a unit string for a UDQ.
Definition UDQConfig.cpp:320
bool has_keyword(const std::string &keyword) const
Query whether or not a particular UDQ exists in the collection.
Definition UDQConfig.cpp:278
std::vector< UDQDefine > definitions() const
Retrieve defining expressions and evaluation objects for all known UDQs.
Definition UDQConfig.cpp:478
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:596
bool clear_pending_assignments()
Clear all pending assignments.
Definition UDQConfig.cpp:421
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:335
void add_table(const std::string &name, UDT udt)
Incorporate a user defined table.
Definition UDQConfig.cpp:416
const UDQAssign & assign(const std::string &key) const
Retrieve any pending assignment object for a single UDQ.
Definition UDQConfig.cpp:473
UDQInput operator[](const std::string &keyword) const
Unprocessed input object for named quantity.
Definition UDQConfig.cpp:547
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:507
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:655
bool operator==(const UDQConfig &config) const
Equality predicate.
Definition UDQConfig.cpp:640
const UDQFunctionTable & function_table() const
Retrieve run's active UDQ function table.
Definition UDQConfig.cpp:630
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