Bembel
 
Loading...
Searching...
No Matches
DiscreteLinearForm.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#ifndef BEMBEL_SRC_LINEARFORM_DISCRETELINEARFORM_HPP_
12#define BEMBEL_SRC_LINEARFORM_DISCRETELINEARFORM_HPP_
13
14namespace Bembel {
20template <typename Derived, typename LinOp>
22 public:
24 // constructors
28 init_DiscreteLinearForm(ansatz_space);
29 }
31 // init_DiscreteLinearForm
33 void init_DiscreteLinearForm(const AnsatzSpace<LinOp> &ansatz_space) {
34 ansatz_space_ = ansatz_space;
35 deg_ = ansatz_space_.get_polynomial_degree() + 1;
36 return;
37 }
39 // compute
41
44 void compute() {
46 auto Q = GS[deg_];
48 auto super_space = ansatz_space_.get_superspace();
49 const ElementTree &element_tree = super_space.get_mesh().get_element_tree();
51 auto polynomial_degree = super_space.get_polynomial_degree();
52 auto polynomial_degree_plus_one_squared =
53 (polynomial_degree + 1) * (polynomial_degree + 1);
54 const auto function_space_dimension =
56 Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar, Eigen::Dynamic,
58 intval(polynomial_degree_plus_one_squared, function_space_dimension);
59 Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar, Eigen::Dynamic,
61 disc_lf_matrix(polynomial_degree_plus_one_squared * number_of_elements,
63 disc_lf_matrix.setZero();
64 for (auto element = element_tree.cpbegin(); element != element_tree.cpend();
65 ++element) {
66 intval.setZero();
67 for (auto i = 0; i < Q.w_.size(); ++i) {
68 super_space.map2surface(*element, Q.xi_.col(i),
69 element->get_h() * Q.w_(i), &qp);
70 lf_.evaluateIntegrand_impl(super_space, qp, &intval);
71 }
72 disc_lf_matrix.block(polynomial_degree_plus_one_squared * element->id_, 0,
73 polynomial_degree_plus_one_squared,
75 }
76 disc_lf_ =
77 ansatz_space_.get_transformation_matrix().transpose() *
78 Eigen::Map<Eigen::Matrix<typename LinearOperatorTraits<LinOp>::Scalar,
79 Eigen::Dynamic, 1>>(
80 disc_lf_matrix.data(),
81 disc_lf_matrix.rows() * disc_lf_matrix.cols());
82 return;
83 }
85 // setter
87 void set_degree(const int &deg) { deg_ = deg; }
89 // getter
91 Derived &get_linear_form() { return lf_; }
92 const Eigen::Matrix<typename LinearFormTraits<Derived>::Scalar,
93 Eigen::Dynamic, 1>
94 &get_discrete_linear_form() const {
95 return disc_lf_;
96 }
98 // private member variables
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_
The AnsatzSpace is the class that handles the assembly of the discrete basis.
int get_polynomial_degree() const
Retrieves the polynomial degree of this AnsatzSpace.
const SuperSpace< Derived > & get_superspace() const
Retrieves the reference to the SuperSpace associated with this AnsatzSpace.
const Eigen::SparseMatrix< double > & get_transformation_matrix() const
Retrieves the transformation matrix associated with this AnsatzSpace.
This class, given a LinearForm with defined traits, takes care of the assembly of the right hand side...
This class organizes an element structure on a Geometry object and handles refinement.
int get_number_of_elements() const
Return number of elements in the ElementTree.
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceOutputDimension()