Skip to content
Snippets Groups Projects
Commit dd746cab authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[freeflow] Remove unnecessary phaseIdx as function arguments

parent 14c47dbc
No related branches found
No related tags found
1 merge request!868Freeflow/cleanup
...@@ -63,7 +63,6 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::staggered > ...@@ -63,7 +63,6 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::staggered >
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
static constexpr int numComponents = ModelTraits::numComponents(); static constexpr int numComponents = ModelTraits::numComponents();
static constexpr int phaseIdx = Indices::phaseIdx;
static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles); static constexpr bool useMoles = GET_PROP_VALUE(TypeTag, UseMoles);
static_assert(ModelTraits::numPhases() == 1, "Only one phase allowed supported!"); static_assert(ModelTraits::numPhases() == 1, "Only one phase allowed supported!");
...@@ -112,11 +111,11 @@ public: ...@@ -112,11 +111,11 @@ public:
} }
const Scalar tij = transmissibility_(problem, fvGeometry, elemVolVars, scvf, compIdx); const Scalar tij = transmissibility_(problem, fvGeometry, elemVolVars, scvf, compIdx);
const Scalar insideMoleFraction = insideVolVars.moleFraction(phaseIdx, compIdx); const Scalar insideMoleFraction = insideVolVars.moleFraction(compIdx);
const Scalar outsideMolarDensity = scvf.boundary() ? insideVolVars.molarDensity() : outsideVolVars.molarDensity(); const Scalar outsideMolarDensity = scvf.boundary() ? insideVolVars.molarDensity() : outsideVolVars.molarDensity();
const Scalar avgDensity = 0.5*(insideMolarDensity + outsideMolarDensity); const Scalar avgDensity = 0.5*(insideMolarDensity + outsideMolarDensity);
const Scalar outsideMoleFraction = outsideVolVars.moleFraction(phaseIdx, compIdx); const Scalar outsideMoleFraction = outsideVolVars.moleFraction(compIdx);
flux[compIdx] = avgDensity * tij * (insideMoleFraction - outsideMoleFraction); flux[compIdx] = avgDensity * tij * (insideMoleFraction - outsideMoleFraction);
} }
...@@ -161,7 +160,7 @@ public: ...@@ -161,7 +160,7 @@ public:
const auto& insideVolVars = elemVolVars[insideScv]; const auto& insideVolVars = elemVolVars[insideScv];
const Scalar insideDistance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm(); const Scalar insideDistance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
const Scalar insideD = insideVolVars.effectiveDiffusivity(phaseIdx, compIdx); const Scalar insideD = insideVolVars.effectiveDiffusivity(compIdx);
const Scalar ti = calculateOmega_(insideDistance, insideD, 1.0); const Scalar ti = calculateOmega_(insideDistance, insideD, 1.0);
if(scvf.boundary()) if(scvf.boundary())
...@@ -171,7 +170,7 @@ public: ...@@ -171,7 +170,7 @@ public:
const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx()); const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()]; const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
const Scalar outsideDistance = (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(); const Scalar outsideDistance = (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm();
const Scalar outsideD = outsideVolVars.effectiveDiffusivity(phaseIdx, compIdx); const Scalar outsideD = outsideVolVars.effectiveDiffusivity(compIdx);
const Scalar tj = calculateOmega_(outsideDistance, outsideD, 1.0); const Scalar tj = calculateOmega_(outsideDistance, outsideD, 1.0);
tij = scvf.area()*(ti * tj)/(ti + tj); tij = scvf.area()*(ti * tj)/(ti + tj);
......
...@@ -109,9 +109,9 @@ public: ...@@ -109,9 +109,9 @@ public:
for (int compIdx = 0; compIdx < numComponents-1; compIdx++) for (int compIdx = 0; compIdx < numComponents-1; compIdx++)
{ {
//calculate x_inside //calculate x_inside
const auto xInside = insideVolVars.moleFraction(phaseIdx, compIdx); const auto xInside = insideVolVars.moleFraction(compIdx);
//calculate outside molefraction with the respective transmissibility //calculate outside molefraction with the respective transmissibility
const auto xOutside = outsideVolVars.moleFraction(phaseIdx, compIdx); const auto xOutside = outsideVolVars.moleFraction(compIdx);
moleFracInside[compIdx] = xInside; moleFracInside[compIdx] = xInside;
moleFracOutside[compIdx] = xOutside; moleFracOutside[compIdx] = xOutside;
...@@ -218,7 +218,7 @@ private: ...@@ -218,7 +218,7 @@ private:
for (int compIIdx = 0; compIIdx < numComponents-1; compIIdx++) for (int compIIdx = 0; compIIdx < numComponents-1; compIIdx++)
{ {
const auto xi = volVars.moleFraction(phaseIdx, compIIdx); const auto xi = volVars.moleFraction(compIIdx);
//calculate diffusivity for i,numComponents //calculate diffusivity for i,numComponents
auto fluidState = volVars.fluidState(); auto fluidState = volVars.fluidState();
...@@ -237,7 +237,7 @@ private: ...@@ -237,7 +237,7 @@ private:
if (compkIdx == compIIdx) if (compkIdx == compIIdx)
continue; continue;
const auto xk = volVars.moleFraction(phaseIdx, compkIdx); const auto xk = volVars.moleFraction(compkIdx);
Scalar tik = FluidSystem::binaryDiffusionCoefficient(fluidState, Scalar tik = FluidSystem::binaryDiffusionCoefficient(fluidState,
paramCache, paramCache,
phaseIdx, phaseIdx,
......
...@@ -58,7 +58,7 @@ class NavierStokesVolumeVariablesImplementation<TypeTag, false> ...@@ -58,7 +58,7 @@ class NavierStokesVolumeVariablesImplementation<TypeTag, false>
using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity; using Element = typename GridView::template Codim<0>::Entity;
static const int defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); static const int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
public: public:
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
extrusionFactor_ = problem.extrusionFactor(element, scv, elemSol); extrusionFactor_ = problem.extrusionFactor(element, scv, elemSol);
completeFluidState(elemSol, problem, element, scv, fluidState_); completeFluidState(elemSol, problem, element, scv, fluidState_);
}; }
/*! /*!
* \brief Returns the primary variables at the dof associated with a given scv. * \brief Returns the primary variables at the dof associated with a given scv.
...@@ -105,21 +105,21 @@ public: ...@@ -105,21 +105,21 @@ public:
const Scalar t = problem.temperatureAtPos(scv.dofPosition()); const Scalar t = problem.temperatureAtPos(scv.dofPosition());
fluidState.setTemperature(t); fluidState.setTemperature(t);
fluidState.setPressure(defaultPhaseIdx, elemSol[0][Indices::pressureIdx]); fluidState.setPressure(phaseIdx, elemSol[0][Indices::pressureIdx]);
// saturation in a single phase is always 1 and thus redundant // saturation in a single phase is always 1 and thus redundant
// to set. But since we use the fluid state shared by the // to set. But since we use the fluid state shared by the
// immiscible multi-phase models, so we have to set it here... // immiscible multi-phase models, so we have to set it here...
fluidState.setSaturation(defaultPhaseIdx, 1.0); fluidState.setSaturation(phaseIdx, 1.0);
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::ParameterCache paramCache;
paramCache.updatePhase(fluidState, defaultPhaseIdx); paramCache.updatePhase(fluidState, phaseIdx);
Scalar value = FluidSystem::density(fluidState, paramCache, defaultPhaseIdx); Scalar value = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(defaultPhaseIdx, value); fluidState.setDensity(phaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, defaultPhaseIdx); value = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
fluidState.setViscosity(defaultPhaseIdx, value); fluidState.setViscosity(phaseIdx, value);
} }
/*! /*!
...@@ -148,47 +148,47 @@ public: ...@@ -148,47 +148,47 @@ public:
* \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within * \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within
* the control volume. * the control volume.
*/ */
Scalar pressure(int phaseIdx = 0) const Scalar pressure() const
{ return fluidState_.pressure(defaultPhaseIdx); } { return fluidState_.pressure(phaseIdx); }
/*! /*!
* \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the * \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the
* control volume. * control volume.
*/ */
Scalar density(int phaseIdx = 0) const Scalar density() const
{ return fluidState_.density(defaultPhaseIdx); } { return fluidState_.density(phaseIdx); }
/*! /*!
* \brief Returns the mass density of a given phase within the * \brief Returns the mass density of a given phase within the
* control volume. * control volume.
*/ */
Scalar molarDensity(int phaseIdx = 0) const Scalar molarDensity() const
{ {
return fluidState_.molarDensity(defaultPhaseIdx); return fluidState_.molarDensity(phaseIdx);
} }
/*! /*!
* \brief Returns the molar mass of a given phase within the * \brief Returns the molar mass of a given phase within the
* control volume. * control volume.
*/ */
Scalar molarMass(int phaseIdx = 0) const Scalar molarMass() const
{ {
return fluidState_.averageMolarMass(defaultPhaseIdx); return fluidState_.averageMolarMass(phaseIdx);
} }
/*! /*!
* \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the * \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
* control volume. * control volume.
*/ */
Scalar viscosity(int phaseIdx = 0) const Scalar viscosity() const
{ return fluidState_.viscosity(defaultPhaseIdx); } { return fluidState_.viscosity(phaseIdx); }
/*! /*!
* \brief Return the effective dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the * \brief Return the effective dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
* control volume. * control volume.
*/ */
Scalar effectiveViscosity(int phaseIdx = 0) const Scalar effectiveViscosity() const
{ return viscosity(defaultPhaseIdx); } { return viscosity(); }
/*! /*!
* \brief Return the fluid state of the control volume. * \brief Return the fluid state of the control volume.
...@@ -210,8 +210,7 @@ public: ...@@ -210,8 +210,7 @@ public:
//! This is needed for completing the fluid state //! This is needed for completing the fluid state
template<class FluidState, class ParameterCache> template<class FluidState, class ParameterCache>
static Scalar enthalpy(const FluidState& fluidState, static Scalar enthalpy(const FluidState& fluidState,
const ParameterCache& paramCache, const ParameterCache& paramCache)
const int defaultPhaseIdx)
{ {
return 0; return 0;
} }
...@@ -239,7 +238,7 @@ class NavierStokesVolumeVariablesImplementation<TypeTag, true> ...@@ -239,7 +238,7 @@ class NavierStokesVolumeVariablesImplementation<TypeTag, true>
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices); using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
static const int defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); static const int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
static const int temperatureIdx = Indices::temperatureIdx; static const int temperatureIdx = Indices::temperatureIdx;
...@@ -278,25 +277,25 @@ public: ...@@ -278,25 +277,25 @@ public:
FluidState& fluidState) FluidState& fluidState)
{ {
fluidState.setTemperature(elemSol[0][Indices::temperatureIdx]); fluidState.setTemperature(elemSol[0][Indices::temperatureIdx]);
fluidState.setPressure(defaultPhaseIdx, elemSol[0][Indices::pressureIdx]); fluidState.setPressure(phaseIdx, elemSol[0][Indices::pressureIdx]);
// saturation in a single phase is always 1 and thus redundant // saturation in a single phase is always 1 and thus redundant
// to set. But since we use the fluid state shared by the // to set. But since we use the fluid state shared by the
// immiscible multi-phase models, so we have to set it here... // immiscible multi-phase models, so we have to set it here...
fluidState.setSaturation(defaultPhaseIdx, 1.0); fluidState.setSaturation(phaseIdx, 1.0);
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::ParameterCache paramCache;
paramCache.updatePhase(fluidState, defaultPhaseIdx); paramCache.updatePhase(fluidState, phaseIdx);
Scalar value = FluidSystem::density(fluidState, paramCache, defaultPhaseIdx); Scalar value = FluidSystem::density(fluidState, paramCache, phaseIdx);
fluidState.setDensity(defaultPhaseIdx, value); fluidState.setDensity(phaseIdx, value);
value = FluidSystem::viscosity(fluidState, paramCache, defaultPhaseIdx); value = FluidSystem::viscosity(fluidState, paramCache, phaseIdx);
fluidState.setViscosity(defaultPhaseIdx, value); fluidState.setViscosity(phaseIdx, value);
// compute and set the enthalpy // compute and set the enthalpy
value = FluidSystem::enthalpy(fluidState, paramCache, defaultPhaseIdx); value = FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
fluidState.setEnthalpy(defaultPhaseIdx, value); fluidState.setEnthalpy(phaseIdx, value);
} }
/*! /*!
...@@ -304,28 +303,28 @@ public: ...@@ -304,28 +303,28 @@ public:
* sub-control volume. * sub-control volume.
*/ */
Scalar internalEnergy() const Scalar internalEnergy() const
{ return this->fluidState_.internalEnergy(defaultPhaseIdx); } { return this->fluidState_.internalEnergy(phaseIdx); }
/*! /*!
* \brief Returns the total enthalpy of the fluid phase in the sub-control * \brief Returns the total enthalpy of the fluid phase in the sub-control
* volume. * volume.
*/ */
Scalar enthalpy() const Scalar enthalpy() const
{ return this->fluidState_.enthalpy(defaultPhaseIdx); } { return this->fluidState_.enthalpy(phaseIdx); }
/*! /*!
* \brief Return the specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ * \brief Return the specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$
* in the sub-control volume. * in the sub-control volume.
*/ */
Scalar heatCapacity() const Scalar heatCapacity() const
{ return FluidSystem::heatCapacity(this->fluidState_, defaultPhaseIdx); } { return FluidSystem::heatCapacity(this->fluidState_, phaseIdx); }
/*! /*!
* \brief Returns the thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ * \brief Returns the thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
* of the fluid phase in the sub-control volume. * of the fluid phase in the sub-control volume.
*/ */
Scalar thermalConductivity() const Scalar thermalConductivity() const
{ return FluidSystem::thermalConductivity(this->fluidState_, defaultPhaseIdx); } { return FluidSystem::thermalConductivity(this->fluidState_, phaseIdx); }
//! The temperature is a primary variable for non-isothermal models //! The temperature is a primary variable for non-isothermal models
using ParentType::temperature; using ParentType::temperature;
...@@ -342,10 +341,9 @@ public: ...@@ -342,10 +341,9 @@ public:
//! This is needed for completing the fluid state //! This is needed for completing the fluid state
template<class FluidState, class ParameterCache> template<class FluidState, class ParameterCache>
static Scalar enthalpy(const FluidState& fluidState, static Scalar enthalpy(const FluidState& fluidState,
const ParameterCache& paramCache, const ParameterCache& paramCache)
const int defaultPhaseIdx)
{ {
return FluidSystem::enthalpy(fluidState, paramCache, defaultPhaseIdx); return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
} }
}; };
......
...@@ -64,7 +64,6 @@ class NavierStokesNCFluxVariablesImpl<TypeTag, DiscretizationMethod::staggered> ...@@ -64,7 +64,6 @@ class NavierStokesNCFluxVariablesImpl<TypeTag, DiscretizationMethod::staggered>
// The index of the component balance equation that gets replaced with the total mass balance // The index of the component balance equation that gets replaced with the total mass balance
static const int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx); static const int replaceCompEqIdx = GET_PROP_VALUE(TypeTag, ReplaceCompEqIdx);
static const int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
using ParentType = NavierStokesFluxVariables<TypeTag>; using ParentType = NavierStokesFluxVariables<TypeTag>;
...@@ -101,7 +100,7 @@ public: ...@@ -101,7 +100,7 @@ public:
auto upwindTerm = [compIdx](const auto& volVars) auto upwindTerm = [compIdx](const auto& volVars)
{ {
const auto density = useMoles ? volVars.molarDensity() : volVars.density(); const auto density = useMoles ? volVars.molarDensity() : volVars.density();
const auto fraction = useMoles ? volVars.moleFraction(phaseIdx, compIdx) : volVars.massFraction(phaseIdx, compIdx); const auto fraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
return density * fraction; return density * fraction;
}; };
......
...@@ -60,7 +60,6 @@ class NavierStokesNCResidualImpl<TypeTag, DiscretizationMethod::staggered> ...@@ -60,7 +60,6 @@ class NavierStokesNCResidualImpl<TypeTag, DiscretizationMethod::staggered>
enum { enum {
conti0EqIdx = Indices::conti0EqIdx, conti0EqIdx = Indices::conti0EqIdx,
phaseIdx = Indices::phaseIdx,
// The index of the component balance equation // The index of the component balance equation
// that gets replaced with the total mass balance // that gets replaced with the total mass balance
...@@ -91,7 +90,7 @@ public: ...@@ -91,7 +90,7 @@ public:
{ {
const int eqIdx = conti0EqIdx + compIdx; const int eqIdx = conti0EqIdx + compIdx;
const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(phaseIdx, compIdx) : volVars.massFraction(phaseIdx, compIdx); const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
const Scalar s = density * massOrMoleFraction; const Scalar s = density * massOrMoleFraction;
if (eqIdx != replaceCompEqIdx) if (eqIdx != replaceCompEqIdx)
...@@ -131,7 +130,7 @@ protected: ...@@ -131,7 +130,7 @@ protected:
if(eqIdx != conti0EqIdx && bcTypes.isDirichletCell(eqIdx)) if(eqIdx != conti0EqIdx && bcTypes.isDirichletCell(eqIdx))
{ {
const auto& insideVolVars = elemVolVars[insideScv]; const auto& insideVolVars = elemVolVars[insideScv];
const Scalar massOrMoleFraction = useMoles ? insideVolVars.moleFraction(phaseIdx, compIdx) : insideVolVars.massFraction(phaseIdx, compIdx); const Scalar massOrMoleFraction = useMoles ? insideVolVars.moleFraction(compIdx) : insideVolVars.massFraction(compIdx);
residual[eqIdx] = massOrMoleFraction - problem.dirichletAtPos(insideScv.center())[eqIdx]; residual[eqIdx] = massOrMoleFraction - problem.dirichletAtPos(insideScv.center())[eqIdx];
} }
} }
......
...@@ -83,16 +83,15 @@ public: ...@@ -83,16 +83,15 @@ public:
completeFluidState(elemSol, problem, element, scv, this->fluidState_); completeFluidState(elemSol, problem, element, scv, this->fluidState_);
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::ParameterCache paramCache;
paramCache.updateAll(this->fluidState_); paramCache.updateAll(this->fluidState_);
int compIIdx = phaseIdx; int compIIdx = mainCompIdx;
for (unsigned int compJIdx = 0; compJIdx < numComponents; ++compJIdx) for (unsigned int compJIdx = 0; compJIdx < numComponents; ++compJIdx)
{ {
// binary diffusion coefficents // binary diffusion coefficents
if(compIIdx!= compJIdx) if(compIIdx!= compJIdx)
{ {
setDiffusionCoefficient_(phaseIdx, compJIdx, setDiffusionCoefficient_(compJIdx,
FluidSystem::binaryDiffusionCoefficient(this->fluidState_, FluidSystem::binaryDiffusionCoefficient(this->fluidState_,
paramCache, paramCache,
phaseIdx, phaseIdx,
...@@ -152,7 +151,7 @@ public: ...@@ -152,7 +151,7 @@ public:
fluidState.setViscosity(phaseIdx, value); fluidState.setViscosity(phaseIdx, value);
// compute and set the enthalpy // compute and set the enthalpy
const Scalar h = ParentType::enthalpy(fluidState, paramCache, phaseIdx); const Scalar h = ParentType::enthalpy(fluidState, paramCache);
fluidState.setEnthalpy(phaseIdx, h); fluidState.setEnthalpy(phaseIdx, h);
} }
...@@ -160,58 +159,54 @@ public: ...@@ -160,58 +159,54 @@ public:
/*! /*!
* \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$ * \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$
* *
* \param pIdx the index of the fluid phase
* \param compIdx the index of the component * \param compIdx the index of the component
*/ */
Scalar massFraction(int pIdx, int compIdx) const Scalar massFraction(int compIdx) const
{ {
assert(pIdx == phaseIdx); return this->fluidState_.massFraction(phaseIdx, compIdx);
return this->fluidState_.massFraction(pIdx, compIdx);
} }
/*! /*!
* \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$ * \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$
* *
* \param pIdx the index of the fluid phase
* \param compIdx the index of the component * \param compIdx the index of the component
*/ */
Scalar moleFraction(int pIdx, int compIdx) const Scalar moleFraction(int compIdx) const
{ {
assert(pIdx == phaseIdx); return this->fluidState_.moleFraction(phaseIdx, compIdx);
return this->fluidState_.moleFraction(pIdx, compIdx);
} }
/*! /*!
* \brief Returns the mass density of a given phase \f$\mathrm{[kg/m^3]}\f$ * \brief Returns the mass density of a given phase \f$\mathrm{[kg/m^3]}\f$
*
* \param pIdx the index of the fluid phase
*/ */
Scalar molarDensity(int pIdx = phaseIdx) const Scalar molarDensity() const
{ {
assert(pIdx == phaseIdx); return this->fluidState_.molarDensity(phaseIdx);
return this->fluidState_.molarDensity(pIdx);
} }
/*! /*!
* \brief Returns the diffusion coefficient \f$\mathrm{[m^2/s]}\f$ * \brief Returns the diffusion coefficient \f$\mathrm{[m^2/s]}\f$
*
* \param compIdx the index of the component
*/ */
Scalar diffusionCoefficient(int pIdx, int compIdx) const Scalar diffusionCoefficient(int compIdx) const
{ {
assert(pIdx == phaseIdx); if (compIdx < phaseIdx)
if (compIdx < pIdx) return diffCoefficient_[phaseIdx][compIdx];
return diffCoefficient_[pIdx][compIdx]; else if (compIdx > phaseIdx)
else if (compIdx > pIdx) return diffCoefficient_[phaseIdx][compIdx-1];
return diffCoefficient_[pIdx][compIdx-1];
else else
DUNE_THROW(Dune::InvalidStateException, "Diffusion coefficient called for phaseIdx = compIdx"); DUNE_THROW(Dune::InvalidStateException, "Diffusion coefficient called for phaseIdx = compIdx");
} }
/*! /*!
* \brief Returns the effective diffusion coefficient \f$\mathrm{[m^2/s]}\f$ * \brief Returns the effective diffusion coefficient \f$\mathrm{[m^2/s]}\f$
*
* \param compIdx the index of the component
*/ */
Scalar effectiveDiffusivity(int pIdx, int compIdx) const Scalar effectiveDiffusivity(int compIdx) const
{ {
return diffusionCoefficient(pIdx, compIdx); return diffusionCoefficient(compIdx);
} }
protected: protected:
...@@ -222,13 +217,12 @@ protected: ...@@ -222,13 +217,12 @@ protected:
const Implementation &asImp_() const const Implementation &asImp_() const
{ return *static_cast<const Implementation*>(this); } { return *static_cast<const Implementation*>(this); }
void setDiffusionCoefficient_(int pIdx, int compIdx, Scalar d) void setDiffusionCoefficient_(int compIdx, Scalar d)
{ {
assert(pIdx == phaseIdx); if (compIdx < phaseIdx)
if (compIdx < pIdx) diffCoefficient_[phaseIdx][compIdx] = std::move(d);
diffCoefficient_[pIdx][compIdx] = std::move(d); else if (compIdx > phaseIdx)
else if (compIdx > pIdx) diffCoefficient_[phaseIdx][compIdx-1] = std::move(d);
diffCoefficient_[pIdx][compIdx-1] = std::move(d);
else else
DUNE_THROW(Dune::InvalidStateException, "Diffusion coefficient for phaseIdx = compIdx doesn't exist"); DUNE_THROW(Dune::InvalidStateException, "Diffusion coefficient for phaseIdx = compIdx doesn't exist");
} }
......
...@@ -47,11 +47,11 @@ public: ...@@ -47,11 +47,11 @@ public:
for (int j = 0; j < FluidSystem::numComponents; ++j) for (int j = 0; j < FluidSystem::numComponents; ++j)
{ {
vtk.addVolumeVariable([j](const auto& v){ return v.massFraction(phaseIdx,j); }, "X^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx)); vtk.addVolumeVariable([j](const auto& v){ return v.massFraction(j); }, "X^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx));
vtk.addVolumeVariable([j](const auto& v){ return v.moleFraction(phaseIdx,j); }, "x^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx)); vtk.addVolumeVariable([j](const auto& v){ return v.moleFraction(j); }, "x^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx));
if (j != phaseIdx) if (j != phaseIdx)
{ {
vtk.addVolumeVariable([j](const auto& v){ return v.diffusionCoefficient(phaseIdx,j); }, "D^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx)); vtk.addVolumeVariable([j](const auto& v){ return v.diffusionCoefficient(j); }, "D^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(phaseIdx));
} }
} }
} }
......
...@@ -70,8 +70,6 @@ class RANSVolumeVariablesImplementation<TypeTag, false> ...@@ -70,8 +70,6 @@ class RANSVolumeVariablesImplementation<TypeTag, false>
using DimVector = Dune::FieldVector<Scalar, dimWorld>; using DimVector = Dune::FieldVector<Scalar, dimWorld>;
using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>; using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
static const int defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
public: public:
using FluidState = typename GET_PROP_TYPE(TypeTag, FluidState); using FluidState = typename GET_PROP_TYPE(TypeTag, FluidState);
...@@ -236,7 +234,6 @@ class RANSVolumeVariablesImplementation<TypeTag, true> ...@@ -236,7 +234,6 @@ class RANSVolumeVariablesImplementation<TypeTag, true>
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices); using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
static const int defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
// static const int temperatureIdx = Indices::temperatureIdx; // static const int temperatureIdx = Indices::temperatureIdx;
public: public:
......
...@@ -51,6 +51,8 @@ class RANSNCVolumeVariables ...@@ -51,6 +51,8 @@ class RANSNCVolumeVariables
using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity; using Element = typename GridView::template Codim<0>::Entity;
static constexpr auto phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
public: public:
/*! /*!
...@@ -91,10 +93,12 @@ public: ...@@ -91,10 +93,12 @@ public:
/*! /*!
* \brief Returns the effective diffusion coefficient \f$\mathrm{[m^2/s]}\f$ * \brief Returns the effective diffusion coefficient \f$\mathrm{[m^2/s]}\f$
*
* \param compIdx the index of the component
*/ */
Scalar effectiveDiffusivity(int pIdx, int compIdx) const Scalar effectiveDiffusivity(int compIdx) const
{ {
return ParentTypeCompositional::diffusionCoefficient(pIdx, compIdx) return ParentTypeCompositional::diffusionCoefficient(compIdx)
+ eddyDiffusivity(); + eddyDiffusivity();
} }
......
...@@ -253,17 +253,16 @@ public: ...@@ -253,17 +253,16 @@ public:
if (globalPos[0] < 0.5) if (globalPos[0] < 0.5)
{ {
x_co2_left += elemVolVars[scv].moleFraction(0,2); x_co2_left += elemVolVars[scv].moleFraction(FluidSystem::CO2Idx);
x_n2_left += elemVolVars[scv].moleFraction(FluidSystem::N2Idx);
x_n2_left += elemVolVars[scv].moleFraction(0,1); x_h2_left += elemVolVars[scv].moleFraction(FluidSystem::H2Idx);
x_h2_left += elemVolVars[scv].moleFraction(0,0);
i +=1; i +=1;
} }
else else
{ {
x_co2_right += elemVolVars[scv].moleFraction(0,2); x_co2_right += elemVolVars[scv].moleFraction(FluidSystem::CO2Idx);
x_n2_right += elemVolVars[scv].moleFraction(0,1); x_n2_right += elemVolVars[scv].moleFraction(FluidSystem::N2Idx);
x_h2_right += elemVolVars[scv].moleFraction(0,0); x_h2_right += elemVolVars[scv].moleFraction(FluidSystem::H2Idx);
j +=1; j +=1;
} }
......
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