GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/fluxvariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 24 25 96.0%
Functions: 456 519 87.9%
Branches: 39 52 75.0%

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 PorousmediumflowModels
10 * \brief Base class for the flux variables in porous medium models
11 */
12
13 #ifndef DUMUX_POROUSMEDIUMFLOW_FLUXVARIABLES_HH
14 #define DUMUX_POROUSMEDIUMFLOW_FLUXVARIABLES_HH
15
16 #include <bitset>
17 #include <array>
18
19 #include <dumux/common/properties.hh>
20 #include <dumux/flux/fluxvariablesbase.hh>
21 #include <dumux/flux/upwindscheme.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup PorousmediumflowModels
27 * \brief The porous medium flux variables class that computes advective / convective,
28 * molecular diffusive and heat conduction fluxes.
29 *
30 * \param TypeTag The type tag for access to type traits
31 * \param UpScheme The upwind scheme to be applied to advective fluxes
32 * \note Not all specializations are currently implemented
33 */
34 template<class TypeTag,
35 class UpScheme = UpwindScheme<GetPropType<TypeTag, Properties::GridGeometry>> >
36 class PorousMediumFluxVariables
37 : public FluxVariablesBase<GetPropType<TypeTag, Properties::Problem>,
38 typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView,
39 typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView,
40 typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView>
41 {
42 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
43 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
44
45 enum
46 {
47 numPhases = ModelTraits::numFluidPhases(),
48 numComponents = ModelTraits::numFluidComponents()
49 };
50
51 public:
52 using UpwindScheme = UpScheme;
53 using AdvectionType = GetPropType<TypeTag, Properties::AdvectionType>;
54 using DispersionFluxType = GetPropType<TypeTag, Properties::DispersionFluxType>;
55 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
56 using HeatConductionType = GetPropType<TypeTag, Properties::HeatConductionType>;
57
58 static constexpr bool enableAdvection = ModelTraits::enableAdvection();
59 static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion();
60 static constexpr bool enableCompositionalDispersion = ModelTraits::enableCompositionalDispersion();
61 static constexpr bool enableThermalDispersion = ModelTraits::enableThermalDispersion();
62 static constexpr bool enableEnergyBalance = ModelTraits::enableEnergyBalance();
63 static constexpr bool enableThermalNonEquilibrium = getPropValue<TypeTag, Properties::EnableThermalNonEquilibrium>();
64
65 //! The constructor
66 562959360 PorousMediumFluxVariables()
67 562959360 {
68
9/13
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 4142870 times.
✓ Branch 2 taken 23332 times.
✓ Branch 3 taken 340 times.
✓ Branch 4 taken 13967 times.
✓ Branch 5 taken 38840 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 9900 times.
✓ Branch 9 taken 47203 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 31948800 times.
✗ Branch 13 not taken.
562959360 advFluxIsCached_.reset();
69
20/25
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 4713200 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 4169714 times.
✓ Branch 5 taken 340 times.
✓ Branch 6 taken 62172 times.
✓ Branch 7 taken 14307 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38840 times.
✓ Branch 10 taken 13967 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 43859 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 309100 times.
✓ Branch 16 taken 43859 times.
✓ Branch 17 taken 3344 times.
✓ Branch 18 taken 13100 times.
✓ Branch 19 taken 31948674 times.
✓ Branch 20 taken 3344 times.
✓ Branch 21 taken 31948674 times.
✓ Branch 23 taken 126 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 126 times.
✗ Branch 27 not taken.
1122584424 advFluxBeforeUpwinding_.fill(0.0);
70 }
71
72 /*!
73 * \brief Returns the advective flux computed by the respective law.
74 */
75 template<typename FunctionType>
76 5698552453 Scalar advectiveFlux([[maybe_unused]] const int phaseIdx, [[maybe_unused]] const FunctionType& upwindTerm) const
77 {
78 if constexpr (enableAdvection)
79 {
80
6/6
✓ Branch 0 taken 1148831389 times.
✓ Branch 1 taken 1395159674 times.
✓ Branch 2 taken 1148831389 times.
✓ Branch 3 taken 1395159674 times.
✓ Branch 4 taken 1148831389 times.
✓ Branch 5 taken 1395159674 times.
17095657359 if (!advFluxIsCached_[phaseIdx])
81 {
82
83
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19381448 times.
✓ Branch 2 taken 170775443 times.
✓ Branch 3 taken 19381448 times.
2949485833 advFluxBeforeUpwinding_[phaseIdx] = AdvectionType::flux(this->problem(),
84 this->element(),
85 this->fvGeometry(),
86 this->elemVolVars(),
87 this->scvFace(),
88 phaseIdx,
89 this->elemFluxVarsCache());
90
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190156891 times.
2910722937 advFluxIsCached_.set(phaseIdx, true);
91 }
92
93 //! Give the upwind scheme access to the cached variables
94 11397104906 return UpwindScheme::apply(*this, upwindTerm, advFluxBeforeUpwinding_[phaseIdx], phaseIdx);
95 }
96 else
97 return 0.0;
98 }
99
100 /*!
101 * \brief Returns the diffusive fluxes computed by the respective law.
102 */
103 712139663 Dune::FieldVector<Scalar, numComponents> molecularDiffusionFlux([[maybe_unused]] const int phaseIdx) const
104 {
105 if constexpr (enableMolecularDiffusion)
106 915455004 return MolecularDiffusionType::flux(this->problem(),
107 this->element(),
108 this->fvGeometry(),
109 this->elemVolVars(),
110 this->scvFace(),
111 phaseIdx,
112 712139663 this->elemFluxVarsCache());
113 else
114 return Dune::FieldVector<Scalar, numComponents>(0.0);
115 }
116
117 /*!
118 * \brief Returns the compositional dispersion flux computed by the respective law.
119 */
120 10657400 Dune::FieldVector<Scalar, numComponents> compositionalDispersionFlux([[maybe_unused]] const int phaseIdx) const
121 {
122 if constexpr (enableCompositionalDispersion)
123 {
124 10657400 return DispersionFluxType::compositionalDispersionFlux(this->problem(),
125 this->element(),
126 this->fvGeometry(),
127 this->elemVolVars(),
128 this->scvFace(),
129 phaseIdx,
130 10657400 this->elemFluxVarsCache());
131 }
132 else
133 return Dune::FieldVector<Scalar, numComponents>(0.0);
134 }
135
136 /*!
137 * \brief Returns the thermal dispersion flux computed by the respective law.
138 */
139 5600000 Dune::FieldVector<Scalar, 1> thermalDispersionFlux([[maybe_unused]] const int phaseIdx = 0) const
140 {
141 if constexpr (enableThermalDispersion)
142 {
143 5600000 return DispersionFluxType::thermalDispersionFlux(this->problem(),
144 this->element(),
145 this->fvGeometry(),
146 this->elemVolVars(),
147 this->scvFace(),
148 phaseIdx,
149 5600000 this->elemFluxVarsCache());
150 }
151 else
152 return Dune::FieldVector<Scalar, 1>(0.0);
153 }
154
155 /*!
156 * \brief Returns the conductive flux computed by the respective law.
157 * \note This overload is used in models considering local thermal equilibrium
158 */
159 196781001 Scalar heatConductionFlux() const
160 {
161 static_assert(!enableThermalNonEquilibrium, "This only works for thermal equilibrium");
162 if constexpr (enableEnergyBalance)
163 208902013 return HeatConductionType::flux(this->problem(),
164 this->element(),
165 this->fvGeometry(),
166 this->elemVolVars(),
167 this->scvFace(),
168 196781001 this->elemFluxVarsCache());
169 else
170 return 0.0;
171 }
172
173 /*!
174 * \brief Returns the conductive flux computed by the respective law.
175 * \note This overload is used in models considering local thermal nonequilibrium
176 */
177 13274140 Scalar heatConductionFlux([[maybe_unused]] const int phaseIdx) const
178 {
179 if constexpr (enableEnergyBalance)
180 13274140 return HeatConductionType::flux(this->problem(),
181 this->element(),
182 this->fvGeometry(),
183 this->elemVolVars(),
184 this->scvFace(),
185 phaseIdx,
186 13274140 this->elemFluxVarsCache());
187 else
188 return 0.0;
189 }
190
191 private:
192 //! simple caching if advection flux is used twice with different upwind function
193 mutable std::bitset<numPhases> advFluxIsCached_;
194 mutable std::array<Scalar, numPhases> advFluxBeforeUpwinding_;
195 };
196
197 } // end namespace Dumux
198
199 #endif
200