Loading...
Searching...
No Matches
UDQSet.hpp
/*
Copyright 2019 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UDQSET_HPP
#define UDQSET_HPP
#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
#include <cstddef>
#include <optional>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>
namespace Opm {
class RegionSetMatchResult;
class SegmentSet;
} // namespace Opm
namespace Opm {
class UDQScalar
{
public:
UDQScalar() = default;
explicit UDQScalar(const double value, const std::size_t num = 0);
explicit UDQScalar(const std::string& wgname, const std::size_t num = 0);
void operator+=(const UDQScalar& rhs);
void operator+=(double rhs);
void operator*=(const UDQScalar& rhs);
void operator*=(double rhs);
void operator/=(const UDQScalar& rhs);
void operator/=(double rhs);
void operator-=(const UDQScalar& rhs);
void operator-=(double rhs);
operator bool() const;
void assign(const std::optional<double>& value);
void assign(double value);
bool defined() const;
double get() const;
const std::optional<double>& value() const { return this->m_value; }
const std::string& wgname() const { return this->m_wgname; }
std::size_t number() const { return this->m_num; }
bool operator==(const UDQScalar& other) const;
public:
std::optional<double> m_value{};
std::string m_wgname{};
std::size_t m_num = 0;
};
class UDQSet
{
public:
// Connections and segments.
struct EnumeratedItems
{
std::string name{};
std::vector<std::size_t> numbers{};
bool operator==(const EnumeratedItems& rhs) const;
static EnumeratedItems serializationTestObject();
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(this->name);
serializer(this->numbers);
}
};
static std::vector<EnumeratedItems>
enumerateItems(const RegionSetMatchResult& regionSet);
static std::vector<EnumeratedItems>
enumerateItems(const SegmentSet& segmentSet);
UDQSet(const std::string& name, UDQVarType var_type);
UDQSet(const std::string& name, UDQVarType var_type,
const std::vector<std::string>& wgnames);
UDQSet(const std::string& name, UDQVarType var_type,
const std::vector<EnumeratedItems>& items);
UDQSet(const std::string& name, UDQVarType var_type, std::size_t size);
UDQSet(const std::string& name, std::size_t size);
static UDQSet scalar(const std::string& name,
const std::optional<double>& scalar_value);
static UDQSet scalar(const std::string& name, double value);
static UDQSet empty(const std::string& name);
static UDQSet wells(const std::string& name,
const std::vector<std::string>& wells);
static UDQSet wells(const std::string& name,
const std::vector<std::string>& wells,
double scalar_value);
static UDQSet groups(const std::string& name,
const std::vector<std::string>& groups);
static UDQSet groups(const std::string& name,
const std::vector<std::string>& groups,
double scalar_value);
static UDQSet field(const std::string& name, double scalar_value);
static UDQSet segments(const std::string& name,
const std::vector<EnumeratedItems>& segments);
static UDQSet segments(const std::string& name,
const std::vector<EnumeratedItems>& segments,
const double scalar_value);
static UDQSet regions(const std::string& name,
const std::vector<EnumeratedItems>& regSetColl);
static UDQSet regions(const std::string& name,
const std::vector<EnumeratedItems>& regSetColl,
const double scalar_value);
void assign(const std::optional<double>& value);
void assign(std::size_t index, const std::optional<double>& value);
void assign(const std::string& wgname, const std::optional<double>& value);
void assign(const std::string& wgname, std::size_t number, const std::optional<double>& value);
void assign(double value);
void assign(std::size_t index, double value);
void assign(const std::string& wgname, double value);
bool has(const std::string& name) const;
std::size_t size() const;
void operator+=(const UDQSet& rhs);
void operator+=(double rhs);
void operator-=(const UDQSet& rhs);
void operator-=(double rhs);
void operator*=(const UDQSet& rhs);
void operator*=(double rhs);
void operator/=(const UDQSet& rhs);
void operator/=(double rhs);
const UDQScalar& operator[](std::size_t index) const;
const UDQScalar& operator[](const std::string& wgname) const;
const UDQScalar& operator()(const std::string& well, const std::size_t item) const;
std::vector<UDQScalar>::const_iterator begin() const;
std::vector<UDQScalar>::const_iterator end() const;
std::vector<std::string> wgnames() const;
std::vector<double> defined_values() const;
std::size_t defined_size() const;
const std::string& name() const;
void name(const std::string& name);
UDQVarType var_type() const;
bool operator==(const UDQSet& other) const;
private:
std::string m_name;
UDQVarType m_var_type = UDQVarType::NONE;
std::vector<UDQScalar> values;
UDQSet() = default;
};
UDQScalar operator+(const UDQScalar& lhs, const UDQScalar& rhs);
UDQScalar operator+(const UDQScalar& lhs, double rhs);
UDQScalar operator+(double lhs, const UDQScalar& rhs);
UDQScalar operator-(const UDQScalar& lhs, const UDQScalar& rhs);
UDQScalar operator-(const UDQScalar& lhs, double rhs);
UDQScalar operator-(double lhs, const UDQScalar& rhs);
UDQScalar operator*(const UDQScalar& lhs, const UDQScalar& rhs);
UDQScalar operator*(const UDQScalar& lhs, double rhs);
UDQScalar operator*(double lhs, const UDQScalar& rhs);
UDQScalar operator/(const UDQScalar& lhs, const UDQScalar& rhs);
UDQScalar operator/(const UDQScalar& lhs, double rhs);
UDQScalar operator/(double lhs, const UDQScalar& rhs);
UDQSet operator+(const UDQSet& lhs, const UDQSet& rhs);
UDQSet operator+(const UDQSet& lhs, double rhs);
UDQSet operator+(double lhs, const UDQSet& rhs);
UDQSet operator-(const UDQSet& lhs, const UDQSet& rhs);
UDQSet operator-(const UDQSet& lhs, double rhs);
UDQSet operator-(double lhs, const UDQSet& rhs);
UDQSet operator*(const UDQSet& lhs, const UDQSet& rhs);
UDQSet operator*(const UDQSet& lhs, double rhs);
UDQSet operator*(double lhs, const UDQSet& rhs);
UDQSet operator/(const UDQSet& lhs, const UDQSet& rhs);
UDQSet operator/(const UDQSet& lhs, double rhs);
UDQSet operator/(double lhs, const UDQSet&rhs);
} // namespace Opm
#endif // UDQSET_HPP
Opm::RegionSetMatchResult
Result Set From RegionSetMatcher's Matching Process.
Definition RegionSetMatcher.hpp:44
Opm::SegmentSet
Result Set From SegmentMatcher's Matching Process.
Definition SegmentMatcher.hpp:43
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::UDQScalar
Definition UDQSet.hpp:40
Opm::UDQScalar::operator/=
void operator/=(const UDQScalar &rhs)
Divide this UDQ scalar by other.
Definition UDQSet.cpp:100
Opm::UDQScalar::operator-=
void operator-=(const UDQScalar &rhs)
Subtract other UDQ scalar from this.
Definition UDQSet.cpp:88
Opm::UDQScalar::value
const std::optional< double > & value() const
Retrive contained numeric value.
Definition UDQSet.hpp:156
Opm::UDQScalar::assign
void assign(const std::optional< double > &value)
Assign numeric value to this UDQ scalar.
Definition UDQSet.cpp:68
Opm::UDQScalar::number
std::size_t number() const
Retrive numbered item, typically segment or connection, to which this scalar is associated.
Definition UDQSet.hpp:165
Opm::UDQScalar::operator+=
void operator+=(const UDQScalar &rhs)
Add other UDQ scalar to this.
Definition UDQSet.cpp:112
Opm::UDQScalar::m_value
std::optional< double > m_value
Scalar value.
Definition UDQSet.hpp:175
Opm::UDQScalar::wgname
const std::string & wgname() const
Retrive named well/group to which this scalar is associated.
Definition UDQSet.hpp:159
Opm::UDQScalar::operator*=
void operator*=(const UDQScalar &rhs)
Multiply UDQ scalar into this.
Definition UDQSet.cpp:124
Opm::UDQScalar::operator==
bool operator==(const UDQScalar &other) const
Equality predicate.
Definition UDQSet.cpp:141
Opm::UDQScalar::m_wgname
std::string m_wgname
Associated well/group name.
Definition UDQSet.hpp:178
Opm::UDQScalar::defined
bool defined() const
Predicate for whether or not this UDQ scalar has a defined value.
Definition UDQSet.cpp:51
Opm::UDQScalar::m_num
std::size_t m_num
Numbered item.
Definition UDQSet.hpp:182
Opm::UDQScalar::get
double get() const
Retrive contained numeric value.
Definition UDQSet.cpp:56
Opm::UDQSet
Definition UDQSet.hpp:187
Opm::UDQSet::begin
std::vector< UDQScalar >::const_iterator begin() const
Range-for traversal support (beginning of range).
Definition UDQSet.cpp:539
Opm::UDQSet::empty
static UDQSet empty(const std::string &name)
Form an empty UDQ set.
Definition UDQSet.cpp:234
Opm::UDQSet::operator()
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...
Definition UDQSet.cpp:520
Opm::UDQSet::operator-=
void operator-=(const UDQSet &rhs)
Subtract UDQ set from this.
Definition UDQSet.cpp:433
Opm::UDQSet::field
static UDQSet field(const std::string &name, double scalar_value)
Form a UDQ set at the field level.
Definition UDQSet.cpp:239
Opm::UDQSet::operator+=
void operator+=(const UDQSet &rhs)
Add other UDQ set into this.
Definition UDQSet.cpp:415
Opm::UDQSet::operator[]
const UDQScalar & operator[](std::size_t index) const
Access individual UDQ scalar at particular index in UDQ set.
Definition UDQSet.cpp:495
Opm::UDQSet::name
const std::string & name() const
Retrive the name of this UDQ set.
Definition UDQSet.cpp:164
Opm::UDQSet::defined_values
std::vector< double > defined_values() const
Retrive the UDQ set's defined values only.
Definition UDQSet.cpp:473
Opm::UDQSet::wells
static UDQSet wells(const std::string &name, const std::vector< std::string > &wells)
Form a UDQ set pertaining to a set of named wells.
Definition UDQSet.cpp:246
Opm::UDQSet::wgnames
std::vector< std::string > wgnames() const
Retrive names of entities associate to this UDQ set.
Definition UDQSet.cpp:402
Opm::UDQSet::end
std::vector< UDQScalar >::const_iterator end() const
Range-for traversal support (one past end of range).
Definition UDQSet.cpp:544
Opm::UDQSet::operator==
bool operator==(const UDQSet &other) const
Equality comparison operator.
Definition UDQSet.cpp:784
Opm::UDQSet::operator*=
void operator*=(const UDQSet &rhs)
Multiply other UDQ set into this.
Definition UDQSet.cpp:437
Opm::UDQSet::UDQSet
UDQSet(const std::string &name, UDQVarType var_type)
Construct empty, named UDQ set of specific variable type.
Definition UDQSet.cpp:173
Opm::UDQSet::groups
static UDQSet groups(const std::string &name, const std::vector< std::string > &groups)
Form a UDQ set pertaining to a set of named groups.
Definition UDQSet.cpp:261
Opm::UDQSet::var_type
UDQVarType var_type() const
Retrive the variable type of this UDQ set (e.g., well, group, field, segment &c).
Definition UDQSet.cpp:397
Opm::UDQSet::has
bool has(const std::string &name) const
Predicate for whether or not named UDQ element exists.
Definition UDQSet.cpp:306
Opm::UDQSet::defined_size
std::size_t defined_size() const
Retrive the UDQ set's number of defined values.
Definition UDQSet.cpp:486
Opm::UDQSet::size
std::size_t size() const
Number of elements in UDQ set.
Definition UDQSet.cpp:315
Opm::UDQSet::assign
void assign(const std::optional< double > &value)
Assign value to every element of the UDQ set.
Definition UDQSet.cpp:386
Opm::UDQSet::scalar
static UDQSet scalar(const std::string &name, const std::optional< double > &scalar_value)
Form a UDQ set pertaining to a single scalar value.
Definition UDQSet.cpp:226
Opm::UDQSet::operator/=
void operator/=(const UDQSet &rhs)
Divide this UDQ set by other UDQ set.
Definition UDQSet.cpp:455
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::UDQSet::EnumeratedItems
Definition UDQSet.hpp:191