MultisegmentWellPrimaryVariables: remove unnecessary Scalar template parameter

use the Scalar type from the FluidSystem
This commit is contained in:
Arne Morten Kvarving 2024-02-22 15:17:09 +01:00
parent 5affbf4bd5
commit e2e6385918
5 changed files with 48 additions and 47 deletions

View File

@ -32,7 +32,7 @@ namespace Opm
class DeferredLogger; class DeferredLogger;
class GroupState; class GroupState;
template<class Scalar, int numWellEq, int numEq> class MultisegmentWellEquations; template<class Scalar, int numWellEq, int numEq> class MultisegmentWellEquations;
template<class FluidSystem, class Indices, class Scalar> class MultisegmentWellPrimaryVariables; template<class FluidSystem, class Indices> class MultisegmentWellPrimaryVariables;
class Schedule; class Schedule;
class SummaryState; class SummaryState;
template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices; template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices;
@ -61,7 +61,7 @@ public:
static constexpr int numWellEq = Indices::numPhases+1; static constexpr int numWellEq = Indices::numPhases+1;
using Scalar = typename FluidSystem::Scalar; using Scalar = typename FluidSystem::Scalar;
using Equations = MultisegmentWellEquations<Scalar,numWellEq,Indices::numEq>; using Equations = MultisegmentWellEquations<Scalar,numWellEq,Indices::numEq>;
using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>; using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices>;
using EvalWell = DenseAd::Evaluation<Scalar, numWellEq+Indices::numEq>; using EvalWell = DenseAd::Evaluation<Scalar, numWellEq+Indices::numEq>;
//! \brief Constructor initializes reference to well. //! \brief Constructor initializes reference to well.

View File

