GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/LinearForm/RotatedTangentialTrace.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 3 3 100.0%
Branches: 25 50 50.0%

Line Branch Exec Source
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2022 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11 #ifndef BEMBEL_SRC_LINEARFORM_ROTATEDTANGENTIALTRACE_HPP_
12 #define BEMBEL_SRC_LINEARFORM_ROTATEDTANGENTIALTRACE_HPP_
13
14 namespace Bembel {
15
16 template <typename Scalar>
17 class RotatedTangentialTrace;
18
19 template <typename ScalarT>
20 struct LinearFormTraits<RotatedTangentialTrace<ScalarT>> {
21 typedef ScalarT Scalar;
22 };
23
24 /**
25 * \ingroup LinearForm
26 * \brief This class provides a specialization of the linear form required
27 *for the solution of the electric field integral equation.
28 **/
29 template <typename Scalar>
30 class RotatedTangentialTrace
31 : public LinearFormBase<RotatedTangentialTrace<Scalar>, Scalar> {
32 public:
33 2 RotatedTangentialTrace() {}
34 2 void set_function(
35 const std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)>
36 &function) {
37 2 function_ = function;
38 2 }
39 template <class T>
40 918 void evaluateIntegrand_impl(
41 const T &super_space, const SurfacePoint &p,
42 Eigen::Matrix<Scalar, Eigen::Dynamic, 2> *intval) const {
43 918 auto polynomial_degree = super_space.get_polynomial_degree();
44 918 auto polynomial_degree_plus_one_squared =
45 918 (polynomial_degree + 1) * (polynomial_degree + 1);
46
47 // get evaluation points on unit square
48
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto s = p.segment<2>(0);
49
50 // get quadrature weights
51
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto ws = p(2);
52
53 // get points on geometry and tangential derivatives
54
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto x_f = p.segment<3>(3);
55
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto x_f_dx = p.segment<3>(6);
56
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto x_f_dy = p.segment<3>(9);
57
58 // compute surface measures from tangential derivatives
59
2/4
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
918 auto x_n = x_f_dx.cross(x_f_dy).normalized();
60
61 // tangential component + quadrature weights
62 // use n x f x n = f-<f,n>n to avoid troubles with -flto flag in combination
63 // of .cross()
64
2/4
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
918 auto fun_x_f = function_(x_f);
65
4/8
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 918 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 918 times.
✗ Branch 11 not taken.
918 auto tangential_component = (fun_x_f - fun_x_f.dot(x_n) * x_n) * ws;
66
67 // extract tangential component
68
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto component_x = x_f_dx.dot(tangential_component);
69
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 auto component_y = x_f_dy.dot(tangential_component);
70
71 // evaluate shape functions
72
2/4
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
918 auto phiPhiVec = super_space.basis(s);
73
74 // multiply basis functions with integrand
75 918 Eigen::Matrix<Scalar, Eigen::Dynamic, 2> phiPhiMat(
76
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 polynomial_degree_plus_one_squared, 2);
77
3/6
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 918 times.
✗ Branch 8 not taken.
918 phiPhiMat.col(0) = component_x * phiPhiVec;
78
3/6
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 918 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 918 times.
✗ Branch 8 not taken.
918 phiPhiMat.col(1) = component_y * phiPhiVec;
79
80 // compute integrals
81
1/2
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
918 (*intval) += phiPhiMat;
82 1836 return;
83 918 }
84
85 private:
86 std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)> function_;
87 };
88 } // namespace Bembel
89
90 #endif // BEMBEL_SRC_LINEARFORM_ROTATEDTANGENTIALTRACE_HPP_
91