ConnFracStatistics.hpp
Go to the documentation of this file.
1/*
2 Copyright 2024 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 OPM_CONNFRACSTATISTICS_HPP
21#define OPM_CONNFRACSTATISTICS_HPP
22
24
25#include <array>
26#include <cstddef>
27#include <type_traits>
28
29namespace Opm {
30
35template <typename Scalar>
37{
38public:
41 enum class Quantity : std::size_t
42 {
44 Pressure,
45
47 FlowRate,
48
50 Width,
51
52 // -------------------------------------------------------------
53 // Helper. Must be last enumerator.
54 NumQuantities,
55 };
56
61 using SamplePoint = std::array
62 <Scalar, static_cast<std::underlying_type_t<Quantity>>(Quantity::NumQuantities)>;
63
69 template <class Serializer>
70 void serializeOp(Serializer& serializer)
71 {
72 serializer(this->quantity_);
73 }
74
77 void reset()
78 {
79 for (auto& q : this->quantity_) { q.reset(); }
80 }
81
88 void addSamplePoint(const SamplePoint& samplePoint)
89 {
90 for (auto qIdx = 0*samplePoint.size(); qIdx < samplePoint.size(); ++qIdx) {
91 this->quantity_[qIdx].addSamplePoint(samplePoint[qIdx]);
92 }
93 }
94
101 {
102 return this->quantity_[ static_cast<std::underlying_type_t<Quantity>>(q) ];
103 }
104
107 {
108 auto stat = ConnFracStatistics{};
109
110 stat.quantity_
112
113 return stat;
114 }
115
122 bool operator==(const ConnFracStatistics& that) const
123 {
124 return this->quantity_ == that.quantity_;
125 }
126
127private:
128 using StatArray = std::array<
130 static_cast<std::underlying_type_t<Quantity>>(Quantity::NumQuantities)
131 >;
132
134 StatArray quantity_{};
135};
136
137} // namespace Opm
138
139#endif // OPM_CONNFRACSTATISTICS_HPP
Definition: ConnFracStatistics.hpp:37
void reset()
Definition: ConnFracStatistics.hpp:77
bool operator==(const ConnFracStatistics &that) const
Definition: ConnFracStatistics.hpp:122
void addSamplePoint(const SamplePoint &samplePoint)
Definition: ConnFracStatistics.hpp:88
std::array< Scalar, static_cast< std::underlying_type_t< Quantity > >(Quantity::NumQuantities)> SamplePoint
Definition: ConnFracStatistics.hpp:62
Quantity
Definition: ConnFracStatistics.hpp:42
const RunningStatistics< Scalar > & statistics(const Quantity q) const
Definition: ConnFracStatistics.hpp:100
static ConnFracStatistics serializationTestObject()
Create a serialisation test object.
Definition: ConnFracStatistics.hpp:106
void serializeOp(Serializer &serializer)
Definition: ConnFracStatistics.hpp:70
Definition: RunningStatistics.hpp:36
Definition: blackoilboundaryratevector.hh:39