Commit 149f77c1 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[cleanup] Use convenience function for temperature

Implement a temperature() function in the volvars and use it
instead of volvars.fluidstate().xtemperature().
This reuqired the implementation of two template functions
to ensure that the correct temperature() function is called
depending on the number of energy equations considered.
parent b5ea2643
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
// index for the element volume variables // index for the element volume variables
int volVarsIdx = face.fapIndices[idx]; int volVarsIdx = face.fapIndices[idx];
tmp *= elemVolVars[volVarsIdx].fluidState().temperature(/*phaseIdx=*/0); tmp *= elemVolVars[volVarsIdx].temperature(/*phaseIdx=*/0);
temperatureGradient += tmp; temperatureGradient += tmp;
} }
......
...@@ -161,7 +161,7 @@ public: ...@@ -161,7 +161,7 @@ public:
// heat stored in the rock matrix // heat stored in the rock matrix
storage[energyEqIdx] += storage[energyEqIdx] +=
volVars.fluidState().temperature(/*phaseIdx=*/0) volVars.temperature(/*phaseIdx=*/0)
* volVars.solidDensity() * volVars.solidDensity()
* (1.0 - volVars.porosity()) * (1.0 - volVars.porosity())
* volVars.solidHeatCapacity(); * volVars.solidHeatCapacity();
......
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
const VolumeVariables &volVars = elemVolVars[scvIdx]; const VolumeVariables &volVars = elemVolVars[scvIdx];
if (temperatureOutput_) if (temperatureOutput_)
temperature_[dofIdxGlobal] = volVars.fluidState().temperature(/*phaseIdx=*/0); temperature_[dofIdxGlobal] = volVars.temperature(/*phaseIdx=*/0);
} }
} }
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
int gobalIdx = this->problem_.model().dofMapper().subIndex(element, scvIdx, dofCodim); int gobalIdx = this->problem_.model().dofMapper().subIndex(element, scvIdx, dofCodim);
const VolumeVariables &volVars = elemVolVars[scvIdx]; const VolumeVariables &volVars = elemVolVars[scvIdx];
if (temperatureOutput_) temperature_[gobalIdx] = volVars.fluidState().temperature(/*phaseIdx=*/0); if (temperatureOutput_) temperature_[gobalIdx] = volVars.temperature(/*phaseIdx=*/0);
for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
if (enthalpyOutput_) if (enthalpyOutput_)
enthalpy_[phaseIdx][gobalIdx] = volVars.enthalpy(phaseIdx); enthalpy_[phaseIdx][gobalIdx] = volVars.enthalpy(phaseIdx);
......
...@@ -184,7 +184,7 @@ if (!std::isfinite(volumeFlux)) ...@@ -184,7 +184,7 @@ if (!std::isfinite(volumeFlux))
+ +
( 1. - massUpwindWeight)*dn.molarity(phaseIdx, compIdx) ); ( 1. - massUpwindWeight)*dn.molarity(phaseIdx, compIdx) );
if (!std::isfinite(flux[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) ) ; DUNE_THROW(NumericalProblem, "Calculated non-finite normal flux in phase " << phaseIdx << " comp " << compIdx << "T: "<< up.temperature(phaseIdx) << "S "<<up.saturation(phaseIdx) ) ;
} }
} }
} }
......
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
Valgrind::CheckDefined(mu_nPhaseWComp); Valgrind::CheckDefined(mu_nPhaseWComp);
const Scalar characteristicLength = volVars.characteristicLength() ; const Scalar characteristicLength = volVars.characteristicLength() ;
const Scalar temperature = volVars.fluidState().temperature(wPhaseIdx); const Scalar temperature = volVars.temperature(wPhaseIdx);
const Scalar pn = volVars.pressure(nPhaseIdx); const Scalar pn = volVars.pressure(nPhaseIdx);
const Scalar henry = FluidSystem::henry(temperature) ; const Scalar henry = FluidSystem::henry(temperature) ;
const Scalar gradNinWApprox = ( mu_wPhaseNComp - mu_nPhaseNCompEquil) / characteristicLength; // very 2p2c // 1. / henry * const Scalar gradNinWApprox = ( mu_wPhaseNComp - mu_nPhaseNCompEquil) / characteristicLength; // very 2p2c // 1. / henry *
......
...@@ -321,6 +321,34 @@ public: ...@@ -321,6 +321,34 @@ public:
Scalar density(const int phaseIdx) const Scalar density(const int phaseIdx) const
{ return fluidState_.density(phaseIdx); } { return fluidState_.density(phaseIdx); }
/*!
* \brief Returns the fluid/solid phase temperature
* in the sub-control volume for the assumption of local thermal
* non-equillibrium where there is more than one energy equation
* and each phase and the matrix can have different temperatures
*
* \param phaseIdx The local index of the phases
*/
template <class T = TypeTag>
typename std::enable_if<(GET_PROP_VALUE(T, NumEnergyEquations) > 1), Scalar>::type temperature(const unsigned int phaseIdx) const
{
return EnergyVolumeVariables::temperature(phaseIdx);
}
/*!
* \brief Returns the fluid/solid phase temperature
* in the sub-control volume for the assumption of local thermal
* equillibrium where there is only one or no energy equation
* and all phases including the matrix have the same temperature
*
* \param phaseIdx The local index of the phases
*/
template <class T = TypeTag>
typename std::enable_if<(GET_PROP_VALUE(T, NumEnergyEquations) < 2), Scalar>::type temperature(const unsigned int phaseIdx) const
{
return fluidState_.temperature(phaseIdx);
}
/*! /*!
* \brief Return enthalpy \f$\mathrm{[kg/m^3]}\f$ the of the fluid phase. * \brief Return enthalpy \f$\mathrm{[kg/m^3]}\f$ the of the fluid phase.
*/ */
......
...@@ -481,8 +481,8 @@ public: ...@@ -481,8 +481,8 @@ public:
const Scalar pn = elemVolVars[scvIdx].pressure(nPhaseIdx); const Scalar pn = elemVolVars[scvIdx].pressure(nPhaseIdx);
const Scalar pw = elemVolVars[scvIdx].pressure(wPhaseIdx); const Scalar pw = elemVolVars[scvIdx].pressure(wPhaseIdx);
const Scalar Tn = elemVolVars[scvIdx].fluidState().temperature(nPhaseIdx); const Scalar Tn = elemVolVars[scvIdx].temperature(nPhaseIdx);
const Scalar Tw = elemVolVars[scvIdx].fluidState().temperature(wPhaseIdx); const Scalar Tw = elemVolVars[scvIdx].temperature(wPhaseIdx);
fluidState.setPressure(nPhaseIdx, pn); fluidState.setPressure(nPhaseIdx, pn);
fluidState.setPressure(wPhaseIdx, pw); fluidState.setPressure(wPhaseIdx, pw);
......
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