added: MultisegmentWellAssemble::assemblePressureLoss

extracted from MultisegmentWellEval::handleAccelerationPressureLoss
This commit is contained in:
Arne Morten Kvarving 2022-11-18 12:09:43 +01:00
parent 4ebde4e003
commit d64508f3b8
4 changed files with 45 additions and 12 deletions

View File

@ -48,7 +48,6 @@ assembleControlEq(const WellState& well_state,
const double rho,
const EvalWell& wqTotal,
const EvalWell& bhp,
const int SPres,
const std::function<EvalWell(const int)>& getQs,
Equations& eqns,
DeferredLogger& deferred_logger) const
@ -155,6 +154,24 @@ assembleControlEq(const WellState& well_state,
}
}
template<class FluidSystem, class Indices, class Scalar>
void MultisegmentWellAssemble<FluidSystem,Indices,Scalar>::
assemblePressureLoss(const int seg,
const int seg_upwind,
const EvalWell& accelerationPressureLoss,
Equations& eqns) const
{
eqns.resWell_[seg][SPres] -= accelerationPressureLoss.value();
eqns.duneD_[seg][seg][SPres][SPres] -= accelerationPressureLoss.derivative(SPres + Indices::numEq);
eqns.duneD_[seg][seg][SPres][WQTotal] -= accelerationPressureLoss.derivative(WQTotal + Indices::numEq);
if constexpr (has_wfrac_variable) {
eqns.duneD_[seg][seg_upwind][SPres][WFrac] -= accelerationPressureLoss.derivative(WFrac + Indices::numEq);
}
if constexpr (has_gfrac_variable) {
eqns.duneD_[seg][seg_upwind][SPres][GFrac] -= accelerationPressureLoss.derivative(GFrac + Indices::numEq);
}
}
#define INSTANCE(...) \
template class MultisegmentWellAssemble<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>;
@ -175,8 +192,10 @@ INSTANCE(BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,1u,0u>)
// Blackoil
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,false,1u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,true,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,0u,0u,false,true,2u,0u>)
INSTANCE(BlackOilIndices<1u,0u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,1u,0u,0u,false,false,0u,0u>)
INSTANCE(BlackOilIndices<0u,0u,1u,0u,false,false,0u,0u>)

View File

@ -43,6 +43,21 @@ class WellState;
template<class FluidSystem, class Indices, class Scalar>
class MultisegmentWellAssemble
{
static constexpr bool has_water = (Indices::waterSwitchIdx >= 0);
static constexpr bool has_gas = (Indices::compositionSwitchIdx >= 0);
static constexpr bool has_oil = (Indices::numPhases - has_gas - has_water) > 0;
// In the implementation, one should use has_wfrac_variable
// rather than has_water to check if you should do something
// with the variable at the WFrac location, similar for GFrac.
static constexpr bool has_wfrac_variable = has_water && Indices::numPhases > 1;
static constexpr bool has_gfrac_variable = has_gas && has_oil;
static constexpr int WQTotal = 0;
static constexpr int WFrac = has_wfrac_variable ? 1 : -1000;
static constexpr int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
static constexpr int SPres = has_wfrac_variable + has_gfrac_variable + 1;
public:
static constexpr int numWellEq = Indices::numPhases+1;
using Equations = MultisegmentWellEquations<Scalar,numWellEq,Indices::numEq>;
@ -62,11 +77,17 @@ public:
const double rho,
const EvalWell& wqTotal,
const EvalWell& bhp,
const int SPres,
const std::function<EvalWell(const int)>& getQs,
Equations& eqns,
DeferredLogger& deferred_logger) const;
//! \brief Assemble pressure loss term.
void assemblePressureLoss(const int seg,
const int seg_upwind,
const EvalWell& accelerationPressureLoss,
Equations& eqns) const;
private:
const WellInterfaceIndices<FluidSystem,Indices,Scalar>& well_; //!< Reference to well
};

View File

@ -33,6 +33,7 @@
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/MSWellHelpers.hpp>
#include <opm/simulators/wells/MultisegmentWellAssemble.hpp>
#include <opm/simulators/wells/RateConverter.hpp>
#include <opm/simulators/wells/WellAssemble.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
@ -1148,15 +1149,8 @@ handleAccelerationPressureLoss(const int seg,
auto& segments = well_state.well(baseif_.indexOfWell()).segments;
segments.pressure_drop_accel[seg] = accelerationPressureLoss.value();
linSys_.resWell_[seg][SPres] -= accelerationPressureLoss.value();
linSys_.duneD_[seg][seg][SPres][SPres] -= accelerationPressureLoss.derivative(SPres + Indices::numEq);
linSys_.duneD_[seg][seg][SPres][WQTotal] -= accelerationPressureLoss.derivative(WQTotal + Indices::numEq);
if (has_wfrac_variable) {
linSys_.duneD_[seg][seg_upwind][SPres][WFrac] -= accelerationPressureLoss.derivative(WFrac + Indices::numEq);
}
if (has_gfrac_variable) {
linSys_.duneD_[seg][seg_upwind][SPres][GFrac] -= accelerationPressureLoss.derivative(GFrac + Indices::numEq);
}
MultisegmentWellAssemble<FluidSystem,Indices,Scalar>(baseif_).
assemblePressureLoss(seg, seg_upwind, accelerationPressureLoss, linSys_);
}
template<typename FluidSystem, typename Indices, typename Scalar>

View File

@ -1683,7 +1683,6 @@ namespace Opm
getRefDensity(),
this->getWQTotal(),
this->getBhp(),
SPres,
gQ,
this->linSys_,
deferred_logger);