opm-common
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 <cstddef>
24 #include <string>
25 #include <unordered_map>
26 #include <vector>
27 
28 namespace Opm {
29 
30 // The purpose of this class is to transport in-place values from the
31 // simulator code to the summary output code. The code is written very much
32 // to fit in with the current implementation in the simulator. Functions
33 // which do not take both region set name and region ID arguments are
34 // intended for field-level values.
35 class Inplace
36 {
37 public:
38  // The Inplace class is implemented in close connection to the black-oil
39  // output module in opm-simulators. There are certain idiosyncracies
40  // here which are due to that coupling. For instance the enumerators
41  // PressurePV, HydroCarbonPV, PressureHydroCarbonPV, and
42  // DynamicPoreVolume are not included in the return value from phases().
43  enum class Phase {
44  WATER = 0, // Omitted from mixingPhases()
45  OIL = 1, // Omitted from mixingPhases()
46  GAS = 2, // Omitted from mixingPhases()
47  OilInLiquidPhase = 3,
48  OilInGasPhase = 4,
49  GasInLiquidPhase = 5,
50  GasInGasPhase = 6,
51  PoreVolume = 7,
52  PressurePV = 8, // Omitted from both phases() and mixingPhases()
53  HydroCarbonPV = 9, // Omitted from both phases() and mixingPhases()
54  PressureHydroCarbonPV = 10, // Omitted from both phases() and mixingPhases()
55  DynamicPoreVolume = 11, // Omitted from both phases() and mixingPhases()
56  WaterResVolume = 12,
57  OilResVolume = 13,
58  GasResVolume = 14,
59  SALT = 15,
60  CO2InWaterPhase = 16,
61  CO2InGasPhaseInMob = 17,
62  CO2InGasPhaseMob = 18,
63  CO2InGasPhaseInMobKrg = 19,
64  CO2InGasPhaseMobKrg = 20,
65  WaterInGasPhase = 21,
66  WaterInWaterPhase = 22,
67  CO2Mass = 23,
68  CO2MassInWaterPhase = 24,
69  CO2MassInGasPhase = 25,
70  CO2MassInGasPhaseInMob = 26,
71  CO2MassInGasPhaseMob = 27,
72  CO2MassInGasPhaseInMobKrg = 28,
73  CO2MassInGasPhaseMobKrg = 29,
74  CO2MassInGasPhaseEffectiveTrapped = 30,
75  CO2MassInGasPhaseEffectiveUnTrapped = 31,
76  CO2MassInGasPhaseMaximumTrapped = 32,
77  CO2MassInGasPhaseMaximumUnTrapped = 33,
78  MicrobialMass = 34,
79  OxygenMass = 35,
80  UreaMass = 36,
81  BiofilmMass = 37,
82  CalciteMass = 38,
83  WaterMass = 39,
84  };
85 
89 
91  static std::string EclString(const Phase phase);
92 
105  void add(const std::string& region,
106  Phase phase,
107  std::size_t region_number,
108  double value);
109 
115  void add(Phase phase, double value);
116 
132  double get(const std::string& region,
133  Phase phase,
134  std::size_t region_number) const;
135 
144  double get(Phase phase) const;
145 
158  bool has(const std::string& region,
159  Phase phase,
160  std::size_t region_number) const;
161 
168  bool has(Phase phase) const;
169 
172  std::size_t max_region() const;
173 
182  std::size_t max_region(const std::string& region_name) const;
183 
195  std::vector<double>
196  get_vector(const std::string& region, Phase phase) const;
197 
200  static const std::vector<Phase>& phases();
201 
204  static const std::vector<Phase>& mixingPhases();
205 
211  template<class Serializer>
212  void serializeOp(Serializer& serializer)
213  {
214  serializer(phase_values);
215  }
216 
223  bool operator==(const Inplace& rhs) const;
224 
225 private:
226  using ValueMap = std::unordered_map<std::size_t, double>;
227  using PhaseMap = std::unordered_map<Phase, ValueMap>;
228  using RegionMap = std::unordered_map<std::string, PhaseMap>;
229 
232  RegionMap phase_values{};
233 };
234 
235 } // namespace Opm
236 
237 #endif // ORIGINAL_OIP
static std::string EclString(const Phase phase)
Converts phase enum to ECL textual representation.
Definition: Inplace.cpp:77
void add(const std::string &region, Phase phase, std::size_t region_number, double value)
Assign value of particular quantity in specific region of named region set.
Definition: Inplace.cpp:132
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static const std::vector< Phase > & phases()
Get iterable list of all quantities which can be handled/updated in a generic way.
Definition: Inplace.cpp:254
bool has(const std::string &region, Phase phase, std::size_t region_number) const
Check existence of particular quantity in specific region of named region set.
Definition: Inplace.cpp:180
bool operator==(const Inplace &rhs) const
Equality predicate.
Definition: Inplace.cpp:306
static Inplace serializationTestObject()
Create non-defaulted object suitable for testing the serialisation operation.
Definition: Inplace.cpp:69
static const std::vector< Phase > & mixingPhases()
Get iterable list of all quantities, other than "pure" phases, which can be handled/updated in a gene...
Definition: Inplace.cpp:265
std::vector< double > get_vector(const std::string &region, Phase phase) const
Linearised per-region values for a given phase in a specific region set.
Definition: Inplace.cpp:227
Class for (de-)serializing.
Definition: Serializer.hpp:94
void serializeOp(Serializer &serializer)
Serialisation interface.
Definition: Inplace.hpp:212
std::size_t max_region() const
Retrieve the maximum region ID registered across all quantities in all registered region sets...
Definition: Inplace.cpp:203
Definition: Inplace.hpp:35