OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
quadrature.tpp
Go to the documentation of this file.
1// OpenBEM - Copyright (C) 2026 Shashwat Sharma
2
3// This file is part of OpenBEM.
4
5// OpenBEM is free software: you can redistribute it and/or modify it under the terms of the
6// GNU General Public License as published by the Free Software Foundation, either version 3
7// of the License, or (at your option) any later version.
8
9// You should have received a copy of the GNU General Public License along with OpenBEM.
10// If not, see <https://www.gnu.org/licenses/>.
11
12
18#ifndef BEM_RWG_OPINT_SRC_QUAD_I
19#define BEM_RWG_OPINT_SRC_QUAD_I
20
21#include "types.hpp"
23
24
25namespace bem::rwg
26{
27
28template <typename TriangleQuadratureType, typename ScalarKernelType>
30 const Complex k,
31 const Triangle<2>& src_tri,
33 )
34{
35
36 // Lambda used for iterative or adaptive numerical integration
38 {
40 r_src_3d.topRows(2) = r_src;
42 for (std::size_t rs = 0; rs < r_src.cols(); ++rs)
43 vals[rs] = kernel_.kernel(r_obs.rowwise().mean(), r_src_3d.col(rs), k);
44 return vals;
45 };
46
47 // Get the quadrature points and weights
48 tri_quad_.compute_points_weights(src_tri, eval);
49
50 EigMatNX<Float, 3> points_3d = EigMatNX<Float, 3>::Zero(3, tri_quad_.points().cols());
51 points_3d.topRows(2) = tri_quad_.points();
52
53 // Assemble the integration results
55
56 if (base::compute_g_terms_)
57 {
58 result.g.setZero(1, r_obs.cols());
59 result.rs_g.setZero(2, r_obs.cols());
60
61 for (std::size_t rs = 0; rs < points_3d.cols(); ++rs)
62 {
63 for (std::size_t ro = 0; ro < r_obs.cols(); ++ro)
64 {
65 Complex g = kernel_.kernel(
66 r_obs.col(ro), points_3d.col(rs), k
67 ) * tri_quad_.weights()[rs];
68
69 result.g[ro] += g;
70 for (uint8_t ii = 0; ii < 2; ii++)
71 result.rs_g(ii, ro) += g * points_3d(ii, rs);
72 }
73 }
74 }
75
76 if (base::compute_grad_g_terms_)
77 {
78 result.grad_g.setZero(3, r_obs.cols());
79
80 for (std::size_t rs = 0; rs < points_3d.cols(); ++rs)
81 {
82 for (std::size_t ro = 0; ro < r_obs.cols(); ++ro)
83 {
84 EigColVecN<Complex, 3> grad_g = kernel_.grad_kernel(
85 r_obs.col(ro), points_3d.col(rs), k
86 ) * tri_quad_.weights()[rs];
87
88 for (uint8_t ii = 0; ii < 3; ii++)
89 result.grad_g(ii, ro) += grad_g[ii];
90 }
91 }
92 }
93
94
95#ifdef EXTRA_DEBUG
96 std::string text = "Integral eval points:\n";
97 for (std::size_t ii = 0; ii < points_3d.cols(); ii++)
98 text += std::to_string(points_3d(0, ii)) + " " +
99 std::to_string(points_3d(1, ii)) + " " +
100 std::to_string(0.0) + "\n";
101 Log::make_debug_section(text);
102#endif
103
104 return result;
105
106};
107
108}
109
110#endif
SrcResult integrate(const Complex k, const Triangle< 2 > &src_tri, ConstEigRef< EigMatNX< Float, 3 > > r_obs) override
Computes the integral over the source triangle.
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
Eigen::Matrix< T, 1, Eigen::Dynamic > EigRowVec
Dynamic-size row vector containing type T.
Definition types.hpp:90
std::complex< Float > Complex
Complex floating point number.
Definition types.hpp:51
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
Definition types.hpp:86
Eigen::Matrix< T, N, Eigen::Dynamic > EigMatNX
Fixed-height matrix with N rows containing type T.
Definition types.hpp:78
Namespace for RWG-based BEM functionality.
Data structure to hold the results of integration over the source triangle.
Definition base.hpp:37