26#ifndef DUMUX_ENERGY_VOLUME_VARIABLES_HH
27#define DUMUX_ENERGY_VOLUME_VARIABLES_HH
30#include <dune/common/std/type_traits.hh>
43template <
typename T,
typename ...Ts>
44using SolidHeatCapacityDetector =
decltype(std::declval<T>().solidHeatCapacity(std::declval<Ts>()...));
46template<
class T,
typename ...Args>
47static constexpr bool hasSolidHeatCapacity()
48{
return Dune::Std::is_detected<SolidHeatCapacityDetector, T, Args...>::value; }
50template <
typename T,
typename ...Ts>
51using SolidDensityDetector =
decltype(std::declval<T>().solidDensity(std::declval<Ts>()...));
53template<
class T,
typename ...Args>
54static constexpr bool hasSolidDensity()
55{
return Dune::Std::is_detected<SolidDensityDetector, T, Args...>::value; }
57template <
typename T,
typename ...Ts>
58using SolidThermalConductivityDetector =
decltype(std::declval<T>().solidThermalConductivity(std::declval<Ts>()...));
60template<
class T,
typename ...Args>
61static constexpr bool hasSolidThermalConductivity()
62{
return Dune::Std::is_detected<SolidThermalConductivityDetector, T, Args...>::value; }
64template<
class Sol
idSystem>
65struct isInertSolidPhase :
public std::false_type {};
67template<
class Scalar,
class Component>
68struct isInertSolidPhase<SolidSystems::
InertSolidPhase<Scalar, Component>> :
public std::true_type {};
75template <
class IsothermalTraits,
class Impl,
bool enableEnergyBalance>
85template<
class IsothermalTraits,
class Impl>
92template<
class IsothermalTraits,
class Impl>
95 using Scalar =
typename IsothermalTraits::PrimaryVariables::value_type;
98 using FluidState =
typename IsothermalTraits::FluidState;
99 using SolidState =
typename IsothermalTraits::SolidState;
103 template<
class ElemSol,
class Problem,
class Element,
class Scv>
105 const Problem& problem,
106 const Element& element,
113 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
115 fluidState.setTemperature(phaseIdx, T);
117 solidState.setTemperature(T);
120 template<
class ElemSol,
class Problem,
class Element,
class Scv>
122 const Problem& problem,
123 const Element &element,
130 template<
class Flu
idState,
class ParameterCache>
132 const ParameterCache& paramCache,
145template<
class Traits,
class Impl>
148 using Scalar =
typename Traits::PrimaryVariables::value_type;
149 using Idx =
typename Traits::ModelTraits::Indices;
151 using EffCondModel =
typename Traits::EffectiveThermalConductivityModel;
153 static constexpr int temperatureIdx = Idx::temperatureIdx;
154 static constexpr int numEnergyEq = Traits::ModelTraits::numEnergyEq();
156 static constexpr bool fullThermalEquilibrium = (numEnergyEq == 1);
157 static constexpr bool fluidThermalEquilibrium = (numEnergyEq == 2);
172 template<
class ElemSol,
class Problem,
class Element,
class Scv>
174 const Problem& problem,
175 const Element& element,
180 if constexpr (fullThermalEquilibrium)
183 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
184 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
186 fluidState.setTemperature(phaseIdx, T);
188 solidState.setTemperature(T);
194 if constexpr (fluidThermalEquilibrium)
196 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
197 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
199 fluidState.setTemperature(phaseIdx, T);
205 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
208 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx + phaseIdx];
209 fluidState.setTemperature(phaseIdx, T);
212 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][temperatureIdx+numEnergyEq-1];
217 template<
class ElemSol,
class Problem,
class Element,
class Scv>
219 const Problem& problem,
220 const Element &element,
224 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
225 solidState.setHeatCapacity(cs);
227 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
228 solidState.setDensity(rhos);
230 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
231 solidState.setThermalConductivity(lambdas);
237 if constexpr (fullThermalEquilibrium)
240 lambdaEff_[0] = EffCondModel::effectiveThermalConductivity(asImp_());
242 else if constexpr (fluidThermalEquilibrium)
245 Scalar fluidLambda = 0.0;
246 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
247 fluidLambda += fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
249 lambdaEff_[0] = fluidLambda;
250 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
255 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
256 lambdaEff_[phaseIdx] = fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
257 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
268 {
return asImp_().fluidState().internalEnergy(phaseIdx); }
277 {
return asImp_().fluidState().enthalpy(phaseIdx); }
284 {
return asImp_().solidState().temperature(); }
293 {
return asImp_().fluidState().temperature(phaseIdx); }
300 {
return asImp_().solidState().heatCapacity(); }
307 {
return asImp_().solidState().density(); }
314 {
return asImp_().solidState().thermalConductivity(); }
321 {
return FluidSystem::thermalConductivity(asImp_().fluidState(), phaseIdx); }
327 template<
bool enable = fullThermalEquilibrium,
328 std::enable_if_t<enable, int> = 0>
330 {
return lambdaEff_[0]; }
336 template<
bool enable = fluidThermalEquilibrium,
337 std::enable_if_t<enable, int> = 0>
339 {
return lambdaEff_[0]; }
346 template<
bool enable = fluidThermalEquilibrium,
347 std::enable_if_t<enable, int> = 0>
349 {
return lambdaEff_[numEnergyEq-1]; }
356 template<
bool enable = (!fullThermalEquilibrium && !fluidThermalEquilibrium),
357 std::enable_if_t<enable, int> = 0>
359 {
return lambdaEff_[phaseIdx]; }
363 template<
class ParameterCache>
365 const ParameterCache& paramCache,
368 return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
372 const Impl &
asImp_()
const {
return *
static_cast<const Impl*
>(
this); }
373 Impl &
asImp_() {
return *
static_cast<Impl*
>(
this); }
401 template<
class ElemSol,
class Problem,
class Element,
class Scv,
402 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
403 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
404 const Problem& problem,
405 const Element& element,
407 const SolidState& solidState)
409 return SolidSystem::heatCapacity(solidState);
422 template<
class ElemSol,
class Problem,
class Element,
class Scv,
423 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
424 Scalar solidDensity_(
const ElemSol& elemSol,
425 const Problem& problem,
426 const Element& element,
428 const SolidState& solidState)
443 template<
class ElemSol,
class Problem,
class Element,
class Scv,
444 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
445 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
446 const Problem& problem,
447 const Element& element,
449 const SolidState& solidState)
451 return SolidSystem::thermalConductivity(solidState);
473 template<
class ElemSol,
class Problem,
class Element,
class Scv,
474 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
475 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
476 const Problem& problem,
477 const Element& element,
479 const SolidState& solidState)
481 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
482 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
483 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
484 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
498 template<
class ElemSol,
class Problem,
class Element,
class Scv,
499 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
500 Scalar solidDensity_(
const ElemSol& elemSol,
501 const Problem& problem,
502 const Element& element,
504 const SolidState& solidState)
506 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
507 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
508 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
509 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
523 template<
class ElemSol,
class Problem,
class Element,
class Scv,
524 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
525 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
526 const Problem& problem,
527 const Element& element,
529 const SolidState& solidState)
531 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
532 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
533 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
534 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
537 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 temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
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:76
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:121
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:131
typename IsothermalTraits::FluidSystem FluidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:100
typename IsothermalTraits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:99
typename IsothermalTraits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:98
void updateEffectiveThermalConductivity()
The effective thermal conductivity is zero for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:139
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:104
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:292
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:306
const Impl & asImp_() const
Definition: porousmediumflow/nonisothermal/volumevariables.hh:372
Scalar enthalpy(const int phaseIdx) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:276
Scalar effectivePhaseThermalConductivity(const int phaseIdx) const
Returns the effective thermal conductivity per fluid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:358
Scalar fluidThermalConductivity(const int phaseIdx) const
Returns the thermal conductivity of a fluid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:320
Scalar temperatureSolid() const
Returns the temperature in fluid / solid phase(s) the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:283
Scalar internalEnergy(const int phaseIdx) const
Returns the total internal energy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:267
void updateEffectiveThermalConductivity()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:235
typename Traits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:161
Scalar solidHeatCapacity() const
Returns the total heat capacity of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:299
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:173
Scalar effectiveSolidThermalConductivity() const
Returns the effective thermal conductivity of the solid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:348
Idx Indices
Export the indices.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:165
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:364
typename Traits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:167
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:218
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity in the sub-control volume. Specific to equilibirum models...
Definition: porousmediumflow/nonisothermal/volumevariables.hh:329
Scalar solidThermalConductivity() const
Returns the thermal conductivity of the solid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:313
Scalar effectiveFluidThermalConductivity() const
Returns the effective thermal conductivity of the fluids in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:338
Impl & asImp_()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:373
typename Traits::SolidSystem SolidSystem
export the underlying solid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:169
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:42
Base class for the model specific class which provides access to all volume averaged quantities.