IOConfig.hpp
Go to the documentation of this file.
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 
26 
27 
28 namespace Opm {
29 
30  /*The IOConfig class holds data about input / ouput configurations
31 
32  Amongst these configuration settings, a IOConfig object knows if
33  a restart file should be written for a specific report step
34 
35  The write of restart files is governed by several eclipse keywords.
36  These keywords are all described in the eclipse manual, but some
37  of them are rather porly described there.
38  To have equal sets of restart files written from Eclipse and Flow for various
39  configurations, we have made a qualified guess on the behaviour
40  for some of the keywords (by running eclipse for different configurations,
41  and looked at which restart files that have been written).
42 
43 
44  ------ RPTSOL RESTART (solution section) ------
45  If RPTSOL RESTART > 1 initial restart file is written.
46 
47 
48  ------ RPTRST (solution section) ------
49  Eclipse manual states that the initial restart file is to be written
50  if RPTSOL RESTART > 1. But - due to that the initial restart file
51  is written from Eclipse for data where RPTSOL RESTART is not set, - we
52  have made a guess that when RPTRST is set in SOLUTION (no basic though...),
53  it means that the initial restart file should be written.
54  Running of eclipse with different settings have proven this to be a qualified guess.
55 
56 
57  ------ RPTRST BASIC=0 (solution or schedule section) ------
58  No restart files are written
59 
60 
61  ------ RPTRST BASIC=1 or RPTRST BASIC=2 (solution or schedule section) ------
62  Restart files are written for every timestep, from timestep 1 to number of timesteps.
63  (Write of inital timestep is governed by a separate setting)
64 
65  Notice! Eclipse simulator RPTRST BASIC=1 writes restart files for every
66  report step, but only keeps the last one written. This functionality is
67  not supported in Flow; so to compare Eclipse results with Flow results
68  for every report step, set RPTRST BASIC=2 for the eclipse run
69 
70 
71  ------ RPTRST BASIC=3 FREQ=n (solution or schedule section) ------
72  Restart files are created every nth report time. Default frequency is 1 (every report step)
73 
74  If a frequency higher than 1 is given:
75  start_rs = report step the setting was given.
76  write report step rstep if (rstep >= start_rs) && ((rstep % frequency) == 0).
77 
78 
79  ------ RPTRST BASIC=4 FREQ=n or RPTRST BASIC=5 FREQ=n (solution or schedule section) ------
80  For the settings BASIC 4 or BASIC 5, - first report step of every new year(4) or new month(5),
81  the first report step is compared with report step 0 (start), and then every report step is
82  compared with the previous one to see if year/month has changed.
83 
84  This leaves us with a set of timesteps.
85  All timesteps in the set that are higher or equal to the timestep the RPTRST keyword was set on is written.
86 
87  If in addition FREQUENCY is given (higher than 1), every n'the value of this set are to be written.
88 
89  If the setting BASIC=4 or BASIC=5 is set on a timestep that is a member of the set "first timestep of
90  each year" / "First timestep of each month", then the timestep that is freq-1 timesteps (within the set) from
91  this start timestep will be written, and then every n'the timestep (within the set) from this one will be written.
92 
93  If the setting BASIC=4 or BASIC=5 is set on a timestep that is not a member of the list "first timestep of
94  each year" / "First timestep of each month", then the list is searched for the closest timestep that are
95  larger than the timestep that introduced the setting, and then; same as above - the timestep that is freq-1
96  timesteps from this one (within the set) will be written, and then every n'the timestep (within the set) from
97  this one will be written.
98 
99 
100  ------ RPTRST BASIC=6 (solution or schedule section) ------
101  Not supported in Flow
102 
103 
104  ------ Default ------
105  If no keywords for config of writing restart files have been handled; no restart files are written.
106 
107  */
108 
109 
110 
111  class IOConfig {
112 
113  public:
114 
115  explicit IOConfig(const std::string& input_path = "");
116 
117 
118  bool getWriteRestartFile(size_t timestep) const;
119  bool getWriteEGRIDFile() const;
120  bool getWriteINITFile() const;
121  bool getUNIFOUT() const;
122  bool getUNIFIN() const;
123  bool getFMTIN() const;
124  bool getFMTOUT() const;
125  const std::string& getEclipseInputPath() const;
126 
127  void overrideRestartWriteInterval(size_t interval);
128 
129  void handleRPTRSTBasic(TimeMapConstPtr timemap,
130  size_t timestep,
131  size_t basic,
132  size_t frequency = 1,
133  bool update_default = false,
134  bool reset_global = false);
135  void handleRPTSCHEDRestart(TimeMapConstPtr timemap, size_t timestep, size_t restart);
136  void handleSolutionSection(TimeMapConstPtr timemap, std::shared_ptr<const SOLUTIONSection> solutionSection);
137  void handleGridSection(std::shared_ptr<const GRIDSection> gridSection);
138  void handleRunspecSection(std::shared_ptr<const RUNSPECSection> runspecSection);
139  void setWriteInitialRestartFile(bool writeInitialRestartFile);
140  boost::gregorian::date getTimestepDate(size_t timestep) const;
141  void dumpRestartConfig() const;
142 
143 
144 
145 
146  private:
147 
148  void assertTimeMap(TimeMapConstPtr timemap);
149  bool getWriteRestartFileFrequency(size_t timestep,
150  size_t start_timestep,
151  size_t frequency,
152  bool years = false,
153  bool months = false) const;
154  void handleRPTSOL(DeckKeywordConstPtr keyword);
155 
156 
157  TimeMapConstPtr m_timemap;
158  bool m_write_INIT_file;
159  bool m_write_EGRID_file;
160  bool m_write_initial_RST_file;
161  bool m_UNIFIN;
162  bool m_UNIFOUT;
163  bool m_FMTIN;
164  bool m_FMTOUT;
165  std::string m_eclipse_input_path;
166  bool m_ignore_RPTSCHED_RESTART;
167 
168 
169 
170  struct restartConfig {
171  /*
172  The content of this struct is logically divided in two; either the
173  restart behaviour is governed by { timestep , basic , frequency }, or
174  alternatively by { rptshec_restart_set , rptsched_restart }.
175 
176  The former triplet is mainly governed by the RPTRST keyword and the
177  latter pair by the RPTSCHED keyword.
178  */
179  size_t timestep;
180  size_t basic;
181  size_t frequency;
182  bool rptsched_restart_set;
183  size_t rptsched_restart;
184 
185  bool operator!=(const restartConfig& rhs) {
186  bool ret = true;
187  if ((this->timestep == rhs.timestep) &&
188  (this->basic == rhs.basic) &&
189  (this->frequency == rhs.frequency)) {
190  ret = false;
191  }
192  return ret;
193  }
194  };
195 
196 
197  std::shared_ptr<DynamicState<restartConfig>> m_restart_output_config;
198 
199 
200  };
201 
202 
203  typedef std::shared_ptr<IOConfig> IOConfigPtr;
204  typedef std::shared_ptr<const IOConfig> IOConfigConstPtr;
205 
206 } //namespace Opm
207 
208 
209 
210 #endif
const std::string & getEclipseInputPath() const
bool getWriteEGRIDFile() const
bool getUNIFOUT() const
std::shared_ptr< const IOConfig > IOConfigConstPtr
Definition: IOConfig.hpp:204
std::shared_ptr< const TimeMap > TimeMapConstPtr
Definition: TimeMap.hpp:77
Definition: Deck.hpp:29
std::shared_ptr< const DeckKeyword > DeckKeywordConstPtr
Definition: DeckKeyword.hpp:71
IOConfig(const std::string &input_path="")
void setWriteInitialRestartFile(bool writeInitialRestartFile)
Definition: IOConfig.hpp:111
bool getWriteINITFile() const
void handleRPTSCHEDRestart(TimeMapConstPtr timemap, size_t timestep, size_t restart)
bool getUNIFIN() const
void dumpRestartConfig() const
bool getFMTIN() const
boost::gregorian::date getTimestepDate(size_t timestep) const
void handleSolutionSection(TimeMapConstPtr timemap, std::shared_ptr< const SOLUTIONSection > solutionSection)
bool getWriteRestartFile(size_t timestep) const
bool getFMTOUT() const
void handleGridSection(std::shared_ptr< const GRIDSection > gridSection)
void overrideRestartWriteInterval(size_t interval)
void handleRunspecSection(std::shared_ptr< const RUNSPECSection > runspecSection)
std::shared_ptr< IOConfig > IOConfigPtr
Definition: IOConfig.hpp:203
void handleRPTRSTBasic(TimeMapConstPtr timemap, size_t timestep, size_t basic, size_t frequency=1, bool update_default=false, bool reset_global=false)