GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/ClusterTree/ClusterTree.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 7 7 100.0%
Branches: 24 40 60.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_CLUSTERTREE_CLUSTERTREE_HPP_
12 #define BEMBEL_SRC_CLUSTERTREE_CLUSTERTREE_HPP_
13
14 namespace Bembel {
15
16 /**
17 * \ingroup ClusterTree
18 * \brief The ClusterTree class introduces an element structure on a Geometry
19 * object. Note that we do not introduce a mesh in the classical sense, but only
20 * introduce a system of local coordinates via an ElementTree.
21 */
22 class ClusterTree {
23 public:
24 /**
25 * \brief Copy constructor (deleted).
26 *
27 * \param other The ClusterTree instance to copy from.
28 */
29 ClusterTree(const ClusterTree& other) = delete;
30
31 /**
32 * \brief Move constructor (deleted).
33 *
34 * \param other The ClusterTree instance to move from.
35 */
36 ClusterTree(ClusterTree&& other) = delete;
37
38 /**
39 * \brief Copy assignment operator (deleted).
40 *
41 * \param other The ClusterTree instance to copy from.
42 * \return Reference to this ClusterTree instance.
43 */
44 ClusterTree& operator=(const ClusterTree& other) = delete;
45
46 /**
47 * \brief Move assignment operator (deleted).
48 *
49 * \param other The ClusterTree instance to move from.
50 * \return Reference to this ClusterTree instance.
51 */
52 ClusterTree& operator=(ClusterTree&& other) = delete;
53 //////////////////////////////////////////////////////////////////////////////
54 /// constructors
55 //////////////////////////////////////////////////////////////////////////////
56 /**
57 * \brief Default constructor.
58 */
59
1/2
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 ClusterTree() {}
60 /**
61 * \brief Constructs a ClusterTree object for a given refinement level.
62 *
63 * Initializes a new instance of the ClusterTree class with the given geometry
64 * and refinement level.
65 *
66 * \param geom The geometry object to construct a cluster tree on.
67 * \param M refinement level of the ElementTree.
68 */
69 ClusterTree(const Geometry& geom, int M) { init_ClusterTree(geom, M); }
70 //////////////////////////////////////////////////////////////////////////////
71 /// init
72 //////////////////////////////////////////////////////////////////////////////
73 /**
74 * \brief Initializes a ClusterTree object for a given refinement level.
75 *
76 * This function initializes the ElementTree for an uniform refinement level.
77 * After that the point list is filled.
78 *
79 * \param geom The geometry object to construct a cluster tree on.
80 * \param M refinement level of the ElementTree.
81 */
82 168 void init_ClusterTree(const Geometry& geom, int M) {
83 168 element_tree_.init_ElementTree(geom, M);
84 168 points_ = element_tree_.computeElementEnclosings();
85 168 return;
86 }
87 //////////////////////////////////////////////////////////////////////////////
88 /// getter
89 //////////////////////////////////////////////////////////////////////////////
90 /**
91 * \brief Return reference to the ElementTree.
92 *
93 * \return Reference to the ElementTree.
94 */
95 ElementTree& get_element_tree() { return element_tree_; }
96 /**
97 * \brief Return const reference to the ElementTree.
98 *
99 * \return Const Reference to the ElementTree.
100 */
101 30311 const ElementTree& get_element_tree() const { return element_tree_; }
102 /**
103 * \brief Return point list with coordinates.
104 *
105 * \return 3xN matrix with N number of points in the ElementTree.
106 */
107 const Eigen::MatrixXd& get_points() const { return points_; }
108 /**
109 * \brief Return const reference to the Geometry.
110 *
111 * \return Const Reference to the PatchVector.
112 */
113 99825301 const PatchVector& get_geometry() const {
114 99825301 return element_tree_.get_geometry();
115 }
116 /**
117 * \brief Return maximum level of refinement.
118 *
119 * \return Level of refinement.
120 */
121 2567937 int get_max_level() const { return element_tree_.get_max_level(); }
122 /**
123 * \brief Return number of elements in the ElementTree.
124 *
125 * \return Number of elements.
126 */
127 9 int get_number_of_elements() const {
128 9 return element_tree_.get_number_of_elements();
129 }
130 //////////////////////////////////////////////////////////////////////////////
131 /// member functions
132 //////////////////////////////////////////////////////////////////////////////
133 /**
134 * \brief Check all patches at the mid points of the edges if the
135 * parametrization and normal vector match.
136 */
137 168 void checkOrientation() {
138
1/2
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
168 std::vector<std::array<int, 4>> edges = element_tree_.patchTopologyInfo();
139 std::vector<Eigen::Vector2d> edge_midpoints = {
140 Eigen::Vector2d(Constants::edgemps[0][0], Constants::edgemps[1][0]), //
141 Eigen::Vector2d(Constants::edgemps[0][1], Constants::edgemps[1][1]), //
142 Eigen::Vector2d(Constants::edgemps[0][2], Constants::edgemps[1][2]), //
143 Eigen::Vector2d(Constants::edgemps[0][3], Constants::edgemps[1][3]) //
144
5/10
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 168 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 168 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 168 times.
✗ Branch 15 not taken.
168 };
145 168 const PatchVector& geo = element_tree_.get_geometry();
146
2/2
✓ Branch 5 taken 2280 times.
✓ Branch 6 taken 168 times.
2448 for (auto edge : edges) {
147
6/6
✓ Branch 1 taken 1717 times.
✓ Branch 2 taken 563 times.
✓ Branch 4 taken 342 times.
✓ Branch 5 taken 1375 times.
✓ Branch 6 taken 342 times.
✓ Branch 7 taken 1938 times.
2280 if (edge[2] > 0 && edge[3] > 0) {
148
1/2
✓ Branch 5 taken 342 times.
✗ Branch 6 not taken.
342 Eigen::Vector3d a = geo[edge[0]].eval(edge_midpoints[edge[2]]);
149
1/2
✓ Branch 5 taken 342 times.
✗ Branch 6 not taken.
342 Eigen::Vector3d b = geo[edge[1]].eval(edge_midpoints[edge[3]]);
150
1/2
✓ Branch 5 taken 342 times.
✗ Branch 6 not taken.
342 Eigen::Vector3d na = geo[edge[0]].evalNormal(edge_midpoints[edge[2]]);
151
1/2
✓ Branch 5 taken 342 times.
✗ Branch 6 not taken.
342 Eigen::Vector3d nb = geo[edge[1]].evalNormal(edge_midpoints[edge[3]]);
152
3/6
✓ Branch 1 taken 342 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 342 times.
✗ Branch 7 not taken.
342 assert((a - b).norm() < Constants::pt_comp_tolerance &&
153 "These points should coincide according to the element tree");
154
2/4
✓ Branch 1 taken 342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 342 times.
✗ Branch 4 not taken.
342 assert(a.dot(b) > 0 &&
155 "Normals across patches are oriented the same way");
156 }
157 }
158 336 return;
159 168 }
160 //////////////////////////////////////////////////////////////////////////////
161 /// private members
162 //////////////////////////////////////////////////////////////////////////////
163 private:
164 ElementTree element_tree_;
165 Eigen::MatrixXd points_;
166 //////////////////////////////////////////////////////////////////////////////
167 };
168 } // namespace Bembel
169 #endif // BEMBEL_SRC_CLUSTERTREE_CLUSTERTREE_HPP_
170