VFPProperties: template Scalar type

This commit is contained in:
Arne Morten Kvarving 2024-02-19 14:00:51 +01:00
parent 29d142b5e4
commit 3747981347
6 changed files with 24 additions and 19 deletions

View File

@ -46,7 +46,7 @@ struct Setup
std::shared_ptr<Python> python; std::shared_ptr<Python> python;
std::unique_ptr<const Schedule> schedule; std::unique_ptr<const Schedule> schedule;
std::unique_ptr<SummaryState> summary_state; std::unique_ptr<SummaryState> summary_state;
std::unique_ptr<VFPProperties> vfp_properties; std::unique_ptr<VFPProperties<double>> vfp_properties;
Setup(const std::string& file) Setup(const std::string& file)
{ {
@ -63,7 +63,9 @@ struct Setup
const int step = 0; const int step = 0;
const auto& sched_state = schedule->operator[](step); const auto& sched_state = schedule->operator[](step);
WellState<double> well_state(phaseUsage(runspec.phases())); WellState<double> well_state(phaseUsage(runspec.phases()));
vfp_properties = std::make_unique<VFPProperties>(sched_state.vfpinj(), sched_state.vfpprod(), well_state); vfp_properties = std::make_unique<VFPProperties<double>>(sched_state.vfpinj(),
sched_state.vfpprod(),
well_state);
}; };
}; };

View File

@ -63,7 +63,7 @@ namespace Opm {
class Schedule; class Schedule;
struct SimulatorUpdate; struct SimulatorUpdate;
class SummaryConfig; class SummaryConfig;
class VFPProperties; template<class Scalar> class VFPProperties;
template<class Scalar> class WellInterfaceGeneric; template<class Scalar> class WellInterfaceGeneric;
template<class Scalar> class WellState; template<class Scalar> class WellState;
} // namespace Opm } // namespace Opm
@ -557,7 +557,7 @@ protected:
mutable std::unordered_set<std::string> closed_this_step_; mutable std::unordered_set<std::string> closed_this_step_;
GuideRate guideRate_; GuideRate guideRate_;
std::unique_ptr<VFPProperties> vfp_properties_{}; std::unique_ptr<VFPProperties<Scalar>> vfp_properties_{};
std::map<std::string, Scalar> node_pressures_; // Storing network pressures for output. std::map<std::string, Scalar> node_pressures_; // Storing network pressures for output.
// previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword // previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword

View File

@ -275,7 +275,7 @@ namespace Opm {
{ {
const auto& sched_state = this->schedule()[timeStepIdx]; const auto& sched_state = this->schedule()[timeStepIdx];
this->vfp_properties_ = std::make_unique<VFPProperties> this->vfp_properties_ = std::make_unique<VFPProperties<Scalar>>
(sched_state.vfpinj(), sched_state.vfpprod(), this->wellState()); (sched_state.vfpinj(), sched_state.vfpprod(), this->wellState());
} }
} }

View File

