move getFrictionPressureLoss to MultisegmentWellSegments

This commit is contained in:
Arne Morten Kvarving 2022-12-19 14:20:55 +01:00
parent ef7b2aca4e
commit 4acfec9d1d
4 changed files with 34 additions and 31 deletions

View File

@ -179,34 +179,6 @@ extendEval(const Eval& in) const
return out;
}
template<typename FluidSystem, typename Indices, typename Scalar>
typename MultisegmentWellEval<FluidSystem,Indices,Scalar>::EvalWell
MultisegmentWellEval<FluidSystem,Indices,Scalar>::
getFrictionPressureLoss(const int seg) const
{
const EvalWell mass_rate = segments_.mass_rates_[seg];
const int seg_upwind = segments_.upwinding_segments_[seg];
EvalWell density = segments_.densities_[seg_upwind];
EvalWell visc = segments_.viscosities_[seg_upwind];
// WARNING
// We disregard the derivatives from the upwind density to make sure derivatives
// wrt. to different segments dont get mixed.
if (seg != seg_upwind) {
density.clearDerivatives();
visc.clearDerivatives();
}
const int outlet_segment_index = this->segmentNumberToIndex(this->segmentSet()[seg].outletSegment());
const double length = this->segmentSet()[seg].totalLength() - this->segmentSet()[outlet_segment_index].totalLength();
assert(length > 0.);
const double roughness = this->segmentSet()[seg].roughness();
const double area = this->segmentSet()[seg].crossArea();
const double diameter = this->segmentSet()[seg].internalDiameter();
const double sign = mass_rate < 0. ? 1.0 : - 1.0;
return sign * mswellhelpers::frictionPressureLoss(length, diameter, area, roughness, density, mass_rate, visc);
}
template<typename FluidSystem, typename Indices, typename Scalar>
typename MultisegmentWellEval<FluidSystem,Indices,Scalar>::EvalWell
MultisegmentWellEval<FluidSystem,Indices,Scalar>::
@ -476,7 +448,7 @@ assembleDefaultPressureEq(const int seg,
pressure_equation -= hydro_pressure_drop;
if (this->frictionalPressureLossConsidered()) {
const auto friction_pressure_drop = getFrictionPressureLoss(seg);
const auto friction_pressure_drop = segments_.getFrictionPressureLoss(seg);
pressure_equation -= friction_pressure_drop;
segments.pressure_drop_friction[seg] = friction_pressure_drop.value();
}

View File

@ -107,8 +107,6 @@ protected:
const double relaxed_inner_tolerance_pressure_ms_well,
const bool relax_tolerance) const;
EvalWell getFrictionPressureLoss(const int seg) const;
std::pair<bool, std::vector<Scalar> >
getFiniteWellResiduals(const std::vector<Scalar>& B_avg,
DeferredLogger& deferred_logger) const;

View File

@ -31,6 +31,7 @@
#include <opm/models/blackoil/blackoiltwophaseindices.hh>
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/wells/MSWellHelpers.hpp>
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
#include <fmt/format.h>
@ -439,6 +440,36 @@ getSurfaceVolume(const EvalWell& temperature,
return volume / vol_ratio;
}
template<class FluidSystem, class Indices, class Scalar>
typename MultisegmentWellSegments<FluidSystem,Indices,Scalar>::EvalWell
MultisegmentWellSegments<FluidSystem,Indices,Scalar>::
getFrictionPressureLoss(const int seg) const
{
const EvalWell mass_rate = mass_rates_[seg];
const int seg_upwind = upwinding_segments_[seg];
EvalWell density = densities_[seg_upwind];
EvalWell visc = viscosities_[seg_upwind];
// WARNING
// We disregard the derivatives from the upwind density to make sure derivatives
// wrt. to different segments dont get mixed.
if (seg != seg_upwind) {
density.clearDerivatives();
visc.clearDerivatives();
}
const auto& segment_set = well_.wellEcl().getSegments();
const int outlet_segment_index = segment_set.segmentNumberToIndex(segment_set[seg].outletSegment());
const double length = segment_set[seg].totalLength() - segment_set[outlet_segment_index].totalLength();
assert(length > 0.);
const double roughness = segment_set[seg].roughness();
const double area = segment_set[seg].crossArea();
const double diameter = segment_set[seg].internalDiameter();
const double sign = mass_rate < 0. ? 1.0 : - 1.0;
return sign * mswellhelpers::frictionPressureLoss(length, diameter, area, roughness, density, mass_rate, visc);
}
#define INSTANCE(...) \
template class MultisegmentWellSegments<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;

View File

@ -55,6 +55,8 @@ public:
const int pvt_region_index,
const int seg_idx) const;
EvalWell getFrictionPressureLoss(const int seg) const;
// TODO: trying to use the information from the Well opm-parser as much
// as possible, it will possibly be re-implemented later for efficiency reason.