move loadRestartSegmentData into BlackoilWellModelRestart

This commit is contained in:
Arne Morten Kvarving
2022-10-24 09:36:05 +02:00
parent 0b32c1afd9
commit 09c1127c34
4 changed files with 39 additions and 38 deletions

View File

@@ -415,38 +415,6 @@ getWellEcl(const std::string& well_name) const
return *well_ecl;
}
void
BlackoilWellModelGeneric::
loadRestartSegmentData(const std::string& well_name,
const std::vector<data::Rates::opt>& phs,
const data::Well& rst_well,
SingleWellState& ws)
{
const auto& segment_set = this->getWellEcl(well_name).getSegments();
const auto& rst_segments = rst_well.segments;
// \Note: Eventually we need to handle the situations that some segments are shut
assert(0u + segment_set.size() == rst_segments.size());
const auto np = phs.size();
const auto pres_idx = data::SegmentPressures::Value::Pressure;
auto& segments = ws.segments;
auto& segment_pressure = segments.pressure;
auto& segment_rates = segments.rates;
for (const auto& [segNum, rst_segment] : rst_segments) {
const int segment_index = segment_set.segmentNumberToIndex(segNum);
// Recovering segment rates and pressure from the restart values
segment_pressure[segment_index] = rst_segment.pressures[pres_idx];
const auto& rst_segment_rates = rst_segment.rates;
for (auto p = 0*np; p < np; ++p) {
segment_rates[segment_index*np + p] = rst_segment_rates.get(phs[p]);
}
}
}
void
BlackoilWellModelGeneric::
loadRestartWellData(const std::string& well_name,
@@ -477,7 +445,7 @@ loadRestartWellData(const std::string& well_name,
BlackoilWellModelRestart(*this).loadRestartConnectionData(phs, rst_well, old_perf_data, ws);
if (handle_ms_well && !rst_well.segments.empty()) {
this->loadRestartSegmentData(well_name, phs, rst_well, ws);
BlackoilWellModelRestart(*this).loadRestartSegmentData(well_name, phs, rst_well, ws);
}
}

View File

@@ -286,11 +286,6 @@ protected:
std::map<std::string, data::GroupData>& gvalues) const;
void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues) const;
void loadRestartSegmentData(const std::string& well_name,
const std::vector<data::Rates::opt>& phs,
const data::Well& rst_well,
SingleWellState& ws);
void loadRestartWellData(const std::string& well_name,
const bool handle_ms_well,
const std::vector<data::Rates::opt>& phs,

View File

@@ -23,6 +23,7 @@
#include <config.h>
#include <opm/simulators/wells/BlackoilWellModelRestart.hpp>
#include <opm/simulators/wells/BlackoilWellModelGeneric.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <opm/simulators/wells/SingleWellState.hpp>
@@ -52,4 +53,35 @@ loadRestartConnectionData(const std::vector<data::Rates::opt>& phs,
}
}
void BlackoilWellModelRestart::
loadRestartSegmentData(const std::string& well_name,
const std::vector<data::Rates::opt>& phs,
const data::Well& rst_well,
SingleWellState& ws) const
{
const auto& segment_set = wellModel_.getWellEcl(well_name).getSegments();
const auto& rst_segments = rst_well.segments;
// \Note: Eventually we need to handle the situations that some segments are shut
assert(0u + segment_set.size() == rst_segments.size());
const auto np = phs.size();
const auto pres_idx = data::SegmentPressures::Value::Pressure;
auto& segments = ws.segments;
auto& segment_pressure = segments.pressure;
auto& segment_rates = segments.rates;
for (const auto& [segNum, rst_segment] : rst_segments) {
const int segment_index = segment_set.segmentNumberToIndex(segNum);
// Recovering segment rates and pressure from the restart values
segment_pressure[segment_index] = rst_segment.pressures[pres_idx];
const auto& rst_segment_rates = rst_segment.rates;
for (auto p = 0*np; p < np; ++p) {
segment_rates[segment_index*np + p] = rst_segment_rates.get(phs[p]);
}
}
}
} // namespace Opm

View File

@@ -48,6 +48,12 @@ public:
const std::vector<PerforationData>& old_perf_data,
SingleWellState& ws) const;
//! \brief Loads per-segment data from restart structures.
void loadRestartSegmentData(const std::string& well_name,
const std::vector<data::Rates::opt>& phs,
const data::Well& rst_well,
SingleWellState& ws) const;
private:
const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model
};