22 #ifndef OPM_MULTISEGMENTWELL_PRIMARY_VARIABLES_HEADER_INCLUDED 23 #define OPM_MULTISEGMENTWELL_PRIMARY_VARIABLES_HEADER_INCLUDED 25 #include <opm/material/densead/Evaluation.hpp> 27 #include <opm/simulators/wells/MultisegmentWellEquations.hpp> 28 #include <opm/input/eclipse/Schedule/SummaryState.hpp> 29 #include <opm/input/eclipse/Units/Units.hpp> 39 template <
typename Scalar,
typename IndexTraits>
class MultisegmentWellGeneric;
40 template<
class Flu
idSystem,
class Indices>
class WellInterfaceIndices;
41 template<
typename Scalar,
typename IndexTraits>
class WellState;
43 template<
class Flu
idSystem,
class Indices>
44 class MultisegmentWellPrimaryVariables
62 static constexpr
bool has_wfrac_variable = Indices::waterEnabled && Indices::oilEnabled;
63 static constexpr
bool has_gfrac_variable = Indices::gasEnabled && Indices::numPhases > 1;
64 static constexpr
bool enable_energy = Indices::enableFullyImplicitThermal;
66 static constexpr
int WQTotal = 0;
67 static constexpr
int WFrac = has_wfrac_variable ? 1 : -1000;
68 static constexpr
int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
71 static constexpr
int Temperature = enable_energy ? has_wfrac_variable + has_gfrac_variable + 1 : -1000;
72 static constexpr
int SPres = has_wfrac_variable + has_gfrac_variable + 1 + enable_energy;
75 static constexpr
int numWellEq = Indices::numPhases + 1 + enable_energy;
77 using Scalar =
typename FluidSystem::Scalar;
78 using IndexTraits =
typename FluidSystem::IndexTraitsType;
79 using EvalWell = DenseAd::Evaluation<Scalar, Indices::numEq + numWellEq>;
81 using Equations = MultisegmentWellEquations<Scalar,IndexTraits, numWellEq, Indices::numEq>;
82 using BVectorWell =
typename Equations::BVectorWell;
84 explicit MultisegmentWellPrimaryVariables(
const WellInterfaceIndices<FluidSystem,Indices>& well)
89 void resize(
const int numSegments);
92 void update(
const WellState<Scalar, IndexTraits>& well_state,
93 const bool stop_or_zero_rate_target);
97 const Scalar relaxation_factor,
99 const bool stop_or_zero_rate_target,
100 const Scalar max_pressure_change);
103 void copyToWellState(
const MultisegmentWellGeneric<Scalar, IndexTraits>& mswell,
105 WellState<Scalar, IndexTraits>& well_state,
106 const SummaryState& summary_state,
107 DeferredLogger& deferred_logger)
const;
112 const int compIdx)
const;
117 const int compIdx)
const;
121 const int seg_upwind,
122 const int comp_idx)
const;
135 const int comp_idx)
const;
138 EvalWell
getQs(
const int comp_idx)
const;
144 const std::array<EvalWell, numWellEq>&
eval(
const int idx)
const 145 {
return evaluation_[idx]; }
148 const std::array<Scalar, numWellEq>&
value(
const int idx)
const 149 {
return value_[idx]; }
152 void setValue(
const int idx,
const std::array<Scalar, numWellEq>& val)
153 { value_[idx] = val; }
164 void setEvaluationsFromValues();
167 void processFractions(
const int seg);
170 EvalWell volumeFraction(
const int seg,
171 const int compIdx)
const;
175 std::vector<std::array<Scalar, numWellEq>> value_;
179 std::vector<std::array<EvalWell, numWellEq>> evaluation_;
183 static constexpr
double bhp_lower_limit = 1. * unit::barsa - 1. * unit::Pascal;
184 static constexpr
double seg_pres_lower_limit = 0.;
189 #endif // OPM_MULTISEGMENTWELL_PRIMARY_VARIABLES_HEADER_INCLUDED EvalWell getSegmentRate(const int seg, const int comp_idx) const
Get rate for a component in a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:696
const std::array< EvalWell, numWellEq > & eval(const int idx) const
Returns a const ref to an array of evaluations.
Definition: MultisegmentWellPrimaryVariables.hpp:144
void updateNewton(const BVectorWell &dwells, const Scalar relaxation_factor, const Scalar DFLimit, const bool stop_or_zero_rate_target, const Scalar max_pressure_change)
Update values from newton update vector.
Definition: MultisegmentWellPrimaryVariables.cpp:173
EvalWell getQs(const int comp_idx) const
Returns scaled rate for a component.
Definition: MultisegmentWellPrimaryVariables.cpp:705
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
EvalWell surfaceVolumeFraction(const int seg, const int compIdx) const
Returns surface volume fraction for a component in a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:616
void scaledWellFractions(std::vector< Scalar > &fractions, DeferredLogger &deferred_logger) const
get scaled fractions of top segment.
Definition: MultisegmentWellPrimaryVariables.cpp:741
EvalWell volumeFractionScaled(const int seg, const int compIdx) const
Returns scaled volume fraction for a component in a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:599
void update(const WellState< Scalar, IndexTraits > &well_state, const bool stop_or_zero_rate_target)
Copy values from well state.
Definition: MultisegmentWellPrimaryVariables.cpp:70
EvalWell getWQTotal() const
Get WQTotal.
Definition: MultisegmentWellPrimaryVariables.cpp:713
EvalWell getBhp() const
Get bottomhole pressure.
Definition: MultisegmentWellPrimaryVariables.cpp:688
void setValue(const int idx, const std::array< Scalar, numWellEq > &val)
Set a value array. Note that this does not also set the corresponding evaluation. ...
Definition: MultisegmentWellPrimaryVariables.hpp:152
Definition: MultisegmentWellAssemble.hpp:38
Definition: DeferredLogger.hpp:56
EvalWell getSegmentPressure(const int seg) const
Get pressure for a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:672
EvalWell getSegmentRateUpwinding(const int seg, const int seg_upwind, const int comp_idx) const
Returns upwinding rate for a component in a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:632
const std::array< Scalar, numWellEq > & value(const int idx) const
Returns a value array.
Definition: MultisegmentWellPrimaryVariables.hpp:148
void outputLowLimitPressureSegments(DeferredLogger &deferred_logger) const
output the segments with pressure close to lower pressure limit for debugging purpose ...
Definition: MultisegmentWellPrimaryVariables.cpp:721
void copyToWellState(const MultisegmentWellGeneric< Scalar, IndexTraits > &mswell, const Scalar rho, WellState< Scalar, IndexTraits > &well_state, const SummaryState &summary_state, DeferredLogger &deferred_logger) const
Copy values to well state.
Definition: MultisegmentWellPrimaryVariables.cpp:239
EvalWell getSegmentTemperature(const int seg) const
Get temperature for a segment.
Definition: MultisegmentWellPrimaryVariables.cpp:680
void resize(const int numSegments)
Resize values and evaluations.
Definition: MultisegmentWellPrimaryVariables.cpp:49