@ -36,6 +36,7 @@ class VFPProdTable;
* A thin wrapper class that holds one VFPProdProperties and one * A thin wrapper class that holds one VFPProdProperties and one
* VFPInjProperties object. * VFPInjProperties object.
*/ */
template<class Scalar>
class VFPProperties { class VFPProperties {
public: public:
/** /**
@ -47,8 +48,8 @@ public:
VFPProperties(const std::vector<std::reference_wrapper<const VFPInjTable>>& inj_tables, VFPProperties(const std::vector<std::reference_wrapper<const VFPInjTable>>& inj_tables,
const std::vector<std::reference_wrapper<const VFPProdTable>>& prod_tables, const std::vector<std::reference_wrapper<const VFPProdTable>>& prod_tables,
const WellState<double>& well_state) const WellState<Scalar>& well_state)
:well_state_(well_state) : well_state_(well_state)
{ {
for (const auto& vfpinj : inj_tables) for (const auto& vfpinj : inj_tables)
this->m_inj.addTable( vfpinj ); this->m_inj.addTable( vfpinj );
@ -60,7 +61,7 @@ public:
/** /**
* Returns the VFP properties for injection wells * Returns the VFP properties for injection wells
*/ */
const VFPInjProperties<double>* getInj() const const VFPInjProperties<Scalar>* getInj() const
{ {
return &m_inj; return &m_inj;
} }
@ -68,12 +69,13 @@ public:
/** /**
* Returns the VFP properties for production wells * Returns the VFP properties for production wells
*/ */
const VFPProdProperties<double>* getProd() const const VFPProdProperties<Scalar>* getProd() const
{ {
return &m_prod; return &m_prod;
} }
double getExplicitWFR(const int table_id, const std::size_t well_index) const { Scalar getExplicitWFR(const int table_id, const std::size_t well_index) const
{
const auto& rates = well_state_.well(well_index).prev_surface_rates; const auto& rates = well_state_.well(well_index).prev_surface_rates;
const auto& pu = well_state_.phaseUsage(); const auto& pu = well_state_.phaseUsage();
const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0;
@ -83,7 +85,8 @@ public:
return detail::getWFR(table, aqua, liquid, vapour); return detail::getWFR(table, aqua, liquid, vapour);
} }
double getExplicitGFR(const int table_id, const std::size_t well_index) const { Scalar getExplicitGFR(const int table_id, const std::size_t well_index) const
{
const auto& rates = well_state_.well(well_index).prev_surface_rates; const auto& rates = well_state_.well(well_index).prev_surface_rates;
const auto& pu = well_state_.phaseUsage(); const auto& pu = well_state_.phaseUsage();
const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0;
@ -94,9 +97,9 @@ public:
} }
private: private:
VFPInjProperties<double> m_inj; VFPInjProperties<Scalar> m_inj;
VFPProdProperties<double> m_prod; VFPProdProperties<Scalar> m_prod;
const WellState<double>& well_state_; const WellState<Scalar>& well_state_;
}; };
} // namespace Opm } // namespace Opm

View File

@ -374,7 +374,7 @@ closeCompletions(const WellTestState& wellTestState)
template<class Scalar> template<class Scalar>
void WellInterfaceGeneric<Scalar>:: void WellInterfaceGeneric<Scalar>::
setVFPProperties(const VFPProperties* vfp_properties_arg) setVFPProperties(const VFPProperties<Scalar>* vfp_properties_arg)
{ {
vfp_properties_ = vfp_properties_arg; vfp_properties_ = vfp_properties_arg;
} }

View File

@ -40,7 +40,7 @@ class ParallelWellInfo;
struct PerforationData; struct PerforationData;
struct PhaseUsage; struct PhaseUsage;
class SummaryState; class SummaryState;
class VFPProperties; template<class Scalar> class VFPProperties;
class WellTestState; class WellTestState;
template<class Scalar> class WellState; template<class Scalar> class WellState;
template<class Scalar> class SingleWellState; template<class Scalar> class SingleWellState;
@ -94,7 +94,7 @@ public:
void initCompletions(); void initCompletions();
void closeCompletions(const WellTestState& wellTestState); void closeCompletions(const WellTestState& wellTestState);
void setVFPProperties(const VFPProperties* vfp_properties_arg); void setVFPProperties(const VFPProperties<Scalar>* vfp_properties_arg);
void setPrevSurfaceRates(WellState<Scalar>& well_state, void setPrevSurfaceRates(WellState<Scalar>& well_state,
const WellState<Scalar>& prev_well_state) const; const WellState<Scalar>& prev_well_state) const;
void setGuideRate(const GuideRate* guide_rate_arg); void setGuideRate(const GuideRate* guide_rate_arg);
@ -129,7 +129,7 @@ public:
Scalar gravity() const { return gravity_; } Scalar gravity() const { return gravity_; }
const VFPProperties* vfpProperties() const { return vfp_properties_; } const VFPProperties<Scalar>* vfpProperties() const { return vfp_properties_; }
const ParallelWellInfo& parallelWellInfo() const { return parallel_well_info_; } const ParallelWellInfo& parallelWellInfo() const { return parallel_well_info_; }
@ -358,7 +358,7 @@ protected:
std::vector<Scalar> inj_fc_multiplier_; std::vector<Scalar> inj_fc_multiplier_;
Scalar well_efficiency_factor_; Scalar well_efficiency_factor_;
const VFPProperties* vfp_properties_; const VFPProperties<Scalar>* vfp_properties_;
const GuideRate* guide_rate_; const GuideRate* guide_rate_;
std::vector<std::string> well_control_log_; std::vector<std::string> well_control_log_;