Skip to content
Snippets Groups Projects
Commit 28f187c4 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[tracer][localresidual] Use free function for density

parent e9a7d5cf
No related branches found
No related tags found
1 merge request!1696Feature/diffusion laws mass refvelocity
...@@ -242,24 +242,22 @@ public: ...@@ -242,24 +242,22 @@ public:
const auto& insideVolVars = curElemVolVars[scvf.insideScvIdx()]; const auto& insideVolVars = curElemVolVars[scvf.insideScvIdx()];
const auto& outsideVolVars = curElemVolVars[scvf.outsideScvIdx()]; const auto& outsideVolVars = curElemVolVars[scvf.outsideScvIdx()];
const auto insideWeight = std::signbit(volFlux) ? (1.0 - upwindWeight) : upwindWeight; const Scalar insideWeight = std::signbit(volFlux) ? (1.0 - upwindWeight) : upwindWeight;
const auto outsideWeight = 1.0 - insideWeight; const Scalar outsideWeight = 1.0 - insideWeight;
const auto advDerivII = volFlux*rho(insideVolVars)*insideWeight; const auto advDerivII = volFlux*rho(insideVolVars)*insideWeight;
const auto advDerivIJ = volFlux*rho(outsideVolVars)*outsideWeight; const auto advDerivIJ = volFlux*rho(outsideVolVars)*outsideWeight;
// diffusive term // diffusive term
auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation(); const auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation();
const auto& fluxCache = elemFluxVarsCache[scvf]; const auto& fluxCache = elemFluxVarsCache[scvf];
const auto rhoInside = (referenceSystemFormulation == ReferenceSystemFormulation::massAveraged) ? insideVolVars.density(phaseIdx) : insideVolVars.molarDensity(phaseIdx); const Scalar rhoInside = massOrMolarDensity(insideVolVars, referenceSystemFormulation, phaseIdx);
const Scalar rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystemFormulation, phaseIdx);
const auto rhoOutside = (referenceSystemFormulation == ReferenceSystemFormulation::massAveraged) ? outsideVolVars.density(phaseIdx) : outsideVolVars.molarDensity(phaseIdx); const Scalar massOrMolarDensity = 0.5*(rhoInside + rhoOutside);
const auto massOrMolarDensity = 0.5*(rhoInside + rhoOutside);
for (int compIdx = 0; compIdx < numComponents; ++compIdx) for (int compIdx = 0; compIdx < numComponents; ++compIdx)
{ {
// diffusive term // diffusive term
auto diffDeriv = 0.0; Scalar diffDeriv = 0.0;
if (referenceSystemFormulation == ReferenceSystemFormulation::massAveraged) if (referenceSystemFormulation == ReferenceSystemFormulation::massAveraged)
{ {
diffDeriv = useMoles ? massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx)/FluidSystem::molarMass(compIdx) diffDeriv = useMoles ? massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx)/FluidSystem::molarMass(compIdx)
...@@ -268,7 +266,7 @@ public: ...@@ -268,7 +266,7 @@ public:
else if (referenceSystemFormulation == ReferenceSystemFormulation::molarAveraged) else if (referenceSystemFormulation == ReferenceSystemFormulation::molarAveraged)
{ {
diffDeriv = useMoles ? massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx) diffDeriv = useMoles ? massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx)
: massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx)*FluidSystem::molarMass(compIdx); : massOrMolarDensity*fluxCache.diffusionTij(phaseIdx, compIdx)*FluidSystem::molarMass(compIdx);
} }
else else
DUNE_THROW(Dune::NotImplemented, "other reference systems than mass and molar averaged are not implemented"); DUNE_THROW(Dune::NotImplemented, "other reference systems than mass and molar averaged are not implemented");
......
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