GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/scalarfluxvariablescachefiller.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 16 18 88.9%
Functions: 9 15 60.0%
Branches: 8 8 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 NavierStokesModel
10 * \brief A helper class to fill the flux variables cache
11 */
12 #ifndef DUMUX_FREEFLOW_SCALAR_FLUXVARIABLESCACHE_FILLER_HH
13 #define DUMUX_FREEFLOW_SCALAR_FLUXVARIABLESCACHE_FILLER_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/common/parameters.hh>
17
18 #include <dumux/discretization/method.hh>
19 #include <dumux/discretization/extrusion.hh>
20 #include <dumux/flux/referencesystemformulation.hh>
21 #include <dumux/common/typetraits/problem.hh>
22
23 namespace Dumux {
24
25 // forward declaration
26 template<class Problem, class ModelTraits, bool diffusionIsSolDependent, bool heatConductionIsSolDependent, class DiscretizationMethod>
27 class FreeFlowScalarFluxVariablesCacheFillerImplementation;
28
29 /*!
30 * \ingroup NavierStokesModel
31 * \brief The flux variables cache filler class for free flow
32 *
33 * Helps filling the flux variables cache depending on several policies
34 */
35 template<class Problem, class ModelTraits, bool diffusionIsSolDependent, bool heatConductionIsSolDependent>
36 using FreeFlowScalarFluxVariablesCacheFiller = FreeFlowScalarFluxVariablesCacheFillerImplementation<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent, typename ProblemTraits<Problem>::GridGeometry::DiscretizationMethod>;
37
38 //! Specialization of the flux variables cache filler for the cell centered tpfa method
39 template<class Problem, class ModelTraits, bool diffusionIsSolDependent, bool heatConductionIsSolDependent>
40 class FreeFlowScalarFluxVariablesCacheFillerImplementation<Problem, ModelTraits, diffusionIsSolDependent, heatConductionIsSolDependent, DiscretizationMethods::CCTpfa>
41 {
42 using GridGeometry = typename ProblemTraits<Problem>::GridGeometry;
43 using GridView = typename GridGeometry::GridView;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45 using SubControlVolume = typename GridGeometry::SubControlVolume;
46 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
47
48 using Element = typename GridView::template Codim<0>::Entity;
49
50 static constexpr bool diffusionEnabled = ModelTraits::enableMolecularDiffusion();
51 static constexpr bool heatConductionEnabled = ModelTraits::enableEnergyBalance();
52
53 public:
54 static constexpr bool isSolDependent = (diffusionEnabled && diffusionIsSolDependent) ||
55 (heatConductionEnabled && heatConductionIsSolDependent);
56
57 //! The constructor. Sets the problem pointer
58 1195701 FreeFlowScalarFluxVariablesCacheFillerImplementation(const Problem& problem)
59 1256901 : problemPtr_(&problem) {}
60
61 /*!
62 * \brief function to fill the flux variables caches
63 *
64 * \param fluxVarsCacheContainer Either the element or global flux variables cache
65 * \param scvfFluxVarsCache The flux var cache to be updated corresponding to the given scvf
66 * \param element The finite element
67 * \param fvGeometry The finite volume geometry
68 * \param elemVolVars The element volume variables
69 * \param scvf The corresponding sub-control volume face
70 * \param forceUpdateAll if true, forces all caches to be updated (even the solution-independent ones)
71 */
72 template<class FluxVariablesCacheContainer, class FluxVariablesCache, class ElementVolumeVariables>
73 10823380 void fill(FluxVariablesCacheContainer& fluxVarsCacheContainer,
74 FluxVariablesCache& scvfFluxVarsCache,
75 const Element& element,
76 const FVElementGeometry& fvGeometry,
77 const ElementVolumeVariables& elemVolVars,
78 const SubControlVolumeFace& scvf,
79 const bool forceUpdateAll = false)
80 {
81 // fill the physics-related quantities of the caches
82
2/2
✓ Branch 0 taken 377600 times.
✓ Branch 1 taken 10445780 times.
10823380 if (forceUpdateAll)
83 {
84 if constexpr (diffusionEnabled)
85 337600 fillDiffusion_(scvfFluxVarsCache, element, fvGeometry, elemVolVars, scvf);
86 if constexpr (heatConductionEnabled)
87 47000 fillHeatConduction_(scvfFluxVarsCache, element, fvGeometry, elemVolVars, scvf);
88 }
89 else
90 {
91 if constexpr (diffusionEnabled && diffusionIsSolDependent)
92 7524680 fillDiffusion_(scvfFluxVarsCache, element, fvGeometry, elemVolVars, scvf);
93 if constexpr (heatConductionEnabled && heatConductionIsSolDependent)
94 5182860 fillHeatConduction_(scvfFluxVarsCache, element, fvGeometry, elemVolVars, scvf);
95 }
96 10823380 }
97
98 private:
99
100 const Problem& problem() const
101 { return *problemPtr_; }
102
103
104 //! method to fill the diffusive quantities
105 template<class FluxVariablesCache, class ElementVolumeVariables>
106 7862280 void fillDiffusion_(FluxVariablesCache& scvfFluxVarsCache,
107 const Element& element,
108 const FVElementGeometry& fvGeometry,
109 const ElementVolumeVariables& elemVolVars,
110 const SubControlVolumeFace& scvf)
111 {
112 using DiffusionType = typename ElementVolumeVariables::VolumeVariables::MolecularDiffusionType;
113 using DiffusionFiller = typename DiffusionType::Cache::Filler;
114 using FluidSystem = typename ElementVolumeVariables::VolumeVariables::FluidSystem;
115
116 static constexpr int numPhases = ModelTraits::numFluidPhases();
117 static constexpr int numComponents = ModelTraits::numFluidComponents();
118
119 // forward to the filler of the diffusive quantities
120 if constexpr (FluidSystem::isTracerFluidSystem())
121 for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
122 for (unsigned int compIdx = 0; compIdx < numComponents; ++compIdx)
123 DiffusionFiller::fill(scvfFluxVarsCache, phaseIdx, compIdx, problem(), element, fvGeometry, elemVolVars, scvf, *this);
124 else
125
2/2
✓ Branch 0 taken 7862280 times.
✓ Branch 1 taken 7862280 times.
15724560 for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
126
2/2
✓ Branch 0 taken 7862280 times.
✓ Branch 1 taken 15724560 times.
23586840 for (unsigned int compIdx = 0; compIdx < numComponents; ++compIdx)
127
2/2
✓ Branch 0 taken 7862280 times.
✓ Branch 1 taken 7862280 times.
15724560 if (compIdx != FluidSystem::getMainComponent(phaseIdx))
128 7862280 DiffusionFiller::fill(scvfFluxVarsCache, phaseIdx, compIdx, problem(), element, fvGeometry, elemVolVars, scvf, *this);
129 7862280 }
130
131 //! method to fill the quantities related to heat conduction
132 template<class FluxVariablesCache, class ElementVolumeVariables>
133 void fillHeatConduction_(FluxVariablesCache& scvfFluxVarsCache,
134 const Element& element,
135 const FVElementGeometry& fvGeometry,
136 const ElementVolumeVariables& elemVolVars,
137 const SubControlVolumeFace& scvf)
138 {
139 using HeatConductionType = typename ElementVolumeVariables::VolumeVariables::HeatConductionType;
140 using HeatConductionFiller = typename HeatConductionType::Cache::Filler;
141
142 // forward to the filler of the diffusive quantities
143 5229860 HeatConductionFiller::fill(scvfFluxVarsCache, problem(), element, fvGeometry, elemVolVars, scvf, *this);
144 }
145
146 const Problem* problemPtr_;
147 };
148
149 } // end namespace Dumux
150
151 #endif
152