From f0b363baa56f3eb4f34ecf945de6b5640f7a3316 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 22 Sep 2015 17:15:55 +0200 Subject: [PATCH] adding wells_multisegment_ member for multisegment model and also updating the createSolver() function. --- opm/autodiff/BlackoilMultiSegmentModel.hpp | 11 ++-- .../BlackoilMultiSegmentModel_impl.hpp | 57 +------------------ ...latorFullyImplicitBlackoilMultiSegment.hpp | 10 ++++ ...FullyImplicitBlackoilMultiSegment_impl.hpp | 30 +++++++++- 4 files changed, 48 insertions(+), 60 deletions(-) diff --git a/opm/autodiff/BlackoilMultiSegmentModel.hpp b/opm/autodiff/BlackoilMultiSegmentModel.hpp index c1b55bdcb..2c51d621b 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel.hpp @@ -84,7 +84,8 @@ namespace Opm { Opm::EclipseStateConstPtr eclState, const bool has_disgas, const bool has_vapoil, - const bool terminal_output); + const bool terminal_output, + const std::vector& wells_multisegment); /// Called once before each time step. /// \param[in] dt time step size @@ -171,13 +172,13 @@ namespace Opm { V well_perforatoin_cell_pressure_diffs_; - const std::vector wells_multi_segment_; + const std::vector wells_multisegment_; // return wells object // TODO: remove this wells structure using Base::wells; - const std::vector& wellsMultiSegment() const { return wells_multi_segment_; } + const std::vector& wellsMultiSegment() const { return wells_multisegment_; } SolutionState variableState(const ReservoirState& x, @@ -455,8 +456,8 @@ namespace Opm { }; /// Providing types by template specialisation of ModelTraits for BlackoilMultiSegmentModel. - template - struct ModelTraits< BlackoilMultiSegmentModel > + template + struct ModelTraits< BlackoilMultiSegmentModel > { typedef BlackoilState ReservoirState; typedef WellStateMultiSegment WellState; diff --git a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp index a1f0f3fc3..6dc653e57 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp @@ -72,7 +72,8 @@ namespace Opm { Opm::EclipseStateConstPtr eclState, const bool has_disgas, const bool has_vapoil, - const bool terminal_output) + const bool terminal_output, + const std::vector& wells_multisegment) : Base(param, grid, fluid, geo, rock_comp_props, wells_arg, linsolver, eclState, has_disgas, has_vapoil, terminal_output) // not all will be necessary eventually @@ -81,62 +82,10 @@ namespace Opm { , well_perforation_pressure_cell_diffs_adb_(ADB::null()) , well_perforation_cell_densities_adb_(ADB::null()) , well_perforations_segment_pressure_diffs_(ADB::null()) + , wells_multisegment_(wells_multisegment) { } - /* grid_ (grid) - , fluid_ (fluid) - , geo_ (geo) - , rock_comp_props_(rock_comp_props) - , wells_ (wells_arg) - , vfp_properties_(eclState->getTableManager()->getVFPInjTables(), eclState->getTableManager()->getVFPProdTables()) - , linsolver_ (linsolver) - , active_(detail::activePhases(fluid.phaseUsage())) - , canph_ (detail::active2Canonical(fluid.phaseUsage())) - , cells_ (detail::buildAllCells(Opm::AutoDiffGrid::numCells(grid))) - , ops_ (grid, eclState) - , wops_ (wells_) - , has_disgas_(has_disgas) - , has_vapoil_(has_vapoil) - , param_( param ) - , use_threshold_pressure_(false) - , rq_ (fluid.numPhases()) - , phaseCondition_(AutoDiffGrid::numCells(grid)) - , isRs_(V::Zero(AutoDiffGrid::numCells(grid))) - , isRv_(V::Zero(AutoDiffGrid::numCells(grid))) - , isSg_(V::Zero(AutoDiffGrid::numCells(grid))) - // , well_perforation_densities_adb_(ADB::null()) - // , well_perforation_pressure_diffs_adb_(ADB::null()) - // , well_perforation_pressure_cell_diffs_adb_(ADB::null()) - // , well_perforation_cell_densities_adb_(ADB::null()) - // , well_perforations_segment_pressure_diffs_(ADB::null()) - , residual_ ( { std::vector(fluid.numPhases(), ADB::null()), - ADB::null(), - ADB::null(), - { 1.1169, 1.0031, 0.0031 }} ) // the default magic numbers - , terminal_output_ (terminal_output) - { -#if HAVE_MPI - if ( linsolver_.parallelInformation().type() == typeid(ParallelISTLInformation) ) - { - const ParallelISTLInformation& info = - boost::any_cast(linsolver_.parallelInformation()); - if ( terminal_output_ ) { - // Only rank 0 does print to std::cout if terminal_output is enabled - terminal_output_ = (info.communicator().rank()==0); - } - int local_number_of_wells = wells_->number_of_wells; - int global_number_of_wells = info.communicator().sum(local_number_of_wells); - wells_active_ = ( global_number_of_wells > 0 ); - }else - { - wells_active_ = (wells_->number_of_wells > 0 ); - } -#else - wells_active_ = (wells_->number_of_wells > 0 ); -#endif - } */ - diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment.hpp index e3b295c0d..509d5a282 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment.hpp @@ -54,6 +54,7 @@ class SimulatorFullyImplicitBlackoilMultiSegment typedef SimulatorTraits Traits; typedef typename Traits::ReservoirState ReservoirState; typedef typename Traits::WellState WellState; + typedef typename Traits::Solver Solver; public: // forward the constructor to the base class SimulatorFullyImplicitBlackoilMultiSegment(const parameter::ParameterGroup& param, @@ -72,10 +73,14 @@ public: eclipse_state, output_writer, threshold_pressures_by_face) {} + SimulatorReport run(SimulatorTimer& timer, ReservoirState& state); protected: + + std::unique_ptr createSolver(const Wells* wells, std::vector& wells_multisegment); + using Base::output_writer_; using Base::param_; using Base::solver_; @@ -85,6 +90,11 @@ protected: using Base::props_; using Base::is_parallel_run_; using Base::allcells_; + using Base::model_param_; + using Base::geo_; + using Base::rock_comp_props_; + using Base::has_disgas_; + using Base::has_vapoil_; }; } // namespace Opm diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp index 8000c56a7..e123a96e1 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp @@ -23,6 +23,34 @@ namespace Opm { + template + auto SimulatorFullyImplicitBlackoilMultiSegment:: + createSolver(const Wells* wells, std::vector& wells_multisegment) + -> std::unique_ptr + { + typedef typename Traits::Model Model; + + auto model = std::unique_ptr(new Model(model_param_, + grid_, + props_, + geo_, + rock_comp_props_, + wells, + solver_, + eclipse_state_, + has_disgas_, + has_vapoil_, + terminal_output_, + wells_multisegment)); + + if (!Base::threshold_pressures_by_face_.empty()) { + model->setThresholdPressures(Base::threshold_pressures_by_face_); + } + + return std::unique_ptr(new Solver(Base::solver_param_, std::move(model))); + + } + template SimulatorReport SimulatorFullyImplicitBlackoilMultiSegment::run(SimulatorTimer& timer, ReservoirState& state) @@ -115,7 +143,7 @@ namespace Opm // Run a multiple steps of the solver depending on the time step control. solver_timer.start(); - auto solver = Base::asImpl().createSolver(wells); + auto solver = createSolver(wells, wells_multisegment); // If sub stepping is enabled allow the solver to sub cycle // in case the report steps are too large for the solver to converge