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,
140template<
class IsothermalTraits,
class Impl>
143 using Scalar =
typename IsothermalTraits::PrimaryVariables::value_type;
147 static const int temperatureIdx = Idx::temperatureIdx;
148 static const int numEnergyEq = IsothermalTraits::ModelTraits::numEnergyEq();
159 template<
class ElemSol,
class Problem,
class Element,
class Scv>
161 const Problem& problem,
162 const Element& element,
167 if (numEnergyEq == 1)
170 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
171 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
173 fluidState.setTemperature(phaseIdx, T);
175 solidState.setTemperature(T);
181 if (numEnergyEq == 2)
183 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
184 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
186 fluidState.setTemperature(phaseIdx, T);
192 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
195 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx + phaseIdx];
196 fluidState.setTemperature(phaseIdx, T);
199 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][temperatureIdx+numEnergyEq-1];
204 template<
class ElemSol,
class Problem,
class Element,
class Scv>
206 const Problem& problem,
207 const Element &element,
211 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
212 solidState.setHeatCapacity(cs);
214 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
215 solidState.setDensity(rhos);
217 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
218 solidState.setThermalConductivity(lambdas);
228 {
return asImp_().fluidState().internalEnergy(phaseIdx); }
237 {
return asImp_().fluidState().enthalpy(phaseIdx); }
244 {
return asImp_().solidState().temperature(); }
253 {
return asImp_().fluidState().temperature(phaseIdx); }
260 {
return asImp_().solidState().heatCapacity(); }
267 {
return asImp_().solidState().density(); }
273 {
return asImp_().solidState().thermalConductivity(); }
280 {
return FluidSystem::thermalConductivity(asImp_().fluidState(), phaseIdx); }
284 template<
class ParameterCache>
286 const ParameterCache& paramCache,
289 return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
293 const Impl &
asImp_()
const {
return *
static_cast<const Impl*
>(
this); }
294 Impl &
asImp_() {
return *
static_cast<Impl*
>(
this); }
322 template<
class ElemSol,
class Problem,
class Element,
class Scv,
323 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
324 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
325 const Problem& problem,
326 const Element& element,
328 const SolidState& solidState)
330 return SolidSystem::heatCapacity(solidState);
343 template<
class ElemSol,
class Problem,
class Element,
class Scv,
344 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
345 Scalar solidDensity_(
const ElemSol& elemSol,
346 const Problem& problem,
347 const Element& element,
349 const SolidState& solidState)
364 template<
class ElemSol,
class Problem,
class Element,
class Scv,
365 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
366 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
367 const Problem& problem,
368 const Element& element,
370 const SolidState& solidState)
372 return SolidSystem::thermalConductivity(solidState);
394 template<
class ElemSol,
class Problem,
class Element,
class Scv,
395 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
396 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
397 const Problem& problem,
398 const Element& element,
400 const SolidState& solidState)
402 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
403 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
404 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
405 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
419 template<
class ElemSol,
class Problem,
class Element,
class Scv,
420 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
421 Scalar solidDensity_(
const ElemSol& elemSol,
422 const Problem& problem,
423 const Element& element,
425 const SolidState& solidState)
427 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
428 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
429 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
430 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
444 template<
class ElemSol,
class Problem,
class Element,
class Scv,
445 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
446 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
447 const Problem& problem,
448 const Element& element,
450 const SolidState& solidState)
452 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
453 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
454 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
455 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
A solid phase consisting of a single inert solid component.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
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 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
Impl & asImp_()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:294
Scalar solidThermalConductivity() const
Returns the thermal conductivity of the solid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:272
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:252
Scalar solidDensity() const
Returns the mass density of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:266
Scalar solidHeatCapacity() const
Returns the total heat capacity of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:259
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:285
Scalar fluidThermalConductivity(const int phaseIdx) const
Returns the thermal conductivity of a fluid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:279
const Impl & asImp_() const
Definition: porousmediumflow/nonisothermal/volumevariables.hh:293
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:205
typename IsothermalTraits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:153
Scalar internalEnergy(const int phaseIdx) const
Returns the total internal energy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:227
typename IsothermalTraits::FluidSystem FluidSystem
export the underlying fluid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:155
Scalar temperatureSolid() const
Returns the temperature in fluid / solid phase(s) the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:243
Scalar enthalpy(const int phaseIdx) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:236
typename IsothermalTraits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:152
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:160
typename IsothermalTraits::SolidSystem SolidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:156
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
Base class for the model specific class which provides access to all volume averaged quantities.