move segment_inlets_ to MultisegmentWellSegments

This commit is contained in:
Arne Morten Kvarving 2022-12-19 13:52:21 +01:00
parent 2766427df0
commit 5755c94256
8 changed files with 37 additions and 39 deletions

View File

@ -51,6 +51,7 @@ void MultisegmentWellEquations<Scalar,numWellEq,numEq>::
init(const int num_cells,
const int numPerfs,
const std::vector<int>& cells,
const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>& perforations)
{
duneB_.setBuildMode(OffDiagMatWell::row_wise);
@ -65,7 +66,7 @@ init(const int num_cells,
// NNZ = number_of_segments + 2 * (number_of_inlets / number_of_outlets)
{
int nnz_d = well_.numberOfSegments();
for (const std::vector<int>& inlets : well_.segmentInlets()) {
for (const std::vector<int>& inlets : segment_inlets) {
nnz_d += 2 * inlets.size();
}
duneD_.setSize(well_.numberOfSegments(), well_.numberOfSegments(), nnz_d);
@ -90,7 +91,7 @@ init(const int num_cells,
row.insert(seg);
// insert the item related to its inlets
for (const int& inlet : well_.segmentInlets()[seg]) {
for (const int& inlet : segment_inlets[seg]) {
row.insert(inlet);
}
}

View File

@ -71,11 +71,13 @@ public:
//! \param num_cells Total number of cells
//! \param numPerfs Number of perforations
//! \param cells Cell indices for perforations
//! \param perforations Cell indices for segment perforations
//! \param segment_inlets Cell indices for segment inlets
//! \param segment_perforations Cell indices for segment perforations
void init(const int num_cells,
const int numPerfs,
const std::vector<int>& cells,
const std::vector<std::vector<int>>& perforations);
const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>& segment_perforations);
//! \brief Set all coefficients to 0.
void clear();

View File

@ -69,7 +69,8 @@ MultisegmentWellEval<FluidSystem,Indices,Scalar>::
initMatrixAndVectors(const int num_cells)
{
linSys_.init(num_cells, baseif_.numPerfs(),
baseif_.cells(), segments_.perforations_);
baseif_.cells(), segments_.inlets_,
segments_.perforations_);
primary_variables_.resize(this->numberOfSegments());
}
@ -755,7 +756,7 @@ handleAccelerationPressureLoss(const int seg,
EvalWell accelerationPressureLoss = mswellhelpers::velocityHead(area, mass_rate, density);
// handling the velocity head of intlet segments
for (const int inlet : this->segment_inlets_[seg]) {
for (const int inlet : this->segments_.inlets_[seg]) {
const int seg_upwind_inlet = segments_.upwinding_segments_[inlet];
const double inlet_area = this->segmentSet()[inlet].crossArea();
EvalWell inlet_density = this->segments_.densities_[seg_upwind_inlet];

View File

@ -46,21 +46,8 @@ template<typename Scalar>
MultisegmentWellGeneric<Scalar>::
MultisegmentWellGeneric(WellInterfaceGeneric& baseif)
: baseif_(baseif)
, segment_inlets_(numberOfSegments())
, segment_depth_diffs_(numberOfSegments(), 0.0)
{
// initialize the segment_inlets_
for (int seg = 0; seg < numberOfSegments(); ++seg) {
const Segment& segment = segmentSet()[seg];
const int segment_number = segment.segmentNumber();
const int outlet_segment_number = segment.outletSegment();
if (outlet_segment_number > 0) {
const int segment_index = segmentNumberToIndex(segment_number);
const int outlet_segment_index = segmentNumberToIndex(outlet_segment_number);
segment_inlets_[outlet_segment_index].push_back(segment_index);
}
}
// calculating the depth difference between the segment and its oulet_segments
// for the top segment, we will make its zero unless we find other purpose to use this value
for (int seg = 1; seg < numberOfSegments(); ++seg) {
@ -75,7 +62,8 @@ MultisegmentWellGeneric(WellInterfaceGeneric& baseif)
template<typename Scalar>
void
MultisegmentWellGeneric<Scalar>::
scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_perforations,
scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>& segment_perforations,
WellState& well_state) const
{
auto& ws = well_state.well(baseif_.indexOfWell());
@ -105,7 +93,7 @@ scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_perf
}
std::vector<double> rates;
WellState::calculateSegmentRates(segment_inlets_,
WellState::calculateSegmentRates(segment_inlets,
segment_perforations,
perforation_rates,
num_single_phase, 0, rates);
@ -150,14 +138,6 @@ compPressureDrop() const
return segmentSet().compPressureDrop();
}
template<typename Scalar>
const std::vector<std::vector<int>>&
MultisegmentWellGeneric<Scalar>::
segmentInlets() const
{
return segment_inlets_;
}
template<typename Scalar>
int
MultisegmentWellGeneric<Scalar>::

View File

@ -41,9 +41,6 @@ template <typename Scalar>
class MultisegmentWellGeneric
{
public:
//! \brief Returns the inlet segments for each segment.
const std::vector<std::vector<int>>& segmentInlets() const;
// get the WellSegments from the well_ecl_
const WellSegments& segmentSet() const;
@ -58,7 +55,8 @@ protected:
MultisegmentWellGeneric(WellInterfaceGeneric& baseif);
// scale the segment rates and pressure based on well rates and bhp
void scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_perforations,
void scaleSegmentRatesWithWellRates(const std::vector<std::vector<int>>& segment_inlets,
const std::vector<std::vector<int>>& segment_perforations,
WellState& well_state) const;
void scaleSegmentPressuresWithBhp(WellState& well_state) const;
@ -76,9 +74,6 @@ protected:
const WellInterfaceGeneric& baseif_;
// the inlet segments for each segment. It is for convenience and efficiency reason
std::vector<std::vector<int>> segment_inlets_;
std::vector<double> segment_depth_diffs_;
};

View File

@ -43,6 +43,7 @@ MultisegmentWellSegments(const int numSegments,
WellInterfaceGeneric& well)
: perforations_(numSegments)
, perforation_depth_diffs_(well.numPerfs(), 0.0)
, inlets_(well.wellEcl().getSegments().size())
, densities_(numSegments, 0.0)
, mass_rates_(numSegments, 0.0)
, viscosities_(numSegments, 0.0)
@ -83,6 +84,18 @@ MultisegmentWellSegments(const int numSegments,
i_perf_wells++;
}
}
// initialize the segment_inlets_
for (const Segment& segment : segment_set) {
const int segment_number = segment.segmentNumber();
const int outlet_segment_number = segment.outletSegment();
if (outlet_segment_number > 0) {
const int segment_index = segment_set.segmentNumberToIndex(segment_number);
const int outlet_segment_index = segment_set.segmentNumberToIndex(outlet_segment_number);
inlets_[outlet_segment_index].push_back(segment_index);
}
}
}
#define INSTANCE(...) \

View File

@ -57,6 +57,9 @@ public:
// the segment the perforation belongs to
std::vector<double> perforation_depth_diffs_;
// the inlet segments for each segment. It is for convenience and efficiency reason
std::vector<std::vector<int>> inlets_;
// the densities of segment fluids
// we should not have this member variable
std::vector<EvalWell> densities_;

View File

@ -161,7 +161,9 @@ namespace Opm
Base::updateWellStateWithTarget(ebos_simulator, group_state, well_state, deferred_logger);
// scale segment rates based on the wellRates
// and segment pressure based on bhp
this->scaleSegmentRatesWithWellRates(this->segments_.perforations_, well_state);
this->scaleSegmentRatesWithWellRates(this->segments_.inlets_,
this->segments_.perforations_,
well_state);
this->scaleSegmentPressuresWithBhp(well_state);
}
@ -441,7 +443,8 @@ namespace Opm
ws.surface_rates[phase] = sign * ws.well_potentials[phase];
}
}
well_copy.scaleSegmentRatesWithWellRates(this->segments_.perforations_,
well_copy.scaleSegmentRatesWithWellRates(this->segments_.inlets_,
this->segments_.perforations_,
well_state_copy);
well_copy.calculateExplicitQuantities(ebosSimulator, well_state_copy, deferred_logger);
@ -1587,7 +1590,7 @@ namespace Opm
// considering the contributions from the inlet segments
{
for (const int inlet : this->segment_inlets_[seg]) {
for (const int inlet : this->segments_.inlets_[seg]) {
const int inlet_upwind = this->segments_.upwinding_segments_[inlet];
for (int comp_idx = 0; comp_idx < this->num_components_; ++comp_idx) {
const EvalWell inlet_rate =