00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef OPM_SIMULATORBASE_HEADER_INCLUDED
00022 #define OPM_SIMULATORBASE_HEADER_INCLUDED
00023
00024 #include <opm/material/densead/Math.hpp>
00025 #include <opm/autodiff/DuneMatrix.hpp>
00026
00027 #include <opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp>
00028 #include <opm/core/utility/parameters/ParameterGroup.hpp>
00029 #include <opm/common/ErrorMacros.hpp>
00030
00031 #include <opm/autodiff/GeoProps.hpp>
00032 #include <opm/autodiff/BlackoilModel.hpp>
00033 #include <opm/autodiff/BlackoilPropsAdFromDeck.hpp>
00034 #include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
00035 #include <opm/autodiff/RateConverter.hpp>
00036
00037 #include <opm/core/grid.h>
00038 #include <opm/core/wells.h>
00039 #include <opm/core/well_controls.h>
00040 #include <opm/core/pressure/flow_bc.h>
00041
00042 #include <opm/core/simulator/SimulatorReport.hpp>
00043 #include <opm/simulators/timestepping/SimulatorTimer.hpp>
00044 #include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
00045 #include <opm/core/utility/StopWatch.hpp>
00046 #include <opm/core/utility/miscUtilities.hpp>
00047 #include <opm/core/utility/miscUtilitiesBlackoil.hpp>
00048
00049 #include <opm/core/props/rock/RockCompressibility.hpp>
00050
00051 #include <opm/core/simulator/BlackoilState.hpp>
00052 #include <opm/simulators/timestepping/AdaptiveTimeStepping.hpp>
00053 #include <opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.hpp>
00054
00055 #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
00056 #include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
00057 #include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
00058 #include <opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.hpp>
00059
00060
00061 #include <boost/filesystem.hpp>
00062 #include <boost/lexical_cast.hpp>
00063
00064 #include <algorithm>
00065 #include <cstddef>
00066 #include <cassert>
00067 #include <functional>
00068 #include <memory>
00069 #include <numeric>
00070 #include <fstream>
00071 #include <iostream>
00072 #include <string>
00073 #include <unordered_map>
00074 #include <utility>
00075 #include <vector>
00076
00077 namespace Opm
00078 {
00079
00080 template <class Simulator>
00081 struct SimulatorTraits;
00082
00084 template <class Implementation>
00085 class SimulatorBase
00086 {
00087 typedef SimulatorTraits<Implementation> Traits;
00088
00089 public:
00090 typedef typename Traits::ReservoirState ReservoirState;
00091 typedef typename Traits::WellState WellState;
00092 typedef typename Traits::OutputWriter OutputWriter;
00093 typedef typename Traits::Grid Grid;
00094 typedef typename Traits::Solver Solver;
00095 typedef typename Traits::WellModel WellModel;
00096
00124 SimulatorBase(const ParameterGroup& param,
00125 const Grid& grid,
00126 DerivedGeology& geo,
00127 BlackoilPropsAdFromDeck& props,
00128 const RockCompressibility* rock_comp_props,
00129 NewtonIterationBlackoilInterface& linsolver,
00130 const double* gravity,
00131 const bool disgas,
00132 const bool vapoil,
00133 std::shared_ptr<EclipseState> eclipse_state,
00134 OutputWriter& output_writer,
00135 const std::vector<double>& threshold_pressures_by_face,
00136 const std::unordered_set<std::string>& defunct_well_names);
00137
00144 SimulatorReport run(SimulatorTimer& timer,
00145 ReservoirState& state);
00146
00147 protected:
00148 Implementation& asImpl() { return *static_cast<Implementation*>(this); }
00149 const Implementation& asImpl() const { return *static_cast<const Implementation*>(this); }
00150
00151 void handleAdditionalWellInflow(SimulatorTimer& timer,
00152 WellsManager& wells_manager,
00153 WellState& well_state,
00154 const Wells* wells);
00155
00156 std::unique_ptr<Solver> createSolver(const WellModel& well_model);
00157
00158 void
00159 computeRESV(const std::size_t step,
00160 const Wells* wells,
00161 const BlackoilState& x,
00162 WellState& xw);
00163
00164 void
00165 FIPUnitConvert(const UnitSystem& units,
00166 std::vector<std::vector<double> >& fip);
00167
00168 void
00169 FIPUnitConvert(const UnitSystem& units,
00170 std::vector<double>& fip);
00171
00172 std::vector<double>
00173 FIPTotals(const std::vector<std::vector<double> >& fip, const ReservoirState& state);
00174
00175 void
00176 outputFluidInPlace(const std::vector<double>& oip, const std::vector<double>& cip, const UnitSystem& units, const int reg);
00177
00178
00179 void updateListEconLimited(const std::unique_ptr<Solver>& solver,
00180 const Schedule& schedule,
00181 const int current_step,
00182 const Wells* wells,
00183 const WellState& well_state,
00184 DynamicListEconLimited& list_econ_limited) const;
00185
00186 void initHysteresisParams(ReservoirState& state);
00187
00188
00189 typedef RateConverter::
00190 SurfaceToReservoirVoidage< BlackoilPropsAdFromDeck::FluidSystem,
00191 std::vector<int> > RateConverterType;
00192 typedef typename Traits::Model Model;
00193 typedef typename Model::ModelParameters ModelParameters;
00194 typedef typename Solver::SolverParameters SolverParameters;
00195
00196 const ParameterGroup param_;
00197 ModelParameters model_param_;
00198 SolverParameters solver_param_;
00199
00200
00201 const Grid& grid_;
00202 BlackoilPropsAdFromDeck& props_;
00203 const RockCompressibility* rock_comp_props_;
00204 const double* gravity_;
00205
00206 DerivedGeology& geo_;
00207 NewtonIterationBlackoilInterface& solver_;
00208
00209 std::vector<int> allcells_;
00210 const bool has_disgas_;
00211 const bool has_vapoil_;
00212 bool terminal_output_;
00213
00214 std::shared_ptr<EclipseState> eclipse_state_;
00215
00216 OutputWriter& output_writer_;
00217 RateConverterType rateConverter_;
00218
00219 std::vector<double> threshold_pressures_by_face_;
00220
00221 bool is_parallel_run_;
00222
00223
00224
00225 std::unordered_set<std::string> defunct_well_names_;
00226 };
00227
00228 }
00229
00230 #include "SimulatorBase_impl.hpp"
00231 #endif // OPM_SIMULATORBASE_HEADER_INCLUDED