Bembel
 
Loading...
Searching...
No Matches
DiscreteLocalOperator.hpp
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_LINEAROPERATOR_DISCRETELOCALOPERATOR_HPP_
13#define BEMBEL_SRC_LINEAROPERATOR_DISCRETELOCALOPERATOR_HPP_
14
15namespace Bembel {
21template <typename Derived>
24 static void compute(
25 Eigen::SparseMatrix<typename LinearOperatorTraits<Derived>::Scalar>
26 *disc_op,
27 const Derived &lin_op, const AnsatzSpace<Derived> &ansatz_space) {
28 // Extract numbers
29 const auto &super_space = ansatz_space.get_superspace();
30 const auto &element_tree = super_space.get_mesh().get_element_tree();
31 const auto &number_of_elements = element_tree.get_number_of_elements();
32 const auto vector_dimension =
34 const auto polynomial_degree = super_space.get_polynomial_degree();
35 const auto polynomial_degree_plus_one_squared =
36 (polynomial_degree + 1) * (polynomial_degree + 1);
37
38 // Quadrature
40 auto ffield_deg = lin_op.get_FarfieldQuadratureDegree(polynomial_degree);
41 auto Q = GS[ffield_deg];
42
43 // Triplets
44 typedef Eigen::Triplet<typename LinearOperatorTraits<Derived>::Scalar> T;
45 std::vector<T> tripletList;
46 tripletList.reserve(polynomial_degree_plus_one_squared *
47 polynomial_degree_plus_one_squared *
49
50 // Iterate over elements
51 for (auto element = element_tree.cpbegin(); element != element_tree.cpend();
52 ++element) {
53 Eigen::Matrix<typename LinearOperatorTraits<Derived>::Scalar,
54 Eigen::Dynamic, Eigen::Dynamic>
55 intval(vector_dimension * polynomial_degree_plus_one_squared,
56 vector_dimension * polynomial_degree_plus_one_squared);
57 intval.setZero();
58 // Iterate over quadrature points
59 for (auto i = 0; i < Q.w_.size(); ++i) {
61 super_space.map2surface(*element, Q.xi_.col(i), Q.w_(i), &qp);
62 lin_op.evaluateIntegrand(super_space, qp, qp, &intval);
63 }
64 // Transform local element matrices to triplets
65 for (auto i = 0; i < vector_dimension; ++i)
66 for (auto j = 0; j < vector_dimension; ++j)
67 for (auto ii = 0; ii < polynomial_degree_plus_one_squared; ++ii)
68 for (auto jj = 0; jj < polynomial_degree_plus_one_squared; ++jj)
69 tripletList.push_back(
70 T(polynomial_degree_plus_one_squared *
71 (j * number_of_elements + element->id_) +
72 jj,
73 polynomial_degree_plus_one_squared *
74 (i * number_of_elements + element->id_) +
75 ii,
76 intval(j * polynomial_degree_plus_one_squared + jj,
77 i * polynomial_degree_plus_one_squared + ii)));
78 }
79 disc_op->resize(vector_dimension * polynomial_degree_plus_one_squared *
81 vector_dimension * polynomial_degree_plus_one_squared *
83 disc_op->setFromTriplets(tripletList.begin(), tripletList.end());
84 const auto &projector = ansatz_space.get_transformation_matrix();
85 disc_op[0] = projector.transpose() * (disc_op[0] * projector);
86 return;
87 }
88};
89
96template <typename Derived>
98 Eigen::SparseMatrix<typename LinearOperatorTraits<Derived>::Scalar>,
99 Derived>;
100
105template <typename Derived>
107 Eigen::SparseMatrix<typename LinearOperatorTraits<Derived>::Scalar>,
108 Derived> {
110 static void compute(
111 Eigen::SparseMatrix<typename LinearOperatorTraits<Derived>::Scalar>
112 *disc_op,
113 const Derived &lin_op, const AnsatzSpace<Derived> &ansatz_space) {
116 return;
117 }
118};
119
120} // namespace Bembel
121#endif // BEMBEL_SRC_LINEAROPERATOR_DISCRETELOCALOPERATOR_HPP_
The AnsatzSpace is the class that handles the assembly of the discrete basis.
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceOutputDimension()
Helper struct which mimics the DiscreteOperatorComputer struct to assemble sparse matrices of local o...
Helper struct that is used in order to partially specialise the compute routine of DiscreteOperator f...
struct containing specifications on the linear operator has to be specialized or derived for any part...