mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
BlackOilPolymerModules: use if constexpr
This commit is contained in:
parent
5213f3b526
commit
d2ba89f39a
@ -307,7 +307,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (enablePolymerMolarWeight) {
|
||||
if constexpr (enablePolymerMolarWeight) {
|
||||
const auto& plyvmhTable = eclState.getTableManager().getPlyvmhTable();
|
||||
if (!plyvmhTable.empty()) {
|
||||
assert(plyvmhTable.size() == numMixRegions);
|
||||
@ -428,7 +428,7 @@ public:
|
||||
plymaxMaxConcentration_.resize(numRegions);
|
||||
plymixparToddLongstaff_.resize(numRegions);
|
||||
|
||||
if (enablePolymerMolarWeight) {
|
||||
if constexpr (enablePolymerMolarWeight) {
|
||||
plyvmhCoefficients_.resize(numRegions);
|
||||
}
|
||||
}
|
||||
@ -502,10 +502,7 @@ public:
|
||||
*/
|
||||
static void registerParameters()
|
||||
{
|
||||
if (!enablePolymer)
|
||||
// polymers have been disabled at compile time
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer)
|
||||
VtkBlackOilPolymerModule<TypeTag>::registerParameters();
|
||||
}
|
||||
|
||||
@ -515,24 +512,20 @@ public:
|
||||
static void registerOutputModules(Model& model,
|
||||
Simulator& simulator)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
// polymers have been disabled at compile time
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer)
|
||||
model.addOutputModule(new VtkBlackOilPolymerModule<TypeTag>(simulator));
|
||||
}
|
||||
|
||||
static bool primaryVarApplies(unsigned pvIdx)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
// polymers have been disabled at compile time
|
||||
return false;
|
||||
|
||||
if (!enablePolymerMolarWeight)
|
||||
return pvIdx == polymerConcentrationIdx;
|
||||
|
||||
// both enablePolymer and enablePolymerMolarWeight are true here
|
||||
if constexpr (enablePolymer) {
|
||||
if constexpr (enablePolymerMolarWeight)
|
||||
return pvIdx == polymerConcentrationIdx || pvIdx == polymerMoleWeightIdx;
|
||||
else
|
||||
return pvIdx == polymerConcentrationIdx;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string primaryVarName(unsigned pvIdx)
|
||||
@ -557,14 +550,14 @@ public:
|
||||
|
||||
static bool eqApplies(unsigned eqIdx)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
return false;
|
||||
|
||||
if (!enablePolymerMolarWeight)
|
||||
return eqIdx == contiPolymerEqIdx;
|
||||
|
||||
// both enablePolymer and enablePolymerMolarWeight are true here
|
||||
if constexpr (enablePolymer) {
|
||||
if constexpr (enablePolymerMolarWeight)
|
||||
return eqIdx == contiPolymerEqIdx || eqIdx == contiPolymerMolarWeightEqIdx;
|
||||
else
|
||||
return eqIdx == contiPolymerEqIdx;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string eqName(unsigned eqIdx)
|
||||
@ -590,9 +583,7 @@ public:
|
||||
static void addStorage(Dune::FieldVector<LhsEval, numEq>& storage,
|
||||
const IntensiveQuantities& intQuants)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer) {
|
||||
const auto& fs = intQuants.fluidState();
|
||||
|
||||
LhsEval surfaceVolumeWater =
|
||||
@ -619,23 +610,22 @@ public:
|
||||
storage[contiPolymerEqIdx] += accumulationPolymer;
|
||||
|
||||
// tracking the polymer molecular weight
|
||||
if (enablePolymerMolarWeight) {
|
||||
if constexpr (enablePolymerMolarWeight) {
|
||||
accumulationPolymer = max(accumulationPolymer, 1e-10);
|
||||
|
||||
storage[contiPolymerMolarWeightEqIdx] += accumulationPolymer
|
||||
* Toolbox::template decay<LhsEval> (intQuants.polymerMoleWeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void computeFlux(RateVector& flux,
|
||||
const ElementContext& elemCtx,
|
||||
unsigned scvfIdx,
|
||||
unsigned timeIdx)
|
||||
static void computeFlux([[maybe_unused]] RateVector& flux,
|
||||
[[maybe_unused]] const ElementContext& elemCtx,
|
||||
[[maybe_unused]] unsigned scvfIdx,
|
||||
[[maybe_unused]] unsigned timeIdx)
|
||||
|
||||
{
|
||||
if (!enablePolymer)
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer) {
|
||||
const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
|
||||
|
||||
const unsigned upIdx = extQuants.upstreamIndex(FluidSystem::waterPhaseIdx);
|
||||
@ -643,7 +633,6 @@ public:
|
||||
const auto& up = elemCtx.intensiveQuantities(upIdx, timeIdx);
|
||||
const unsigned contiWaterEqIdx = Indices::conti0EqIdx + Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx);
|
||||
|
||||
|
||||
if (upIdx == inIdx) {
|
||||
flux[contiPolymerEqIdx] =
|
||||
extQuants.volumeFlux(waterPhaseIdx)
|
||||
@ -670,7 +659,7 @@ public:
|
||||
}
|
||||
|
||||
// flux related to transport of polymer molecular weight
|
||||
if (enablePolymerMolarWeight) {
|
||||
if constexpr (enablePolymerMolarWeight) {
|
||||
if (upIdx == inIdx)
|
||||
flux[contiPolymerMolarWeightEqIdx] =
|
||||
flux[contiPolymerEqIdx]*up.polymerMoleWeight();
|
||||
@ -678,7 +667,7 @@ public:
|
||||
flux[contiPolymerMolarWeightEqIdx] =
|
||||
flux[contiPolymerEqIdx]*decay<Scalar>(up.polymerMoleWeight());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -696,21 +685,18 @@ public:
|
||||
template <class DofEntity>
|
||||
static void serializeEntity(const Model& model, std::ostream& outstream, const DofEntity& dof)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer) {
|
||||
unsigned dofIdx = model.dofMapper().index(dof);
|
||||
const PrimaryVariables& priVars = model.solution(/*timeIdx=*/0)[dofIdx];
|
||||
outstream << priVars[polymerConcentrationIdx];
|
||||
outstream << priVars[polymerMoleWeightIdx];
|
||||
}
|
||||
}
|
||||
|
||||
template <class DofEntity>
|
||||
static void deserializeEntity(Model& model, std::istream& instream, const DofEntity& dof)
|
||||
{
|
||||
if (!enablePolymer)
|
||||
return;
|
||||
|
||||
if constexpr (enablePolymer) {
|
||||
unsigned dofIdx = model.dofMapper().index(dof);
|
||||
PrimaryVariables& priVars0 = model.solution(/*timeIdx=*/0)[dofIdx];
|
||||
PrimaryVariables& priVars1 = model.solution(/*timeIdx=*/1)[dofIdx];
|
||||
@ -722,6 +708,7 @@ public:
|
||||
priVars1[polymerConcentrationIdx] = priVars0[polymerConcentrationIdx];
|
||||
priVars1[polymerMoleWeightIdx] = priVars0[polymerMoleWeightIdx];
|
||||
}
|
||||
}
|
||||
|
||||
static const Scalar plyrockDeadPoreVolume(const ElementContext& elemCtx,
|
||||
unsigned scvIdx,
|
||||
@ -1048,10 +1035,9 @@ public:
|
||||
const auto linearizationType = elemCtx.linearizationType();
|
||||
const PrimaryVariables& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
|
||||
polymerConcentration_ = priVars.makeEvaluation(polymerConcentrationIdx, timeIdx, linearizationType);
|
||||
if (enablePolymerMolarWeight) {
|
||||
if constexpr (enablePolymerMolarWeight) {
|
||||
polymerMoleWeight_ = priVars.makeEvaluation(polymerMoleWeightIdx, timeIdx, linearizationType);
|
||||
}
|
||||
const Scalar cmax = PolymerModule::plymaxMaxConcentration(elemCtx, dofIdx, timeIdx);
|
||||
|
||||
// permeability reduction due to polymer
|
||||
const Scalar& maxAdsorbtion = PolymerModule::plyrockMaxAdsorbtion(elemCtx, dofIdx, timeIdx);
|
||||
@ -1067,7 +1053,8 @@ public:
|
||||
const Evaluation resistanceFactor = 1.0 + (residualResistanceFactor - 1.0) * polymerAdsorption_ / maxAdsorbtion;
|
||||
|
||||
// compute effective viscosities
|
||||
if (!enablePolymerMolarWeight) {
|
||||
if constexpr (!enablePolymerMolarWeight) {
|
||||
const Scalar cmax = PolymerModule::plymaxMaxConcentration(elemCtx, dofIdx, timeIdx);
|
||||
const auto& fs = asImp_().fluidState_;
|
||||
const Evaluation& muWater = fs.viscosity(waterPhaseIdx);
|
||||
const auto& viscosityMultiplier = PolymerModule::plyviscViscosityMultiplierTable(elemCtx, dofIdx, timeIdx);
|
||||
@ -1113,10 +1100,10 @@ public:
|
||||
|
||||
const Evaluation& polymerMoleWeight() const
|
||||
{
|
||||
if (!enablePolymerMolarWeight)
|
||||
throw std::logic_error("polymerMoleWeight() is called but polymer milecular weight is disabled");
|
||||
|
||||
if constexpr (enablePolymerMolarWeight)
|
||||
return polymerMoleWeight_;
|
||||
else
|
||||
throw std::logic_error("polymerMoleWeight() is called but polymer milecular weight is disabled");
|
||||
}
|
||||
|
||||
const Scalar& polymerDeadPoreVolume() const
|
||||
|
Loading…
Reference in New Issue
Block a user