opm-common
Toggle main menu visibility
Loading...
Searching...
No Matches
UnitSystem.hpp
1
/*
2
Copyright 2013 Statoil 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 UNITSYSTEM_H
21
#define UNITSYSTEM_H
22
23
#include <opm/input/eclipse/Units/Dimension.hpp>
24
25
#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
26
27
#include <map>
28
#include <memory>
29
#include <string>
30
#include <vector>
31
32
namespace
Opm
{
33
34
class
UnitSystem {
35
public
:
36
enum class
UnitType {
37
UNIT_TYPE_METRIC = 0,
38
UNIT_TYPE_FIELD = 1,
39
UNIT_TYPE_LAB = 2,
40
UNIT_TYPE_PVT_M = 3,
41
UNIT_TYPE_INPUT = 4
42
};
43
44
enum class
measure :
int
{
45
identity,
46
length,
47
time,
48
runtime,
49
density,
50
pressure,
51
pressure_drop,
52
temperature_absolute,
53
temperature,
54
viscosity,
55
permeability,
56
area,
57
liquid_surface_volume,
58
gas_surface_volume,
59
volume,
60
geometric_volume,
61
liquid_surface_rate,
62
gas_surface_rate,
63
rate,
64
geometric_volume_rate,
65
pipeflow_velocity,
66
transmissibility,
67
effective_Kh,
68
mass,
69
mass_rate,
70
gas_oil_ratio,
71
oil_gas_ratio,
72
water_cut,
73
gas_formation_volume_factor,
74
oil_formation_volume_factor,
75
water_formation_volume_factor,
76
gas_inverse_formation_volume_factor,
77
oil_inverse_formation_volume_factor,
78
water_inverse_formation_volume_factor,
79
liquid_productivity_index,
80
gas_productivity_index,
81
energy,
82
energy_rate,
83
icd_strength,
84
aicd_strength,
85
concentration,
86
gas_oil_ratio_rate,
87
moles,
88
ppm,
89
ymodule,
90
thermalconductivity,
91
dfactor,
92
_count
// New entries must be added *before* this
93
};
94
95
explicit
UnitSystem(
int
ecl_id);
96
explicit
UnitSystem(UnitType
unit
= UnitType::UNIT_TYPE_METRIC);
97
explicit
UnitSystem(
const
std::string& deck_name);
98
99
static
UnitSystem serializationTestObject();
100
101
const
std::string& getName()
const
;
102
UnitType getType()
const
;
103
int
ecl_id()
const
;
104
105
void
addDimension(
const
std::string& dimension ,
const
Dimension
& dim);
106
void
addDimension(
const
std::string& dimension,
double
SIfactor,
double
SIoffset = 0.0);
107
const
Dimension
& getNewDimension(
const
std::string& dimension);
108
const
Dimension
& getDimension(
const
std::string& dimension)
const
;
109
Dimension
getDimension(measure m)
const
;
110
Dimension
uda_dim(UDAControl control)
const
;
111
112
bool
hasDimension(
const
std::string& dimension)
const
;
113
bool
equal(
const
UnitSystem& other)
const
;
114
115
bool
operator==(
const
UnitSystem& )
const
;
116
bool
operator!=(
const
UnitSystem& )
const
;
117
static
bool
rst_cmp(
const
UnitSystem& full_arg,
const
UnitSystem& rst_arg);
118
119
Dimension
parse(
const
std::string& dimension)
const
;
120
121
double
from_si(
const
std::string& dimension,
double
)
const
;
122
double
to_si(
const
std::string& dimension,
double
)
const
;
123
double
from_si( measure,
double
)
const
;
124
double
to_si( measure,
double
)
const
;
125
void
from_si( measure, std::vector<double>& )
const
;
126
void
to_si( measure, std::vector<double>& )
const
;
127
const
char
* name( measure )
const
;
128
std::string deck_name()
const
;
129
std::size_t use_count()
const
;
130
131
static
bool
valid_name(
const
std::string& deck_name);
132
static
UnitSystem newMETRIC();
133
static
UnitSystem newFIELD();
134
static
UnitSystem newLAB();
135
static
UnitSystem newPVT_M();
136
static
UnitSystem newINPUT();
137
138
template
<
class
Serializer>
139
void
serializeOp(
Serializer
& serializer)
140
{
141
serializer(m_name);
142
serializer(m_unittype);
143
serializer(m_dimensions);
144
serializer(m_use_count);
145
if
(!serializer.
isSerializing
())
146
init();
147
}
148
149
private
:
150
Dimension
parseFactor(
const
std::string& )
const
;
151
void
init();
152
void
initINPUT();
153
void
initMETRIC();
154
void
initFIELD();
155
void
initPVT_M();
156
void
initLAB();
157
158
std::string m_name;
159
UnitType m_unittype;
160
std::map< std::string , Dimension > m_dimensions;
161
const
double
* measure_table_to_si_offset;
162
const
double
* measure_table_from_si;
163
const
double
* measure_table_to_si;
164
const
char
*
const
* unit_name_table;
165
166
/*
167
The active unit system is determined runtime, to be certain that we do
168
not end up in a situation where we first use the default unit system,
169
and then subsequently change it.
170
171
The Deck::selectActiveUnitSystem() method has this code:
172
173
const auto& current = this->getActiveUnitSystem();
174
if (current.use_count() > 0)
175
throw std::logic_error("Sorry - can not change unit system halways");
176
177
178
*/
179
mutable
std::size_t m_use_count = 0;
180
};
181
182
}
// namespace Opm
183
184
#endif
// UNITSYSTEM_H
Opm::Dimension
Definition
Dimension.hpp:27
Opm::Serializer
Class for (de-)serializing.
Definition
Serializer.hpp:94
Opm::Serializer::isSerializing
bool isSerializing() const
Returns true if we are currently doing a serialization operation.
Definition
Serializer.hpp:207
Opm::unit
Definition of various units.
Definition
Units.hpp:84
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
opm
input
eclipse
Units
UnitSystem.hpp
Generated by
1.17.0