Merge pull request #5858 from akva2/blackoilwellmodel_temperature_constexpr

BlackoilWellModel::computeWellTemperature: use if constexpr
This commit is contained in:
Arne Morten Kvarving 2025-01-15 10:41:25 +01:00 committed by GitHub
commit ecc231a2a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 53 deletions

View File

@ -2065,13 +2065,13 @@ reportGroupSwitching(DeferredLogger& local_deferredLogger) const
for (const auto& [grname, grdata] : this->switched_inj_groups_) { for (const auto& [grname, grdata] : this->switched_inj_groups_) {
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS}; const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
for (Phase phase : all) { for (Phase phase : all) {
if (!this->prevWGState().group_state.has_injection_control(grname, phase)) {
continue;
}
const auto& ctrls = grdata[static_cast<std::underlying_type_t<Phase>>(phase)]; const auto& ctrls = grdata[static_cast<std::underlying_type_t<Phase>>(phase)];
if (ctrls.empty()) { if (ctrls.empty()) {
continue; continue;
} }
if ( !this->prevWGState().group_state.has_injection_control(grname, phase))
continue;
const Group::InjectionCMode& oldControl = const Group::InjectionCMode& oldControl =
this->prevWGState().group_state.injection_control(grname, phase); this->prevWGState().group_state.injection_control(grname, phase);

View File

@ -2397,9 +2397,7 @@ namespace Opm {
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
computeWellTemperature() computeWellTemperature()
{ {
if (!has_energy_) if constexpr (has_energy_) {
return;
int np = this->numPhases(); int np = this->numPhases();
Scalar cellInternalEnergy; Scalar cellInternalEnergy;
Scalar cellBinv; Scalar cellBinv;
@ -2410,7 +2408,7 @@ namespace Opm {
const Well& well = this->wells_ecl_[wellID]; const Well& well = this->wells_ecl_[wellID];
auto& ws = this->wellState().well(wellID); auto& ws = this->wellState().well(wellID);
if (well.isInjector()) { if (well.isInjector()) {
if( !(ws.status == WellStatus::STOP)){ if (ws.status != WellStatus::STOP) {
this->wellState().well(wellID).temperature = well.inj_temperature(); this->wellState().well(wellID).temperature = well.inj_temperature();
continue; continue;
} }
@ -2433,12 +2431,12 @@ namespace Opm {
Scalar cellTemperatures = fs.temperature(/*phaseIdx*/0).value(); Scalar cellTemperatures = fs.temperature(/*phaseIdx*/0).value();
Scalar weight_factor = 0.0; Scalar weight_factor = 0.0;
for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
{
if (!FluidSystem::phaseIsActive(phaseIdx)) { if (!FluidSystem::phaseIsActive(phaseIdx)) {
continue; continue;
} }
cellInternalEnergy = fs.enthalpy(phaseIdx).value() - fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value(); cellInternalEnergy = fs.enthalpy(phaseIdx).value() -
fs.pressure(phaseIdx).value() / fs.density(phaseIdx).value();
cellBinv = fs.invB(phaseIdx).value(); cellBinv = fs.invB(phaseIdx).value();
cellDensity = fs.density(phaseIdx).value(); cellDensity = fs.density(phaseIdx).value();
perfPhaseRate = perf_phase_rate[perf*np + phaseIdx]; perfPhaseRate = perf_phase_rate[perf*np + phaseIdx];
@ -2452,6 +2450,7 @@ namespace Opm {
this->wellState().well(wellID).temperature = weighted_temperature / total_weight; this->wellState().well(wellID).temperature = weighted_temperature / total_weight;
} }
} }
}
template <typename TypeTag> template <typename TypeTag>