Bembel
DiscreteOperator.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_LINEAROPERATOR_DISCRETEOPERATOR_HPP_
12 #define BEMBEL_SRC_LINEAROPERATOR_DISCRETEOPERATOR_HPP_
13 
14 namespace Bembel {
21 template <typename MatrixFormat, typename Derived>
27 template <typename Derived, typename Scalar>
29  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>, Derived> {
31  static void compute(
32  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> *disc_op,
33  const Derived &lin_op, const AnsatzSpace<Derived> &ansatz_space) {
35  const SuperSpace<Derived> &super_space = ansatz_space.get_superspace();
36  const ElementTree &element_tree = super_space.get_mesh().get_element_tree();
37  auto number_of_elements = element_tree.get_number_of_elements();
38  const auto vector_dimension =
39  getFunctionSpaceVectorDimension<LinearOperatorTraits<Derived>::Form>();
40  auto polynomial_degree = super_space.get_polynomial_degree();
41  auto polynomial_degree_plus_one_squared =
42  (polynomial_degree + 1) * (polynomial_degree + 1);
43  auto ffield_deg = lin_op.get_FarfieldQuadratureDegree(polynomial_degree);
44  auto ffield_qnodes =
45  DuffyTrick::computeFfieldQnodes(super_space, GS[ffield_deg]);
46  disc_op->resize(vector_dimension * polynomial_degree_plus_one_squared *
47  number_of_elements,
48  vector_dimension * polynomial_degree_plus_one_squared *
49  number_of_elements);
50 #pragma omp parallel
51  {
52 #pragma omp single
53  {
54  for (auto element1 = element_tree.cpbegin();
55  element1 != element_tree.cpend(); ++element1)
56  for (auto element2 = element_tree.cpbegin();
57  element2 != element_tree.cpend(); ++element2) {
58 #pragma omp task firstprivate(element1, element2)
59  {
60  Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> intval(
61  vector_dimension * polynomial_degree_plus_one_squared,
62  vector_dimension * polynomial_degree_plus_one_squared);
64  lin_op, super_space, *element1, *element2, GS,
65  ffield_qnodes[element1->id_], ffield_qnodes[element2->id_],
66  &intval);
67  for (auto i = 0; i < vector_dimension; ++i)
68  for (auto j = 0; j < vector_dimension; ++j)
69  disc_op->block(polynomial_degree_plus_one_squared *
70  (i * number_of_elements + element1->id_),
71  polynomial_degree_plus_one_squared *
72  (j * number_of_elements + element2->id_),
73  polynomial_degree_plus_one_squared,
74  polynomial_degree_plus_one_squared) =
75  intval.block(i * polynomial_degree_plus_one_squared,
76  j * polynomial_degree_plus_one_squared,
77  polynomial_degree_plus_one_squared,
78  polynomial_degree_plus_one_squared);
79  }
80  }
81  }
82  }
83  auto projector = ansatz_space.get_transformation_matrix();
84  disc_op[0] = projector.transpose() * (disc_op[0] * projector);
85  return;
86  }
87 };
92 template <typename Derived>
94  Eigen::H2Matrix<typename LinearOperatorTraits<Derived>::Scalar>, Derived> {
96  static void compute(
98  const Derived &lin_op, const AnsatzSpace<Derived> &ansatz_space) {
99  disc_op->init_H2Matrix(lin_op, ansatz_space);
100  return;
101  }
102 };
107 template <typename MatrixFormat, typename Derived>
109  public:
111  // constructors
113  DiscreteOperator() {}
114  explicit DiscreteOperator(const AnsatzSpace<Derived> &ansatz_space) {
115  init_DiscreteOperator(ansatz_space);
116  }
118  // init_DiscreteOperator
120  void init_DiscreteOperator(const AnsatzSpace<Derived> &ansatz_space) {
121  ansatz_space_ = ansatz_space;
122  return;
123  }
125  // compute
127  inline void compute() {
129  ansatz_space_);
130  return;
131  }
133  // getter
135  const MatrixFormat &get_discrete_operator() const { return disc_op_; }
136  const Derived &get_linear_operator() const { return lin_op_; }
137  Derived &get_linear_operator() { return lin_op_; }
139  // private member variables
141  private:
142  Derived lin_op_;
143  MatrixFormat disc_op_;
144  AnsatzSpace<Derived> ansatz_space_;
145 };
146 
147 } // namespace Bembel
148 #endif // BEMBEL_SRC_LINEAROPERATOR_DISCRETEOPERATOR_HPP_
The AnsatzSpace is the class that handles the assembly of the discrete basis.
Definition: AnsatzSpace.hpp:25
const Eigen::SparseMatrix< double > & get_transformation_matrix() const
Retrieves the transformation matrix associated with this AnsatzSpace.
const SuperSpace< Derived > & get_superspace() const
Retrieves the reference to the SuperSpace associated with this AnsatzSpace.
ElementTree & get_element_tree()
getter
Definition: ClusterTree.hpp:95
This class organizes an element structure on a Geometry object and handles refinement.
Definition: ElementTree.hpp:32
ElementTreeNode::const_iterator cpbegin() const
Returns an iterator to the beginning of the sequence represented by the leafs as ElementTreeNodes of ...
ElementTreeNode::const_iterator cpend() const
Returns an iterator one past the end of the sequence represented by the leafs as ElementTreeNodes of ...
int get_number_of_elements() const
Return number of elements in the ElementTree.
forward definition of the H2Matrix Class in order to define traits
Definition: H2Matrix.hpp:60
Hierarchical Matrix class, which extends the EigenBase class.
void evaluateBilinearForm(const LinearOperatorBase< Derived > &linOp, const T &super_space, const ElementTreeNode &e1, const ElementTreeNode &e2, const CubatureVector &GS, const ElementSurfacePoints &ffield_qnodes1, const ElementSurfacePoints &ffield_qnodes2, Eigen::Matrix< typename LinearOperatorTraits< Derived >::Scalar, Eigen::Dynamic, Eigen::Dynamic > *intval)
This function wraps the quadrature routines for the DuffyTrick and returns all integrals for the give...
std::vector< ElementSurfacePoints > computeFfieldQnodes(const T &super_space, const Cubature &Q)
evaluates a given quadrature on all surface panels storage format is qNodes.col(k) = [xi,...
Routines for the evalutation of pointwise errors.
Definition: AnsatzSpace.hpp:14
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...
The superspace manages local polynomial bases on each element of the mesh and provides an interface t...
Definition: SuperSpace.hpp:22