GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/box/fourierslawnonequilibrium.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 21 95.2%
Functions: 2 6 33.3%
Branches: 21 28 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 BoxFlux
10 * \brief This file contains the data which is required to calculate
11 * energy fluxes due to molecular diffusion with Fourier's law.
12 */
13 #ifndef DUMUX_DISCRETIZATION_BOX_FOURIERS_LAW_NONEQUILIBRIUM_HH
14 #define DUMUX_DISCRETIZATION_BOX_FOURIERS_LAW_NONEQUILIBRIUM_HH
15
16 #include <dune/common/fvector.hh>
17
18 #include <dumux/common/math.hh>
19 #include <dumux/common/properties.hh>
20
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/extrusion.hh>
23
24 #include <dumux/flux/facetensoraverage.hh>
25
26 namespace Dumux {
27
28 // forward declaration
29 template <class TypeTag, class DiscretizationMethod>
30 class FouriersLawNonEquilibriumImplementation;
31
32 /*!
33 * \ingroup BoxFlux
34 * \brief Specialization of Fourier's Law for the box method for thermal nonequilibrium models.
35 */
36 template <class TypeTag>
37 class FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethods::Box>
38 {
39 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
40 using Problem = GetPropType<TypeTag, Properties::Problem>;
41 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
44 using Extrusion = Extrusion_t<GridGeometry>;
45 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
46 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
47 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
48 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
49 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
50 using Element = typename GridView::template Codim<0>::Entity;
51
52 static constexpr auto numEnergyEqSolid = getPropValue<TypeTag, Properties::NumEnergyEqSolid>();
53 static constexpr auto numEnergyEqFluid = getPropValue<TypeTag, Properties::NumEnergyEqFluid>();
54 static constexpr auto numEnergyEq = numEnergyEqSolid + numEnergyEqFluid;
55 static constexpr auto sPhaseIdx = ModelTraits::numFluidPhases();
56
57 public:
58 /*!
59 * \brief Returns the heat flux within a fluid or solid
60 * phase (in J/s) across the given sub-control volume face.
61 */
62 11951120 static Scalar flux(const Problem& problem,
63 const Element& element,
64 const FVElementGeometry& fvGeometry,
65 const ElementVolumeVariables& elemVolVars,
66 const SubControlVolumeFace& scvf,
67 const int phaseIdx,
68 const ElementFluxVariablesCache& elemFluxVarsCache)
69 {
70 // get inside and outside diffusion tensors and calculate the harmonic mean
71
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11951120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11951120 times.
23902240 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
72
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11951120 times.
✓ Branch 2 taken 9611920 times.
✓ Branch 3 taken 2339200 times.
11951120 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
73
2/2
✓ Branch 0 taken 9611920 times.
✓ Branch 1 taken 2339200 times.
11951120 const auto& insideVolVars = elemVolVars[insideScv];
74
2/2
✓ Branch 0 taken 9611920 times.
✓ Branch 1 taken 2339200 times.
11951120 const auto& outsideVolVars = elemVolVars[outsideScv];
75 11951120 const auto computeLambda = [&](const auto& v){
76 if constexpr (numEnergyEq == 1)
77 return v.effectiveThermalConductivity();
78 else if constexpr (numEnergyEqFluid == 1)
79 return (phaseIdx != sPhaseIdx)
80
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
18713600 ? v.effectiveFluidThermalConductivity()
81 : v.effectiveSolidThermalConductivity();
82 else
83 29090880 return v.effectivePhaseThermalConductivity(phaseIdx);
84 };
85
86
2/2
✓ Branch 0 taken 9611920 times.
✓ Branch 1 taken 2339200 times.
11951120 auto insideLambda = computeLambda(insideVolVars);
87
2/2
✓ Branch 0 taken 9611920 times.
✓ Branch 1 taken 2339200 times.
11951120 auto outsideLambda = computeLambda(outsideVolVars);
88
89 // scale by extrusion factor
90 11951120 insideLambda *= insideVolVars.extrusionFactor();
91 11951120 outsideLambda *= outsideVolVars.extrusionFactor();
92
93 // the resulting averaged diffusion tensor
94
2/4
✓ Branch 0 taken 11951120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11951120 times.
✗ Branch 3 not taken.
23902240 const auto lambda = faceTensorAverage(insideLambda, outsideLambda, scvf.unitOuterNormal());
95
96 // evaluate gradTemp at integration point
97 11951120 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
98
99 11951120 Dune::FieldVector<Scalar, GridView::dimensionworld> gradTemp(0.0);
100
4/4
✓ Branch 0 taken 47804480 times.
✓ Branch 1 taken 11951120 times.
✓ Branch 2 taken 47804480 times.
✓ Branch 3 taken 11951120 times.
71706720 for (auto&& scv : scvs(fvGeometry))
101 {
102 // compute the temperature gradient with the shape functions
103
2/2
✓ Branch 0 taken 28750720 times.
✓ Branch 1 taken 19053760 times.
47804480 if (phaseIdx < numEnergyEqFluid)
104 115002880 gradTemp.axpy(elemVolVars[scv].temperatureFluid(phaseIdx), fluxVarsCache.gradN(scv.indexInElement()));
105 else
106 76215040 gradTemp.axpy(elemVolVars[scv].temperatureSolid(), fluxVarsCache.gradN(scv.indexInElement()));
107 }
108
109 // compute the heat conduction flux
110 23902240 return -1.0*vtmv(scvf.unitOuterNormal(), lambda, gradTemp)*Extrusion::area(fvGeometry, scvf);
111 }
112 };
113
114 } // end namespace Dumux
115
116 #endif
117