opm-common
RSTConfig.hpp
1
/*
2
Copyright 2021 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 OPM_RST_CONFIG_HPP
21
#define OPM_RST_CONFIG_HPP
22
23
/*
24
The RestartConfig class internalizes information of when (at which
25
report steps) we should save restart files, and which properties
26
should be included in the restart files. The configuration of this
27
immensely complex, and this code is unfortunately also way too
28
complex.
29
30
The most basic question to disentangle is the "When to write restart
31
files" versus "What data to store write in the restart file". As
32
expressed in the deck keywords this completely entangled, in this
33
implementation we have tried to disentangle it:
34
35
Keywords involved
36
-----------------
37
38
RPTRST: This is the main keyword for configuring restart output; it
39
can be used to configure bothe when to write the files and which
40
properties should be included in the restart files.
41
42
43
RPTSCHED: The main purpose of the RPTSCHED keyword is to configure
44
output from the SCHEDULE section to the PRINT file. However the
45
mneomnic RESTART=n can be used to turn writing of restart files
46
on, and also for values > 2 to some configuration of what is
47
written to the restart file:
48
49
RESTART=1 : As RPTRST,BASIC=1
50
RESTART>1 : As RPTRST,BASIC=2
51
RESTART>2 : Flow is added to restart file
52
RESTART>3 : Fluid in place is added to restart file
53
RESTART=6 : Restart file for every timestep.
54
55
56
57
RPTSOL: The RPTSOL keyword is very similar to the RPTCHED keyword,
58
it configures output from the SOLUTION section to the PRINT file,
59
but just as the RPTSCHED keyword it accepts a RESTART=n mnenonic
60
which can be used similarly to the BASIC=n mnenonic of the RPTRST
61
keyword. In particular the writing of an initial restart files
62
with initial equilibrium solution is controlled by the RPTSOL
63
keyword. If the restart mneonic is greater than 2 that can be
64
used to configure FLOWS and FIP keywords in the restart file.
65
66
RESTART=1 : As RPTRST,BASIC=1
67
RESTART>1 : As RPTRST,BASIC=2
68
RESTART>2 : Flow is added to restart file
69
RESTART>3 : Fluid in place is added to restart file
70
71
72
The basic rule in ECLIPSE is generally that the 'last keyword wins',
73
but for the RPTRST RPTSHCED combination a BASIC setting with n >= 3
74
will override consecutive RESTART=n settings from RPTSCHED.
75
76
77
When to write restart files:
78
----------------------------
79
80
When to write the restart file is governed by the BASIC=n setting in
81
the RPTRST keyword and the RESTART=n settings in the RPTSOL and
82
RPTSCHED keywords. The most common setting is 'ON' - i.e. BASIC=2
83
which means write a restart file for every report step, that can be
84
turned off again with BASIC=0. For BASIC>2 there are varietes of
85
every n'th report step, and the first report step in every month and
86
every year.
87
88
89
Old style / new style
90
---------------------
91
92
All of the relevant keywords can be specified using a new style
93
based on string mneomnics and alternatively an old style represented
94
with a *strictly ordered* list of integers. For instance both of
95
these keywords request restart files written for every report step;
96
in addition to the fields required to actually restart the files
97
should contain the relative permeabilities KRO, KRW, KRG:
98
99
RPTRST
100
BASIC=2 KRG KRW KRO /
101
102
103
RPTRST
104
2 9*0 3*1 17*0
105
106
Integer controls and string mneomnics can not be mixed in the same
107
keyword, but they can be mixed in the same deck - and that is
108
actually quite common.
109
110
111
What is written to the restart file
112
-----------------------------------
113
114
The BASIC=n mneonics request the writing of a restart file which
115
should contain 'all properties required to restart', in addition you
116
can configure extra keywords to be added to the restart file. This
117
is configured by just adding a list as:
118
119
RPTRST
120
BASIC=2 KRG KRW KRO /
121
122
It is really *not clear* what is the correct persistence semantics
123
for these keywords, consider for insance the following series of keywords:
124
125
-- Request restart file at every report step, the restart files
126
-- should contain additional properties KRO, KRG and KRW.
127
RPTRST
128
BASIC=2 KRG KRW KRO /
129
130
-- Advance the simulator forward with TSTEP / DATES
131
TSTEP / DATES / WCONxxx
132
133
-- Turn writing of restart files OFF using integer controls.
134
RPTRST
135
0 /
136
137
-- Advance the simulator forward with TSTEP / DATES
138
TSTEP / DATES / WCONxxx
139
140
-- Turn writing of restart files ON using integer controls.
141
RPTRST
142
2 /
143
144
When writing of restart files is turned on again with the last
145
RPTRST keyword, should still the relative permeabilites KRO, KRW and
146
KRG be added to the restart files? The model we have implemented is:
147
148
- The list of keywords written to the restart file is persisted
149
independtly of the BASIC=n setting.
150
151
- Using string based mnonics you can *only add* kewyords to be
152
written to the files. To stop writing a keyword you must use an
153
integer control with value 0.
154
155
Based on this best guess heuristic the final restart files will
156
still contain KRO, KRW and KRG.
157
158
159
160
What is required to restart?
161
----------------------------
162
163
A restart capable files is requested with the 'BASIC' mneomnic, but
164
exactly which properties the 'BASIC' keyword is expanded to is the
165
responsability of the simulator; i.e. for a black oil simulation you
166
will at the very least need the expansion:
167
168
BASIC -> PRESSURE, SWAT, SGAS, RS, RV
169
170
But this class just carries the boolean information: Yes - restart
171
is requested - expanding as illustrated is the responsability of the
172
simulator.
173
174
175
176
177
What is not supported?
178
----------------------
179
180
The SAVE keyword is not supported in OPM at all, this implies that
181
the SAVE and SFREQ mneomics are not supported.
182
183
184
Graphics-Only Restart Files (NORST)
185
-----------------------------------
186
187
The NORST mnemonic controls the generation of graphics-only restart
188
files, which are suitable for visualization but cannot be used for
189
restarting simulations. When NORST > 0:
190
191
NORST = 1: The restart file does not contain arrays that are required for restarting
192
but are not normally needed for graphical output. Example: hysteresis arrays
193
(if present in the simulation) are omitted. All standard solution arrays
194
(pressure, saturations, dissolved gas, etc.) and well arrays are included.
195
This gives a reasonably compact file that still allows well results to be
196
visualized.
197
198
NORST = 2: The restart file further excludes all well arrays (IWEL, XWEL, ZWEL, XCON, and
199
any other well‑related arrays). In a standard black‑oil simulation, the file
200
then contains only: the main solution arrays (PRESSURE, SWAT, SGAS, RS) and any
201
additional arrays requested by other restart controls (e.g., RPTRST). This produces
202
the smallest possible restart file, suitable for fast loading of reservoir‑wide
203
properties.
204
205
Graphics-only restart files are marked internally and will fail if
206
used in a restart attempt.
207
*/
208
209
#include <map>
210
#include <optional>
211
#include <string>
212
#include <unordered_set>
213
#include <utility>
214
215
namespace
Opm
{
216
217
class
DeckKeyword;
218
class
ErrorGuard;
219
class
ParseContext;
220
class
SOLUTIONSection;
221
222
}
// namespace Opm
223
224
namespace
Opm
{
225
226
class
RSTConfig
227
{
228
public
:
229
RSTConfig
() =
default
;
230
RSTConfig
(
const
SOLUTIONSection
& solution_section,
231
const
ParseContext
& parseContext,
232
bool
compositional_arg,
233
ErrorGuard
& errors);
234
235
void
update(
const
DeckKeyword
& keyword,
236
const
ParseContext
& parseContext,
237
ErrorGuard
& errors);
238
239
static
RSTConfig
first(
const
RSTConfig
& src);
240
static
RSTConfig
serializationTestObject();
241
242
template
<
class
Serializer>
243
void
serializeOp(
Serializer
& serializer)
244
{
245
serializer(write_rst_file);
246
serializer(keywords);
247
serializer(basic);
248
serializer(freq);
249
serializer(save);
250
serializer(compositional);
251
serializer(this->solution_only_keywords);
252
serializer(norst);
253
}
254
255
bool
operator==(
const
RSTConfig
& other)
const
;
256
257
std::optional<bool> write_rst_file{};
258
std::map<std::string, int> keywords{};
259
std::optional<int> basic{};
260
std::optional<int> freq{};
261
bool
save {
false
};
262
bool
compositional {
false
};
263
std::optional<int> norst{};
// Graphics-only restart file control
264
265
private
:
266
std::unordered_set<std::string> solution_only_keywords{};
267
268
void
handleRPTSOL(
const
DeckKeyword
& keyword,
269
const
ParseContext
& parse_context,
270
ErrorGuard
& errors);
271
272
void
handleRPTRST(
const
DeckKeyword
& keyword,
273
const
ParseContext
& parse_context,
274
ErrorGuard
& errors);
275
276
void
handleRPTRSTSOLUTION(
const
DeckKeyword
& keyword,
277
const
ParseContext
& parse_context,
278
ErrorGuard
& errors);
279
280
void
handleRPTSCHED(
const
DeckKeyword
& keyword,
281
const
ParseContext
& parse_context,
282
ErrorGuard
& errors);
283
284
void
update_schedule(
const
std::pair<std::optional<int>, std::optional<int>>& basic_freq);
285
};
286
287
}
// namespace Opm
288
289
#endif // OPM_RST_CONFIG_HPP
Opm::SOLUTIONSection
Definition:
DeckSection.hpp:135
Opm::RSTConfig
Definition:
RSTConfig.hpp:226
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition:
Exceptions.hpp:30
Opm::ParseContext
Control parser behaviour in failure conditions.
Definition:
ParseContext.hpp:114
Opm::Serializer
Class for (de-)serializing.
Definition:
Serializer.hpp:95
Opm::DeckKeyword
Definition:
DeckKeyword.hpp:38
Opm::ErrorGuard
Definition:
ErrorGuard.hpp:30
opm
input
eclipse
Schedule
RSTConfig.hpp
Generated by
1.8.14