WellGroupConstraints: template Scalar type

This commit is contained in:
Arne Morten Kvarving 2024-02-19 14:34:38 +01:00
parent f70c7f15f8
commit d25ea9ec26
2 changed files with 40 additions and 34 deletions

View File

@ -33,12 +33,13 @@
namespace Opm
{
std::pair<bool, double>
WellGroupConstraints::
template<class Scalar>
std::pair<bool, Scalar>
WellGroupConstraints<Scalar>::
checkGroupConstraintsInj(const Group& group,
const WellState<double>& well_state,
const GroupState<double>& group_state,
const double efficiencyFactor,
const WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Scalar efficiencyFactor,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
@ -69,12 +70,12 @@ checkGroupConstraintsInj(const Group& group,
}
// Make conversion factors for RESV <-> surface rates.
std::vector<double> resv_coeff(well_.phaseUsage().num_phases, 1.0);
std::vector<Scalar> resv_coeff(well_.phaseUsage().num_phases, 1.0);
rateConverter(0, well_.pvtRegionIdx(), group.name(), resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
const auto& ws = well_state.well(well_.indexOfWell());
// Call check for the well's injection phase.
return WellGroupHelpers<double>::checkGroupConstraintsInj(well_.name(),
return WellGroupHelpers<Scalar>::checkGroupConstraintsInj(well_.name(),
well_.wellEcl().groupName(),
group,
well_state,
@ -91,23 +92,24 @@ checkGroupConstraintsInj(const Group& group,
deferred_logger);
}
std::pair<bool, double>
WellGroupConstraints::
template<class Scalar>
std::pair<bool, Scalar>
WellGroupConstraints<Scalar>::
checkGroupConstraintsProd(const Group& group,
const WellState<double>& well_state,
const GroupState<double>& group_state,
const double efficiencyFactor,
const WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Scalar efficiencyFactor,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
DeferredLogger& deferred_logger) const
{
// Make conversion factors for RESV <-> surface rates.
std::vector<double> resv_coeff(well_.phaseUsage().num_phases, 1.0);
std::vector<Scalar> resv_coeff(well_.phaseUsage().num_phases, 1.0);
rateConverter(0, well_.pvtRegionIdx(), group.name(), resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS.
const auto& ws = well_state.well(well_.indexOfWell());
return WellGroupHelpers<double>::checkGroupConstraintsProd(well_.name(),
return WellGroupHelpers<Scalar>::checkGroupConstraintsProd(well_.name(),
well_.wellEcl().groupName(),
group,
well_state,
@ -123,9 +125,10 @@ checkGroupConstraintsProd(const Group& group,
deferred_logger);
}
bool WellGroupConstraints::
checkGroupConstraints(WellState<double>& well_state,
const GroupState<double>& group_state,
template<class Scalar>
bool WellGroupConstraints<Scalar>::
checkGroupConstraints(WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
@ -146,8 +149,8 @@ checkGroupConstraints(WellState<double>& well_state,
// check, skipping over only the single group parent whose
// control is the active one for the well (if any).
const auto& group = schedule.getGroup(well.groupName(), well_.currentStep());
const double efficiencyFactor = well.getEfficiencyFactor();
const std::pair<bool, double> group_constraint =
const Scalar efficiencyFactor = well.getEfficiencyFactor();
const std::pair<bool, Scalar> group_constraint =
this->checkGroupConstraintsInj(group, well_state,
group_state, efficiencyFactor,
schedule, summaryState,
@ -177,8 +180,8 @@ checkGroupConstraints(WellState<double>& well_state,
// check, skipping over only the single group parent whose
// control is the active one for the well (if any).
const auto& group = schedule.getGroup(well.groupName(), well_.currentStep());
const double efficiencyFactor = well.getEfficiencyFactor();
const std::pair<bool, double> group_constraint =
const Scalar efficiencyFactor = well.getEfficiencyFactor();
const std::pair<bool, Scalar> group_constraint =
this->checkGroupConstraintsProd(group, well_state,
group_state, efficiencyFactor,
schedule, summaryState,
@ -199,4 +202,6 @@ checkGroupConstraints(WellState<double>& well_state,
return false;
}
template class WellGroupConstraints<double>;
} // namespace Opm

View File

@ -44,45 +44,46 @@ template<class Scalar> class WellInterfaceGeneric;
template<class Scalar> class WellState;
//! \brief Class for computing well group constraints.
template<class Scalar>
class WellGroupConstraints {
public:
//! \brief Constructor sets reference to well.
WellGroupConstraints(const WellInterfaceGeneric<double>& well) : well_(well) {}
WellGroupConstraints(const WellInterfaceGeneric<Scalar>& well) : well_(well) {}
using RateConvFunc = std::function<void(const RegionId,
const int,
const std::optional<std::string>&,
std::vector<double>&)>;
std::vector<Scalar>&)>;
bool checkGroupConstraints(WellState<double>& well_state,
const GroupState<double>& group_state,
bool checkGroupConstraints(WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
DeferredLogger& deferred_logger) const;
private:
std::pair<bool, double>
std::pair<bool, Scalar>
checkGroupConstraintsInj(const Group& group,
const WellState<double>& well_state,
const GroupState<double>& group_state,
const double efficiencyFactor,
const WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Scalar efficiencyFactor,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
DeferredLogger& deferred_logger) const;
std::pair<bool, double>
std::pair<bool, Scalar>
checkGroupConstraintsProd(const Group& group,
const WellState<double>& well_state,
const GroupState<double>& group_state,
const double efficiencyFactor,
const WellState<Scalar>& well_state,
const GroupState<Scalar>& group_state,
const Scalar efficiencyFactor,
const Schedule& schedule,
const SummaryState& summaryState,
const RateConvFunc& rateConverter,
DeferredLogger& deferred_logger) const;
const WellInterfaceGeneric<double>& well_; //!< Reference to well interface
const WellInterfaceGeneric<Scalar>& well_; //!< Reference to well interface
};
}