Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup NavierStokesModel | ||
10 | * \copydoc Dumux::NavierStokesFluxVariablesImpl | ||
11 | */ | ||
12 | #ifndef DUMUX_NAVIERSTOKES_SCALAR_CONSERVATION_MODEL_FLUXVARIABLES_HH | ||
13 | #define DUMUX_NAVIERSTOKES_SCALAR_CONSERVATION_MODEL_FLUXVARIABLES_HH | ||
14 | |||
15 | #include <dumux/common/math.hh> | ||
16 | #include <dumux/common/typetraits/problem.hh> | ||
17 | #include <dumux/flux/fluxvariablesbase.hh> | ||
18 | #include <dumux/discretization/extrusion.hh> | ||
19 | #include <dumux/discretization/method.hh> | ||
20 | #include <dumux/flux/upwindscheme.hh> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | /*! | ||
25 | * \ingroup NavierStokesModel | ||
26 | * \brief The flux variables base class for scalar quantities balanced in the Navier-Stokes model. | ||
27 | */ | ||
28 | template<class Problem, | ||
29 | class ModelTraits, | ||
30 | class FluxTypes, | ||
31 | class ElementVolumeVariables, | ||
32 | class ElementFluxVariablesCache, | ||
33 | class UpwindScheme = UpwindScheme<typename ProblemTraits<Problem>::GridGeometry>> | ||
34 | class NavierStokesScalarConservationModelFluxVariables | ||
35 | : public FluxVariablesBase<Problem, | ||
36 | typename ProblemTraits<Problem>::GridGeometry::LocalView, | ||
37 | ElementVolumeVariables, | ||
38 | ElementFluxVariablesCache> | ||
39 | { | ||
40 | using Scalar = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables::value_type; | ||
41 | using GridGeometry = typename ProblemTraits<Problem>::GridGeometry; | ||
42 | using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; | ||
43 | using Element = typename GridGeometry::GridView::template Codim<0>::Entity; | ||
44 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
45 | using Extrusion = Extrusion_t<typename ProblemTraits<Problem>::GridGeometry>; | ||
46 | |||
47 | public: | ||
48 | |||
49 | struct AdvectionType | ||
50 | { | ||
51 | static Scalar flux(const Problem& problem, | ||
52 | const Element& element, | ||
53 | const FVElementGeometry& fvGeometry, | ||
54 | const ElementVolumeVariables& elemVolVars, | ||
55 | const SubControlVolumeFace& scvf, | ||
56 | const int phaseIdx, | ||
57 | const ElementFluxVariablesCache& elemFluxVarsCache) | ||
58 | { | ||
59 | const auto velocity = problem.faceVelocity(element, fvGeometry, scvf); | ||
60 | const Scalar volumeFlux = velocity*scvf.unitOuterNormal()*Extrusion::area(fvGeometry, scvf)*extrusionFactor_(elemVolVars, scvf); | ||
61 | return volumeFlux; | ||
62 | } | ||
63 | }; | ||
64 | |||
65 | /*! | ||
66 | * \brief Returns the advective flux computed by the respective law. | ||
67 | */ | ||
68 | template<typename FunctionType> | ||
69 | 192891262 | Scalar getAdvectiveFlux(const FunctionType& upwindTerm) const | |
70 | { | ||
71 | if constexpr (ModelTraits::enableAdvection()) | ||
72 | { | ||
73 | 192891262 | const auto& scvf = this->scvFace(); | |
74 | 192891262 | const auto velocity = this->problem().faceVelocity(this->element(), this->fvGeometry(), scvf); | |
75 | 752997464 | const Scalar volumeFlux = velocity*scvf.unitOuterNormal()*Extrusion::area(this->fvGeometry(), scvf)*extrusionFactor_(this->elemVolVars(), scvf); | |
76 | 192891262 | return UpwindScheme::apply(*this, upwindTerm, volumeFlux, 0/*phaseIdx*/); | |
77 | } | ||
78 | else | ||
79 | return 0.0; | ||
80 | } | ||
81 | |||
82 | /*! | ||
83 | * \brief Returns the conductive energy flux computed by the respective law. | ||
84 | */ | ||
85 | 9745750 | Scalar heatConductionFlux() const | |
86 | { | ||
87 | if constexpr (ModelTraits::enableEnergyBalance()) | ||
88 | { | ||
89 | using HeatConductionType = typename FluxTypes::HeatConductionType; | ||
90 | 9745750 | return HeatConductionType::flux(this->problem(), | |
91 | this->element(), | ||
92 | this->fvGeometry(), | ||
93 | this->elemVolVars(), | ||
94 | this->scvFace(), | ||
95 | 9745750 | this->elemFluxVarsCache()); | |
96 | } | ||
97 | else | ||
98 | return 0.0; | ||
99 | } | ||
100 | |||
101 | /*! | ||
102 | * \brief Returns the advective energy flux. | ||
103 | */ | ||
104 | Scalar heatAdvectionFlux() const | ||
105 | { | ||
106 | if constexpr (ModelTraits::enableEnergyBalance()) | ||
107 | { | ||
108 | 58474500 | const auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); }; | |
109 | 9745750 | return getAdvectiveFlux(upwindTerm); | |
110 | } | ||
111 | else | ||
112 | return 0.0; | ||
113 | } | ||
114 | |||
115 | /*! | ||
116 | * \brief Returns the total energy flux. | ||
117 | */ | ||
118 | 9745750 | Scalar heatFlux() const | |
119 | { | ||
120 | 9745750 | return heatConductionFlux() + heatAdvectionFlux(); | |
121 | } | ||
122 | |||
123 | /*! | ||
124 | * \brief Adds the energy flux to a given flux vector. | ||
125 | */ | ||
126 | template<class NumEqVector> | ||
127 | ✗ | void addHeatFlux(NumEqVector& flux) const | |
128 | { | ||
129 | if constexpr (ModelTraits::enableEnergyBalance()) | ||
130 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
3942400 | flux[ModelTraits::Indices::energyEqIdx] = heatFlux(); |
131 | ✗ | } | |
132 | |||
133 | private: | ||
134 | |||
135 | 145505474 | static Scalar extrusionFactor_(const ElementVolumeVariables& elemVolVars, const SubControlVolumeFace& scvf) | |
136 | { | ||
137 |
4/4✓ Branch 0 taken 6968304 times.
✓ Branch 1 taken 9010812 times.
✓ Branch 2 taken 6968304 times.
✓ Branch 3 taken 9010812 times.
|
291010948 | const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()]; |
138 |
3/4✓ Branch 0 taken 6968304 times.
✓ Branch 1 taken 9010812 times.
✓ Branch 2 taken 15979116 times.
✗ Branch 3 not taken.
|
282000136 | const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()]; |
139 |
1/2✓ Branch 0 taken 145505474 times.
✗ Branch 1 not taken.
|
145505474 | return harmonicMean(insideVolVars.extrusionFactor(), outsideVolVars.extrusionFactor()); |
140 | } | ||
141 | }; | ||
142 | |||
143 | } // end namespace Dumux | ||
144 | |||
145 | #endif | ||
146 |