GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porenetwork/2p/elementfluxvariablescache.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 16 21 76.2%
Functions: 8 11 72.7%
Branches: 11 22 50.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 PNMTwoPModel
10 * \brief Element flux variable cache
11 */
12 #ifndef DUMUX_PNM_2P_ELEMNT_FLUXVARSCACHE_HH
13 #define DUMUX_PNM_2P_ELEMNT_FLUXVARSCACHE_HH
14
15 #include <cstddef>
16 #include <vector>
17 #include <utility>
18
19 #include <dumux/discretization/cvfe/elementfluxvariablescache.hh>
20
21 namespace Dumux::PoreNetwork {
22
23 /*!
24 * \ingroup PNMTwoPModel
25 * \brief The flux variables caches for an element
26 */
27 template<class GFVC, bool cachingEnabled>
28 class PNMTwoPElementFluxVariablesCache;
29
30 /*!
31 * \ingroup PNMTwoPModel
32 * \brief The flux variables caches for an element with caching enabled
33 */
34 template<class GFVC>
35 class PNMTwoPElementFluxVariablesCache<GFVC, true> : public CVFEElementFluxVariablesCache<GFVC, true>
36 {
37 using ParentType = CVFEElementFluxVariablesCache<GFVC, true>;
38 public:
39 using ParentType::ParentType;
40 };
41
42 /*!
43 * \ingroup PNMTwoPModel
44 * \brief The flux variables caches for an element with caching disabled
45 */
46 template<class GFVC>
47 class PNMTwoPElementFluxVariablesCache<GFVC, false>
48 {
49 public:
50 //! export the type of the grid flux variables cache
51 using GridFluxVariablesCache = GFVC;
52
53 //! export the type of the flux variables cache
54 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
55
56 158267 PNMTwoPElementFluxVariablesCache(const GridFluxVariablesCache& global)
57
1/4
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 6 taken 31352 times.
✗ Branch 7 not taken.
316534 : gridFluxVarsCachePtr_(&global) {}
58
59 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
60 // We assume the FVGeometries to be bound at this point
61 template<class FVElementGeometry, class ElementVolumeVariables>
62 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars) &
65
2/6
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 4 taken 124713 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 31352 times.
✗ Branch 9 not taken.
281104 { bindElement(element, fvGeometry, elemVolVars); }
66
67 /*!
68 * \brief bind the local view (r-value overload)
69 * This overload is called when an instance of this class is a temporary in the usage context
70 * This allows a usage like this: `const auto view = localView(...).bind(element);`
71 */
72 template<class FVElementGeometry, class ElementVolumeVariables>
73 PNMTwoPElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars) &&
76 {
77
1/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 4 taken 31352 times.
✗ Branch 5 not taken.
31352 this->bind(element, fvGeometry, elemVolVars);
78 31352 return std::move(*this);
79 }
80
81 template<class FVElementGeometry, class ElementVolumeVariables>
82 312456 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
83 const FVElementGeometry& fvGeometry,
84 const ElementVolumeVariables& elemVolVars) &
85 {
86
2/2
✓ Branch 0 taken 312456 times.
✓ Branch 1 taken 312456 times.
937368 for (auto&& scvf : scvfs(fvGeometry))
87 624912 fluxVarsCache_.update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf, gridFluxVarsCache().invasionState().invaded(element));
88 312456 }
89
90 /*!
91 * \brief bind the local view (r-value overload)
92 * This overload is called when an instance of this class is a temporary in the usage context
93 * This allows a usage like this: `const auto view = localView(...).bind(element);`
94 */
95 template<class FVElementGeometry, class ElementVolumeVariables>
96 PNMTwoPElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
97 const FVElementGeometry& fvGeometry,
98 const ElementVolumeVariables& elemVolVars) &&
99 {
100 this->bindElement(element, fvGeometry, elemVolVars);
101 return std::move(*this);
102 }
103
104 template<class FVElementGeometry, class ElementVolumeVariables>
105 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
106 const FVElementGeometry& fvGeometry,
107 const ElementVolumeVariables& elemVolVars,
108 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
109 {
110 fluxVarsCache_.update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf, gridFluxVarsCache().invasionState().invaded(element));
111 }
112
113 /*!
114 * \brief bind the local view (r-value overload)
115 * This overload is called when an instance of this class is a temporary in the usage context
116 * This allows a usage like this: `const auto view = localView(...).bind(element);`
117 */
118 template<class FVElementGeometry, class ElementVolumeVariables>
119 PNMTwoPElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
120 const FVElementGeometry& fvGeometry,
121 const ElementVolumeVariables& elemVolVars,
122 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
123 {
124 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
125 return std::move(*this);
126 }
127
128 /*!
129 * \brief Update the caches if the volume variables have changed and the cache is solution-dependent
130 * \note Results in undefined behaviour if called before bind() or with a different element
131 */
132 template<class FVElementGeometry, class ElementVolumeVariables>
133 647364 void update(const typename FVElementGeometry::Element& element,
134 const FVElementGeometry& fvGeometry,
135 const ElementVolumeVariables& elemVolVars)
136 {
137 if constexpr (FluxVariablesCache::isSolDependent)
138 {
139
2/2
✓ Branch 0 taken 647364 times.
✓ Branch 1 taken 647364 times.
1942092 for (const auto& scvf : scvfs(fvGeometry))
140 2589456 fluxVarsCache_.update(
141 647364 gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf,
142 1294728 gridFluxVarsCache().invasionState().invaded(element)
143 );
144 }
145 647364 }
146
147 //! access operator
148 template<class SubControlVolumeFace>
149 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
150
3/4
✓ Branch 0 taken 33903 times.
✓ Branch 1 taken 28801 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1641413 times.
2254137 { return fluxVarsCache_; }
151
152 //! access operator
153 template<class SubControlVolumeFace>
154 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
155 { return fluxVarsCache_; }
156
157 //! The global object we are a restriction of
158 const GridFluxVariablesCache& gridFluxVarsCache() const
159 { return *gridFluxVarsCachePtr_; }
160
161 private:
162 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
163 FluxVariablesCache fluxVarsCache_;
164 };
165
166 } // end namespace Dumux::PoreNetwork
167
168 #endif
169