Commit 543e9d25 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[navierstokesnc][volvars] Make sure to use default phase idx

parent 2e5a396e
......@@ -57,12 +57,12 @@ class NavierStokesNCVolumeVariables : public NavierStokesVolumeVariables<TypeTag
enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents),
numPhases = FluidSystem::numPhases,
phaseIdx = Indices::phaseIdx,
mainCompIdx = Indices::mainCompIdx,
pressureIdx = Indices::pressureIdx
};
static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);
static constexpr auto defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
public:
......@@ -89,16 +89,16 @@ public:
typename FluidSystem::ParameterCache paramCache;
paramCache.updateAll(this->fluidState_);
int compIIdx = phaseIdx;
int compIIdx = defaultPhaseIdx;
for (unsigned int compJIdx = 0; compJIdx < numComponents; ++compJIdx)
{
// binary diffusion coefficents
if(compIIdx!= compJIdx)
{
setDiffusionCoefficient_(phaseIdx, compJIdx,
setDiffusionCoefficient_(defaultPhaseIdx, compJIdx,
FluidSystem::binaryDiffusionCoefficient(this->fluidState_,
paramCache,
phaseIdx,
defaultPhaseIdx,
compIIdx,
compJIdx));
}
......@@ -116,14 +116,14 @@ public:
{
const Scalar t = ParentType::temperature(elemSol, problem, element, scv);
fluidState.setTemperature(t);
fluidState.setSaturation(/*phaseIdx=*/0, 1.);
fluidState.setSaturation(defaultPhaseIdx, 1.);
fluidState.setPressure(/*phaseIdx=*/0, elemSol[0][Indices::pressureIdx]);
fluidState.setPressure(defaultPhaseIdx, elemSol[0][Indices::pressureIdx]);
// saturation in a single phase is always 1 and thus redundant
// to set. But since we use the fluid state shared by the
// immiscible multi-phase models, so we have to set it here...
fluidState.setSaturation(/*phaseIdx=*/0, 1.0);
fluidState.setSaturation(defaultPhaseIdx, 1.0);
Scalar fracMinor = 0.0;
int transportEqIdx = 1;
......@@ -135,28 +135,28 @@ public:
const Scalar moleOrMassFraction = elemSol[0][transportEqIdx++] + 1.0;
if(useMoles)
fluidState.setMoleFraction(phaseIdx, compIdx, moleOrMassFraction -1.0);
fluidState.setMoleFraction(defaultPhaseIdx, compIdx, moleOrMassFraction -1.0);
else
fluidState.setMassFraction(phaseIdx, compIdx, moleOrMassFraction -1.0);
fluidState.setMassFraction(defaultPhaseIdx, compIdx, moleOrMassFraction -1.0);
fracMinor += moleOrMassFraction - 1.0;
}
if(useMoles)
fluidState.setMoleFraction(phaseIdx, mainCompIdx, 1.0 - fracMinor);
fluidState.setMoleFraction(defaultPhaseIdx, mainCompIdx, 1.0 - fracMinor);
else
fluidState.setMassFraction(phaseIdx, mainCompIdx, 1.0 - fracMinor);
fluidState.setMassFraction(defaultPhaseIdx, mainCompIdx, 1.0 - fracMinor);
typename FluidSystem::ParameterCache paramCache;
paramCache.updatePhase(fluidState, phaseIdx);
paramCache.updatePhase(fluidState, defaultPhaseIdx);
Scalar value = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(phaseIdx, value);
Scalar value = FluidSystem::density(fluidState, paramCache, defaultPhaseIdx);
fluidState.setDensity(defaultPhaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
fluidState.setViscosity(phaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, defaultPhaseIdx);
fluidState.setViscosity(defaultPhaseIdx, value);
// compute and set the enthalpy
const Scalar h = ParentType::enthalpy(fluidState, paramCache, phaseIdx);
fluidState.setEnthalpy(phaseIdx, h);
const Scalar h = ParentType::enthalpy(fluidState, paramCache, defaultPhaseIdx);
fluidState.setEnthalpy(defaultPhaseIdx, h);
}
......@@ -167,7 +167,10 @@ public:
* \param compIdx the index of the component
*/
Scalar massFraction(int phaseIdx, int compIdx) const
{ return this->fluidState_.massFraction(phaseIdx, compIdx); }
{
assert(phaseIdx == defaultPhaseIdx);
return this->fluidState_.massFraction(phaseIdx, compIdx);
}
/*!
* \brief Returns the mole fraction of a component in the phase
......@@ -176,7 +179,10 @@ public:
* \param compIdx the index of the component
*/
Scalar moleFraction(int phaseIdx, int compIdx) const
{ return this->fluidState_.moleFraction(phaseIdx, compIdx); }
{
assert(phaseIdx == defaultPhaseIdx);
return this->fluidState_.moleFraction(phaseIdx, compIdx);
}
/*!
* \brief Returns the mass density of a given phase within the
......@@ -184,9 +190,9 @@ public:
*
* \param phaseIdx The phase index
*/
Scalar molarDensity() const
Scalar molarDensity(int phaseIdx = 0) const
{
return this->fluidState_.molarDensity(phaseIdx);
return this->fluidState_.molarDensity(defaultPhaseIdx);
}
/*!
......@@ -194,6 +200,7 @@ public:
*/
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
{
assert(phaseIdx == defaultPhaseIdx);
if (compIdx < phaseIdx)
return diffCoefficient_[phaseIdx][compIdx];
else if (compIdx > phaseIdx)
......@@ -212,6 +219,7 @@ protected:
void setDiffusionCoefficient_(int phaseIdx, int compIdx, Scalar d)
{
assert(phaseIdx == defaultPhaseIdx);
if (compIdx < phaseIdx)
diffCoefficient_[phaseIdx][compIdx] = std::move(d);
else if (compIdx > phaseIdx)
......@@ -220,7 +228,6 @@ protected:
DUNE_THROW(Dune::InvalidStateException, "Diffusion coeffiecient for phaseIdx = compIdx doesn't exist");
}
std::array<std::array<Scalar, numComponents-1>, numPhases> diffCoefficient_;
};
......
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