My Project
IOConfig.hpp
1/*
2 Copyright 2015 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_IO_CONFIG_HPP
21#define OPM_IO_CONFIG_HPP
22
23#include <string>
24
25namespace Opm {
26
27 class Deck;
28 class GRIDSection;
29 class RUNSPECSection;
30
31 /*The IOConfig class holds data about input / output configurations
32
33 Amongst these configuration settings, a IOConfig object knows if
34 a restart file should be written for a specific report step
35
36 The write of restart files is governed by several eclipse keywords.
37 These keywords are all described in the eclipse manual, but some
38 of them are rather porly described there.
39 To have equal sets of restart files written from Eclipse and Flow for various
40 configurations, we have made a qualified guess on the behaviour
41 for some of the keywords (by running eclipse for different configurations,
42 and looked at which restart files that have been written).
43
44
45 ------ RPTSOL RESTART (solution section) ------
46 If RPTSOL RESTART > 1 initial restart file is written.
47
48
49 ------ RPTRST (solution section) ------
50 Eclipse manual states that the initial restart file is to be written
51 if RPTSOL RESTART > 1. But - due to that the initial restart file
52 is written from Eclipse for data where RPTSOL RESTART is not set, - we
53 have made a guess that when RPTRST is set in SOLUTION (no basic though...),
54 it means that the initial restart file should be written.
55 Running of eclipse with different settings have proven this to be a qualified guess.
56
57
58 ------ RPTRST BASIC=0 (solution or schedule section) ------
59 No restart files are written
60
61
62 ------ RPTRST BASIC=1 or RPTRST BASIC=2 (solution or schedule section) ------
63 Restart files are written for every timestep, from timestep 1 to number of timesteps.
64 (Write of inital timestep is governed by a separate setting)
65
66 Notice! Eclipse simulator RPTRST BASIC=1 writes restart files for every
67 report step, but only keeps the last one written. This functionality is
68 not supported in Flow; so to compare Eclipse results with Flow results
69 for every report step, set RPTRST BASIC=2 for the eclipse run
70
71
72 ------ RPTRST BASIC=3 FREQ=n (solution or schedule section) ------
73 Restart files are created every nth report time. Default frequency is 1 (every report step)
74
75 If a frequency higher than 1 is given:
76 start_rs = report step the setting was given.
77 write report step rstep if (rstep >= start_rs) && ((rstep % frequency) == 0).
78
79
80 ------ RPTRST BASIC=4 FREQ=n or RPTRST BASIC=5 FREQ=n (solution or schedule section) ------
81 For the settings BASIC 4 or BASIC 5, - first report step of every new year(4) or new month(5),
82 the first report step is compared with report step 0 (start), and then every report step is
83 compared with the previous one to see if year/month has changed.
84
85 This leaves us with a set of timesteps.
86 All timesteps in the set that are higher or equal to the timestep the RPTRST keyword was set on is written.
87
88 If in addition FREQUENCY is given (higher than 1), every n'the value of this set are to be written.
89
90 If the setting BASIC=4 or BASIC=5 is set on a timestep that is a member of the set "first timestep of
91 each year" / "First timestep of each month", then the timestep that is freq-1 timesteps (within the set) from
92 this start timestep will be written, and then every n'the timestep (within the set) from this one will be written.
93
94 If the setting BASIC=4 or BASIC=5 is set on a timestep that is not a member of the list "first timestep of
95 each year" / "First timestep of each month", then the list is searched for the closest timestep that are
96 larger than the timestep that introduced the setting, and then; same as above - the timestep that is freq-1
97 timesteps from this one (within the set) will be written, and then every n'the timestep (within the set) from
98 this one will be written.
99
100
101 ------ RPTRST BASIC=6 (solution or schedule section) ------
102 Not supported in Flow
103
104
105 ------ Default ------
106 If no keywords for config of writing restart files have been handled; no restart files are written.
107
108
109 ECL compatible restart
110 ======================
111
112 Unfortunately flow & eclipse are not compatible across restarts. The
113 RestartIO implementation can write restart files for flow -> flow restart
114 or alternatively for flow -> eclipse restart. This is regulated by the
115 boolean flag ecl_compatible_restart in the IOConfig class. The difference
116 between the two are as follows:
117
118 ecl_compatible_restart = false:
119
120 1. The 'extra' fields in the RestartValue structure are actually
121 written to disk.
122
123 2. You can optionally ask the RestartIO::save() function to save the
124 solution in double precision.
125
126 3. The RestartIO::save() function will save opm specific vector OPM_IWEL
127 and OPM_XWEL.
128
129 ecl_compatible_restart = true:
130
131 1. The 'extra' fields in the RestartValue are silently ignored.
132
133 2. If request double precision solution data that is silently ignored,
134 it will be float.
135
136 3. The OPM_IWEL and OPM_XWEL vectors will not be written.
137
138 Observe that the solution data in the RestartValue is passed
139 unconditionally to the solution section in the restart file, so if you
140 pass a field in the solution section which Eclipse does not recognize you
141 will end up with a restart file which Eclipse can not read, even if you
142 have set ecl_compatible_restart to true.
143 */
144
145
146
147 class IOConfig {
148
149 public:
150
151 IOConfig() = default;
152 explicit IOConfig( const Deck& );
153 explicit IOConfig( const std::string& input_path );
154
155 static IOConfig serializationTestObject();
156
157 void setEclCompatibleRST(bool ecl_rst);
158 bool getEclCompatibleRST() const;
159 bool getWriteEGRIDFile() const;
160 bool getWriteINITFile() const;
161 bool getUNIFOUT() const;
162 bool getUNIFIN() const;
163 bool getFMTIN() const;
164 bool getFMTOUT() const;
165 const std::string& getEclipseInputPath() const;
166
167 void overrideNOSIM(bool nosim);
168 void consistentFileFlags();
169
170 std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const;
171
172 bool getOutputEnabled() const;
173 void setOutputEnabled(bool enabled);
174
175 std::string getOutputDir() const;
176 void setOutputDir(const std::string& outputDir);
177
178 const std::string& getBaseName() const;
179 void setBaseName(const std::string& baseName);
180
183 std::string fullBasePath( ) const;
184
185 std::string getInputDir() const;
186
187 bool initOnly() const;
188
189 bool operator==(const IOConfig& data) const;
190 static bool rst_cmp(const IOConfig& full_config, const IOConfig& rst_config);
191
192
193 template<class Serializer>
194 void serializeOp(Serializer& serializer)
195 {
196 serializer(m_write_INIT_file);
197 serializer(m_write_EGRID_file);
198 serializer(m_UNIFIN);
199 serializer(m_UNIFOUT);
200 serializer(m_FMTIN);
201 serializer(m_FMTOUT);
202 serializer(m_deck_filename);
203 serializer(m_output_enabled);
204 serializer(m_output_dir);
205 serializer(m_nosim);
206 serializer(m_base_name);
207 serializer(ecl_compatible_rst);
208 }
209
210 private:
211 bool m_write_INIT_file = false;
212 bool m_write_EGRID_file = true;
213 bool m_UNIFIN = false;
214 bool m_UNIFOUT = false;
215 bool m_FMTIN = false;
216 bool m_FMTOUT = false;
217 std::string m_deck_filename;
218 bool m_output_enabled = true;
219 std::string m_output_dir;
220 bool m_nosim;
221 std::string m_base_name;
222 bool ecl_compatible_rst = true;
223
224 IOConfig( const GRIDSection&,
225 const RUNSPECSection&,
226 bool nosim,
227 const std::string& input_path );
228
229 };
230
231} //namespace Opm
232
233
234
235#endif
Definition: Deck.hpp:49
Definition: DeckSection.hpp:119
Definition: IOConfig.hpp:147
std::string fullBasePath() const
Return a string consisting of outputpath and basename; i.e.
Definition: DeckSection.hpp:114
Class for (de-)serializing.
Definition: Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30