GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/facetensoraverage.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 15 16 93.8%
Functions: 2 5 40.0%
Branches: 36 38 94.7%

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 Flux
10 * \brief A free function to average a Tensor at an interface.
11 */
12 #ifndef DUMUX_FACE_TENSOR_AVERAGE_HH
13 #define DUMUX_FACE_TENSOR_AVERAGE_HH
14
15 #include <dune/common/fmatrix.hh>
16 #include <dumux/common/math.hh>
17
18 namespace Dumux {
19
20 /*!
21 * \brief Average of a discontinuous scalar field at discontinuity interface
22 * (for compatibility reasons with the function below)
23 * \return the harmonic average of the scalars
24 * \param T1 first scalar parameter
25 * \param T2 second scalar parameter
26 * \param normal The unit normal vector of the interface
27 */
28 template <class Scalar, int dim>
29 Scalar faceTensorAverage(const Scalar T1,
30 const Scalar T2,
31 const Dune::FieldVector<Scalar, dim>& normal)
32
17/18
✓ Branch 0 taken 134430376 times.
✓ Branch 1 taken 2020000 times.
✓ Branch 2 taken 256261076 times.
✓ Branch 3 taken 112696 times.
✓ Branch 4 taken 126787900 times.
✓ Branch 5 taken 236313396 times.
✓ Branch 6 taken 271546032 times.
✓ Branch 7 taken 123248010 times.
✓ Branch 8 taken 4223260 times.
✓ Branch 9 taken 269906046 times.
✓ Branch 10 taken 4287832 times.
✓ Branch 11 taken 2689918 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 4247824 times.
✓ Branch 14 taken 10976 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 10974 times.
1596013356 { return Dumux::harmonicMean(T1, T2); }
33
34 /*!
35 * \brief Average of a discontinuous tensorial field at discontinuity interface
36 * \note We do a harmonic average of the part normal to the interface (alpha*I) and
37 * an arithmetic average of the tangential part (T - alpha*I).
38 * \return the averaged tensor
39 * \param T1 first tensor
40 * \param T2 second tensor
41 * \param normal The unit normal vector of the interface
42 */
43 template <class Scalar, int dim>
44 11490912 Dune::FieldMatrix<Scalar, dim> faceTensorAverage(const Dune::FieldMatrix<Scalar, dim>& T1,
45 const Dune::FieldMatrix<Scalar, dim>& T2,
46 const Dune::FieldVector<Scalar, dim>& normal)
47 {
48 // determine nT*k*n
49 11490912 Dune::FieldVector<Scalar, dim> tmp;
50 11490912 Dune::FieldVector<Scalar, dim> tmp2;
51 11490912 T1.mv(normal, tmp);
52 T2.mv(normal, tmp2);
53 const Scalar alpha1 = tmp*normal;
54 11490912 const Scalar alpha2 = tmp2*normal;
55
56
1/2
✓ Branch 0 taken 11490912 times.
✗ Branch 1 not taken.
11490912 const Scalar alphaHarmonic = Dumux::harmonicMean(alpha1, alpha2);
57 11490912 const Scalar alphaAverage = 0.5*(alpha1 + alpha2);
58
59 11490912 Dune::FieldMatrix<Scalar, dim> T(0.0);
60
2/2
✓ Branch 0 taken 14523024 times.
✓ Branch 1 taken 11490912 times.
26013936 for (int i = 0; i < dim; ++i)
61 {
62
2/2
✓ Branch 0 taken 20587248 times.
✓ Branch 1 taken 14523024 times.
35110272 for (int j = 0; j < dim; ++j)
63 {
64
12/12
✓ Branch 0 taken 6064224 times.
✓ Branch 1 taken 6064224 times.
✓ Branch 2 taken 6064224 times.
✓ Branch 3 taken 6064224 times.
✓ Branch 4 taken 6064224 times.
✓ Branch 5 taken 6064224 times.
✓ Branch 6 taken 6064224 times.
✓ Branch 7 taken 6064224 times.
✓ Branch 8 taken 6064224 times.
✓ Branch 9 taken 6064224 times.
✓ Branch 10 taken 6064224 times.
✓ Branch 11 taken 6064224 times.
98147088 T[i][j] += 0.5*(T1[i][j] + T2[i][j]);
65
2/2
✓ Branch 0 taken 6064224 times.
✓ Branch 1 taken 6064224 times.
12128448 if (i == j)
66 35110272 T[i][j] += alphaHarmonic - alphaAverage;
67 }
68 }
69
70 11490912 return T;
71 }
72
73 } // end namespace Dumux
74
75 #endif
76