Skip to content
Snippets Groups Projects
Commit 60b05c5b authored by Timo Koch's avatar Timo Koch
Browse files

[staggered] Use tag dispatch instead of Dune::Hybrid::ifElse

Unfortunately clang seems to compile the else branch even if the compile time
condition is true. From the Dune documentation it didn't come clear to me how to
fix this for more elaborate functions.
parent 35c7838f
No related branches found
No related tags found
1 merge request!725Fix/compiler errors and warnings clang
...@@ -111,27 +111,8 @@ public: ...@@ -111,27 +111,8 @@ public:
CellCenterPrimaryVariables flux = fluxVars.computeFluxForCellCenter(problem, element, fvGeometry, elemVolVars, CellCenterPrimaryVariables flux = fluxVars.computeFluxForCellCenter(problem, element, fvGeometry, elemVolVars,
elemFaceVars, scvf, elemFluxVarsCache[scvf]); elemFaceVars, scvf, elemFluxVarsCache[scvf]);
// add energy fluxes for non-isothermal models computeFluxForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>(),
Dune::Hybrid::ifElse(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(), problem, element, fvGeometry, elemVolVars, elemFaceVars, scvf, elemFluxVarsCache, flux);
[&](auto IF)
{
// if we are on an inflow/outflow boundary, use the volVars of the element itself
// TODO: catch neumann and outflow in localResidual's evalBoundary_()
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
if(bcTypes.isOutflow(Indices::energyBalanceIdx))
isOutflow = true;
}
auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); };
using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
flux[Indices::energyBalanceIdx] = FluxVariables::advectiveFluxForCellCenter(elemVolVars, elemFaceVars, scvf, upwindTerm, isOutflow);
flux[Indices::energyBalanceIdx] += HeatConductionType::diffusiveFluxForCellCenter(problem, element, fvGeometry, elemVolVars, scvf);
});
return flux; return flux;
} }
...@@ -165,12 +146,8 @@ public: ...@@ -165,12 +146,8 @@ public:
CellCenterPrimaryVariables storage; CellCenterPrimaryVariables storage;
storage[Indices::massBalanceIdx] = volVars.density(); storage[Indices::massBalanceIdx] = volVars.density();
// add energy storage for non-isothermal models computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(),
Dune::Hybrid::ifElse(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(), problem, scv, volVars, storage);
[&](auto IF)
{
storage[Indices::energyBalanceIdx] = volVars.density() * volVars.internalEnergy();
});
return storage; return storage;
} }
...@@ -344,6 +321,51 @@ protected: ...@@ -344,6 +321,51 @@ protected:
} }
} }
//! Evaluate energy fluxes entering or leaving the cell center control volume for non isothermal models
void computeFluxForCellCenterNonIsothermal_(std::true_type,
const Problem& problem,
const Element &element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars,
const SubControlVolumeFace &scvf,
const ElementFluxVariablesCache& elemFluxVarsCache,
CellCenterPrimaryVariables& flux) const
{
// if we are on an inflow/outflow boundary, use the volVars of the element itself
// TODO: catch neumann and outflow in localResidual's evalBoundary_()
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
if(bcTypes.isOutflow(Indices::energyBalanceIdx))
isOutflow = true;
}
auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); };
using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
flux[Indices::energyBalanceIdx] = FluxVariables::advectiveFluxForCellCenter(elemVolVars, elemFaceVars, scvf, upwindTerm, isOutflow);
flux[Indices::energyBalanceIdx] += HeatConductionType::diffusiveFluxForCellCenter(problem, element, fvGeometry, elemVolVars, scvf);
}
//! Evaluate energy fluxes entering or leaving the cell center control volume for non isothermal models
template <typename... Args>
void computeFluxForCellCenterNonIsothermal_(std::false_type, Args&&... args) const {}
//! Evaluate energy storage for non isothermal models
void computeStorageForCellCenterNonIsothermal_(std::true_type,
const Problem& problem,
const SubControlVolume& scv,
const VolumeVariables& volVars,
CellCenterPrimaryVariables& storage) const
{
storage[Indices::energyBalanceIdx] = volVars.density() * volVars.internalEnergy();
}
//! Evaluate energy storage for isothermal models
template <typename... Args>
void computeStorageForCellCenterNonIsothermal_(std::false_type, Args&&... args) const {}
private: private:
......
...@@ -102,12 +102,8 @@ public: ...@@ -102,12 +102,8 @@ public:
if(replaceCompEqIdx < numComponents) if(replaceCompEqIdx < numComponents)
storage[replaceCompEqIdx] = density; storage[replaceCompEqIdx] = density;
// add energy storage for non-isothermal models this->computeStorageForCellCenterNonIsothermal_(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(),
Dune::Hybrid::ifElse(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(), problem, scv, volVars, storage);
[&](auto IF)
{
storage[Indices::energyBalanceIdx] = volVars.density() * volVars.internalEnergy();
});
return storage; return storage;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment