23#include <opm/input/eclipse/EclipseState/Phase.hpp>
27#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
38namespace Opm::RestartIO {
75 using iterator_category = std::forward_iterator_tag;
82 using value_type = std::pair<std::size_t, double>;
85 using difference_type = int;
88 using pointer =
const value_type*;
91 using reference =
const value_type&;
96 Iterator& operator++()
106 Iterator operator++(
int)
118 reference operator*()
121 return this->deref_value_;
130 return &this->deref_value_;
138 bool operator==(
const Iterator& that)
const
140 return (this->ix_ == that.ix_)
141 && (this->i_ == that.i_)
142 && (this->value_ == that.value_);
150 bool operator!=(
const Iterator& that)
const
152 return ! (*
this == that);
155 friend class ValueRange;
163 Iterator(std::size_t ix,
165 const std::variant<double, const double*>& value)
166 : ix_{ix}, i_{i}, value_{value}
172 std::variant<double, const double*> value_;
174 value_type deref_value_{};
180 Iterator begin()
const
181 {
return this->makeIterator(this->begin_); }
185 {
return this->makeIterator(this->end_); }
203 ValueRange(std::size_t begin_arg,
207 : begin_{begin_arg}, end_{end_arg}, i_{i}, value_{value}
223 ValueRange(std::size_t begin_arg,
227 : begin_{begin_arg}, end_{end_arg}, i_{i}, value_{value}
231 std::size_t begin_{};
243 std::variant<double, const double*> value_{};
250 Iterator makeIterator(
const std::size_t ix)
const
252 return { ix, this->i_, this->value_ };
268 UDQVarType category{UDQVarType::NONE};
283 RstUDQ(
const std::string& name_arg,
284 const std::string& unit_arg,
285 const std::string& define_arg,
286 UDQUpdate status_arg);
295 RstUDQ(
const std::string& name_arg,
296 const std::string& unit_arg);
302 void prepareValues();
318 void addValue(
const int entity,
const int subEntity,
const double value);
335 void assignScalarValue(
const double value);
340 void addEntityName(std::string_view wgname);
349 double scalarValue()
const;
352 std::size_t numEntities()
const;
360 ValueRange operator[](
const std::size_t i)
const;
366 const std::vector<std::string>& entityNames()
const
368 return this->wgnames_;
379 const std::vector<int>& nameIndex()
const;
385 std::string_view definingExpression()
const;
388 UDQUpdate currentUpdateStatus()
const;
394 bool isDefine()
const
396 return this->definition_.has_value();
401 bool isScalar()
const
403 return std::holds_alternative<double>(this->sa_);
412 using Graph = utility::CSRGraphFromCoordinates<int, true, true>;
424 Definition(
const std::string& expression_arg,
425 const UDQUpdate status_arg)
426 : expression { expression_arg }
427 , status { status_arg }
431 std::string expression{};
456 std::variant<std::monostate, double, std::vector<double>> sa_;
461 std::vector<std::string> wgnames_{};
466 std::optional<int> maxEntityIdx_{};
469 mutable std::optional<std::vector<int>> wgNameIdx_{};
475 std::optional<Definition> definition_{};
478 bool isUDQSet()
const
480 return std::holds_alternative<std::vector<double>>(this->sa_);
489 ValueRange scalarRange(
const std::size_t i)
const;
498 ValueRange udqSetRange(
const std::size_t i)
const;
500 void ensureValidNameIndex()
const;
526 RstRecord(UDAControl c,
536 std::size_t input_index;
541 std::size_t use_count;
544 std::size_t wg_offset;
547 std::size_t num_wg_elems;
553 RstUDQActive() =
default;
566 RstUDQActive(
const std::vector<int>& iuad,
567 const std::vector<int>& iuap,
568 const std::vector<int>& igph);
571 std::vector<int> wg_index{};
574 std::vector<RstRecord> iuad{};
577 std::vector<Phase> ig_phase{};
Facility for converting collection of region ID pairs into a sparse (CSR) adjacency matrix representa...