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
#include <map>
185
#include <optional>
186
#include <string>
187
#include <unordered_set>
188
#include <utility>
189
190
namespace
Opm
{
191
192
class
DeckKeyword;
193
class
ErrorGuard;
194
class
ParseContext;
195
class
SOLUTIONSection;
196
197
}
// namespace Opm
198
199
namespace
Opm
{
200
201
class
RSTConfig
202
{
203
public
:
204
RSTConfig
() =
default
;
205
RSTConfig
(
const
SOLUTIONSection
& solution_section,
206
const
ParseContext
& parseContext,
207
bool
compositional_arg,
208
ErrorGuard
& errors);
209
210
void
update(
const
DeckKeyword
& keyword,
211
const
ParseContext
& parseContext,
212
ErrorGuard
& errors);
213
214
static
RSTConfig
first(
const
RSTConfig
& src);
215
static
RSTConfig
serializationTestObject();
216
217
template
<
class
Serializer>
218
void
serializeOp(
Serializer
& serializer)
219
{
220
serializer(write_rst_file);
221
serializer(keywords);
222
serializer(basic);
223
serializer(freq);
224
serializer(save);
225
serializer(compositional);
226
serializer(this->solution_only_keywords);
227
}
228
229
bool
operator==(
const
RSTConfig
& other)
const
;
230
231
std::optional<bool> write_rst_file{};
232
std::map<std::string, int> keywords{};
233
std::optional<int> basic{};
234
std::optional<int> freq{};
235
bool
save {
false
};
236
bool
compositional {
false
};
237
238
private
:
239
std::unordered_set<std::string> solution_only_keywords{};
240
241
void
handleRPTSOL(
const
DeckKeyword
& keyword,
242
const
ParseContext
& parse_context,
243
ErrorGuard
& errors);
244
245
void
handleRPTRST(
const
DeckKeyword
& keyword,
246
const
ParseContext
& parse_context,
247
ErrorGuard
& errors);
248
249
void
handleRPTRSTSOLUTION(
const
DeckKeyword
& keyword,
250
const
ParseContext
& parse_context,
251
ErrorGuard
& errors);
252
253
void
handleRPTSCHED(
const
DeckKeyword
& keyword,
254
const
ParseContext
& parse_context,
255
ErrorGuard
& errors);
256
257
void
update_schedule(
const
std::pair<std::optional<int>, std::optional<int>>& basic_freq);
258
};
259
260
}
// namespace Opm
261
262
#endif // OPM_RST_CONFIG_HPP
Opm::SOLUTIONSection
Definition:
DeckSection.hpp:135
Opm::RSTConfig
Definition:
RSTConfig.hpp:201
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:94
Opm::DeckKeyword
Definition:
DeckKeyword.hpp:36
Opm::ErrorGuard
Definition:
ErrorGuard.hpp:30
opm
input
eclipse
Schedule
RSTConfig.hpp
Generated by
1.8.14