version 3.7
freeflow/nonisothermal/localresidual.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FREE_FLOW_ENERGY_LOCAL_RESIDUAL_HH
13#define DUMUX_FREE_FLOW_ENERGY_LOCAL_RESIDUAL_HH
14
17
18namespace Dumux {
19
20// forward declaration
21template<class GridGeometry, class FluxVariables, class DiscretizationMethod, bool enableEneryBalance, bool isCompositional>
23
29template<class GridGeometry, class FluxVariables, bool enableEneryBalance, bool isCompositional>
32 FluxVariables,
33 typename GridGeometry::DiscretizationMethod,
34 enableEneryBalance, isCompositional>;
35
40template<class GridGeometry, class FluxVariables, class DiscretizationMethod, bool isCompositional>
41class FreeFlowEnergyLocalResidualImplementation<GridGeometry, FluxVariables, DiscretizationMethod, false, isCompositional>
42{
43public:
44
46 template <typename... Args>
47 static void fluidPhaseStorage(Args&&... args)
48 {}
49
51 template <typename... Args>
52 static void heatFlux(Args&&... args)
53 {}
54};
55
60template<class GridGeometry, class FluxVariables>
62 FluxVariables,
63 DiscretizationMethods::Staggered,
64 true, false>
65{
66 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
67 using FVElementGeometry = typename GridGeometry::LocalView;
68 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
69
70public:
71
73 template<class NumEqVector, class VolumeVariables>
74 static void fluidPhaseStorage(NumEqVector& storage,
75 const VolumeVariables& volVars)
76 {
77 static constexpr auto localEnergyBalanceIdx = NumEqVector::dimension - 1;
78 storage[localEnergyBalanceIdx] += volVars.density() * volVars.internalEnergy();
79 }
80
82 template<class NumEqVector, class Problem, class ElementVolumeVariables, class ElementFaceVariables>
83 static void heatFlux(NumEqVector& flux,
84 const Problem& problem,
85 const Element &element,
86 const FVElementGeometry& fvGeometry,
87 const ElementVolumeVariables& elemVolVars,
88 const ElementFaceVariables& elemFaceVars,
89 const SubControlVolumeFace& scvf)
90 {
91 static constexpr auto localEnergyBalanceIdx = NumEqVector::dimension - 1;
92
93 auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); };
94 flux[localEnergyBalanceIdx] += FluxVariables::advectiveFluxForCellCenter(problem,
95 fvGeometry,
96 elemVolVars,
97 elemFaceVars,
98 scvf,
99 upwindTerm);
100
101 flux[localEnergyBalanceIdx] += FluxVariables::HeatConductionType::flux(problem,
102 element,
103 fvGeometry,
104 elemVolVars,
105 scvf);
106 }
107};
108
113template<class GridGeometry, class FluxVariables>
115 FluxVariables,
116 DiscretizationMethods::Staggered,
117 true, true>
118 : public FreeFlowEnergyLocalResidualImplementation<GridGeometry,
119 FluxVariables,
120 DiscretizationMethods::Staggered,
121 true, false>
122{
124 FluxVariables,
126 true, false>;
127 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
128 using FVElementGeometry = typename GridGeometry::LocalView;
129 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
130
131public:
133 template<class NumEqVector, class Problem, class ElementVolumeVariables, class ElementFaceVariables>
134 static void heatFlux(NumEqVector& flux,
135 const Problem& problem,
136 const Element &element,
137 const FVElementGeometry& fvGeometry,
138 const ElementVolumeVariables& elemVolVars,
139 const ElementFaceVariables& elemFaceVars,
140 const SubControlVolumeFace& scvf)
141 {
142 ParentType::heatFlux(flux, problem, element, fvGeometry, elemVolVars, elemFaceVars, scvf);
143
144 static constexpr auto localEnergyBalanceIdx = NumEqVector::dimension - 1;
145 auto diffusiveFlux = FluxVariables::MolecularDiffusionType::flux(problem, element, fvGeometry, elemVolVars, scvf);
146 for (int compIdx = 0; compIdx < FluxVariables::numComponents; ++compIdx)
147 {
148 const bool insideIsUpstream = scvf.directionSign() == sign(diffusiveFlux[compIdx]);
149 const auto& upstreamVolVars = insideIsUpstream ? elemVolVars[scvf.insideScvIdx()] : elemVolVars[scvf.outsideScvIdx()];
150
151 if (FluxVariables::MolecularDiffusionType::referenceSystemFormulation() == ReferenceSystemFormulation::massAveraged)
152 flux[localEnergyBalanceIdx] += diffusiveFlux[compIdx] * upstreamVolVars.componentEnthalpy(compIdx);
153 else
154 flux[localEnergyBalanceIdx] += diffusiveFlux[compIdx] * upstreamVolVars.componentEnthalpy(compIdx)* elemVolVars[scvf.insideScvIdx()].molarMass(compIdx);
155
156 }
157 }
158};
159
160} // end namespace Dumux
161
162#endif
static void heatFlux(NumEqVector &flux, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf)
The convective and conductive heat fluxes in the fluid phase.
Definition: freeflow/nonisothermal/localresidual.hh:134
Specialization for staggered one-phase, non-isothermal models.
Definition: freeflow/nonisothermal/localresidual.hh:65
static void heatFlux(NumEqVector &flux, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf)
The convective and conductive heat fluxes in the fluid phase.
Definition: freeflow/nonisothermal/localresidual.hh:83
static void fluidPhaseStorage(NumEqVector &storage, const VolumeVariables &volVars)
The energy storage in the fluid phase.
Definition: freeflow/nonisothermal/localresidual.hh:74
static void heatFlux(Args &&... args)
do nothing for the isothermal case
Definition: freeflow/nonisothermal/localresidual.hh:52
static void fluidPhaseStorage(Args &&... args)
do nothing for the isothermal case
Definition: freeflow/nonisothermal/localresidual.hh:47
Definition: freeflow/nonisothermal/localresidual.hh:22
The available discretization methods in Dumux.
Definition: adapt.hh:17
constexpr int sign(const ValueType &value) noexcept
Sign or signum function.
Definition: math.hh:629
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
The reference frameworks and formulations available for splitting total fluxes into a advective and d...