move updateUpwindingSegments to MultisegmentWellSegments

This commit is contained in:
Arne Morten Kvarving 2022-12-19 15:43:42 +01:00
parent 4b3a6f37d5
commit 12b15b5038
5 changed files with 30 additions and 31 deletions

View File

@ -600,31 +600,6 @@ getWQTotal() const
return evaluation_[0][WQTotal];
}
template<class FluidSystem, class Indices, class Scalar>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::
updateUpwindingSegments(const MultisegmentWellGeneric<Scalar>& mswell,
std::vector<int>& upwinding_segments) const
{
for (size_t seg = 0; seg < value_.size(); ++seg) {
// special treatment is needed for segment 0
if (seg == 0) {
// we are not supposed to have injecting producers and producing injectors
assert(!(well_.isProducer() && evaluation_[seg][WQTotal] > 0.));
assert(!(well_.isInjector() && evaluation_[seg][WQTotal] < 0.));
upwinding_segments[seg] = seg;
continue;
}
// for other normal segments
if (evaluation_[seg][WQTotal] <= 0.) {
upwinding_segments[seg] = seg;
} else {
const int outlet_segment_index = mswell.segmentNumberToIndex(mswell.segmentSet()[seg].outletSegment());
upwinding_segments[seg] = outlet_segment_index;
}
}
}
#define INSTANCE(...) \
template class MultisegmentWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;

View File

@ -133,10 +133,6 @@ public:
//! \brief Get WQTotal.
EvalWell getWQTotal() const;
//! \brief Update upwinding segments.
void updateUpwindingSegments(const MultisegmentWellGeneric<Scalar>& mswell,
std::vector<int>& upwinding_segments) const;
//! \brief Returns a const ref to an evaluation.
const std::array<EvalWell,numWellEq>& eval(const int idx) const
{ return evaluation_[idx]; }

View File

@ -287,6 +287,32 @@ computeFluidProperties(const EvalWell& temperature,
}
}
template<class FluidSystem, class Indices, class Scalar>
void MultisegmentWellSegments<FluidSystem,Indices,Scalar>::
updateUpwindingSegments(const PrimaryVariables& primary_variables)
{
for (size_t seg = 0; seg < perforations_.size(); ++seg) {
// special treatment is needed for segment 0
if (seg == 0) {
// we are not supposed to have injecting producers and producing injectors
assert(!(well_.isProducer() && primary_variables.eval(seg)[primary_variables.WQTotal] > 0.));
assert(!(well_.isInjector() && primary_variables.eval(seg)[primary_variables.WQTotal] < 0.));
upwinding_segments_[seg] = seg;
continue;
}
// for other normal segments
if (primary_variables.eval(seg)[primary_variables.WQTotal] <= 0.) {
upwinding_segments_[seg] = seg;
} else {
const auto& segment_set = well_.wellEcl().getSegments();
const int outlet_segment_index = segment_set.segmentNumberToIndex(segment_set[seg].outletSegment());
upwinding_segments_[seg] = outlet_segment_index;
}
}
}
template<class FluidSystem, class Indices, class Scalar>
typename MultisegmentWellSegments<FluidSystem,Indices,Scalar>::EvalWell
MultisegmentWellSegments<FluidSystem,Indices,Scalar>::

View File

@ -48,6 +48,9 @@ public:
int pvt_region_index,
DeferredLogger& deferred_logger);
//! \brief Update upwinding segments.
void updateUpwindingSegments(const PrimaryVariables& primary_variables);
EvalWell getHydroPressureLoss(const int seg) const;
EvalWell getSurfaceVolume(const EvalWell& temperature,

View File

@ -1534,8 +1534,7 @@ namespace Opm
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;
// update the upwinding segments
this->primary_variables_.updateUpwindingSegments(*this,
this->segments_.upwinding_segments_);
this->segments_.updateUpwindingSegments(this->primary_variables_);
// calculate the fluid properties needed.
computeSegmentFluidProperties(ebosSimulator, deferred_logger);