26#ifndef DUMUX_ENERGY_VOLUME_VARIABLES_HH
27#define DUMUX_ENERGY_VOLUME_VARIABLES_HH
30#include <dune/common/std/type_traits.hh>
42template <
typename T,
typename ...Ts>
43using SolidHeatCapacityDetector =
decltype(std::declval<T>().solidHeatCapacity(std::declval<Ts>()...));
45template<
class T,
typename ...Args>
46static constexpr bool hasSolidHeatCapacity()
47{
return Dune::Std::is_detected<SolidHeatCapacityDetector, T, Args...>::value; }
49template <
typename T,
typename ...Ts>
50using SolidDensityDetector =
decltype(std::declval<T>().solidDensity(std::declval<Ts>()...));
52template<
class T,
typename ...Args>
53static constexpr bool hasSolidDensity()
54{
return Dune::Std::is_detected<SolidDensityDetector, T, Args...>::value; }
56template <
typename T,
typename ...Ts>
57using SolidThermalConductivityDetector =
decltype(std::declval<T>().solidThermalConductivity(std::declval<Ts>()...));
59template<
class T,
typename ...Args>
60static constexpr bool hasSolidThermalConductivity()
61{
return Dune::Std::is_detected<SolidThermalConductivityDetector, T, Args...>::value; }
63template<
class Sol
idSystem>
64struct isInertSolidPhase :
public std::false_type {};
66template<
class Scalar,
class Component>
67struct isInertSolidPhase<SolidSystems::
InertSolidPhase<Scalar, Component>> :
public std::true_type {};
74template <
class IsothermalTraits,
class Impl,
bool enableEnergyBalance>
84template<
class IsothermalTraits,
class Impl>
91template<
class IsothermalTraits,
class Impl>
94 using Scalar =
typename IsothermalTraits::PrimaryVariables::value_type;
97 using FluidState =
typename IsothermalTraits::FluidState;
98 using SolidState =
typename IsothermalTraits::SolidState;
102 template<
class ElemSol,
class Problem,
class Element,
class Scv>
104 const Problem& problem,
105 const Element& element,
111 Scalar T = problem.temperatureAtPos(scv.dofPosition());
112 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
114 fluidState.setTemperature(phaseIdx, T);
116 solidState.setTemperature(T);
119 template<
class ElemSol,
class Problem,
class Element,
class Scv>
121 const Problem& problem,
122 const Element &element,
129 template<
class Flu
idState,
class ParameterCache>
131 const ParameterCache& paramCache,
144template<
class Traits,
class Impl>
147 using Scalar =
typename Traits::PrimaryVariables::value_type;
148 using Idx =
typename Traits::ModelTraits::Indices;
150 using EffCondModel =
typename Traits::EffectiveThermalConductivityModel;
152 static constexpr int temperatureIdx = Idx::temperatureIdx;
153 static constexpr int numEnergyEq = Traits::ModelTraits::numEnergyEq();
155 static constexpr bool fullThermalEquilibrium = (numEnergyEq == 1);
156 static constexpr bool fluidThermalEquilibrium = (numEnergyEq == 2);
167 template<
class ElemSol,
class Problem,
class Element,
class Scv>
169 const Problem& problem,
170 const Element& element,
175 if constexpr (fullThermalEquilibrium)
178 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
179 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
181 fluidState.setTemperature(phaseIdx, T);
183 solidState.setTemperature(T);
189 if constexpr (fluidThermalEquilibrium)
191 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
192 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
194 fluidState.setTemperature(phaseIdx, T);
200 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
203 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx + phaseIdx];
204 fluidState.setTemperature(phaseIdx, T);
207 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][temperatureIdx+numEnergyEq-1];
212 template<
class ElemSol,
class Problem,
class Element,
class Scv>
214 const Problem& problem,
215 const Element &element,
219 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
220 solidState.setHeatCapacity(cs);
222 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
223 solidState.setDensity(rhos);
225 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
226 solidState.setThermalConductivity(lambdas);
232 if constexpr (fullThermalEquilibrium)
235 lambdaEff_[0] = EffCondModel::effectiveThermalConductivity(asImp_());
237 else if constexpr (fluidThermalEquilibrium)
240 Scalar fluidLambda = 0.0;
241 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
242 fluidLambda += fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
244 lambdaEff_[0] = fluidLambda;
245 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
250 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
251 lambdaEff_[phaseIdx] = fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
252 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
263 {
return asImp_().fluidState().internalEnergy(phaseIdx); }
272 {
return asImp_().fluidState().enthalpy(phaseIdx); }
279 {
return asImp_().solidState().temperature(); }
288 {
return asImp_().fluidState().temperature(phaseIdx); }
295 {
return asImp_().solidState().heatCapacity(); }
302 {
return asImp_().solidState().density(); }
309 {
return asImp_().solidState().thermalConductivity(); }
316 {
return FluidSystem::thermalConductivity(asImp_().fluidState(), phaseIdx); }
322 template<
bool enable = fullThermalEquilibrium,
323 std::enable_if_t<enable, int> = 0>
325 {
return lambdaEff_[0]; }
331 template<
bool enable = fluidThermalEquilibrium,
332 std::enable_if_t<enable, int> = 0>
334 {
return lambdaEff_[0]; }
341 template<
bool enable = fluidThermalEquilibrium,
342 std::enable_if_t<enable, int> = 0>
344 {
return lambdaEff_[numEnergyEq-1]; }
351 template<
bool enable = (!fullThermalEquilibrium && !fluidThermalEquilibrium),
352 std::enable_if_t<enable, int> = 0>
354 {
return lambdaEff_[phaseIdx]; }
358 template<
class ParameterCache>
360 const ParameterCache& paramCache,
363 return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
367 const Impl &
asImp_()
const {
return *
static_cast<const Impl*
>(
this); }
368 Impl &
asImp_() {
return *
static_cast<Impl*
>(
this); }
396 template<
class ElemSol,
class Problem,
class Element,
class Scv,
397 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
398 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
399 const Problem& problem,
400 const Element& element,
402 const SolidState& solidState)
404 return SolidSystem::heatCapacity(solidState);
417 template<
class ElemSol,
class Problem,
class Element,
class Scv,
418 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
419 Scalar solidDensity_(
const ElemSol& elemSol,
420 const Problem& problem,
421 const Element& element,
423 const SolidState& solidState)
438 template<
class ElemSol,
class Problem,
class Element,
class Scv,
439 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
440 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
441 const Problem& problem,
442 const Element& element,
444 const SolidState& solidState)
446 return SolidSystem::thermalConductivity(solidState);
468 template<
class ElemSol,
class Problem,
class Element,
class Scv,
469 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
470 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
471 const Problem& problem,
472 const Element& element,
474 const SolidState& solidState)
476 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
477 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
478 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
479 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
493 template<
class ElemSol,
class Problem,
class Element,
class Scv,
494 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
495 Scalar solidDensity_(
const ElemSol& elemSol,
496 const Problem& problem,
497 const Element& element,
499 const SolidState& solidState)
501 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
502 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
503 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
504 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
518 template<
class ElemSol,
class Problem,
class Element,
class Scv,
519 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
520 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
521 const Problem& problem,
522 const Element& element,
524 const SolidState& solidState)
526 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
527 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
528 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
529 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
532 std::array<Scalar, numEnergyEq> lambdaEff_;
The simplest solid phase consisting of a single solid component.
OneCSolid< Scalar, ComponentT, true > InertSolidPhase
A solid phase consisting of a single inert solid component.
Definition: 1csolid.hh:137
std::string solidTemperature() noexcept
I/O name of solid temperature for non-equilibrium models.
Definition: name.hh:60
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Definition: porousmediumflow/nonisothermal/volumevariables.hh:75
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:120
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:130
typename IsothermalTraits::FluidSystem FluidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:99
typename IsothermalTraits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:98
typename IsothermalTraits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:97
void updateEffectiveThermalConductivity()
The effective thermal conductivity is zero for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:138
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
The temperature is obtained from the problem as a constant for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:103
Scalar temperatureFluid(const int phaseIdx) const
Returns the temperature of a fluid phase assuming thermal nonequilibrium the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:287
typename Traits::FluidSystem FluidSystem
export the underlying fluid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:163
Scalar solidDensity() const
Returns the mass density of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:301
const Impl & asImp_() const
Definition: porousmediumflow/nonisothermal/volumevariables.hh:367
Scalar enthalpy(const int phaseIdx) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:271
Scalar effectivePhaseThermalConductivity(const int phaseIdx) const
Returns the effective thermal conductivity per fluid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:353
Scalar fluidThermalConductivity(const int phaseIdx) const
Returns the thermal conductivity of a fluid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:315
Scalar temperatureSolid() const
Returns the temperature in fluid / solid phase(s) the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:278
Scalar internalEnergy(const int phaseIdx) const
Returns the total internal energy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:262
void updateEffectiveThermalConductivity()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:230
typename Traits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:160
Scalar solidHeatCapacity() const
Returns the total heat capacity of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:294
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
The temperature is obtained from the problem as a constant for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:168
Scalar effectiveSolidThermalConductivity() const
Returns the effective thermal conductivity of the solid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:343
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:359
typename Traits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:161
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:213
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity in the sub-control volume. Specific to equilibirum models...
Definition: porousmediumflow/nonisothermal/volumevariables.hh:324
Scalar solidThermalConductivity() const
Returns the thermal conductivity of the solid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:308
Scalar effectiveFluidThermalConductivity() const
Returns the effective thermal conductivity of the fluids in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:333
Impl & asImp_()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:368
typename Traits::SolidSystem SolidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:164
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
Base class for the model specific class which provides access to all volume averaged quantities.