mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-08-26 14:57:12 -05:00
refactoring the construcor of MultisegmentWells
MultisegmentWells is initialized with Wells structure.
This commit is contained in:
@@ -91,7 +91,7 @@ namespace Opm {
|
||||
const bool has_disgas,
|
||||
const bool has_vapoil,
|
||||
const bool terminal_output,
|
||||
const std::vector<WellMultiSegmentConstPtr>& wells_multisegment);
|
||||
const MultisegmentWells& multisegment_wells);
|
||||
|
||||
/// Called once before each time step.
|
||||
/// \param[in] dt time step size
|
||||
|
||||
@@ -68,10 +68,10 @@ namespace Opm {
|
||||
const bool has_disgas,
|
||||
const bool has_vapoil,
|
||||
const bool terminal_output,
|
||||
const std::vector<WellMultiSegmentConstPtr>& wells_multisegment)
|
||||
const MultisegmentWells& multisegment_wells)
|
||||
: Base(param, grid, fluid, geo, rock_comp_props, wells_arg, linsolver,
|
||||
eclState, has_disgas, has_vapoil, terminal_output)
|
||||
, ms_wells_(wells_multisegment)
|
||||
, ms_wells_(multisegment_wells)
|
||||
{
|
||||
ms_wells_.init(&fluid_, &active_, &phaseCondition_);
|
||||
}
|
||||
|
||||
@@ -140,10 +140,12 @@ namespace Opm {
|
||||
|
||||
|
||||
MultisegmentWells::
|
||||
MultisegmentWells(const std::vector<WellMultiSegmentConstPtr>& wells_ms)
|
||||
: wells_multisegment_(wells_ms)
|
||||
, wops_ms_(wells_ms)
|
||||
, num_phases_(wells_ms.empty()? 0 : wells_ms[0]->numberOfPhases())
|
||||
MultisegmentWells(const Wells* wells_arg,
|
||||
const std::vector<WellConstPtr>& wells_ecl,
|
||||
const int time_step)
|
||||
: wells_multisegment_( createMSWellVector(wells_arg, wells_ecl, time_step) )
|
||||
, wops_ms_(wells_multisegment_)
|
||||
, num_phases_(wells_arg ? wells_arg->number_of_phases : 0)
|
||||
, well_segment_perforation_pressure_diffs_(ADB::null())
|
||||
, well_segment_densities_(ADB::null())
|
||||
, well_segment_pressures_delta_(ADB::null())
|
||||
@@ -172,6 +174,48 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
std::vector<WellMultiSegmentConstPtr>
|
||||
MultisegmentWells::createMSWellVector(const Wells* wells_arg,
|
||||
const std::vector<WellConstPtr>& wells_ecl,
|
||||
const int time_step)
|
||||
{
|
||||
std::vector<WellMultiSegmentConstPtr> wells_multisegment;
|
||||
|
||||
if (wells_arg) {
|
||||
// number of wells in wells_arg structure
|
||||
const int nw = wells_arg->number_of_wells;
|
||||
// number of wells in EclipseState
|
||||
const int nw_ecl = wells_ecl.size();
|
||||
|
||||
wells_multisegment.reserve(nw);
|
||||
|
||||
for(int i = 0; i < nw_ecl; ++i) {
|
||||
// not processing SHUT wells
|
||||
if (wells_ecl[i]->getStatus(time_step) == WellCommon::SHUT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// checking if the well can be found in the wells
|
||||
const std::string& well_name = wells_ecl[i]->name();
|
||||
int index_well;
|
||||
for (index_well = 0; index_well < nw; ++index_well) {
|
||||
if (well_name == std::string(wells_arg->name[index_well])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index_well != nw) { // found in the wells
|
||||
wells_multisegment.push_back(std::make_shared<WellMultiSegment>(wells_ecl[i], time_step, wells_arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
return wells_multisegment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
MultisegmentWells::init(const BlackoilPropsAdInterface* fluid_arg,
|
||||
const std::vector<bool>* active_arg,
|
||||
|
||||
@@ -80,7 +80,13 @@ namespace Opm {
|
||||
// --------- Public methods ---------
|
||||
// TODO: using a vector of WellMultiSegmentConstPtr for now
|
||||
// TODO: it should use const Wells or something else later.
|
||||
MultisegmentWells(const std::vector<WellMultiSegmentConstPtr>& wells_multisegment);
|
||||
MultisegmentWells(const Wells* wells_arg,
|
||||
const std::vector<WellConstPtr>& wells_ecl,
|
||||
const int time_step);
|
||||
|
||||
std::vector<WellMultiSegmentConstPtr> createMSWellVector(const Wells* wells_arg,
|
||||
const std::vector<WellConstPtr>& wells_ecl,
|
||||
const int time_step);
|
||||
|
||||
void init(const BlackoilPropsAdInterface* fluid_arg,
|
||||
const std::vector<bool>* active_arg,
|
||||
@@ -174,8 +180,8 @@ namespace Opm {
|
||||
|
||||
protected:
|
||||
// TODO: probably a wells_active_ will be required here.
|
||||
const std::vector<WellMultiSegmentConstPtr> wells_multisegment_;
|
||||
const MultisegmentWellOps wops_ms_;
|
||||
std::vector<WellMultiSegmentConstPtr> wells_multisegment_;
|
||||
MultisegmentWellOps wops_ms_;
|
||||
const int num_phases_;
|
||||
int nseg_total_;
|
||||
int nperf_total_;
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
std::unique_ptr<Solver> createSolver(const Wells* wells, std::vector<WellMultiSegmentConstPtr>& wells_multisegment);
|
||||
std::unique_ptr<Solver> createSolver(const Wells* wells, const MultisegmentWells& multisegment_wells);
|
||||
|
||||
using Base::output_writer_;
|
||||
using Base::param_;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Opm
|
||||
|
||||
template <class GridT>
|
||||
auto SimulatorFullyImplicitBlackoilMultiSegment<GridT>::
|
||||
createSolver(const Wells* wells, std::vector<WellMultiSegmentConstPtr>& wells_multisegment)
|
||||
createSolver(const Wells* wells, const MultisegmentWells& multisegment_wells)
|
||||
-> std::unique_ptr<Solver>
|
||||
{
|
||||
typedef typename Traits::Model Model;
|
||||
@@ -41,7 +41,7 @@ namespace Opm
|
||||
has_disgas_,
|
||||
has_vapoil_,
|
||||
terminal_output_,
|
||||
wells_multisegment));
|
||||
multisegment_wells));
|
||||
|
||||
if (!Base::threshold_pressures_by_face_.empty()) {
|
||||
model->setThresholdPressures(Base::threshold_pressures_by_face_);
|
||||
@@ -112,30 +112,11 @@ namespace Opm
|
||||
// well_state.init(wells, state, prev_well_state);
|
||||
|
||||
const std::vector<WellConstPtr>& wells_ecl = eclipse_state_->getSchedule()->getWells(timer.currentStepNum());
|
||||
std::vector<WellMultiSegmentConstPtr> wells_multisegment;
|
||||
wells_multisegment.reserve(wells_ecl.size());
|
||||
for (size_t i = 0; i < wells_ecl.size(); ++i) {
|
||||
// not processing SHUT wells.
|
||||
if (wells_ecl[i]->getStatus(timer.currentStepNum()) == WellCommon::SHUT) {
|
||||
continue;
|
||||
}
|
||||
// checking if the well can be found in the wells
|
||||
const std::string& well_name = wells_ecl[i]->name();
|
||||
// number of wells in wells
|
||||
const int nw_wells = wells->number_of_wells;
|
||||
int index_well;
|
||||
for (index_well = 0; index_well < nw_wells; ++index_well) {
|
||||
if (well_name == std::string(wells->name[index_well])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const int current_time_step = timer.currentStepNum();
|
||||
|
||||
if (index_well != nw_wells) { // found in the wells
|
||||
wells_multisegment.push_back(std::make_shared<WellMultiSegment>(wells_ecl[i], timer.currentStepNum(), wells));
|
||||
}
|
||||
}
|
||||
const MultisegmentWells multisegment_wells(wells, wells_ecl, current_time_step);
|
||||
|
||||
well_state.init(wells_multisegment, state, prev_well_state);
|
||||
well_state.init(multisegment_wells, state, prev_well_state);
|
||||
|
||||
// give the polymer and surfactant simulators the chance to do their stuff
|
||||
Base::asImpl().handleAdditionalWellInflow(timer, wells_manager, well_state, wells);
|
||||
@@ -153,7 +134,7 @@ namespace Opm
|
||||
// Run a multiple steps of the solver depending on the time step control.
|
||||
solver_timer.start();
|
||||
|
||||
auto solver = createSolver(wells, wells_multisegment);
|
||||
auto solver = createSolver(wells, multisegment_wells);
|
||||
|
||||
// If sub stepping is enabled allow the solver to sub cycle
|
||||
// in case the report steps are too large for the solver to converge
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include <opm/core/well_controls.h>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/autodiff/AutoDiffBlock.hpp>
|
||||
#include <opm/autodiff/WellMultiSegment.hpp>
|
||||
// #include <opm/autodiff/WellMultiSegment.hpp>
|
||||
#include <opm/autodiff/MultisegmentWells.hpp>
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
@@ -64,8 +65,9 @@ namespace Opm
|
||||
/// to give useful initial values to the bhp(), wellRates()
|
||||
/// and perfPhaseRates() fields, depending on controls
|
||||
template <class ReservoirState, class PrevWellState>
|
||||
void init(const std::vector<WellMultiSegmentConstPtr>& wells, const ReservoirState& state, const PrevWellState& prevState)
|
||||
void init(const MultisegmentWells& ms_wells, const ReservoirState& state, const PrevWellState& prevState)
|
||||
{
|
||||
const std::vector<WellMultiSegmentConstPtr>& wells = ms_wells.wells();
|
||||
const int nw = wells.size();
|
||||
nseg_ = 0;
|
||||
nperf_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user