OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
projector_matrix.cpp
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
19
20#include <vector>
21#include <stdexcept>
22
23#include "types.hpp"
26#include "matrix/base.hpp"
27
28
29namespace bem::rwg
30{
31
32template <uint8_t obs_dim>
36 const Complex k
37 )
38{
39 mat.resize(base::obs_cloud_.num_points() * obs_dim, base::src_mesh_.num_edges());
40 mat.preallocate(base::obs_cloud_.num_points() * obs_dim * base::elems_.size() * 3);
41
42 for (Index ii = 0; ii < base::elems_.size(); ++ii)
43 {
44 Triangle<3> src_tri = base::src_mesh_.elem_primitive(base::elems_[ii]);
45
46 EigMatXN<Complex, 3> values = op.compute(k, base::obs_cloud_.points(), src_tri);
47
48 for (uint8_t src_edge = 0; src_edge < 3; ++src_edge)
49 {
50 Index col = base::src_mesh_.elem_edges(src_edge, base::elems_[ii]);
51
52 for (Index obs_point = 0; obs_point < base::obs_cloud_.num_points(); ++obs_point)
53 {
55 {
57 mat.add_value(row, col, values(row, src_edge));
58 }
59 }
60 }
61 }
62
63 mat.assemble();
64
65 return;
66};
67
68
69template <uint8_t obs_dim>
73 const Complex k
74 )
75{
76 mat.resize(base::obs_cloud_.num_points() * obs_dim, base::src_mesh_.num_elems());
77 mat.preallocate(base::obs_cloud_.num_points() * obs_dim * base::elems_.size());
78
79 for (Index ii = 0; ii < base::elems_.size(); ++ii)
80 {
81 Triangle<3> src_tri = base::src_mesh_.elem_primitive(base::elems_[ii]);
82
83 EigMatXN<Complex, 1> values = op.compute(k, base::obs_cloud_.points(), src_tri);
84
85 for (Index obs_point = 0; obs_point < base::obs_cloud_.num_points(); ++obs_point)
86 {
88 {
90 mat.add_value(row, base::elems_[ii], values(row, 0));
91 }
92 }
93 }
94
95 mat.assemble();
96
97 return;
98};
99
100
101template class EdgeProjectorAssembler<1>;
102template class EdgeProjectorAssembler<2>;
103template class EdgeProjectorAssembler<3>;
104
105template class FaceProjectorAssembler<1>;
106template class FaceProjectorAssembler<2>;
107template class FaceProjectorAssembler<3>;
108
109}
void assemble(MatrixBase< Complex > &mat, ProjectorBase< 3 > &op, const Complex k) override
Assembles the projector matrix for edge-based RWG source functions.
void assemble(MatrixBase< Complex > &mat, ProjectorBase< 1 > &op, const Complex k) override
Assembles the projector matrix for face-based pulse source functions.
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.