GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/cctpfa/fourierslawnonequilibrium.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 2 3 66.7%
Branches: 19 24 79.2%

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 CCTpfaFlux
10 * \brief Fourier's law for cell-centered finite volume schemes with two-point flux approximation
11 */
12 #ifndef DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_NONEQUILIBRIUM_HH
13 #define DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_NONEQUILIBRIUM_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/discretization/method.hh>
17 #include <dumux/discretization/extrusion.hh>
18 #include <dumux/discretization/cellcentered/tpfa/computetransmissibility.hh>
19 #include <dumux/flux/fluxvariablescaching.hh>
20
21 namespace Dumux {
22
23 // forward declaration
24 template<class TypeTag, class DiscretizationMethod>
25 class FouriersLawNonEquilibriumImplementation;
26
27 /*!
28 * \ingroup CCTpfaFlux
29 * \brief Fourier's law for cell-centered finite volume schemes with two-point flux approximation
30 */
31 template <class TypeTag>
32 class FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethods::CCTpfa>
33 {
34 using Implementation = FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethods::CCTpfa>;
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 GridView = typename GridGeometry::GridView;
42 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
43 using Element = typename GridView::template Codim<0>::Entity;
44 using ElementFluxVarsCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
45
46 static constexpr int dim = GridView::dimension;
47 static constexpr int dimWorld = GridView::dimensionworld;
48
49 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
50
51 static constexpr auto numEnergyEqSolid = getPropValue<TypeTag, Properties::NumEnergyEqSolid>();
52 static constexpr auto numEnergyEqFluid = getPropValue<TypeTag, Properties::NumEnergyEqFluid>();
53 static constexpr auto numEnergyEq = numEnergyEqSolid + numEnergyEqFluid;
54 static constexpr auto sPhaseIdx = ModelTraits::numFluidPhases();
55
56 public:
57 using DiscretizationMethod = DiscretizationMethods::CCTpfa;
58 //! state the discretization method this implementation belongs to
59 static constexpr DiscretizationMethod discMethod{};
60
61 using Cache = FluxVariablesCaching::EmptyHeatConductionCache;
62
63 /*!
64 * \brief Returns the heat flux within a fluid or solid
65 * phase (in J/s) across the given sub-control volume face.
66 */
67 1323020 static Scalar flux(const Problem& problem,
68 const Element& element,
69 const FVElementGeometry& fvGeometry,
70 const ElementVolumeVariables& elemVolVars,
71 const SubControlVolumeFace& scvf,
72 const int phaseIdx,
73 const ElementFluxVarsCache& elemFluxVarsCache)
74 {
75 1323020 Scalar tInside = 0.0;
76 1323020 Scalar tOutside = 0.0;
77 // get the inside/outside temperatures
78
2/2
✓ Branch 0 taken 661510 times.
✓ Branch 1 taken 661510 times.
1323020 if (phaseIdx < numEnergyEqFluid)
79 {
80 1323020 tInside += elemVolVars[scvf.insideScvIdx()].temperatureFluid(phaseIdx);
81 1323020 tOutside += elemVolVars[scvf.outsideScvIdx()].temperatureFluid(phaseIdx);
82 }
83 else //temp solid
84 {
85 1323020 tInside += elemVolVars[scvf.insideScvIdx()].temperatureSolid();
86 1323020 tOutside += elemVolVars[scvf.outsideScvIdx()].temperatureSolid();
87 }
88
89 1323020 Scalar tij = calculateTransmissibility(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx);
90 1323020 return tij*(tInside - tOutside);
91 }
92
93 //! Compute transmissibilities
94 1323020 static Scalar calculateTransmissibility(const Problem& problem,
95 const Element& element,
96 const FVElementGeometry& fvGeometry,
97 const ElementVolumeVariables& elemVolVars,
98 const SubControlVolumeFace& scvf,
99 const int phaseIdx)
100 {
101
2/2
✓ Branch 0 taken 662340 times.
✓ Branch 1 taken 660680 times.
1323020 const auto insideScvIdx = scvf.insideScvIdx();
102
2/2
✓ Branch 0 taken 662340 times.
✓ Branch 1 taken 660680 times.
1323020 const auto& insideScv = fvGeometry.scv(insideScvIdx);
103 1323020 const auto& insideVolVars = elemVolVars[insideScvIdx];
104 1323020 const auto computeLambda = [&](const auto& v){
105 if constexpr (numEnergyEq == 1)
106 return v.effectiveThermalConductivity();
107 else if constexpr (numEnergyEqFluid == 1)
108 return (phaseIdx != sPhaseIdx)
109
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5288760 ? v.effectiveFluidThermalConductivity()
110 : v.effectiveSolidThermalConductivity();
111 else
112 return v.effectivePhaseThermalConductivity(phaseIdx);
113 };
114
115
2/2
✓ Branch 0 taken 661510 times.
✓ Branch 1 taken 661510 times.
1323020 const auto insideLambda = computeLambda(insideVolVars);
116 1323020 const Scalar ti = computeTpfaTransmissibility(fvGeometry, scvf, insideScv, insideLambda, insideVolVars.extrusionFactor());
117
118 // for the boundary (dirichlet) or at branching points we only need ti
119
4/6
✓ Branch 0 taken 1321360 times.
✓ Branch 1 taken 1660 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1321360 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1321360 times.
1323020 if (scvf.boundary() || scvf.numOutsideScvs() > 1)
120 3320 return Extrusion::area(fvGeometry, scvf)*ti;
121 else // otherwise we compute a tpfa harmonic mean
122 {
123
2/2
✓ Branch 0 taken 660680 times.
✓ Branch 1 taken 660680 times.
1321360 const auto outsideScvIdx = scvf.outsideScvIdx();
124
2/2
✓ Branch 0 taken 660680 times.
✓ Branch 1 taken 660680 times.
1321360 const auto& outsideScv = fvGeometry.scv(outsideScvIdx);
125 1321360 const auto& outsideVolVars = elemVolVars[outsideScvIdx];
126
2/2
✓ Branch 0 taken 660680 times.
✓ Branch 1 taken 660680 times.
1321360 const auto outsideLambda = computeLambda(outsideVolVars);
127
128 Scalar tj;
129 if (dim == dimWorld)
130 // assume the normal vector from outside is anti parallel so we save flipping a vector
131 1321360 tj = -1.0*computeTpfaTransmissibility(fvGeometry, scvf, outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
132 else
133 tj = computeTpfaTransmissibility(fvGeometry, fvGeometry.flipScvf(scvf.index()), outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
134
135 // check for division by zero!
136
1/2
✓ Branch 0 taken 1321360 times.
✗ Branch 1 not taken.
1321360 if (ti*tj <= 0.0)
137 return 0.0;
138 else
139 2642720 return Extrusion::area(fvGeometry, scvf)*(ti * tj)/(ti + tj);
140 }
141 }
142 };
143
144 } // end namespace Dumux
145
146 #endif
147