GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cvfe/fluxvariablescache.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 124 125 99.2%
Branches: 19 30 63.3%

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 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
17 namespace Dumux {
18
19 /*!
20 * \ingroup CVFEDiscretization
21 * \brief Flux variables cache class for control-volume finite element schemes.
22 * For control-volume finite element schemes, this class does not contain any physics-/process-dependent
23 * data. It solely stores disretization-/grid-related data.
24 */
25 template< class Scalar, class GridGeometry >
26 166395060 class CVFEFluxVariablesCache
27 {
28 using GridView = typename GridGeometry::GridView;
29 using Element = typename GridView::template Codim<0>::Entity;
30 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
31
32 using FVElementGeometry = typename GridGeometry::LocalView;
33 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
34
35 static const int dim = GridView::dimension;
36 static const int dimWorld = GridView::dimensionworld;
37
38 using CoordScalar = typename GridView::ctype;
39 using FeLocalBasis = typename GridGeometry::FeCache::FiniteElementType::Traits::LocalBasisType;
40 using ShapeJacobian = typename FeLocalBasis::Traits::JacobianType;
41 using ShapeValue = typename Dune::FieldVector<Scalar, 1>;
42 using JacobianInverseTransposed = typename Element::Geometry::JacobianInverseTransposed;
43
44 public:
45 //! whether the cache needs an update when the solution changes
46 static bool constexpr isSolDependent = false;
47
48 //! update the cache for an scvf
49 template< class Problem, class ElementVolumeVariables >
50 void update(const Problem& problem,
51 const Element& element,
52 const FVElementGeometry& fvGeometry,
53 const ElementVolumeVariables& elemVolVars,
54 const SubControlVolumeFace& scvf)
55 {
56
4/8
✓ Branch 1 taken 158208 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 158208 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 53640 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 53640 times.
✗ Branch 11 not taken.
56322470 update(problem, element, fvGeometry, elemVolVars, scvf.ipGlobal());
57 }
58
59 //! update the cache for a given global position
60 template< class Problem, class ElementVolumeVariables >
61 34005231 void update(const Problem& problem,
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const GlobalPosition& globalPos)
66 {
67 54395135 const auto geometry = element.geometry();
68
1/2
✓ Branch 1 taken 15383270 times.
✗ Branch 2 not taken.
34005231 const auto& localBasis = fvGeometry.feLocalBasis();
69
70 // evaluate shape functions and gradients at the integration point
71 34005231 ipGlobal_ = globalPos;
72 34005231 const auto ipLocal = geometry.local(ipGlobal_);
73 34005231 jacInvT_ = geometry.jacobianInverseTransposed(ipLocal);
74
1/2
✓ Branch 1 taken 15383270 times.
✗ Branch 2 not taken.
34005231 localBasis.evaluateJacobian(ipLocal, shapeJacobian_);
75
1/2
✓ Branch 1 taken 15383270 times.
✗ Branch 2 not taken.
34005231 localBasis.evaluateFunction(ipLocal, shapeValues_); // shape values for rho
76
77 // compute the gradN at for every scv/dof
78
2/4
✓ Branch 1 taken 15383270 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15383270 times.
✗ Branch 5 not taken.
68010462 gradN_.resize(fvGeometry.numScv());
79
4/4
✓ Branch 0 taken 109202892 times.
✓ Branch 1 taken 28161435 times.
✓ Branch 2 taken 109202892 times.
✓ Branch 3 taken 28161435 times.
326407126 for (const auto& scv: scvs(fvGeometry))
80 645991660 jacInvT_.mv(shapeJacobian_[scv.localDofIndex()][0], gradN_[scv.indexInElement()]);
81 34005231 }
82
83 //! returns the global position for which this cache has been updated
84 2401752 const GlobalPosition& ipGlobal() const { return ipGlobal_; }
85 //! returns the shape function gradients in local coordinates at the integration point
86 const std::vector<ShapeJacobian>& shapeJacobian() const { return shapeJacobian_; }
87 //! returns the shape function values at the integration point
88
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 7581024 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 61055 times.
957183220 const std::vector<ShapeValue>& shapeValues() const { return shapeValues_; }
89 //! returns inverse transposed jacobian at the integration point
90 const JacobianInverseTransposed& jacInvT() const { return jacInvT_; }
91 //! returns the shape function gradients in global coordinates at the integration point
92
2/4
✓ Branch 2 taken 28800000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28800000 times.
✗ Branch 5 not taken.
10568858260 const GlobalPosition& gradN(unsigned int scvIdxInElement) const { return gradN_[scvIdxInElement]; }
93
94 private:
95 GlobalPosition ipGlobal_;
96 std::vector<GlobalPosition> gradN_;
97 std::vector<ShapeJacobian> shapeJacobian_;
98 std::vector<ShapeValue> shapeValues_;
99 JacobianInverseTransposed jacInvT_;
100 };
101
102 } // end namespace Dumux
103
104 #endif
105