SimulatorBase.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2013 SINTEF ICT, Applied Mathematics.
3  Copyright 2015 Andreas Lauser
4 
5  This file is part of the Open Porous Media project (OPM).
6 
7  OPM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  OPM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef OPM_SIMULATORBASE_HEADER_INCLUDED
22 #define OPM_SIMULATORBASE_HEADER_INCLUDED
23 
25 #include <opm/core/utility/parameters/ParameterGroup.hpp>
26 #include <opm/common/ErrorMacros.hpp>
27 
34 
35 #include <opm/core/grid.h>
36 #include <opm/core/wells.h>
37 #include <opm/core/well_controls.h>
38 #include <opm/core/pressure/flow_bc.h>
39 
40 #include <opm/core/simulator/SimulatorReport.hpp>
41 #include <opm/core/simulator/SimulatorTimer.hpp>
42 #include <opm/core/simulator/AdaptiveSimulatorTimer.hpp>
43 #include <opm/core/utility/StopWatch.hpp>
44 #include <opm/core/io/vtk/writeVtkData.hpp>
45 #include <opm/core/utility/miscUtilities.hpp>
46 #include <opm/core/utility/miscUtilitiesBlackoil.hpp>
47 
48 #include <opm/core/props/rock/RockCompressibility.hpp>
49 
50 #include <opm/core/simulator/BlackoilState.hpp>
51 #include <opm/core/simulator/AdaptiveTimeStepping.hpp>
52 #include <opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.hpp>
53 
54 #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
55 #include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
56 #include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
57 #include <opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.hpp>
58 
59 
60 #include <boost/filesystem.hpp>
61 #include <boost/lexical_cast.hpp>
62 
63 #include <algorithm>
64 #include <cstddef>
65 #include <cassert>
66 #include <functional>
67 #include <memory>
68 #include <numeric>
69 #include <fstream>
70 #include <iostream>
71 #include <string>
72 #include <unordered_map>
73 #include <utility>
74 #include <vector>
75 
76 namespace Opm
77 {
78 
79  template <class Simulator>
81 
83  template <class Implementation>
85  {
87 
88  public:
90  typedef typename Traits::WellState WellState;
92  typedef typename Traits::Grid Grid;
93  typedef typename Traits::Solver Solver;
94 
122  SimulatorBase(const parameter::ParameterGroup& param,
123  const Grid& grid,
124  const DerivedGeology& geo,
126  const RockCompressibility* rock_comp_props,
128  const double* gravity,
129  const bool disgas,
130  const bool vapoil,
131  std::shared_ptr<EclipseState> eclipse_state,
132  OutputWriter& output_writer,
133  const std::vector<double>& threshold_pressures_by_face);
134 
142  SimulatorReport run(SimulatorTimer& timer,
143  ReservoirState& state);
144 
145  protected:
146  Implementation& asImpl() { return *static_cast<Implementation*>(this); }
147  const Implementation& asImpl() const { return *static_cast<const Implementation*>(this); }
148 
149  void handleAdditionalWellInflow(SimulatorTimer& timer,
150  WellsManager& wells_manager,
151  WellState& well_state,
152  const Wells* wells);
153 
154  std::unique_ptr<Solver> createSolver(const Wells* wells);
155 
156  void
157  computeRESV(const std::size_t step,
158  const Wells* wells,
159  const BlackoilState& x,
160  WellState& xw);
161 
162  // Data.
163  typedef RateConverter::
165  std::vector<int> > RateConverterType;
166  typedef typename Traits::Model Model;
169 
170  const parameter::ParameterGroup param_;
171  ModelParameters model_param_;
172  SolverParameters solver_param_;
173 
174  // Observed objects.
175  const Grid& grid_;
176  BlackoilPropsAdInterface& props_;
177  const RockCompressibility* rock_comp_props_;
178  const double* gravity_;
179  // Solvers
182  // Misc. data
183  std::vector<int> allcells_;
184  const bool has_disgas_;
185  const bool has_vapoil_;
187  // eclipse_state
188  std::shared_ptr<EclipseState> eclipse_state_;
189  // output_writer
190  OutputWriter& output_writer_;
191  RateConverterType rateConverter_;
192  // Threshold pressures.
193  std::vector<double> threshold_pressures_by_face_;
194  // Whether this a parallel simulation or not
196  };
197 
198 } // namespace Opm
199 
200 #include "SimulatorBase_impl.hpp"
201 #endif // OPM_SIMULATORBASE_HEADER_INCLUDED
Definition: GeoProps.hpp:53
GridT Grid
Definition: SimulatorFullyImplicitBlackoil.hpp:39
Definition: BlackoilPropsAdInterface.hpp:38
const double * gravity_
Definition: SimulatorBase.hpp:178
const RockCompressibility * rock_comp_props_
Definition: SimulatorBase.hpp:177
Definition: AdditionalObjectDeleter.hpp:22
ModelTraits< BlackoilModel< Grid > >::ModelParameters ModelParameters
Definition: BlackoilModelBase.hpp:108
const DerivedGeology & geo_
Definition: SimulatorBase.hpp:180
BlackoilState ReservoirState
Definition: SimulatorFullyImplicitBlackoil.hpp:37
Definition: WellStateFullyImplicitBlackoil.hpp:41
const Grid & grid_
Definition: SimulatorBase.hpp:175
Traits::Grid Grid
Definition: SimulatorBase.hpp:92
bool terminal_output_
Definition: SimulatorBase.hpp:186
SimulatorBase(const parameter::ParameterGroup &param, const Grid &grid, const DerivedGeology &geo, BlackoilPropsAdInterface &props, const RockCompressibility *rock_comp_props, NewtonIterationBlackoilInterface &linsolver, const double *gravity, const bool disgas, const bool vapoil, std::shared_ptr< EclipseState > eclipse_state, OutputWriter &output_writer, const std::vector< double > &threshold_pressures_by_face)
Definition: SimulatorBase_impl.hpp:28
Implementation & asImpl()
Definition: SimulatorBase.hpp:146
std::unique_ptr< Solver > createSolver(const Wells *wells)
Definition: SimulatorBase_impl.hpp:333
const Implementation & asImpl() const
Definition: SimulatorBase.hpp:147
Solver::SolverParameters SolverParameters
Definition: SimulatorBase.hpp:168
Traits::Solver Solver
Definition: SimulatorBase.hpp:93
RateConverterType rateConverter_
Definition: SimulatorBase.hpp:191
A Newton solver class suitable for general fully-implicit models.
Definition: NewtonSolver.hpp:33
Class collecting all necessary components for a two-phase simulation.
Definition: SimulatorBase.hpp:84
bool is_parallel_run_
Definition: SimulatorBase.hpp:195
void handleAdditionalWellInflow(SimulatorTimer &timer, WellsManager &wells_manager, WellState &well_state, const Wells *wells)
Definition: SimulatorBase_impl.hpp:326
Traits::OutputWriter OutputWriter
Definition: SimulatorBase.hpp:91
NewtonIterationBlackoilInterface & solver_
Definition: SimulatorBase.hpp:181
SolverParameters solver_param_
Definition: SimulatorBase.hpp:172
Traits::ReservoirState ReservoirState
Definition: SimulatorBase.hpp:89
Interface class for (linear) solvers for the fully implicit black-oil system.
Definition: NewtonIterationBlackoilInterface.hpp:31
Model::ModelParameters ModelParameters
Definition: SimulatorBase.hpp:167
std::vector< int > allcells_
Definition: SimulatorBase.hpp:183
const parameter::ParameterGroup param_
Definition: SimulatorBase.hpp:170
const bool has_disgas_
Definition: SimulatorBase.hpp:184
void computeRESV(const std::size_t step, const Wells *wells, const BlackoilState &x, WellState &xw)
Definition: SimulatorBase_impl.hpp:356
Definition: RateConverter.hpp:353
Traits::Model Model
Definition: SimulatorBase.hpp:166
Definition: SimulatorBase.hpp:80
RateConverter::SurfaceToReservoirVoidage< BlackoilPropsAdInterface, std::vector< int > > RateConverterType
Definition: SimulatorBase.hpp:165
BlackoilPropsAdInterface & props_
Definition: SimulatorBase.hpp:176
Wrapper class for VTK, Matlab, and ECL output.
Definition: SimulatorFullyImplicitBlackoilOutput.hpp:195
OutputWriter & output_writer_
Definition: SimulatorBase.hpp:190
Definition: BlackoilModel.hpp:43
std::shared_ptr< EclipseState > eclipse_state_
Definition: SimulatorBase.hpp:188
const bool has_vapoil_
Definition: SimulatorBase.hpp:185
ModelParameters model_param_
Definition: SimulatorBase.hpp:171
SimulatorReport run(SimulatorTimer &timer, ReservoirState &state)
Definition: SimulatorBase_impl.hpp:77
std::vector< double > threshold_pressures_by_face_
Definition: SimulatorBase.hpp:193
Definition: NewtonSolver.hpp:45
Traits::WellState WellState
Definition: SimulatorBase.hpp:90