Commit fd1a2322 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[cleanup] Use convenience function for concentrations

Implement  molefraction(), massfraction(), molarity()
and molardensity() functions in the volvars and use it
instead of volvars.fluidstate().x().
parent b87bb3b9
......@@ -105,12 +105,12 @@ public:
for (int compIdx = 0; compIdx < numComponents; ++compIdx){
// calculate mole fractions at the integration points of the face
moleFraction_[phaseIdx][compIdx] += elemVolVars[volVarsIdx].fluidState().moleFraction(phaseIdx, compIdx)*
moleFraction_[phaseIdx][compIdx] += elemVolVars[volVarsIdx].moleFraction(phaseIdx, compIdx)*
face.shapeValue[idx];
// calculate mole fraction gradients
tmp = feGrad;
tmp *= elemVolVars[volVarsIdx].fluidState().moleFraction(phaseIdx, compIdx);
tmp *= elemVolVars[volVarsIdx].moleFraction(phaseIdx, compIdx);
moleFractionGrad_[phaseIdx][compIdx] += tmp;
}
}
......
......@@ -77,7 +77,7 @@ public:
for (int compIdx = 0; compIdx < numComponents; ++ compIdx) {
storage[compIdx] +=
volVars.saturation(phaseIdx)*
volVars.fluidState().molarity(phaseIdx, compIdx);
volVars.molarity(phaseIdx, compIdx);
#ifndef NDEBUG
if (!std::isfinite(storage[compIdx]))
DUNE_THROW(NumericalProblem, "Calculated non-finite storage");
......@@ -131,10 +131,10 @@ if (!std::isfinite(volumeFlux))
if (enableSmoothUpwinding_) {
const Scalar kGradPNormal = fluxVars.kGradPNormal(phaseIdx);
const Scalar mobUp = up.mobility(phaseIdx);
const Scalar conUp = up.fluidState().molarity(phaseIdx, compIdx);
const Scalar conUp = up.molarity(phaseIdx, compIdx);
const Scalar mobDn = dn.mobility(phaseIdx);
const Scalar conDn = dn.fluidState().molarity(phaseIdx, compIdx);
const Scalar conDn = dn.molarity(phaseIdx, compIdx);
const Scalar mobConUp = mobUp*conUp;
const Scalar mobConDn = mobDn*conDn;
......@@ -180,9 +180,9 @@ if (!std::isfinite(volumeFlux))
{// not use smooth upwinding
flux[compIdx] =
volumeFlux *
(( massUpwindWeight)*up.fluidState().molarity(phaseIdx, compIdx)
(( massUpwindWeight)*up.molarity(phaseIdx, compIdx)
+
( 1. - massUpwindWeight)*dn.fluidState().molarity(phaseIdx, compIdx) );
( 1. - massUpwindWeight)*dn.molarity(phaseIdx, compIdx) );
if (!std::isfinite(flux[compIdx]))
DUNE_THROW(NumericalProblem, "Calculated non-finite normal flux in phase " << phaseIdx << " comp " << compIdx << "T: "<< up.fluidState().temperature(phaseIdx) << "S "<<up.saturation(phaseIdx) ) ;
}
......@@ -221,8 +221,8 @@ if (!std::isfinite(volumeFlux))
// integration point by the arithmetic mean of the
// concentration of the sub-control volumes
Scalar molarDensityAtIP;
molarDensityAtIP = volVarsI.fluidState().molarDensity(phaseIdx);
molarDensityAtIP += volVarsJ.fluidState().molarDensity(phaseIdx);
molarDensityAtIP = volVarsI.molarDensity(phaseIdx);
molarDensityAtIP += volVarsJ.molarDensity(phaseIdx);
molarDensityAtIP /= 2;
Diffusion::flux(flux, phaseIdx, fluxVars, molarDensityAtIP);
......
......@@ -205,7 +205,7 @@ public:
Scalar x[numPhases][numComponents]; // mass fractions in wetting phase
for(int phaseIdx=0; phaseIdx<numPhases; ++phaseIdx){
for (int compIdx=0; compIdx< numComponents; ++ compIdx){
x[phaseIdx][compIdx] = volVars.fluidState().moleFraction(phaseIdx, compIdx);
x[phaseIdx][compIdx] = volVars.moleFraction(phaseIdx, compIdx);
}
}
Valgrind::CheckDefined(x);
......@@ -221,7 +221,7 @@ public:
#endif
Scalar phaseDensity[numPhases];
for(int phaseIdx=0; phaseIdx<numPhases; ++phaseIdx){
phaseDensity[phaseIdx] = volVars.fluidState().molarDensity(phaseIdx);
phaseDensity[phaseIdx] = volVars.molarDensity(phaseIdx);
}
// diffusion coefficients in wetting phase
......
......@@ -274,6 +274,40 @@ public:
Scalar saturation(int phaseIdx) const
{ return fluidState_.saturation(phaseIdx); }
/*!
* \brief Returns the mass fraction of a given component in a
* given phase within the control volume in \f$[-]\f$.
*
* \param phaseIdx The phase index
* \param compIdx The component index
*/
Scalar massFraction(const int phaseIdx, const int compIdx) const
{ return fluidState_.massFraction(phaseIdx, compIdx); }
/*!
* \brief Returns the mole fraction of a given component in a
* given phase within the control volume in \f$[-]\f$.
*
* \param phaseIdx The phase index
* \param compIdx The component index
*/
Scalar moleFraction(const int phaseIdx, const int compIdx) const
{ return fluidState_.moleFraction(phaseIdx, compIdx); }
/*!
* \brief Return concentration \f$\mathrm{[mol/m^3]}\f$ of a component in the phase.
*
* \param compIdx The index of the component
*/
Scalar molarity(const int phaseIdx, int compIdx) const
{ return fluidState_.molarity(phaseIdx, compIdx); }
/*!
* \brief Return molar density \f$\mathrm{[mol/m^3]}\f$ the of the fluid phase.
*/
Scalar molarDensity(const int phaseIdx) const
{ return fluidState_.molarDensity(phaseIdx);}
/*!
* \brief Returns the effective mobility of a given phase within
* the control volume.
......
......@@ -157,9 +157,9 @@ public:
if (mobilityOutput_) mobility_[phaseIdx][dofIdxGlobal] = volVars.mobility(phaseIdx);
if (averageMolarMassOutput_) averageMolarMass_[phaseIdx][dofIdxGlobal] = volVars.fluidState().averageMolarMass(phaseIdx);
for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
if (moleFracOutput_) moleFrac_[phaseIdx][compIdx][dofIdxGlobal] = volVars.fluidState().moleFraction(phaseIdx, compIdx);
if (massFracOutput_) massFrac_[phaseIdx][compIdx][dofIdxGlobal] = volVars.fluidState().massFraction(phaseIdx, compIdx);
if (molarityOutput_) molarity_[phaseIdx][compIdx][dofIdxGlobal] = volVars.fluidState().molarity(phaseIdx, compIdx);
if (moleFracOutput_) moleFrac_[phaseIdx][compIdx][dofIdxGlobal] = volVars.moleFraction(phaseIdx, compIdx);
if (massFracOutput_) massFrac_[phaseIdx][compIdx][dofIdxGlobal] = volVars.massFraction(phaseIdx, compIdx);
if (molarityOutput_) molarity_[phaseIdx][compIdx][dofIdxGlobal] = volVars.molarity(phaseIdx, compIdx);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment