GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/box/fourierslaw.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 27 27 100.0%
Branches: 14 24 58.3%

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_HH
14 #define DUMUX_DISCRETIZATION_BOX_FOURIERS_LAW_HH
15
16 #include <dumux/common/math.hh>
17 #include <dumux/common/properties.hh>
18 #include <dumux/discretization/method.hh>
19 #include <dumux/discretization/extrusion.hh>
20 #include <dumux/flux/facetensoraverage.hh>
21
22 namespace Dumux {
23
24 // forward declaration
25 template<class TypeTag, class DiscretizationMethod>
26 class FouriersLawImplementation;
27
28 /*!
29 * \ingroup BoxFlux
30 * \brief Specialization of Fourier's Law for the box method.
31 */
32 template <class TypeTag>
33 class FouriersLawImplementation<TypeTag, DiscretizationMethods::Box>
34 {
35 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
36 using Problem = GetPropType<TypeTag, Properties::Problem>;
37 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
38 using FVElementGeometry = typename GridGeometry::LocalView;
39 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
40 using Extrusion = Extrusion_t<GridGeometry>;
41 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
42 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
43 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
44 using Element = typename GridView::template Codim<0>::Entity;
45
46 public:
47 /*!
48 * \brief Returns the heat flux within the porous medium
49 * (in J/s) across the given sub-control volume face.
50 * \note This law assumes thermal equilibrium between the fluid
51 * and solid phases, and uses an effective thermal conductivity
52 * for the overall aggregate.
53 */
54 134248256 static Scalar flux(const Problem& problem,
55 const Element& element,
56 const FVElementGeometry& fvGeometry,
57 const ElementVolumeVariables& elemVolVars,
58 const SubControlVolumeFace& scvf,
59 const ElementFluxVariablesCache& elemFluxVarsCache)
60 {
61 // get inside and outside diffusion tensors and calculate the harmonic mean
62
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129997408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129997408 times.
268496512 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
63
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129997408 times.
✓ Branch 2 taken 129997408 times.
✗ Branch 3 not taken.
134248256 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
64
1/2
✓ Branch 0 taken 129997408 times.
✗ Branch 1 not taken.
134248256 const auto& insideVolVars = elemVolVars[insideScv];
65
1/2
✓ Branch 0 taken 129997408 times.
✗ Branch 1 not taken.
134248256 const auto& outsideVolVars = elemVolVars[outsideScv];
66
67 // effective diffusion tensors
68
1/2
✓ Branch 0 taken 129997408 times.
✗ Branch 1 not taken.
134248256 auto insideLambda = insideVolVars.effectiveThermalConductivity();
69
1/2
✓ Branch 0 taken 129997408 times.
✗ Branch 1 not taken.
134248256 auto outsideLambda = outsideVolVars.effectiveThermalConductivity();
70
71 // scale by extrusion factor
72 134248256 insideLambda *= insideVolVars.extrusionFactor();
73 134248256 outsideLambda *= outsideVolVars.extrusionFactor();
74
75 // the resulting averaged diffusion tensor
76
2/4
✓ Branch 0 taken 129997408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129997408 times.
✗ Branch 3 not taken.
268496512 const auto lambda = faceTensorAverage(insideLambda, outsideLambda, scvf.unitOuterNormal());
77
78 // evaluate gradTemp at integration point
79 134248256 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
80
81 // compute the temperature gradient with the shape functions
82 134248256 Dune::FieldVector<Scalar, GridView::dimensionworld> gradTemp(0.0);
83
4/4
✓ Branch 0 taken 519213792 times.
✓ Branch 1 taken 129997408 times.
✓ Branch 2 taken 519213792 times.
✓ Branch 3 taken 129997408 times.
1340886976 for (auto&& scv : scvs(fvGeometry))
84 2680976160 gradTemp.axpy(elemVolVars[scv].temperature(), fluxVarsCache.gradN(scv.indexInElement()));
85
86 // compute the heat conduction flux
87 268673312 return -1.0*vtmv(scvf.unitOuterNormal(), lambda, gradTemp)*Extrusion::area(fvGeometry, scvf);
88 }
89 };
90
91 } // end namespace Dumux
92
93 #endif
94