OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
generic.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_OPS_GENERIC_H
19#define BEM_RWG_OPS_GENERIC_H
20
21#include <stdexcept>
22#include <iostream>
23
24#include "types.hpp"
25
27
35
36
37namespace bem::rwg
38{
39
48enum class OperatorName
49{
50 VECTOR_SINGLE_LAYER,
51 ROT_VECTOR_SINGLE_LAYER,
52 VECTOR_DOUBLE_LAYER_PV,
53 ROT_VECTOR_DOUBLE_LAYER_PV,
54 SCALAR_SINGLE_LAYER,
55 VECTOR_HYPERSINGULAR,
56 ROT_VECTOR_HYPERSINGULAR,
57 RWG_RWG,
58 ROT_RWG_RWG,
59 PULSE_PULSE,
60 DIVRWG,
61 DEFAULT
62};
63
70std::ostream& operator<<(std::ostream& os, OperatorName op_name)
71{
72
73 switch (op_name)
74 {
75 case OperatorName::VECTOR_SINGLE_LAYER:
76 os << "< RWG | G . RWG >";
77 break;
78 case OperatorName::ROT_VECTOR_SINGLE_LAYER:
79 os << "< nxRWG | G . RWG >";
80 break;
81 case OperatorName::VECTOR_DOUBLE_LAYER_PV:
82 os << "< RWG | gradG x RWG > (pv)";
83 break;
84 case OperatorName::ROT_VECTOR_DOUBLE_LAYER_PV:
85 os << "< nxRWG | gradG x RWG > (pv)";
86 break;
87 case OperatorName::SCALAR_SINGLE_LAYER:
88 os << "< pulse | G . pulse >";
89 break;
90 case OperatorName::VECTOR_HYPERSINGULAR:
91 os << "< RWG | G + (1/k^2) hessG . RWG >";
92 break;
93 case OperatorName::ROT_VECTOR_HYPERSINGULAR:
94 os << "< nxRWG | G + (1/k^2) hessG . RWG >";
95 break;
96 case OperatorName::RWG_RWG:
97 os << "< RWG | RWG >";
98 break;
99 case OperatorName::ROT_RWG_RWG:
100 os << "< nxRWG | RWG >";
101 break;
102 case OperatorName::DIVRWG:
103 os << "< divRWG >";
104 break;
105 default:
106 throw std::invalid_argument(
107 "OperatorName: `op_name` is invalid or not implemented."
108 );
109 break;
110 }
111
112 return os;
113
114}
115
116
120template <typename ObsIntegratorType = ObsStrategic<>>
121class GenericRwgOp: public OperatorBase<3, 3>
122{
123
124 static_assert(
125 std::is_base_of<ObsIntegratorBase, ObsIntegratorType>::value,
126 "GenericRwgOp: `ObsIntegratorType` must derive from `ObsIntegratorBase`"
127 );
128
129public:
130
137 op_name_(op_name),
138 vector_single_layer_(obs_integrator),
139 rot_vector_single_layer_(obs_integrator),
140 vector_double_layer_pv_(obs_integrator),
141 rot_vector_double_layer_pv_(obs_integrator),
142 rot_grad_scalar_single_layer_(obs_integrator),
143 vector_hypersingular_(obs_integrator),
144 rot_vector_hypersingular_(obs_integrator) {};
145
146
158 const Complex k,
159 const Triangle<3>& obs_tri,
160 const Triangle<3>& src_tri
161 ) override;
162
163
164private:
165
166 OperatorName op_name_;
167 VectorSingleLayerOp<ObsIntegratorType> vector_single_layer_;
168 RotVectorSingleLayerOp<ObsIntegratorType> rot_vector_single_layer_;
169 VectorDoubleLayerPvOp<ObsIntegratorType> vector_double_layer_pv_;
170 RotVectorDoubleLayerPvOp<ObsIntegratorType> rot_vector_double_layer_pv_;
171 RotGradScalarSingleLayerOp<ObsIntegratorType> rot_grad_scalar_single_layer_;
172 VectorHypersingularOp<ObsIntegratorType> vector_hypersingular_;
173 RotVectorHypersingularOp<ObsIntegratorType> rot_vector_hypersingular_;
174 RwgRwgOp<> rwg_rwg_;
175 RotRwgRwgOp<> rot_rwg_rwg_;
176
177};
178
179
183template <typename ObsIntegratorType = ObsQuadrature<>>
184class GenericPulseOp: public OperatorBase<1, 1>
185{
186
187 static_assert(
188 std::is_base_of<ObsIntegratorBase, ObsIntegratorType>::value,
189 "GenericPulseOp: `ObsIntegratorType` must derive from `ObsIntegratorBase`"
190 );
191
192public:
193
200 op_name_(op_name), scalar_single_layer_(obs_integrator) {};
201
202
211 const Complex k,
212 const Triangle<3>& obs_tri,
213 const Triangle<3>& src_tri
214 ) override;
215
216
217private:
218
219 OperatorName op_name_;
220 ScalarSingleLayerOp<ObsIntegratorType> scalar_single_layer_;
221
222};
223
228}
229
231
232#endif
Class for computing pulse function operators based on a given OperatorName.
Definition generic.hpp:185
GenericPulseOp(const OperatorName op_name, const ObsIntegratorType obs_integrator=ObsStrategic<>())
Constructs a GenericPulseOp for computing operator op_name with a specified integration object.
Definition generic.hpp:199
EigMatMN< Complex, 1, 1 > compute(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri) override
Computes the operator value for the given observation and source triangles.
Definition generic.tpp:92
Class for computing RWG operators based on a given OperatorName.
Definition generic.hpp:122
GenericRwgOp(const OperatorName op_name, const ObsIntegratorType obs_integrator=ObsStrategic<>())
Constructs a GenericRwgOp for computing operator op_name with a specified integration object.
Definition generic.hpp:136
EigMatMN< Complex, 3, 3 > compute(const Complex k, const Triangle< 3 > &obs_tri, const Triangle< 3 > &src_tri) override
Computes the operator values for the given observation and source triangles.
Definition generic.tpp:32
Base class for RWG-based BEM operators.
Definition base.hpp:41
std::ostream & operator<<(std::ostream &os, OperatorName op_name)
Overloaded output stream operator for OperatorName.
Definition generic.hpp:70
OperatorName
Enum class defining operator names.
Definition generic.hpp:49
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.