GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/util/surfaceL2error.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 22 22 100.0%
Functions: 2 2 100.0%
Branches: 27 50 54.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
12 #ifndef BEMBEL_SRC_UTIL_SURFACEL2ERROR_HPP_
13 #define BEMBEL_SRC_UTIL_SURFACEL2ERROR_HPP_
14
15 namespace Bembel {
16
17 template <typename Op, typename Derived, typename Functor>
18 2 double surfaceL2error(const AnsatzSpace<Op> &ansatz_space,
19 const Eigen::MatrixBase<Derived> &vec,
20 const Functor &functor, int deg = 4) {
21 typedef typename Derived::Scalar Scalar;
22
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 FunctionEvaluator<Op> fun_val(ansatz_space);
23
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 fun_val.set_function(vec);
24 2 Scalar retval = 0;
25
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 GaussSquare<Constants::maximum_quadrature_degree> GS;
26
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 auto Q = GS[deg];
27
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 SurfacePoint qp;
28 2 const auto &super_space = ansatz_space.get_superspace();
29 2 const ElementTree &et = super_space.get_mesh().get_element_tree();
30
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 2 times.
14 for (auto element = et.cpbegin(); element != et.cpend(); ++element) {
31
2/2
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 12 times.
312 for (auto i = 0; i < Q.w_.size(); ++i) {
32
4/8
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 300 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 300 times.
✗ Branch 12 not taken.
300 super_space.map2surface(*element, Q.xi_.col(i), Q.w_(i), &qp);
33 // get points on geometry and tangential derivatives
34
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 const auto &x_f = qp.segment<3>(3);
35
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 const auto &x_f_dx = qp.segment<3>(6);
36
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 const auto &x_f_dy = qp.segment<3>(9);
37
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 const auto &normal = x_f_dx.cross(x_f_dy);
38 // compute surface measures from tangential derivatives
39
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 Scalar x_kappa = normal.norm();
40
2/4
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 300 times.
✗ Branch 6 not taken.
300 const Scalar val = fun_val.evaluate(*element, qp)(0);
41
1/2
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
300 retval += x_kappa * Q.w_(i) * element->get_h() * element->get_h() *
42
4/8
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 300 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
300 (functor(x_f) - val) * (functor(x_f) - val);
43 }
44 }
45 4 return sqrt(retval);
46 2 }
47
48 } // namespace Bembel
49 #endif // BEMBEL_SRC_UTIL_SURFACEL2ERROR_HPP_
50