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
24#include <opm/core/utility/Event.hpp>
25#include <opm/core/utility/share_obj.hpp>
26
27#include <memory> // unique_ptr, shared_ptr
28#include <vector>
29
30struct UnstructuredGrid;
31
32namespace Opm {
33
34// forward definitions
35class Deck;
36class EclipseState;
37class OutputWriter;
38
39namespace parameter { class ParameterGroup; }
40class SimulationDataContainer;
41class SimulatorTimer;
42class TimeMap;
43class WellState;
44struct PhaseUsage;
45
53protected:
59 SimulatorOutputBase (const parameter::ParameterGroup& p,
60 std::shared_ptr <const EclipseState> eclipseState,
61 const Opm::PhaseUsage &phaseUsage,
62 std::shared_ptr <const UnstructuredGrid> grid,
63 std::shared_ptr <const SimulatorTimer> timer,
64 std::shared_ptr <const SimulationDataContainer> state,
65 std::shared_ptr <const WellState> wellState);
66
72
79 operator std::function <void ()> ();
80
82 std::shared_ptr <const SimulatorTimer> timer_;
83 std::shared_ptr <const TimeMap> timeMap_;
84 std::shared_ptr <const SimulationDataContainer> reservoirState_;
85 std::shared_ptr <const WellState> wellState_;
86
88 std::unique_ptr <OutputWriter> writer_;
89
91 virtual void writeOutput ();
92
94 virtual void sync ();
95
96private:
98 std::vector <double>::size_type next_;
99
101 std::vector <double> times_;
102};
103
146template <typename Simulator>
148 SimulatorOutput (const parameter::ParameterGroup& params,
149 std::shared_ptr <const EclipseState> eclipseState,
150 const Opm::PhaseUsage &phaseUsage,
151 std::shared_ptr <const UnstructuredGrid> grid,
152 std::shared_ptr <const SimulatorTimer> timer,
153 std::shared_ptr <const SimulationDataContainer> state,
154 std::shared_ptr <const WellState> wellState,
155 std::shared_ptr <Simulator> sim)
156 // send all other parameters to base class
157 : SimulatorOutputBase (params, eclipseState, phaseUsage,
158 grid, timer, state, wellState)
159
160 // store reference to simulator in derived class
161 , sim_ (sim) {
162
163 // connect simulation with output writer
164 sim->timestep_completed ().add (*this);
165 }
166
172 SimulatorOutput (const parameter::ParameterGroup& params,
173 const EclipseState& eclipseState,
174 const Opm::PhaseUsage &phaseUsage,
175 const UnstructuredGrid& grid,
176 const SimulatorTimer& timer,
177 const SimulationDataContainer& state,
178 const WellState& wellState,
179 Simulator& sim)
180 // send all other parameters to base class
181 : SimulatorOutputBase (params,
182 share_obj (eclipseState),
183 phaseUsage,
184 share_obj (grid),
185 share_obj (timer),
186 share_obj (state),
187 share_obj (wellState))
188
189 // store reference to simulator in derived class
190 , sim_ (share_obj (sim)) {
191
192 // connect simulation with output writer
193 sim_->timestep_completed ().add (*this);
194 }
195protected:
196 // forward this request to the simulator
197 virtual void sync () { sim_->sync (); }
198
199private:
201 std::shared_ptr <Simulator> sim_;
202};
203
204}
205
206#endif /* OPM_SIMULATOR_OUTPUT_HPP */
Definition: SimulatorOutput.hpp:52
std::unique_ptr< OutputWriter > writer_
Created locally and destructed together with us.
Definition: SimulatorOutput.hpp:88
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 SimulationDataContainer > state, std::shared_ptr< const WellState > wellState)
std::shared_ptr< const SimulationDataContainer > reservoirState_
Definition: SimulatorOutput.hpp:84
std::shared_ptr< const SimulatorTimer > timer_
Just hold a reference to these objects that are owned elsewhere.
Definition: SimulatorOutput.hpp:82
std::shared_ptr< const WellState > wellState_
Definition: SimulatorOutput.hpp:85
virtual void sync()
Make sure that the simulator state is up to date before writing.
std::shared_ptr< const TimeMap > timeMap_
Definition: SimulatorOutput.hpp:83
virtual void writeOutput()
Call the writers that were created based on the parameters.
Definition: opmfwd.hpp:15
Definition: SimulatorOutput.hpp:147
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 SimulationDataContainer > state, std::shared_ptr< const WellState > wellState, std::shared_ptr< Simulator > sim)
Definition: SimulatorOutput.hpp:148
virtual void sync()
Make sure that the simulator state is up to date before writing.
Definition: SimulatorOutput.hpp:197
SimulatorOutput(const parameter::ParameterGroup &params, const EclipseState &eclipseState, const Opm::PhaseUsage &phaseUsage, const UnstructuredGrid &grid, const SimulatorTimer &timer, const SimulationDataContainer &state, const WellState &wellState, Simulator &sim)
Definition: SimulatorOutput.hpp:172
Definition: simulator.hpp:31