GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cvfe/fluxvariablescache.hh
Date: 2025-06-28 19:18:10
Exec Total Coverage
Lines: 19 19 100.0%
Functions: 126 127 99.2%
Branches: 18 30 60.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-FileCopyrightText: 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 CVFEDiscretization
10 * \brief Flux variables cache class for control-volume finite element schemes
11 */
12 #ifndef DUMUX_DISCRETIZATION_CVFE_FLUXVARIABLES_CACHE_HH
13 #define DUMUX_DISCRETIZATION_CVFE_FLUXVARIABLES_CACHE_HH
14
15 #include <dune/common/fvector.hh>
16 #include <dumux/common/typetraits/localdofs_.hh>
17 #include <dumux/discretization/cvfe/localdof.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup CVFEDiscretization
23 * \brief Flux variables cache class for control-volume finite element schemes.
24 * For control-volume finite element schemes, this class does not contain any physics-/process-dependent
25 * data. It solely stores disretization-/grid-related data.
26 */
27 template< class Scalar, class GridGeometry >
28 28188007 class CVFEFluxVariablesCache
29 {
30 using GridView = typename GridGeometry::GridView;
31 using Element = typename GridView::template Codim<0>::Entity;
32 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
33
34 using FVElementGeometry = typename GridGeometry::LocalView;
35 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
36
37 static const int dim = GridView::dimension;
38 static const int dimWorld = GridView::dimensionworld;
39
40 using CoordScalar = typename GridView::ctype;
41 using FeLocalBasis = typename GridGeometry::FeCache::FiniteElementType::Traits::LocalBasisType;
42 using ShapeJacobian = typename FeLocalBasis::Traits::JacobianType;
43 using ShapeValue = typename Dune::FieldVector<Scalar, 1>;
44 using JacobianInverseTransposed = typename Element::Geometry::JacobianInverseTransposed;
45
46 public:
47 //! whether the cache needs an update when the solution changes
48 static bool constexpr isSolDependent = false;
49
50 //! update the cache for an scvf
51 template< class Problem, class ElementVolumeVariables >
52
2/4
✓ Branch 1 taken 164475 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53640 times.
✗ Branch 5 not taken.
28616932 void update(const Problem& problem,
53 const Element& element,
54 const FVElementGeometry& fvGeometry,
55 const ElementVolumeVariables& elemVolVars,
56 const SubControlVolumeFace& scvf)
57 {
58
2/4
✓ Branch 1 taken 164475 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53640 times.
✗ Branch 5 not taken.
28616932 update(problem, element, fvGeometry, elemVolVars, scvf.ipGlobal());
59 218115 }
60
61 //! update the cache for a given global position
62 template< class Problem, class ElementVolumeVariables >
63 34724188 void update(const Problem& problem,
64 const Element& element,
65 const FVElementGeometry& fvGeometry,
66 const ElementVolumeVariables& elemVolVars,
67 const GlobalPosition& globalPos)
68 {
69
1/2
✓ Branch 1 taken 15278263 times.
✗ Branch 2 not taken.
34724188 const auto geometry = element.geometry();
70
1/2
✓ Branch 1 taken 111274 times.
✗ Branch 2 not taken.
34724188 const auto& localBasis = fvGeometry.feLocalBasis();
71
72 // evaluate shape functions and gradients at the integration point
73 34724188 ipGlobal_ = globalPos;
74
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 40400 times.
42864474 const auto ipLocal = geometry.local(ipGlobal_);
75 34724188 jacInvT_ = geometry.jacobianInverseTransposed(ipLocal);
76
1/2
✓ Branch 1 taken 15389537 times.
✗ Branch 2 not taken.
34724188 localBasis.evaluateJacobian(ipLocal, shapeJacobian_);
77
1/2
✓ Branch 1 taken 15389537 times.
✗ Branch 2 not taken.
34724188 localBasis.evaluateFunction(ipLocal, shapeValues_); // shape values for rho
78
79 // compute the gradN at for every scv/dof
80
2/4
✓ Branch 1 taken 15389537 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 76360 times.
✗ Branch 5 not taken.
34724188 gradN_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
81
2/2
✓ Branch 0 taken 110853487 times.
✓ Branch 1 taken 28617132 times.
166537947 for (const auto& localDof: localDofs(fvGeometry))
82 263627518 jacInvT_.mv(shapeJacobian_[localDof.index()][0], gradN_[localDof.index()]);
83 34724188 }
84
85 //! returns the global position for which this cache has been updated
86 2401752 const GlobalPosition& ipGlobal() const { return ipGlobal_; }
87 //! returns the shape function gradients in local coordinates at the integration point
88 const std::vector<ShapeJacobian>& shapeJacobian() const { return shapeJacobian_; }
89 //! returns the shape function values at the integration point
90
4/4
✓ Branch 0 taken 372755 times.
✓ Branch 1 taken 5579941 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 433789 times.
958385060 const std::vector<ShapeValue>& shapeValues() const { return shapeValues_; }
91 //! returns inverse transposed jacobian at the integration point
92 const JacobianInverseTransposed& jacInvT() const { return jacInvT_; }
93 //! returns the shape function gradients in global coordinates at the integration point
94
1/2
✓ Branch 1 taken 28800000 times.
✗ Branch 2 not taken.
5373361450 const GlobalPosition& gradN(unsigned int scvIdxInElement) const { return gradN_[scvIdxInElement]; }
95
96 private:
97 GlobalPosition ipGlobal_;
98 std::vector<GlobalPosition> gradN_;
99 std::vector<ShapeJacobian> shapeJacobian_;
100 std::vector<ShapeValue> shapeValues_;
101 JacobianInverseTransposed jacInvT_;
102 };
103
104 } // end namespace Dumux
105
106 #endif
107