My Project
Loading...
Searching...
No Matches
UDQSet.hpp
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef UDQSET_HPP
21#define UDQSET_HPP
22
23#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
24
25#include <cstddef>
26#include <optional>
27#include <stdexcept>
28#include <string>
29#include <unordered_map>
30#include <vector>
31
32namespace Opm {
33 class SegmentSet;
34} // namespace Opm
35
36namespace Opm {
37
39{
40public:
41 UDQScalar() = default;
42
50 explicit UDQScalar(const double value, const std::size_t num = 0);
51
61 explicit UDQScalar(const std::string& wgname, const std::size_t num = 0);
62
69 void operator+=(const UDQScalar& rhs);
70
77 void operator+=(double rhs);
78
85 void operator*=(const UDQScalar& rhs);
86
93 void operator*=(double rhs);
94
101 void operator/=(const UDQScalar& rhs);
102
109 void operator/=(double rhs);
110
117 void operator-=(const UDQScalar& rhs);
118
125 void operator-=(double rhs);
126
130 operator bool() const;
131
136 void assign(const std::optional<double>& value);
137
142 void assign(double value);
143
145 bool defined() const;
146
150 double get() const;
151
155 const std::optional<double>& value() const { return this->m_value; }
156
158 const std::string& wgname() const { return this->m_wgname; }
159
164 std::size_t number() const { return this->m_num; }
165
170 bool operator==(const UDQScalar& other) const;
171
172public:
174 std::optional<double> m_value{};
175
177 std::string m_wgname{};
178
181 std::size_t m_num = 0;
182};
183
184
186{
187public:
188 // Connections and segments.
190 std::string well{};
191 std::vector<std::size_t> numbers{};
192
193 bool operator==(const EnumeratedWellItems& rhs) const;
194 static EnumeratedWellItems serializationTestObject();
195
196 template <class Serializer>
197 void serializeOp(Serializer& serializer)
198 {
199 serializer(this->well);
200 serializer(this->numbers);
201 }
202 };
203
204 static std::vector<EnumeratedWellItems>
205 getSegmentItems(const SegmentSet& segmentSet);
206
212 UDQSet(const std::string& name, UDQVarType var_type);
213
222 UDQSet(const std::string& name, UDQVarType var_type, const std::vector<std::string>& wgnames);
223
234 UDQSet(const std::string& name, UDQVarType var_type, const std::vector<EnumeratedWellItems>& items);
235
240 UDQSet(const std::string& name, UDQVarType var_type, std::size_t size);
241
246 UDQSet(const std::string& name, std::size_t size);
247
255 static UDQSet scalar(const std::string& name, const std::optional<double>& scalar_value);
256
263 static UDQSet scalar(const std::string& name, double value);
264
268 static UDQSet empty(const std::string& name);
269
275 static UDQSet wells(const std::string& name, const std::vector<std::string>& wells);
276
286 static UDQSet wells(const std::string& name, const std::vector<std::string>& wells, double scalar_value);
287
293 static UDQSet groups(const std::string& name, const std::vector<std::string>& groups);
294
304 static UDQSet groups(const std::string& name, const std::vector<std::string>& groups, double scalar_value);
305
313 static UDQSet field(const std::string& name, double scalar_value);
314 static UDQSet segments(const std::string& name,
315 const std::vector<EnumeratedWellItems>& segments);
316 static UDQSet segments(const std::string& name,
317 const std::vector<EnumeratedWellItems>& segments,
318 const double scalar_value);
319
324 void assign(const std::optional<double>& value);
325
333 void assign(std::size_t index, const std::optional<double>& value);
334
341 void assign(const std::string& wgname, const std::optional<double>& value);
342
352 void assign(const std::string& wgname, std::size_t number, const std::optional<double>& value);
353
358 void assign(double value);
359
367 void assign(std::size_t index, double value);
368
375 void assign(const std::string& wgname, double value);
376
378 bool has(const std::string& name) const;
379
382 std::size_t size() const;
383
390 void operator+=(const UDQSet& rhs);
391
395 void operator+=(double rhs);
396
403 void operator-=(const UDQSet& rhs);
404
408 void operator-=(double rhs);
409
416 void operator*=(const UDQSet& rhs);
417
421 void operator*=(double rhs);
422
429 void operator/=(const UDQSet& rhs);
430
434 void operator/=(double rhs);
435
441 const UDQScalar& operator[](std::size_t index) const;
442
448 const UDQScalar& operator[](const std::string& wgname) const;
449
460 const UDQScalar& operator()(const std::string& well, const std::size_t item) const;
461
463 std::vector<UDQScalar>::const_iterator begin() const;
464
466 std::vector<UDQScalar>::const_iterator end() const;
467
469 std::vector<std::string> wgnames() const;
470
472 std::vector<double> defined_values() const;
473
475 std::size_t defined_size() const;
476
478 const std::string& name() const;
479
481 void name(const std::string& name);
482
485 UDQVarType var_type() const;
486
490 bool operator==(const UDQSet& other) const;
491
492private:
494 std::string m_name;
495
497 UDQVarType m_var_type = UDQVarType::NONE;
498
500 std::vector<UDQScalar> values;
501
503 UDQSet() = default;
504};
505
506
507UDQScalar operator+(const UDQScalar& lhs, const UDQScalar& rhs);
508UDQScalar operator+(const UDQScalar& lhs, double rhs);
509UDQScalar operator+(double lhs, const UDQScalar& rhs);
510
511UDQScalar operator-(const UDQScalar& lhs, const UDQScalar& rhs);
512UDQScalar operator-(const UDQScalar& lhs, double rhs);
513UDQScalar operator-(double lhs, const UDQScalar& rhs);
514
515UDQScalar operator*(const UDQScalar& lhs, const UDQScalar& rhs);
516UDQScalar operator*(const UDQScalar& lhs, double rhs);
517UDQScalar operator*(double lhs, const UDQScalar& rhs);
518
519UDQScalar operator/(const UDQScalar& lhs, const UDQScalar& rhs);
520UDQScalar operator/(const UDQScalar& lhs, double rhs);
521UDQScalar operator/(double lhs, const UDQScalar& rhs);
522
523UDQSet operator+(const UDQSet& lhs, const UDQSet& rhs);
524UDQSet operator+(const UDQSet& lhs, double rhs);
525UDQSet operator+(double lhs, const UDQSet& rhs);
526
527UDQSet operator-(const UDQSet& lhs, const UDQSet& rhs);
528UDQSet operator-(const UDQSet& lhs, double rhs);
529UDQSet operator-(double lhs, const UDQSet& rhs);
530
531UDQSet operator*(const UDQSet& lhs, const UDQSet& rhs);
532UDQSet operator*(const UDQSet& lhs, double rhs);
533UDQSet operator*(double lhs, const UDQSet& rhs);
534
535UDQSet operator/(const UDQSet& lhs, const UDQSet& rhs);
536UDQSet operator/(const UDQSet& lhs, double rhs);
537UDQSet operator/(double lhs, const UDQSet&rhs);
538
539} // namespace Opm
540
541#endif // UDQSET_HPP
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition UDQSet.hpp:39
void operator/=(const UDQScalar &rhs)
Divide this UDQ scalar by other.
UDQScalar(const double value, const std::size_t num=0)
Constructor.
void operator-=(const UDQScalar &rhs)
Subtract other UDQ scalar from this.
void operator/=(double rhs)
Divide this UDQ scalar by numeric value.
const std::optional< double > & value() const
Retrive contained numeric value.
Definition UDQSet.hpp:155
void assign(const std::optional< double > &value)
Assign numeric value to this UDQ scalar.
std::size_t number() const
Retrive numbered item, typically segment or connection, to which this scalar is associated.
Definition UDQSet.hpp:164
void operator+=(const UDQScalar &rhs)
Add other UDQ scalar to this.
void assign(double value)
Assign numeric value to this UDQ scalar.
std::optional< double > m_value
Scalar value.
Definition UDQSet.hpp:174
void operator+=(double rhs)
Add numeric value to this UDQ scalar.
void operator*=(double rhs)
Multiply numeric value into this.
const std::string & wgname() const
Retrive named well/group to which this scalar is associated.
Definition UDQSet.hpp:158
void operator*=(const UDQScalar &rhs)
Multiply UDQ scalar into this.
bool operator==(const UDQScalar &other) const
Equality predicate.
std::string m_wgname
Associated well/group name.
Definition UDQSet.hpp:177
bool defined() const
Predicate for whether or not this UDQ scalar has a defined value.
UDQScalar(const std::string &wgname, const std::size_t num=0)
Constructor.
std::size_t m_num
Numbered item.
Definition UDQSet.hpp:181
double get() const
Retrive contained numeric value.
void operator-=(double rhs)
Add other UDQ scalar to this.
Definition UDQSet.hpp:186
std::vector< UDQScalar >::const_iterator begin() const
Range-for traversal support (beginning of range)
void assign(const std::string &wgname, double value)
Assign value to specific element of the UDQ set.
void operator-=(double rhs)
Subtract numeric values from all defined elements of this UDQ set.
const UDQScalar & operator()(const std::string &well, const std::size_t item) const
Access individual UDQ scalar assiociated to particular named well and numbered sub-entity of that nam...
void operator*=(double rhs)
Multiply every defined element with numeric element.
void operator-=(const UDQSet &rhs)
Subtract UDQ set from this.
static UDQSet groups(const std::string &name, const std::vector< std::string > &groups, double scalar_value)
Form a UDQ set pertaining to a set of named groups.
void operator+=(const UDQSet &rhs)
Add other UDQ set into this.
const UDQScalar & operator[](std::size_t index) const
Access individual UDQ scalar at particular index in UDQ set.
const std::string & name() const
Retrive the name of this UDQ set.
UDQSet(const std::string &name, std::size_t size)
Construct empty, named UDQ set of specific variable type.
void assign(double value)
Assign value to every element of the UDQ set.
UDQSet(const std::string &name, UDQVarType var_type, const std::vector< std::string > &wgnames)
Construct named UDQ set of specific variable type for particular set of well/group names.
void operator/=(double rhs)
Divide every defined element with numeric element.
std::vector< double > defined_values() const
Retrive the UDQ set's defined values only.
void operator+=(double rhs)
Add numeric value to all defined elements of this UDQ set.
std::vector< std::string > wgnames() const
Retrive names of entities associate to this UDQ set.
std::vector< UDQScalar >::const_iterator end() const
Range-for traversal support (one past end of range)
UDQSet(const std::string &name, UDQVarType var_type, const std::vector< EnumeratedWellItems > &items)
Construct named UDQ set of specific variable type for numbered well items-typically segments or conne...
static UDQSet empty(const std::string &name)
Form an empty UDQ set.
bool operator==(const UDQSet &other) const
Equality comparison operator.
UDQSet(const std::string &name, UDQVarType var_type, std::size_t size)
Construct empty, named UDQ set of specific variable type.
void operator*=(const UDQSet &rhs)
Multiply other UDQ set into this.
void name(const std::string &name)
Assign the name of this UDQ set.
static UDQSet scalar(const std::string &name, double value)
Form a UDQ set pertaining to a single scalar value.
UDQSet(const std::string &name, UDQVarType var_type)
Construct empty, named UDQ set of specific variable type.
static UDQSet scalar(const std::string &name, const std::optional< double > &scalar_value)
Form a UDQ set pertaining to a single scalar value.
void assign(const std::string &wgname, std::size_t number, const std::optional< double > &value)
Assign value to specific element of the UDQ set.
void assign(std::size_t index, const std::optional< double > &value)
Assign value to specific element of the UDQ set.
UDQVarType var_type() const
Retrive the variable type of this UDQ set (e.g., well, group, field, segment &c).
bool has(const std::string &name) const
Predicate for whether or not named UDQ element exists.
static UDQSet wells(const std::string &name, const std::vector< std::string > &wells)
Form a UDQ set pertaining to a set of named wells.
std::size_t defined_size() const
Retrive the UDQ set's number of defined values.
static UDQSet field(const std::string &name, double scalar_value)
Form a UDQ set at the field level.
std::size_t size() const
Number of elements in UDQ set.
void assign(const std::optional< double > &value)
Assign value to every element of the UDQ set.
void assign(std::size_t index, double value)
Assign value to specific element of the UDQ set.
static UDQSet groups(const std::string &name, const std::vector< std::string > &groups)
Form a UDQ set pertaining to a set of named groups.
void assign(const std::string &wgname, const std::optional< double > &value)
Assign value to specific element of the UDQ set.
void operator/=(const UDQSet &rhs)
Divide this UDQ set by other UDQ set.
const UDQScalar & operator[](const std::string &wgname) const
Access individual UDQ scalar assiociated to particular named entity (well or group).
static UDQSet wells(const std::string &name, const std::vector< std::string > &wells, double scalar_value)
Form a UDQ set pertaining to a set of named wells.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition UDQSet.hpp:189