GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/LinearForm/DiscreteLinearForm.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 35 35 100.0%
Branches: 29 54 53.7%

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_DISCRETELINEARFORM_HPP_
12 #define BEMBEL_SRC_LINEARFORM_DISCRETELINEARFORM_HPP_
13
14 namespace Bembel {
15 /**
16 * \ingroup LinearForm
17 * \brief This class, given a LinearForm with defined traits, takes care of the
18 * assembly of the right hand side.
19 */
20 template <typename Derived, typename LinOp>
21 class DiscreteLinearForm {
22 public:
23 //////////////////////////////////////////////////////////////////////////////
24 // constructors
25 //////////////////////////////////////////////////////////////////////////////
26 DiscreteLinearForm() {}
27
2/4
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
10 explicit DiscreteLinearForm(const AnsatzSpace<LinOp> &ansatz_space) {
28
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 init_DiscreteLinearForm(ansatz_space);
29 10 }
30 //////////////////////////////////////////////////////////////////////////////
31 // init_DiscreteLinearForm
32 //////////////////////////////////////////////////////////////////////////////
33 10 void init_DiscreteLinearForm(const AnsatzSpace<LinOp> &ansatz_space) {
34
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 ansatz_space_ = ansatz_space;
35 10 deg_ = ansatz_space_.get_polynomial_degree() + 1;
36 10 return;
37 }
38 //////////////////////////////////////////////////////////////////////////////
39 // compute
40 //////////////////////////////////////////////////////////////////////////////
41 /**
42 * \todo Add inline commentary
43 **/
44 10 void compute() {
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 GaussSquare<Constants::maximum_quadrature_degree> GS;
46
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 auto Q = GS[deg_];
47
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 SurfacePoint qp;
48 10 auto super_space = ansatz_space_.get_superspace();
49 10 const ElementTree &element_tree = super_space.get_mesh().get_element_tree();
50 10 auto number_of_elements = element_tree.get_number_of_elements();
51 10 auto polynomial_degree = super_space.get_polynomial_degree();
52 10 auto polynomial_degree_plus_one_squared =
53 10 (polynomial_degree + 1) * (polynomial_degree + 1);
54 10 const auto function_space_dimension =
55 getFunctionSpaceVectorDimension<LinearOperatorTraits<LinOp>::Form>();
56 Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar, Eigen::Dynamic,
57 function_space_dimension>
58
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 intval(polynomial_degree_plus_one_squared, function_space_dimension);
59 Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar, Eigen::Dynamic,
60 function_space_dimension>
61
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 disc_lf_matrix(polynomial_degree_plus_one_squared * number_of_elements,
62 function_space_dimension);
63
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 disc_lf_matrix.setZero();
64
2/2
✓ Branch 3 taken 433 times.
✓ Branch 4 taken 10 times.
443 for (auto element = element_tree.cpbegin(); element != element_tree.cpend();
65 433 ++element) {
66
1/2
✓ Branch 1 taken 433 times.
✗ Branch 2 not taken.
433 intval.setZero();
67
2/2
✓ Branch 1 taken 2337 times.
✓ Branch 2 taken 433 times.
2770 for (auto i = 0; i < Q.w_.size(); ++i) {
68
2/4
✓ Branch 1 taken 2337 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2337 times.
✗ Branch 6 not taken.
2337 super_space.map2surface(*element, Q.xi_.col(i),
69
2/4
✓ Branch 3 taken 2337 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2337 times.
✗ Branch 7 not taken.
2337 element->get_h() * Q.w_(i), &qp);
70
1/2
✓ Branch 1 taken 2337 times.
✗ Branch 2 not taken.
2337 lf_.evaluateIntegrand_impl(super_space, qp, &intval);
71 }
72
1/2
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
866 disc_lf_matrix.block(polynomial_degree_plus_one_squared * element->id_, 0,
73 polynomial_degree_plus_one_squared,
74
1/2
✓ Branch 1 taken 433 times.
✗ Branch 2 not taken.
433 function_space_dimension) = intval;
75 }
76
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 disc_lf_ =
77
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 ansatz_space_.get_transformation_matrix().transpose() *
78
3/6
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 Eigen::Map<Eigen::Matrix<typename LinearOperatorTraits<LinOp>::Scalar,
79 Eigen::Dynamic, 1>>(
80 disc_lf_matrix.data(),
81 10 disc_lf_matrix.rows() * disc_lf_matrix.cols());
82 20 return;
83 10 }
84 //////////////////////////////////////////////////////////////////////////////
85 // setter
86 //////////////////////////////////////////////////////////////////////////////
87 void set_degree(const int &deg) { deg_ = deg; }
88 //////////////////////////////////////////////////////////////////////////////
89 // getter
90 //////////////////////////////////////////////////////////////////////////////
91 10 Derived &get_linear_form() { return lf_; }
92 const Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar,
93 Eigen::Dynamic, 1>
94 11 &get_discrete_linear_form() const {
95 11 return disc_lf_;
96 }
97 //////////////////////////////////////////////////////////////////////////////
98 // private member variables
99 //////////////////////////////////////////////////////////////////////////////
100 private:
101 int deg_;
102 Derived lf_;
103 Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar, Eigen::Dynamic, 1>
104 disc_lf_;
105 AnsatzSpace<LinOp> ansatz_space_;
106 };
107
108 } // namespace Bembel
109 #endif // BEMBEL_SRC_LINEARFORM_DISCRETELINEARFORM_HPP_
110