GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/LinearForm/TangentialTrace.hpp
Date: 2024-03-19 14:38:05
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 3 3 100.0%
Branches: 28 56 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_TANGENTIALTRACE_HPP_
12 #define BEMBEL_SRC_LINEARFORM_TANGENTIALTRACE_HPP_
13
14 namespace Bembel {
15
16 template <typename Scalar>
17 class TangentialTrace;
18
19 template <typename ScalarT>
20 struct LinearFormTraits<TangentialTrace<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 TangentialTrace : public LinearFormBase<TangentialTrace<Scalar>, Scalar> {
31 public:
32 1 TangentialTrace() {}
33 1 void set_function(
34 const std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)>
35 &function) {
36 1 function_ = function;
37 1 }
38 template <class T>
39 9 void evaluateIntegrand_impl(
40 const T &super_space, const SurfacePoint &p,
41 Eigen::Matrix<Scalar, Eigen::Dynamic, 2> *intval) const {
42 9 int polynomial_degree = super_space.get_polynomial_degree();
43 9 int polynomial_degree_plus_one_squared =
44 9 (polynomial_degree + 1) * (polynomial_degree + 1);
45
46 // get evaluation points on unit square
47
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Vector2d s = p.segment<2>(0);
48
49 // get quadrature weights
50
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 double ws = p(2);
51
52 // get points on geometry and tangential derivatives
53
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Vector3d x_f = p.segment<3>(3);
54
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Vector3d x_f_dx = p.segment<3>(6);
55
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Vector3d x_f_dy = p.segment<3>(9);
56
57 // compute surface measures from tangential derivatives
58
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Vector3d x_n = x_f_dx.cross(x_f_dy).normalized();
59
60 // tangential component + quadrature weights
61
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Matrix<Scalar, 3, 1> fun_x_f = function_(x_f);
62
3/6
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
9 Eigen::Matrix<Scalar, 3, 1> tangential_component = fun_x_f.cross(x_n) * ws;
63
64 // extract tangential component
65
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 Scalar component_x = x_f_dx.dot(tangential_component);
66
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 Scalar component_y = x_f_dy.dot(tangential_component);
67
68 // evaluate shape functions
69
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> phiPhiVec =
70 super_space.basis(s);
71
72 // multiply basis functions with integrand
73 9 Eigen::Matrix<Scalar, Eigen::Dynamic, 2> phiPhiMat(
74
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 polynomial_degree_plus_one_squared, 2);
75
3/6
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
9 phiPhiMat.col(0) = component_x * phiPhiVec;
76
3/6
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
9 phiPhiMat.col(1) = component_y * phiPhiVec;
77
78 // compute integrals
79
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 (*intval) += phiPhiMat;
80 18 return;
81 9 }
82
83 private:
84 std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)> function_;
85 };
86 } // namespace Bembel
87
88 #endif // BEMBEL_SRC_LINEARFORM_TANGENTIALTRACE_HPP_
89