My Project
Loading...
Searching...
No Matches
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
28namespace 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.
36{
37public:
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 };
79
83
85 static std::string EclString(const Phase phase);
86
99 void add(const std::string& region,
100 Phase phase,
101 std::size_t region_number,
102 double value);
103
109 void add(Phase phase, double value);
110
126 double get(const std::string& region,
127 Phase phase,
128 std::size_t region_number) const;
129
138 double get(Phase phase) const;
139
152 bool has(const std::string& region,
153 Phase phase,
154 std::size_t region_number) const;
155
162 bool has(Phase phase) const;
163
166 std::size_t max_region() const;
167
176 std::size_t max_region(const std::string& region_name) const;
177
189 std::vector<double>
190 get_vector(const std::string& region, Phase phase) const;
191
194 static const std::vector<Phase>& phases();
195
198 static const std::vector<Phase>& mixingPhases();
199
205 template<class Serializer>
206 void serializeOp(Serializer& serializer)
207 {
208 serializer(phase_values);
209 }
210
217 bool operator==(const Inplace& rhs) const;
218
219private:
220 using ValueMap = std::unordered_map<std::size_t, double>;
221 using PhaseMap = std::unordered_map<Phase, ValueMap>;
222 using RegionMap = std::unordered_map<std::string, PhaseMap>;
223
226 RegionMap phase_values{};
227};
228
229} // namespace Opm
230
231#endif // ORIGINAL_OIP
Definition Inplace.hpp:36
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:259
static const std::vector< Phase > & phases()
Get iterable list of all quantities which can be handled/updated in a generic way.
Definition Inplace.cpp:248
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:221
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:174
double get(const std::string &region, Phase phase, std::size_t region_number) const
Retrieve numerical value of particular quantity in specific region of named region set.
Definition Inplace.cpp:139
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:126
std::size_t max_region() const
Retrieve the maximum region ID registered across all quantities in all registered region sets.
Definition Inplace.cpp:197
bool operator==(const Inplace &rhs) const
Equality predicate.
Definition Inplace.cpp:294
static std::string EclString(const Phase phase)
Converts phase enum to ECL textual representation.
Definition Inplace.cpp:77
void serializeOp(Serializer &serializer)
Serialisation interface.
Definition Inplace.hpp:206
Class for (de-)serializing.
Definition Serializer.hpp:94
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30