My Project
Inplace.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 #ifndef ORIGINAL_OIP
21 #define ORIGINAL_OIP
22 
23 #include <string>
24 #include <unordered_map>
25 #include <vector>
26 
27 namespace Opm {
28 
29 
30 class Inplace {
31 public:
32 
33  enum class Phase {
34  WATER = 0,
35  OIL = 1,
36  GAS = 2,
37  OilInLiquidPhase = 3,
38  OilInGasPhase = 4,
39  GasInLiquidPhase = 5,
40  GasInGasPhase = 6,
41  PoreVolume = 7,
42  // The Inplace class is implemented in close relation to the
43  // ecloutputblackoilmodule in opm-simulators, ane there are
44  // certainly idiosyncracies here due to that coupling. For instance
45  // the enum values PressurePV, HydroCarbonPV, PressureHydroCarbonPV,
46  // and DynamicPoreVolume are *not* included in the return value from
47  // phases().
48  PressurePV = 8,
49  HydroCarbonPV = 9,
50  PressureHydroCarbonPV = 10,
51  DynamicPoreVolume = 11,
52  WaterResVolume = 12,
53  OilResVolume = 13,
54  GasResVolume = 14,
55  SALT = 15,
56  };
57 
58  /*
59  The purpose of this class is to transport inplace values from the
60  simulator code to the summary output code. The code is written very much
61  to fit in with the current implementation in the simulator. The functions
62  which don't accept region_name & region_number arguments should be called
63  for totals, i.e. field properties.
64  */
65 
66 
67  void add(const std::string& region, Phase phase, std::size_t region_number, double value);
68  void add(Phase phase, double value);
69 
70  double get(const std::string& region, Phase phase, std::size_t region_number) const;
71  double get(Phase phase) const;
72 
73  bool has(const std::string& region, Phase phase, std::size_t region_number) const;
74  bool has(Phase phase) const;
75 
76  std::size_t max_region() const;
77  std::size_t max_region(const std::string& region_name) const;
78 
79  /*
80  The get_vector functions return a vector length max_region() which
81  contains the values added with the add() function and indexed with
82  (region_number - 1). This is an incarnation of id <-> index confusion and
83  should be replaced with a std::map instead.
84  */
85  std::vector<double> get_vector(const std::string& region, Phase phase) const;
86 
87  static const std::vector<Phase>& phases();
88 private:
89  std::unordered_map<std::string, std::unordered_map<Phase, std::unordered_map<std::size_t, double>>> phase_values;
90 };
91 
92 
93 }
94 
95 #endif
Definition: Inplace.hpp:30
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29