opm-simulators
ConnFracStatistics.hpp
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 
23 #include <opm/simulators/wells/RunningStatistics.hpp>
24 
25 #include <array>
26 #include <cstddef>
27 #include <type_traits>
28 
29 namespace Opm {
30 
35 template <typename Scalar>
37 {
38 public:
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 
127 private:
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
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
void addSamplePoint(const SamplePoint &samplePoint)
Include new element into sample.
Definition: ConnFracStatistics.hpp:88
Quantity
Known quantities for which this collection provides statistics measures.
Definition: ConnFracStatistics.hpp:41
bool operator==(const ConnFracStatistics &that) const
Equality predicate.
Definition: ConnFracStatistics.hpp:122
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: ConnFracStatistics.hpp:70
const RunningStatistics< Scalar > & statistics(const Quantity q) const
Retrieve collection of sample statistics for a single quantity.
Definition: ConnFracStatistics.hpp:100
std::array< Scalar, static_cast< std::underlying_type_t< Quantity > >(Quantity::NumQuantities)> SamplePoint
Sample point representation.
Definition: ConnFracStatistics.hpp:62
Collection of fracturing statistics measures at the connection level.
Definition: ConnFracStatistics.hpp:36
void reset()
Reset internal counters to prepare for calculating a new set of sample statistics.
Definition: ConnFracStatistics.hpp:77
static ConnFracStatistics serializationTestObject()
Create a serialisation test object.
Definition: ConnFracStatistics.hpp:106
Facility for calculating simple sample statistics without having full sample available.
Definition: RunningStatistics.hpp:35