SimulatorOutput.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013 Uni Research AS
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_SIMULATOR_OUTPUT_HPP
21 #define OPM_SIMULATOR_OUTPUT_HPP
22 
23 // need complete def. of this since we use it in template
26 
27 #include <memory> // unique_ptr, shared_ptr
28 #include <vector>
29 
30 struct UnstructuredGrid;
31 
32 namespace Opm {
33 
34 // forward definitions
35 class Deck;
36 class EclipseState;
37 class OutputWriter;
38 namespace parameter { class ParameterGroup; }
39 class SimulatorState;
40 class SimulatorTimer;
41 class TimeMap;
42 class WellState;
43 struct PhaseUsage;
44 
52 protected:
59  std::shared_ptr <const EclipseState> eclipseState,
60  const Opm::PhaseUsage &phaseUsage,
61  std::shared_ptr <const UnstructuredGrid> grid,
62  std::shared_ptr <const SimulatorTimer> timer,
63  std::shared_ptr <const SimulatorState> state,
64  std::shared_ptr <const WellState> wellState);
65 
70  virtual ~SimulatorOutputBase ();
71 
78  operator std::function <void ()> ();
79 
81  std::shared_ptr <const SimulatorTimer> timer_;
82  std::shared_ptr <const TimeMap> timeMap_;
83  std::shared_ptr <const SimulatorState> reservoirState_;
84  std::shared_ptr <const WellState> wellState_;
85 
87  std::unique_ptr <OutputWriter> writer_;
88 
90  virtual void writeOutput ();
91 
93  virtual void sync ();
94 
95 private:
97  std::vector <double>::size_type next_;
98 
100  std::vector <double> times_;
101 };
102 
145 template <typename Simulator>
148  std::shared_ptr <const EclipseState> eclipseState,
149  const Opm::PhaseUsage &phaseUsage,
150  std::shared_ptr <const UnstructuredGrid> grid,
151  std::shared_ptr <const SimulatorTimer> timer,
152  std::shared_ptr <const SimulatorState> state,
153  std::shared_ptr <const WellState> wellState,
154  std::shared_ptr <Simulator> sim)
155  // send all other parameters to base class
156  : SimulatorOutputBase (params, eclipseState, phaseUsage,
157  grid, timer, state, wellState)
158 
159  // store reference to simulator in derived class
160  , sim_ (sim) {
161 
162  // connect simulation with output writer
163  sim->timestep_completed ().add (*this);
164  }
165 
172  const EclipseState& eclipseState,
173  const Opm::PhaseUsage &phaseUsage,
174  const UnstructuredGrid& grid,
175  const SimulatorTimer& timer,
176  const SimulatorState& state,
177  const WellState& wellState,
178  Simulator& sim)
179  // send all other parameters to base class
180  : SimulatorOutputBase (params,
181  share_obj (eclipseState),
182  phaseUsage,
183  share_obj (grid),
184  share_obj (timer),
185  share_obj (state),
186  share_obj (wellState))
187 
188  // store reference to simulator in derived class
189  , sim_ (share_obj (sim)) {
190 
191  // connect simulation with output writer
192  sim_->timestep_completed ().add (*this);
193  }
194 protected:
195  // forward this request to the simulator
196  virtual void sync () { sim_->sync (); }
197 
198 private:
200  std::shared_ptr <Simulator> sim_;
201 };
202 
203 }
204 
205 #endif /* OPM_SIMULATOR_OUTPUT_HPP */
Definition: grid.h:98
Definition: AnisotropicEikonal.hpp:43
Definition: ParameterGroup.hpp:109
Definition: SimulatorOutput.hpp:51
std::shared_ptr< const SimulatorTimer > timer_
Just hold a reference to these objects that are owned elsewhere.
Definition: SimulatorOutput.hpp:81
Definition: SimulatorOutput.hpp:146
Definition: SimulatorState.hpp:16
std::shared_ptr< const WellState > wellState_
Definition: SimulatorOutput.hpp:84
std::unique_ptr< OutputWriter > writer_
Created locally and destructed together with us.
Definition: SimulatorOutput.hpp:87
std::shared_ptr< T > share_obj(T &t)
Definition: share_obj.hpp:43
SimulatorOutputBase(const parameter::ParameterGroup &p, std::shared_ptr< const EclipseState > eclipseState, const Opm::PhaseUsage &phaseUsage, std::shared_ptr< const UnstructuredGrid > grid, std::shared_ptr< const SimulatorTimer > timer, std::shared_ptr< const SimulatorState > state, std::shared_ptr< const WellState > wellState)
SimulatorOutput(const parameter::ParameterGroup &params, const EclipseState &eclipseState, const Opm::PhaseUsage &phaseUsage, const UnstructuredGrid &grid, const SimulatorTimer &timer, const SimulatorState &state, const WellState &wellState, Simulator &sim)
Definition: SimulatorOutput.hpp:171
SimulatorOutput(const parameter::ParameterGroup &params, std::shared_ptr< const EclipseState > eclipseState, const Opm::PhaseUsage &phaseUsage, std::shared_ptr< const UnstructuredGrid > grid, std::shared_ptr< const SimulatorTimer > timer, std::shared_ptr< const SimulatorState > state, std::shared_ptr< const WellState > wellState, std::shared_ptr< Simulator > sim)
Definition: SimulatorOutput.hpp:147
The state of a set of wells.
Definition: WellState.hpp:36
std::shared_ptr< const TimeMap > timeMap_
Definition: SimulatorOutput.hpp:82
Definition: SimulatorTimer.hpp:34
virtual void writeOutput()
Call the writers that were created based on the parameters.
virtual void sync()
Make sure that the simulator state is up to date before writing.
Definition: SimulatorOutput.hpp:196
std::shared_ptr< const SimulatorState > reservoirState_
Definition: SimulatorOutput.hpp:83
const UnstructuredGrid & grid
Definition: ColumnExtract.hpp:31
Definition: BlackoilPhases.hpp:36
virtual void sync()
Make sure that the simulator state is up to date before writing.