OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
double_layer.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_OPS_DOUBLE_LAYER_I
19#define BEM_RWG_OPS_DOUBLE_LAYER_I
20
21#include "types.hpp"
22#include "constants.hpp"
27
28
29namespace bem::rwg
30{
31
32template <typename ObsIntegratorType>
34 const Complex k,
35 const Triangle<3>& obs_tri,
36 const Triangle<3>& src_tri
37 )
38{
41 transform_coordinates(obs_tri_local, src_tri_local, obs_tri, src_tri);
42
43 obs_integrator_.set_compute_terms(false, false, true, false);
44 const ObsResult obs_result = obs_integrator_.integrate(k, obs_tri_local, src_tri_local);
45
46 return assemble(k, obs_tri_local, src_tri_local.to_3d(), obs_result);
47};
48
49
50template <typename ObsIntegratorType>
52 const Complex k,
53 const Triangle<3>& obs_tri,
54 const Triangle<3>& src_tri,
56 )
57{
58
60
63 return result;
64
65 const EigRowVecN<Complex, 9>& I = obs_result.grad_g;
66
67 // source triangle edges
68 for (uint8_t jj = 0; jj < 3; ++jj)
69 {
70 Float xn = src_tri.v((jj + 2) % 3)[0];
71 Float yn = src_tri.v((jj + 2) % 3)[1];
72
73 // observer triangle edges
74 for (uint8_t ii = 0; ii < 3; ++ii)
75 {
76 Float xm = obs_tri.v((ii + 2) % 3)[0];
77 Float ym = obs_tri.v((ii + 2) % 3)[1];
78 Float zm = obs_tri.v((ii + 2) % 3)[2];
79
80 result(ii, jj) = -(-zm * yn * I[0]
81 + zm * I[1] + (yn - ym) * I[2]
82 + zm * xn * I[3] - zm * I[4] + (xm - xn) * I[5]
83 + (xm * yn - ym * xn) * I[6]
84 + (ym - yn) * I[7] + (xn - xm) * I[8]);
85 }
86 }
87
88 result.array() *= (
90 ).array();
91
92 return result;
93
94};
95
96
97template <typename ObsIntegratorType>
99 const Complex k,
101 const Triangle<3>& src_tri
102 )
103{
106 transform_coordinates(obs_tri_local, src_tri_local, obs_tri, src_tri);
107
108 obs_integrator_.set_compute_terms(false, false, true, true);
109 const ObsResult obs_result = obs_integrator_.integrate(k, obs_tri_local, src_tri_local);
110
111 return assemble(k, obs_tri_local, src_tri_local.to_3d(), obs_result);
112};
113
114
115template <typename ObsIntegratorType>
117 const Complex k,
118 const Triangle<3>& obs_tri,
119 const Triangle<3>& src_tri,
120 const ObsResult& obs_result
121 )
122{
123
125
128 return result;
129
130 const EigRowVecN<Complex, 9>& I = obs_result.grad_g;
131 const EigRowVecN<Complex, 15>& I_rot = obs_result.rot_grad_g;
132
133 Float nx = obs_tri.normal()[0];
134 Float ny = obs_tri.normal()[1];
135 Float nz = obs_tri.normal()[2];
136
137 // source triangle edges
138 for (uint8_t jj = 0; jj < 3; ++jj)
139 {
140 Float xn = src_tri.v((jj + 2) % 3)[0];
141 Float yn = src_tri.v((jj + 2) % 3)[1];
142
143 // observer triangle edges
144 for (uint8_t ii = 0; ii < 3; ++ii)
145 {
146 Float xm = obs_tri.v((ii + 2) % 3)[0];
147 Float ym = obs_tri.v((ii + 2) % 3)[1];
148 Float zm = obs_tri.v((ii + 2) % 3)[2];
149
150 result(ii, jj) =
151 yn * (nx * ym - ny * xm) * I[0]
152 + (ny * xm - nx * (ym + yn)) * I[1]
153 + (nz * xm - nx * zm) * I[2]
154 + xn * (ny * xm - nx * ym) * I[3]
155 + (nx * ym - ny * (xm + xn)) * I[4]
156 + (nz * ym - ny * zm) * I[5]
157 + (xn * (nz * xm - nx * zm) + yn * (nz * ym - ny * zm)) * I[6]
158 + (zm * nx - nz * (xm + xn)) * I[7]
159 + (zm * ny - nz * (ym + yn)) * I[8]
160 + yn * ny * I_rot[0] - ny * I_rot[1] - nz * I_rot[2]
161 + nx * I_rot[3] + nx * I_rot[4]
162 + xn * nx * I_rot[5] - nx * I_rot[6] - nz * I_rot[7]
163 + ny * I_rot[8] + ny * I_rot[9]
164 - nx * I_rot[10] - ny * I_rot[11] + (nx * xn + ny * yn) * I_rot[12]
165 + nz * I_rot[13] + nz * I_rot[14];
166 }
167 }
168
169 result.array() *= (
171 ).array();
172
173 return result;
175};
176
177}
178
179#endif
Geometry operations class.
EigMatMN< Complex, 3, 3 > assemble(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri, const ObsResult &obs_result)
Assembles the computed integrals into the final operator values.
EigMatMN< Complex, 3, 3 > compute(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri) override
Computes operator values for the given observation and source triangles.
static EigRowVecN< Float, 3 > normalization(const Triangle< 3 > &tri)
Defines the normalization factor for each RWG function associated with a given triangle.
EigMatMN< Complex, 3, 3 > assemble(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri, const ObsResult &obs_result)
Assembles the computed integrals into the final operator values.
EigMatMN< Complex, 3, 3 > compute(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri) override
Computes operator values for the given observation and source triangles.
Eigen::Matrix< T, M, N > EigMatMN
Fixed-size matrix with M rows and N columns containing type T.
Definition types.hpp:70
double Float
Floating point number.
Definition types.hpp:47
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
Namespace for RWG-based BEM functionality.
Data structure to hold the results of integration over the observation triangle.
Definition base.hpp:37