GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/AnsatzSpace/AnsatzSpace.hpp
Date: 2024-09-30 07:01:38
Exec Total Coverage
Lines: 32 33 97.0%
Functions: 70 70 100.0%
Branches: 8 16 50.0%

Line Branch Exec Source
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2024 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_ANSATZSPACE_ANSATZSPACE_HPP_
12 #define BEMBEL_SRC_ANSATZSPACE_ANSATZSPACE_HPP_
13
14 namespace Bembel {
15 /**
16 * \ingroup AnsatzSpace
17 * \brief The AnsatzSpace is the class that handles the assembly of the
18 *discrete basis.
19 *
20 * It invokes a SuperSpace and uses the Glue and Projector class to
21 *assemble a transformation matrix, which relates the SuperSpace to the desired
22 *basis.
23 */
24 template <typename Derived>
25 class AnsatzSpace {
26 public:
27 enum { Form = LinearOperatorTraits<Derived>::Form };
28 //////////////////////////////////////////////////////////////////////////////
29 // constructors
30 //////////////////////////////////////////////////////////////////////////////
31 /**
32 * \brief Default constructor
33 */
34 298 AnsatzSpace() {}
35 /**
36 * \brief Copy constructor
37 * \param other The object to copy from
38 */
39 298 AnsatzSpace(const AnsatzSpace &other) {
40 298 super_space_ = other.super_space_;
41 298 knot_repetition_ = other.knot_repetition_;
42
1/2
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
298 transformation_matrix_ = other.transformation_matrix_;
43 298 }
44 /**
45 * @brief Move constructor
46 * @param other The object to move from
47 */
48 AnsatzSpace(AnsatzSpace &&other) {
49 super_space_ = other.super_space_;
50 knot_repetition_ = other.knot_repetition_;
51 transformation_matrix_ = other.transformation_matrix_;
52 }
53 /**
54 * \brief Copy assignment operator.
55 *
56 * This operator assigns the contents of another AnsatzSpace object to this
57 * one.
58 *
59 * \param other The AnsatzSpace object to copy from.
60 * \return A reference to the updated AnsatzSpace object.
61 */
62 298 AnsatzSpace &operator=(AnsatzSpace other) {
63 298 super_space_ = other.super_space_;
64 298 knot_repetition_ = other.knot_repetition_;
65 298 transformation_matrix_ = other.transformation_matrix_;
66 298 return *this;
67 }
68 /**
69 * \brief Constructor for AnsatzSpace.
70 *
71 * This constructor initializes an AnsatzSpace object with the provided
72 * parameters.
73 *
74 * \param geometry The geometry object defining the space.
75 * \param refinement_level The refinement level of the space.
76 * \param polynomial_degree The degree of polynomials used in the space.
77 * \param knot_repetition (optional) The number of repetitions of knots in the
78 * space.
79 */
80 272 AnsatzSpace(const Geometry &geometry, int refinement_level,
81 272 int polynomial_degree, int knot_repetition = 1) {
82
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
272 init_AnsatzSpace(geometry, refinement_level, polynomial_degree,
83 knot_repetition);
84 272 return;
85 }
86 //////////////////////////////////////////////////////////////////////////////
87 // init_Ansatzspace
88 //////////////////////////////////////////////////////////////////////////////
89 /**
90 * \brief Initializes the AnsatzSpace object.
91 *
92 * This function initializes the AnsatzSpace object with the provided
93 * parameters. It sets the knot repetition, initializes the super space,
94 * utilizes the Projector and Glue class to create a transformation matrix
95 * which assembles conforming B-Splines from local Bernstein polynomials.
96 *
97 * \param geometry The geometry object.
98 * \param refinement_level The refinement level of the space.
99 * \param polynomial_degree The degree of polynomials used in the space.
100 * \param knot_repetition The number of repetitions of knots in the space.
101 */
102 272 void init_AnsatzSpace(const Geometry &geometry, int refinement_level,
103 int polynomial_degree, int knot_repetition) {
104 272 knot_repetition_ = knot_repetition;
105
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
272 super_space_.init_SuperSpace(geometry, refinement_level, polynomial_degree);
106
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
272 Projector<Derived> proj(super_space_, knot_repetition_);
107
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
272 Glue<Derived> glue(super_space_, proj);
108
1/2
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
272 transformation_matrix_ =
109
2/4
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
544 proj.get_projection_matrix() * glue.get_glue_matrix();
110 544 return;
111 272 }
112 //////////////////////////////////////////////////////////////////////////////
113 // getters
114 //////////////////////////////////////////////////////////////////////////////
115 /**
116 * \brief Retrieves the reference to the SuperSpace associated with this
117 * AnsatzSpace.
118 *
119 * \return A const reference to the SuperSpace.
120 */
121 1110285 const SuperSpace<Derived> &get_superspace() const { return super_space_; }
122
123 /**
124 * \brief Retrieves the knot repetition value of this AnsatzSpace.
125 *
126 * \return The knot repetition value.
127 */
128 int get_knot_repetition() const { return knot_repetition_; }
129
130 /**
131 * \brief Retrieves the refinement level of this AnsatzSpace.
132 *
133 * \return The refinement level.
134 */
135 7680 int get_refinement_level() const {
136 7680 return super_space_.get_refinement_level();
137 }
138
139 /**
140 * \brief Retrieves the polynomial degree of this AnsatzSpace.
141 *
142 * \return The polynomial degree.
143 */
144 287 int get_polynomial_degree() const {
145 287 return super_space_.get_polynomial_degree();
146 }
147
148 /**
149 * \brief Retrieves the number of elements of the underlying ElementTree in
150 * the SuperSpace of this AnsatzSpace.
151 *
152 * \return The number of elements.
153 */
154 int get_number_of_elements() const {
155 return super_space_.get_number_of_elements();
156 }
157
158 /**
159 * \brief Retrieves the number of patches of the underlying Geometry.
160 *
161 * \return The number of patches.
162 */
163 int get_number_of_patches() const {
164 return super_space_.get_number_of_patches();
165 }
166
167 /**
168 * \brief Retrieves the number of degrees of freedom of this AnsatzSpace.
169 *
170 * \return The number of degrees of freedom.
171 */
172 64 int get_number_of_dofs() const { return transformation_matrix_.cols(); }
173
174 /**
175 * \brief Retrieves the geometry associated with this AnsatzSpace.
176 *
177 * \return A const reference to the geometry.
178 */
179 const PatchVector &get_geometry() const {
180 return super_space_.get_geometry();
181 }
182
183 /**
184 * \brief Retrieves the transformation matrix associated with this
185 * AnsatzSpace.
186 *
187 * \return A const reference to the transformation matrix.
188 */
189 158 const Eigen::SparseMatrix<double> &get_transformation_matrix() const {
190 158 return transformation_matrix_;
191 }
192 //////////////////////////////////////////////////////////////////////////////
193 // private member variables
194 //////////////////////////////////////////////////////////////////////////////
195 private:
196 Eigen::SparseMatrix<double> transformation_matrix_;
197 SuperSpace<Derived> super_space_;
198 int knot_repetition_;
199 };
200 } // namespace Bembel
201 #endif // BEMBEL_SRC_ANSATZSPACE_ANSATZSPACE_HPP_
202