My Project
PAvgCalculator.hpp
1 /*
2  Copyright 2020 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 
21 #ifndef PAVE_CALC_HPP
22 #define PAVE_CALC_HPP
23 
24 #include <functional>
25 #include <map>
26 #include <optional>
27 #include <vector>
28 
29 #include <opm/input/eclipse/Schedule/Well/PAvg.hpp>
30 #include <opm/input/eclipse/Schedule/Well/Connection.hpp>
31 
32 namespace Opm {
33 
34 class WellConnections;
35 class EclipseGrid;
36 class Serializer;
38 public:
39 
40  PAvgCalculator(const std::string& well, double well_ref_depth, const EclipseGrid& grid, const std::vector<double>& porv, const WellConnections& connections, const PAvg& pavg);
41 
42  enum class WBPMode {
43  WBP,
44  WBP4,
45  WBP5,
46  WBP9
47  };
48 
49 
50  struct Neighbour {
51  Neighbour(double porv_arg, std::size_t index_arg) :
52  porv(porv_arg),
53  global_index(index_arg)
54  {}
55 
56  double porv;
57  std::size_t global_index;
58  };
59 
60 
61  struct Connection {
62  Connection(double porv_arg, double cf, ::Opm::Connection::Direction dir_arg, std::size_t index_arg) :
63  porv(porv_arg),
64  cfactor(cf),
65  dir(dir_arg),
66  global_index(index_arg)
67  {
68  }
69 
70  double porv;
71  double cfactor;
72  ::Opm::Connection::Direction dir;
73  std::size_t global_index;
74  std::vector<Neighbour> rect_neighbours;
75  std::vector<Neighbour> diag_neighbours;
76  };
77 
78 
79  const std::string& wname() const;
80  double wbp() const;
81  double wbp4() const;
82  double wbp5() const;
83  double wbp9() const;
84  double wbp(WBPMode mode) const;
85  bool add_pressure(std::size_t global_index, double pressure);
86  void update(Serializer& serializer);
87  const std::vector< std::size_t >& index_list() const;
88  std::pair< std::reference_wrapper<const std::vector<double>>, std::reference_wrapper<const std::vector<bool>> > data() const;
89  void serialize(Serializer& serializer) const;
90 
91 private:
92  void update(const std::vector<double>& p, const std::vector<char>& m);
93  void add_connection(const PAvgCalculator::Connection& conn);
94  void add_neighbour(std::size_t global_index, std::optional<PAvgCalculator::Neighbour> neighbour, bool rect_neighbour);
95  double get_pressure(std::size_t global_index) const;
96  double cf_avg(const std::vector<std::optional<double>>& block_pressure) const;
97  std::pair<double,double> porv_pressure(std::size_t global_index) const;
98  std::vector<std::optional<double>> block_pressures(PAvgCalculator::WBPMode mode) const;
99 
100  std::string well_name;
101  PAvg m_pavg;
102  std::vector<Connection> m_connections;
103  std::map<std::size_t, std::size_t> m_index_map;
104  std::vector<std::size_t> m_index_list;
105  std::vector<double> pressure;
106  std::vector<char> valid_pressure;
107  double ref_depth;
108 };
109 
110 }
111 #endif
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:54
Definition: PAvgCalculator.hpp:37
Definition: PAvg.hpp:28
Definition: Serializer.hpp:38
Definition: WellConnections.hpp:40
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: PAvgCalculator.hpp:61
Definition: PAvgCalculator.hpp:50