opm-common
Toggle main menu visibility
Loading...
Searching...
No Matches
Cells.hpp
1
/*
2
Copyright 2016 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 OPM_OUTPUT_CELLS_HPP
21
#define OPM_OUTPUT_CELLS_HPP
22
23
#include <opm/input/eclipse/Units/UnitSystem.hpp>
24
25
#include <utility>
26
#include <variant>
27
#include <vector>
28
29
namespace
Opm
{
namespace
data {
30
31
// The 3D data which are saved to file are assembled in one large
32
// container. In the container the data is tagged with an element from
33
// the TargetType enum which specifies the vector's intended output
34
// destination.
35
//
36
//RESTART_SOLUTION: Cell-based quantities that are output to the
37
// SOLUTION section of the restart file. ECLIPSE-compatible names.
38
//
39
//RESTART_AUXILIARY: Fields with extra information, not required
40
// for restart. Examples of this include fluid in place values or
41
// evaluations of relative permeability. Will end up in the
42
// restart file. Deprecated and will be removed.
43
//
44
//SUMMARY: Fields which are added only to serve as input data for
45
// calculations of summary results. The Summary implementation can
46
// use data with any tag value, but if it is tagged as SUMMARY it
47
// will not be output anywhere else.
48
//
49
//INIT: Fields which should go to the INIT file.
50
//
51
//RESTART_OPM_EXTENDED: Cell-based quantities that are specific to
52
// OPM-Flow. Output only to extended OPM restart files. Specifically
53
// not output to ECLIPSE-compatible restart files.
54
55
enum class
TargetType
56
{
57
RESTART_SOLUTION,
58
RESTART_AUXILIARY,
59
RESTART_TRACER_SOLUTION,
60
SUMMARY,
61
INIT,
62
RESTART_OPM_EXTENDED,
63
};
64
67
struct
CellData
68
{
70
UnitSystem::measure
dim
{UnitSystem::measure::identity};
71
73
TargetType
target
{TargetType::RESTART_SOLUTION};
74
75
CellData
() =
default
;
76
explicit
CellData
(UnitSystem::measure m,
77
std::vector<double> x,
78
TargetType dest)
79
:
dim
{ m }
80
,
target
{ dest }
81
, data_ { std::move(x) }
82
{}
83
84
explicit
CellData(std::vector<int> x,
85
TargetType dest)
86
:
dim
{
UnitSystem
::measure::identity }
87
,
target
{ dest }
88
, data_ { std::move(x) }
89
{}
90
91
bool
operator==(
const
CellData& cell2)
const
92
{
93
return
(
dim
== cell2.dim)
94
&& (
target
== cell2.target)
95
&& (data_ == cell2.data_);
96
}
97
98
template
<
class
Serializer>
99
void
serializeOp(Serializer& serializer)
100
{
101
serializer(this->
dim
);
102
serializer(this->data_);
103
serializer(this->
target
);
104
}
105
106
static
CellData serializationTestObject()
107
{
108
return
CellData {
109
UnitSystem::measure::runtime,
110
std::vector<double>{1.0, 2.0, 3.0},
111
TargetType::RESTART_OPM_EXTENDED
112
};
113
}
114
115
template
<
class
T>
116
std::vector<T>& data()
117
{
118
return
std::get<std::vector<T>>(data_);
119
}
120
121
template
<
class
T>
122
const
std::vector<T>& data()
const
123
{
124
return
std::get<std::vector<T>>(data_);
125
}
126
127
template
<
class
Visitor>
128
void
visit(Visitor&& visit)
const
129
{
130
std::visit(std::forward<Visitor>(visit), data_);
131
}
132
133
private
:
135
using
DataVector = std::variant<std::monostate,
136
std::vector<double>,
137
std::vector<int>>;
138
139
DataVector data_{};
140
141
};
142
143
}}
// namespace Opm::data
144
145
#endif
//OPM_OUTPUT_CELLS_HPP
Opm::UnitSystem
Definition
UnitSystem.hpp:34
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
Opm::data::CellData
Small struct that keeps track of data for output to restart/summary files.
Definition
Cells.hpp:68
Opm::data::CellData::dim
UnitSystem::measure dim
Dimension of the data to write.
Definition
Cells.hpp:70
Opm::data::CellData::target
TargetType target
File output destination.
Definition
Cells.hpp:73
opm
output
data
Cells.hpp
Generated by
1.17.0