@ -50,7 +50,7 @@ template<typename FluidSystem, typename Indices, typename Scalar>
class MultisegmentWellEval : public MultisegmentWellGeneric<Scalar> class MultisegmentWellEval : public MultisegmentWellGeneric<Scalar>
{ {
protected: protected:
using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>; using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices>;
static constexpr int numWellEq = PrimaryVariables::numWellEq; static constexpr int numWellEq = PrimaryVariables::numWellEq;
static constexpr int SPres = PrimaryVariables::SPres; static constexpr int SPres = PrimaryVariables::SPres;
static constexpr int WQTotal = PrimaryVariables::WQTotal; static constexpr int WQTotal = PrimaryVariables::WQTotal;

View File

@ -44,16 +44,16 @@
namespace Opm { namespace Opm {
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
resize(const int numSegments) resize(const int numSegments)
{ {
value_.resize(numSegments); value_.resize(numSegments);
evaluation_.resize(numSegments); evaluation_.resize(numSegments);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
init() init()
{ {
for (std::size_t seg = 0; seg < value_.size(); ++seg) { for (std::size_t seg = 0; seg < value_.size(); ++seg) {
@ -65,8 +65,8 @@ init()
} }
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
update(const WellState& well_state, const bool stop_or_zero_rate_target) update(const WellState& well_state, const bool stop_or_zero_rate_target)
{ {
static constexpr int Water = BlackoilPhases::Aqua; static constexpr int Water = BlackoilPhases::Aqua;
@ -153,8 +153,8 @@ update(const WellState& well_state, const bool stop_or_zero_rate_target)
} }
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
updateNewton(const BVectorWell& dwells, updateNewton(const BVectorWell& dwells,
const double relaxation_factor, const double relaxation_factor,
const double dFLimit, const double dFLimit,
@ -209,8 +209,8 @@ updateNewton(const BVectorWell& dwells,
} }
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell, copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
const double rho, const double rho,
const bool stop_or_zero_rate_target, const bool stop_or_zero_rate_target,
@ -410,8 +410,8 @@ copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
well_state, summary_state, deferred_logger); well_state, summary_state, deferred_logger);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: void MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
processFractions(const int seg) processFractions(const int seg)
{ {
static constexpr int Water = BlackoilPhases::Aqua; static constexpr int Water = BlackoilPhases::Aqua;
@ -479,9 +479,9 @@ processFractions(const int seg)
} }
} }
template<typename FluidSystem, typename Indices, typename Scalar> template<typename FluidSystem, typename Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
volumeFraction(const int seg, volumeFraction(const int seg,
const unsigned compIdx) const const unsigned compIdx) const
{ {
@ -514,9 +514,9 @@ volumeFraction(const int seg,
return oil_fraction; return oil_fraction;
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
volumeFractionScaled(const int seg, volumeFractionScaled(const int seg,
const int comp_idx) const const int comp_idx) const
{ {
@ -531,9 +531,9 @@ volumeFractionScaled(const int seg,
return this->volumeFraction(seg, comp_idx); return this->volumeFraction(seg, comp_idx);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
surfaceVolumeFraction(const int seg, surfaceVolumeFraction(const int seg,
const int comp_idx) const const int comp_idx) const
{ {
@ -547,9 +547,9 @@ surfaceVolumeFraction(const int seg,
return this->volumeFractionScaled(seg, comp_idx) / sum_volume_fraction_scaled; return this->volumeFractionScaled(seg, comp_idx) / sum_volume_fraction_scaled;
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getSegmentRateUpwinding(const int seg, getSegmentRateUpwinding(const int seg,
const int seg_upwind, const int seg_upwind,
const std::size_t comp_idx) const const std::size_t comp_idx) const
@ -587,50 +587,50 @@ getSegmentRateUpwinding(const int seg,
return segment_rate; return segment_rate;
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getSegmentPressure(const int seg) const getSegmentPressure(const int seg) const
{ {
return evaluation_[seg][SPres]; return evaluation_[seg][SPres];
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getBhp() const getBhp() const
{ {
return this->getSegmentPressure(0); return this->getSegmentPressure(0);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getSegmentRate(const int seg, getSegmentRate(const int seg,
const int comp_idx) const const int comp_idx) const
{ {
return evaluation_[seg][WQTotal] * this->volumeFractionScaled(seg, comp_idx); return evaluation_[seg][WQTotal] * this->volumeFractionScaled(seg, comp_idx);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getQs(const int comp_idx) const getQs(const int comp_idx) const
{ {
return this->getSegmentRate(0, comp_idx); return this->getSegmentRate(0, comp_idx);
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
typename MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::EvalWell typename MultisegmentWellPrimaryVariables<FluidSystem,Indices>::EvalWell
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
getWQTotal() const getWQTotal() const
{ {
return evaluation_[0][WQTotal]; return evaluation_[0][WQTotal];
} }
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
void void
MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>:: MultisegmentWellPrimaryVariables<FluidSystem,Indices>::
outputLowLimitPressureSegments(DeferredLogger& deferred_logger) const outputLowLimitPressureSegments(DeferredLogger& deferred_logger) const
{ {
std::string msg = fmt::format("outputting the segments for well {} with pressures close to the lower limits " std::string msg = fmt::format("outputting the segments for well {} with pressures close to the lower limits "
@ -650,7 +650,7 @@ outputLowLimitPressureSegments(DeferredLogger& deferred_logger) const
} }
#define INSTANCE(...) \ #define INSTANCE(...) \
template class MultisegmentWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__,double>; template class MultisegmentWellPrimaryVariables<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,__VA_ARGS__>;
// One phase // One phase
INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>) INSTANCE(BlackOilOnePhaseIndices<0u,0u,0u,0u,false,false,0u,1u,0u>)

View File

@ -40,7 +40,7 @@ template<class Scalar> class MultisegmentWellGeneric;
template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices; template<class FluidSystem, class Indices, class Scalar> class WellInterfaceIndices;
class WellState; class WellState;
template<class FluidSystem, class Indices, class Scalar> template<class FluidSystem, class Indices>
class MultisegmentWellPrimaryVariables class MultisegmentWellPrimaryVariables
{ {
public: public:
@ -75,6 +75,7 @@ public:
// the number of well equations TODO: it should have a more general strategy for it // the number of well equations TODO: it should have a more general strategy for it
static constexpr int numWellEq = Indices::numPhases + 1; static constexpr int numWellEq = Indices::numPhases + 1;
using Scalar = typename FluidSystem::Scalar;
using EvalWell = DenseAd::Evaluation<double, /*size=*/Indices::numEq + numWellEq>; using EvalWell = DenseAd::Evaluation<double, /*size=*/Indices::numEq + numWellEq>;
using Equations = MultisegmentWellEquations<Scalar,numWellEq,Indices::numEq>; using Equations = MultisegmentWellEquations<Scalar,numWellEq,Indices::numEq>;

View File

@ -43,7 +43,7 @@ namespace Opm {
template<typename FluidSystem, typename Indices, typename Scalar> template<typename FluidSystem, typename Indices, typename Scalar>
class MultisegmentWellSegments class MultisegmentWellSegments
{ {
using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>; using PrimaryVariables = MultisegmentWellPrimaryVariables<FluidSystem,Indices>;
using EvalWell = typename PrimaryVariables::EvalWell; using EvalWell = typename PrimaryVariables::EvalWell;
public: public: