Bembel
 
Loading...
Searching...
No Matches
surfaceL2error.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_UTIL_SURFACEL2ERROR_HPP_
13#define BEMBEL_SRC_UTIL_SURFACEL2ERROR_HPP_
14
15namespace Bembel {
16
17template <typename Op, typename Derived, typename Functor>
18double surfaceL2error(const AnsatzSpace<Op> &ansatz_space,
19 const Eigen::MatrixBase<Derived> &vec,
20 const Functor &functor, int deg = 4) {
21 typedef typename Derived::Scalar Scalar;
23 fun_val.set_function(vec);
24 Scalar retval = 0;
26 auto Q = GS[deg];
28 const auto &super_space = ansatz_space.get_superspace();
29 const ElementTree &et = super_space.get_mesh().get_element_tree();
30 for (auto element = et.cpbegin(); element != et.cpend(); ++element) {
31 for (auto i = 0; i < Q.w_.size(); ++i) {
32 super_space.map2surface(*element, Q.xi_.col(i), Q.w_(i), &qp);
33 // get points on geometry and tangential derivatives
34 const auto &x_f = qp.segment<3>(3);
35 const auto &x_f_dx = qp.segment<3>(6);
36 const auto &x_f_dy = qp.segment<3>(9);
37 const auto &normal = x_f_dx.cross(x_f_dy);
38 // compute surface measures from tangential derivatives
39 Scalar x_kappa = normal.norm();
40 const Scalar val = fun_val.evaluate(*element, qp)(0);
41 retval += x_kappa * Q.w_(i) * element->get_h() * element->get_h() *
42 (functor(x_f) - val) * (functor(x_f) - val);
43 }
44 }
45 return sqrt(retval);
46}
47
48} // namespace Bembel
49#endif // BEMBEL_SRC_UTIL_SURFACEL2ERROR_HPP_
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceOutputDimension()