GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/LinearOperator/LinearOperatorBase.hpp
Date: 2024-03-19 14:38:05
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 28 28 100.0%
Branches: 2 2 100.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_LINEAROPERATOR_LINEAROPERATORBASE_HPP_
12 #define BEMBEL_SRC_LINEAROPERATOR_LINEAROPERATORBASE_HPP_
13
14 namespace Bembel {
15 /**
16 * \ingroup LinearOperator
17 * \brief linear operator base class. this serves as a common interface for
18 * existing linear operators.
19 *
20 * Take a look at the [Design Considerations](\ref CRTPLinearOperator) for
21 * details.
22 **/
23 template <typename Derived>
24 struct LinearOperatorBase {
25 // Constructors
26 17 LinearOperatorBase() {}
27 // the user has to provide the implementation of this function, which
28 // is able to evaluate the integrand of the Galerkin formulation in a
29 // pair of quadrature points represented as a
30 // Surface point [xi; h * w; Chi(xi); dsChi(xi); dtChi(xi)]
31 template <class T>
32 100287940 void evaluateIntegrand(
33 const T &super_space, const SurfacePoint &p1, const SurfacePoint &p2,
34 Eigen::Matrix<typename LinearOperatorTraits<Derived>::Scalar,
35 Eigen::Dynamic, Eigen::Dynamic> *intval) const {
36 100287940 static_cast<const Derived *>(this)->evaluateIntegrand_impl(super_space, p1,
37 p2, intval);
38 100287940 return;
39 }
40 // the user has to provide the implementation of this function, which
41 // is able to evaluate the interpolation values of the Galerkin formulation on
42 // the reference domain in a pair of interpolation points represented as a
43 // Surface point [xi; 1.; Chi(xi); dsChi(xi); dtChi(xi)]
44 Eigen::Matrix<
45 typename LinearOperatorTraits<Derived>::Scalar,
46 getFunctionSpaceVectorDimension<LinearOperatorTraits<Derived>::Form>() *
47 LinearOperatorTraits<Derived>::NumberOfFMMComponents,
48 getFunctionSpaceVectorDimension<LinearOperatorTraits<Derived>::Form>() *
49 LinearOperatorTraits<Derived>::NumberOfFMMComponents>
50 6928416 evaluateFMMInterpolation(const SurfacePoint &p1,
51 const SurfacePoint &p2) const {
52 return static_cast<const Derived *>(this)->evaluateFMMInterpolation_impl(
53 6928416 p1, p2);
54 }
55 // return the required quadrature degree for the far-field
56 39027 int get_FarfieldQuadratureDegree(int ansatz_degree) const {
57 39027 return ansatz_degree - LinearOperatorTraits<Derived>::OperatorOrder + 1;
58 }
59 /**
60 * \brief Compute quadrature degree for numerical integretation close to the
61 * singularity based on distance, refinement level, degree of ansatz
62 * functions and operator_order.
63 *
64 * See also WAVELET GALERKIN SCHEMES FOR BOUNDARY INTEGRAL EQUATIONS -
65 * IMPLEMENTATION AND QUADRATURE by Helmut Harbrecht and Reinhold Schneider
66 * for more details.
67 **/
68 // return the required quadrature degree for the near-field
69 39012 int getNearfieldQuadratureDegree(int ansatz_degree, double distance,
70 int level) const {
71 // if farfield quadrature is computed: take log of distance
72 // otherwise compute quadrature degree for Duffy trick
73 39012 double distance_log =
74
2/2
✓ Branch 0 taken 13740 times.
✓ Branch 1 taken 25272 times.
39012 (distance * (1 << level) < 1) ? -(level * log(2.)) : log(distance);
75
76 // alpha/2 is the convergence rate of the corresponding Galerkin solution,
77 // this ensures the correct convergence rate of the potential
78 39012 int alpha =
79 39012 2 - LinearOperatorTraits<Derived>::OperatorOrder + 2 * ansatz_degree;
80
81 // compute numerator and denominator of quadrature degree
82 39012 double numerator =
83 39012 (alpha + ansatz_degree) * level * log(2.) -
84 39012 (2 - ansatz_degree + LinearOperatorTraits<Derived>::OperatorOrder) *
85 distance_log;
86 39012 double denominator = (level + 2) * log(2.) + distance_log;
87
88 39012 return 0.5 * numerator / denominator;
89 }
90 // pointer to the derived object
91 Derived &derived() { return *static_cast<Derived *>(this); }
92 // const pointer to the derived object
93 const Derived &derived() const { return *static_cast<const Derived *>(this); }
94 };
95 } // namespace Bembel
96 #endif // BEMBEL_SRC_LINEAROPERATOR_LINEAROPERATORBASE_HPP_
97