OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
efie.hpp
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_EFIE_LUMPED_ELEM_H
19#define BEM_RWG_EFIE_LUMPED_ELEM_H
20
21#include <vector>
22
23#include "types.hpp"
24#include "constants.hpp"
25
27#include "matrix/base.hpp"
29
34
35
36namespace bem::rwg
37{
38
48template <typename MatrixType = EigenDenseMatrix<Complex>>
49class TefieLumpedElement: public LumpedElementBase<MatrixType>
50{
51
53 using base::base;
54
55public:
56
62 MatrixType coupling_matrix(const Float f) const override
63 {
65
66 MatrixType D = divergence_matrix();
67 MatrixType Dt;
68 Dt.set_transpose(D);
69
70 MatrixType Lp = phi_matrix(f, base::structure_.mesh(), port_mesh);
71 MatrixType DtLp;
72 DtLp.set_mat_mul(Dt, Lp);
73
75 MatrixType mat;
76 mat.set_mat_mul(DtLp, current_map);
77
78 return mat;
79 };
80
81
87 MatrixType voltage_matrix(const Float f) const override
88 {
90
93
94 MatrixType D = divergence_matrix();
95 MatrixType Lp_divj = phi_matrix(f, port_mesh, base::structure_.mesh());
96 MatrixType Lp_jvol = phi_matrix(f, port_mesh, port_mesh);
97
98 MatrixType Lp_divj_D;
99 Lp_divj_D.set_mat_mul(Lp_divj, D);
100
101 MatrixType Lp_current;
102 Lp_current.set_mat_mul(Lp_jvol, current_map);
103
104 MatrixType voltage_mat;
105 voltage_mat.set_mat_mul(voltage_map, Lp_divj_D);
106
107 MatrixType current_mat;
108 current_mat.set_mat_mul(voltage_map, Lp_current);
109
110 MatrixType mat (base::num_ports(), base::structure_.mesh().num_edges() + base::num_ports());
111 mat.add_block(voltage_mat, 0, 0, -one);
112 mat.add_block(current_mat, 0, base::structure_.mesh().num_edges(), -one);
113
114 return mat;
115 };
116
117
123 MatrixType current_matrix(const Float f) const override
124 {
125 MatrixType mat (base::num_ports(), base::num_ports());
126 for (Index ii = 0; ii < base::num_ports(); ++ii)
127 mat.set_value(ii, ii, base::impedances()[ii]);
128 mat.assemble();
129 return mat;
130 };
131
132
133protected:
134
142 MatrixType phi_matrix(
143 const Float f,
146 ) const
147 {
148 Complex k = base::structure_.background_material().k(f);
149 Complex eps_eff = base::structure_.background_material().eps_eff(f);
150
153 MatrixType Lp;
154 assm_face.assemble(Lp, op_Lp, k);
155 Lp.scale(-one / eps_eff / (J * two_pi * f));
156
157 return Lp;
158 };
159
160
165 virtual MatrixType divergence_matrix() const
166 {
168 FaceEdgeOperatorAssembler assm_div (base::structure_.mesh(), base::structure_.mesh());
169 MatrixType D;
170 assm_div.assemble(D, op_D, 0);
171 return D;
172 };
173
174};
175
176
181template <typename MatrixType = EigenDenseMatrix<Complex>>
182class NefieLumpedElement: public LumpedElementBase<MatrixType>
183{
184
186 using base::base;
187
188public:
189
195 MatrixType coupling_matrix(const Float f) const override
196 {
198 MatrixType Lp = nxphi_matrix(f, base::structure_.mesh(), port_mesh);
200 MatrixType mat;
201 mat.set_mat_mul(Lp, current_map);
202 return mat;
203 };
204
205
211 MatrixType voltage_matrix(const Float f) const override
212 {
213 TefieLumpedElement<MatrixType> tefie_elem (base::structure_, base::terminal_polygons_, base::ports_, base::impedances_);
214 return tefie_elem.voltage_matrix(f);
215 };
216
217
223 MatrixType current_matrix(const Float f) const override
224 {
225 TefieLumpedElement<MatrixType> tefie_elem (base::structure_, base::terminal_polygons_, base::ports_, base::impedances_);
226 return tefie_elem.current_matrix(f);
227 };
228
229
230protected:
231
239 MatrixType nxphi_matrix(
240 const Float f,
243 ) const
244 {
245 Complex k = base::structure_.background_material().k(f);
246 Complex eps_eff = base::structure_.background_material().eps_eff(f);
247
250 MatrixType Lp;
251 assm.assemble(Lp, op_Lp, k);
252 Lp.scale(-one / eps_eff / (J * two_pi * f));
253
254 return Lp;
255 };
256
257};
258
263}
264
265#endif
Class for computing the discrete divergence matrix for RWG functions.
Definition incidence.hpp:48
Class for generating operator matrices for RWG observation and pulse source functions.
Class for generating operator matrices for pulse observation and RWG source functions.
Class for generating operator matrices for pulse observation and source functions.
Base class for generating excitation coefficients and coupling matrices for lumped ports.
Definition base.hpp:51
virtual MatrixType voltage_mapping_matrix() const
Returns the matrix that maps the scalar potential on terminal triangles to the average voltage on the...
Definition base.hpp:251
virtual MatrixType current_mapping_matrix() const
Returns the matrix that maps the total port currents to the volume current densities on terminal tria...
Definition base.hpp:219
Index num_ports() const
Returns the number of excitations (right-hand sides), which equals the number of ports.
Definition base.hpp:110
MeshView< TriangleMesh< 3 > > port_mesh_view() const
Returns a mesh view consisting of all elements associated with the ports.
Definition base.hpp:145
const std::vector< Complex > & impedances() const
Returns a read-only reference to the lumped impedances.
Definition base.hpp:324
Class providing lumped element functionality for the NEFIE.
Definition efie.hpp:183
MatrixType coupling_matrix(const Float f) const override
Returns the matrix the couples the element port current to the NEFIE.
Definition efie.hpp:195
MatrixType current_matrix(const Float f) const override
Returns the matrix associated with terminal currents.
Definition efie.hpp:223
MatrixType voltage_matrix(const Float f) const override
Returns the matrix associated with the potential differences between terminals.
Definition efie.hpp:211
MatrixType nxphi_matrix(const Float f, const TriangleMesh< 3 > &obs_mesh, const TriangleMesh< 3 > &src_mesh) const
Returns the matrix associated with the scalar potential on given source and observation meshes.
Definition efie.hpp:239
void assemble(MatrixBase< Complex > &mat, OperatorType op, const Complex k)
Assembles the operator matrix for a given operator object and source and observation meshes.
Definition base.hpp:115
Class for computing the rotationally-tested gradient of the scalar single-layer potential operator.
Class for computing the scalar single-layer potential operator.
Class providing lumped element functionality for the TEFIE.
Definition efie.hpp:50
virtual MatrixType divergence_matrix() const
Returns the matrix that comptes the divergence matrix for mesh edges.
Definition efie.hpp:165
MatrixType coupling_matrix(const Float f) const override
Returns the matrix the couples the element port current to the TEFIE.
Definition efie.hpp:62
MatrixType voltage_matrix(const Float f) const override
Returns the matrix associated with the potential differences between terminals.
Definition efie.hpp:87
MatrixType current_matrix(const Float f) const override
Returns the matrix associated with terminal currents.
Definition efie.hpp:123
MatrixType phi_matrix(const Float f, const TriangleMesh< 3 > &obs_mesh, const TriangleMesh< 3 > &src_mesh) const
Returns the matrix associated with the scalar potential on given source and observation meshes.
Definition efie.hpp:142
const Complex J
Imaginary unit.
Definition constants.hpp:40
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
std::size_t Index
Unsigned integer type for indices and container sizes.
Definition types.hpp:54
Namespace for RWG-based BEM functionality.