Merge pull request #3235 from akva2/constexpr_micro_optim_wells

Small micro-optims in WellInterface
This commit is contained in:
Joakim Hove 2021-05-12 06:55:22 +02:00 committed by GitHub
commit 817e81d3b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 43 deletions

View File

@ -107,15 +107,15 @@ namespace Opm
typedef Dune::BlockVector<VectorBlockType> BVector;
typedef DenseAd::Evaluation<double, /*size=*/numEq> Eval;
static const bool has_solvent = getPropValue<TypeTag, Properties::EnableSolvent>();
static const bool has_zFraction = getPropValue<TypeTag, Properties::EnableExtbo>();
static const bool has_polymer = getPropValue<TypeTag, Properties::EnablePolymer>();
static constexpr bool has_solvent = getPropValue<TypeTag, Properties::EnableSolvent>();
static constexpr bool has_zFraction = getPropValue<TypeTag, Properties::EnableExtbo>();
static constexpr bool has_polymer = getPropValue<TypeTag, Properties::EnablePolymer>();
static const bool has_energy = getPropValue<TypeTag, Properties::EnableEnergy>();
static const bool has_temperature = getPropValue<TypeTag, Properties::EnableTemperature>();
// flag for polymer molecular weight related
static const bool has_polymermw = getPropValue<TypeTag, Properties::EnablePolymerMW>();
static const bool has_foam = getPropValue<TypeTag, Properties::EnableFoam>();
static const bool has_brine = getPropValue<TypeTag, Properties::EnableBrine>();
static constexpr bool has_foam = getPropValue<TypeTag, Properties::EnableFoam>();
static constexpr bool has_brine = getPropValue<TypeTag, Properties::EnableBrine>();
static const int contiSolventEqIdx = Indices::contiSolventEqIdx;
static const int contiZfracEqIdx = Indices::contiZfracEqIdx;
static const int contiPolymerEqIdx = Indices::contiPolymerEqIdx;

View File

@ -97,10 +97,12 @@ namespace Opm
wsolvent_ = 0.0;
if ((has_solvent || has_zFraction) && well.isInjector()) {
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::GAS) {
wsolvent_ = well_ecl_.getSolventFraction();
if constexpr (has_solvent || has_zFraction) {
if (well.isInjector()) {
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::GAS) {
wsolvent_ = well_ecl_.getSolventFraction();
}
}
}
}
@ -373,20 +375,20 @@ namespace Opm
WellInterface<TypeTag>::
wpolymer() const
{
if (!has_polymer) {
return 0.0;
if constexpr (has_polymer) {
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::WATER) {
WellPolymerProperties polymer = well_ecl_.getPolymerProperties();
const double polymer_injection_concentration = polymer.m_polymerConcentration;
return polymer_injection_concentration;
} else {
// Not a water injection well => no polymer.
return 0.0;
}
}
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::WATER) {
WellPolymerProperties polymer = well_ecl_.getPolymerProperties();
const double polymer_injection_concentration = polymer.m_polymerConcentration;
return polymer_injection_concentration;
} else {
// Not a water injection well => no polymer.
return 0.0;
}
return 0.0;
}
@ -398,19 +400,19 @@ namespace Opm
WellInterface<TypeTag>::
wfoam() const
{
if (!has_foam) {
return 0.0;
if constexpr (has_foam) {
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::GAS) {
WellFoamProperties fprop = well_ecl_.getFoamProperties();
return fprop.m_foamConcentration;
} else {
// Not a gas injection well => no foam.
return 0.0;
}
}
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::GAS) {
WellFoamProperties fprop = well_ecl_.getFoamProperties();
return fprop.m_foamConcentration;
} else {
// Not a gas injection well => no foam.
return 0.0;
}
return 0.0;
}
@ -420,19 +422,19 @@ namespace Opm
WellInterface<TypeTag>::
wsalt() const
{
if (!has_brine) {
return 0.0;
if constexpr (has_brine) {
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::WATER) {
WellBrineProperties fprop = well_ecl_.getBrineProperties();
return fprop.m_saltConcentration;
} else {
// Not a water injection well => no salt (?).
return 0.0;
}
}
auto injectorType = well_ecl_.injectorType();
if (injectorType == InjectorType::WATER) {
WellBrineProperties fprop = well_ecl_.getBrineProperties();
return fprop.m_saltConcentration;
} else {
// Not a water injection well => no salt (?).
return 0.0;
}
return 0.0;
}