GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/staggered/freeflow/fourierslaw.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 13 13 100.0%
Branches: 10 10 100.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 StaggeredFlux
10 * \brief Specialization of Fourier's Law for the staggered free flow method.
11 */
12 #ifndef DUMUX_DISCRETIZATION_STAGGERED_FOURIERS_LAW_HH
13 #define DUMUX_DISCRETIZATION_STAGGERED_FOURIERS_LAW_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/common/math.hh>
17
18 #include <dumux/discretization/method.hh>
19 #include <dumux/discretization/extrusion.hh>
20 #include <dumux/flux/fluxvariablescaching.hh>
21
22 namespace Dumux {
23
24 // forward declaration
25 template<class TypeTag, class DiscretizationMethod>
26 class FouriersLawImplementation;
27
28 /*!
29 * \ingroup StaggeredFlux
30 * \brief Specialization of Fourier's Law for the staggered free flow method.
31 */
32 template <class TypeTag>
33 class FouriersLawImplementation<TypeTag, DiscretizationMethods::Staggered>
34 {
35 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using FVElementGeometry = typename GridGeometry::LocalView;
38 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
39 using Extrusion = Extrusion_t<GridGeometry>;
40 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
41 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
42 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
43
44 public:
45 using DiscretizationMethod = DiscretizationMethods::Staggered;
46 // state the discretization method this implementation belongs to
47 static constexpr DiscretizationMethod discMethod{};
48
49 //! state the type for the corresponding cache
50 //! We don't cache anything for this law
51 using Cache = FluxVariablesCaching::EmptyDiffusionCache;
52
53 /*!
54 * \brief Returns the heat flux within the porous medium
55 * (in J/s) across the given sub-control volume face.
56 * \note This law assumes thermal equilibrium between the fluid
57 * and solid phases, and uses an effective thermal conductivity
58 * for the overall aggregate.
59 */
60 template<class Problem>
61 62256998 static Scalar flux(const Problem& problem,
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const SubControlVolumeFace &scvf)
66 {
67 62256998 Scalar flux(0.0);
68
69 // conductive energy flux is zero for outflow boundary conditions
70
6/6
✓ Branch 0 taken 3974190 times.
✓ Branch 1 taken 58282808 times.
✓ Branch 3 taken 1540188 times.
✓ Branch 4 taken 2434002 times.
✓ Branch 5 taken 1540188 times.
✓ Branch 6 taken 2434002 times.
62256998 if (scvf.boundary() && problem.boundaryTypes(element, scvf).isOutflow(Indices::energyEqIdx))
71 1540188 return flux;
72
73 121433620 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
74 121433620 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
75 121433620 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
76
77 60716810 const Scalar insideTemperature = insideVolVars.temperature();
78 60716810 const Scalar outsideTemperature = outsideVolVars.temperature();
79
80 60716810 const Scalar insideLambda = insideVolVars.effectiveThermalConductivity() * insideVolVars.extrusionFactor();
81 242867240 const Scalar insideDistance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
82
83
2/2
✓ Branch 0 taken 2434002 times.
✓ Branch 1 taken 58282808 times.
60716810 if (scvf.boundary())
84 {
85 2434002 flux = insideLambda * (insideTemperature - outsideTemperature) / insideDistance;
86 }
87 else
88 {
89 116565616 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
90 58282808 const Scalar outsideLambda = outsideVolVars.effectiveThermalConductivity() * outsideVolVars.extrusionFactor();
91 233131232 const Scalar outsideDistance = (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm();
92
2/2
✓ Branch 0 taken 58255900 times.
✓ Branch 1 taken 26908 times.
58282808 const Scalar avgLambda = harmonicMean(insideLambda, outsideLambda, insideDistance, outsideDistance);
93
94 58282808 flux = avgLambda * (insideTemperature - outsideTemperature) / (insideDistance + outsideDistance);
95 }
96
97 60716810 flux *= Extrusion::area(fvGeometry, scvf);
98 60716810 return flux;
99 }
100 };
101
102 } // end namespace Dumux
103
104 #endif
105