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;
41 return kernel_.compute(r_obs.rowwise().mean(), r_src_3d, k);
42 };
43
44 // Get the quadrature points and weights
45 tri_quad_.compute_points_weights(src_tri, eval);
46
47 EigMatNX<Float, 3> points_3d = EigMatNX<Float, 3>::Zero(3, tri_quad_.points().cols());
48 points_3d.topRows(2) = tri_quad_.points();
49
50 // Assemble the integration results
52
53 if (base::compute_g_terms_)
54 {
55 result.g.setZero(1, r_obs.cols());
56 result.rs_g.setZero(2, r_obs.cols());
57
58 for (std::size_t ro = 0; ro < r_obs.cols(); ++ro)
59 {
60 EigRowVec<Complex> gw = kernel_.compute(
61 r_obs.col(ro), points_3d, k
62 ).array() * tri_quad_.weights().array();
63 result.g[ro] = gw.array().sum();
64 result.rs_g.col(ro) = tri_quad_.points() * gw.transpose();
65 }
66 }
67
68 if (base::compute_grad_g_terms_)
69 {
70 result.grad_g.setZero(3, r_obs.cols());
71
72 for (std::size_t ro = 0; ro < r_obs.cols(); ++ro)
73 {
74 result.grad_g.col(ro) = kernel_.compute_grad(
75 r_obs.col(ro), points_3d, k
76 ) * tri_quad_.weights().transpose();
77 }
78 }
79
80 return result;
82};
83
84}
85
86#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
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