Bembel
NeumannTrace.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_NEUMANNTRACE_HPP_
12 #define BEMBEL_SRC_LINEARFORM_NEUMANNTRACE_HPP_
13 
14 namespace Bembel {
15 
16 template <typename Scalar>
17 class NeumannTrace;
18 
19 template <typename ScalarT>
20 struct LinearFormTraits<NeumannTrace<ScalarT>> {
21  typedef ScalarT Scalar;
22 };
23 
30 template <typename Scalar>
31 class NeumannTrace : public LinearFormBase<NeumannTrace<Scalar>, Scalar> {
32  public:
33  NeumannTrace() {}
34  void set_function(
35  const std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)>
36  &function) {
37  function_ = function;
38  }
39  template <class T>
40  void evaluateIntegrand_impl(
41  const T &super_space, const SurfacePoint &p,
42  Eigen::Matrix<Scalar, Eigen::Dynamic, 1> *intval) const {
43  auto polynomial_degree = super_space.get_polynomial_degree();
44  auto polynomial_degree_plus_one_squared =
45  (polynomial_degree + 1) * (polynomial_degree + 1);
46 
47  // get evaluation points on unit square
48  auto s = p.segment<2>(0);
49 
50  // get quadrature weights
51  auto ws = p(2);
52 
53  // get points on geometry and tangential derivatives
54  auto x_f = p.segment<3>(3);
55  auto x_f_dx = p.segment<3>(6);
56  auto x_f_dy = p.segment<3>(9);
57 
58  // compute (unnormalized) surface normal from tangential derivatives
59  auto x_f_n = x_f_dx.cross(x_f_dy);
60 
61  // integrand without basis functions
62  // dot: adjoint in first variable
63  auto integrand = x_f_n.dot(function_(x_f)) * ws;
64 
65  // multiply basis functions with integrand
66  super_space.addScaledBasis(intval, integrand, s);
67 
68  return;
69  }
70 
71  private:
72  std::function<Eigen::Matrix<Scalar, 3, 1>(Eigen::Vector3d)> function_;
73 };
74 } // namespace Bembel
75 
76 #endif // BEMBEL_SRC_LINEARFORM_NEUMANNTRACE_HPP_
This class provides an implementation of the Neumann trace operator and a corresponding method to eva...
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Routines for the evalutation of pointwise errors.
Definition: AnsatzSpace.hpp:14
This class provides a blueprint for the class that needs to be specialized for assembly of the right ...
Definition: LinearForm.hpp:38
This class needs to be specialized, such that key traits for user defined LinearForms are available.
Definition: LinearForm.hpp:25