ngsolve 6.2.2506__cp312-cp312-macosx_10_15_universal2.whl → 6.2.2506.post38.dev0__cp312-cp312-macosx_10_15_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ngsolve might be problematic. Click here for more details.

Files changed (63) hide show
  1. netgen/include/bem_diffops.hpp +475 -0
  2. netgen/include/bspline.hpp +2 -0
  3. netgen/include/contact.hpp +4 -0
  4. netgen/include/h1lumping.hpp +6 -0
  5. netgen/include/kernels.hpp +653 -0
  6. netgen/include/mp_coefficient.hpp +20 -20
  7. netgen/include/mptools.hpp +625 -279
  8. netgen/include/potentialtools.hpp +2 -2
  9. netgen/include/recursive_pol.hpp +2 -2
  10. netgen/include/sparsematrix.hpp +1 -1
  11. netgen/libngbla.dylib +0 -0
  12. netgen/libngcomp.dylib +0 -0
  13. netgen/libngfem.dylib +0 -0
  14. netgen/libngla.dylib +0 -0
  15. netgen/libngsbem.dylib +0 -0
  16. netgen/libngsolve.dylib +0 -0
  17. netgen/libngstd.dylib +0 -0
  18. ngsolve/__init__.pyi +3 -3
  19. ngsolve/cmake/NGSolveConfig.cmake +1 -1
  20. ngsolve/config/__init__.pyi +6 -6
  21. ngsolve/config/config.py +5 -5
  22. ngsolve/config/config.pyi +6 -6
  23. ngsolve/demos/intro/cmagnet.py +19 -22
  24. ngsolve/solve.pyi +1 -1
  25. ngsolve/utils.pyi +1 -1
  26. {ngsolve-6.2.2506.dist-info → ngsolve-6.2.2506.post38.dev0.dist-info}/METADATA +2 -2
  27. {ngsolve-6.2.2506.dist-info → ngsolve-6.2.2506.post38.dev0.dist-info}/RECORD +63 -61
  28. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/Netgen.icns +0 -0
  29. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/bin/ngscxx +0 -0
  30. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/bin/ngsld +0 -0
  31. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/bin/ngsolve.tcl +0 -0
  32. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/bin/ngspy +0 -0
  33. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/beam.geo +0 -0
  34. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/beam.vol +0 -0
  35. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/chip.in2d +0 -0
  36. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/chip.vol +0 -0
  37. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/coil.geo +0 -0
  38. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/coil.vol +0 -0
  39. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/coilshield.geo +0 -0
  40. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/coilshield.vol +0 -0
  41. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/cube.geo +0 -0
  42. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/cube.vol +0 -0
  43. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -0
  44. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d11_chip_nitsche.pde +0 -0
  45. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d1_square.pde +0 -0
  46. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d2_chip.pde +0 -0
  47. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d3_helmholtz.pde +0 -0
  48. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d4_cube.pde +0 -0
  49. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d5_beam.pde +0 -0
  50. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d6_shaft.pde +0 -0
  51. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d7_coil.pde +0 -0
  52. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d8_coilshield.pde +0 -0
  53. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/d9_hybridDG.pde +0 -0
  54. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/doubleglazing.in2d +0 -0
  55. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/doubleglazing.vol +0 -0
  56. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  57. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/shaft.geo +0 -0
  58. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/shaft.vol +0 -0
  59. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/square.in2d +0 -0
  60. {ngsolve-6.2.2506.data → ngsolve-6.2.2506.post38.dev0.data}/data/share/ngsolve/square.vol +0 -0
  61. {ngsolve-6.2.2506.dist-info → ngsolve-6.2.2506.post38.dev0.dist-info}/LICENSE +0 -0
  62. {ngsolve-6.2.2506.dist-info → ngsolve-6.2.2506.post38.dev0.dist-info}/WHEEL +0 -0
  63. {ngsolve-6.2.2506.dist-info → ngsolve-6.2.2506.post38.dev0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,653 @@
1
+ #ifndef KERNELS_hpp
2
+ #define KERNELS_hpp
3
+
4
+ #include "mptools.hpp"
5
+
6
+
7
+ // **************************** The kernels **********************************
8
+
9
+ namespace ngsbem
10
+ {
11
+
12
+ struct KernelTerm
13
+ {
14
+ double fac;
15
+ size_t kernel_comp;
16
+ size_t trial_comp;
17
+ size_t test_comp;
18
+ };
19
+
20
+
21
+ class BaseKernel
22
+ {
23
+ public:
24
+ shared_ptr<SingularMLExpansion<Complex>> CreateMultipoleExpansion (Vec<3> c, double r) const
25
+ {
26
+ throw Exception("Create Multipole Expansion not implemented");
27
+ }
28
+
29
+ shared_ptr<RegularMLExpansion<Complex>> CreateLocalExpansion (Vec<3> c, double r) const
30
+ {
31
+ throw Exception("Create Local Expansion not implemented");
32
+ }
33
+
34
+ template <typename TV>
35
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
36
+ {
37
+ throw Exception("Addsource not implemented");
38
+ }
39
+
40
+ template <typename entry, typename TV>
41
+ void AddSourceTrans(SingularMLExpansion<entry> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
42
+ {
43
+ throw Exception("AddSourceTrans not implemented");
44
+ }
45
+
46
+ template <typename TV>
47
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
48
+ {
49
+ throw Exception("Evaluate not implemented");
50
+ }
51
+
52
+ template <typename entry, typename TV>
53
+ void EvaluateMPTrans(RegularMLExpansion<entry> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
54
+ {
55
+ throw Exception("EvaluateMPTrans not implemented");
56
+ }
57
+ };
58
+
59
+
60
+
61
+
62
+
63
+ /** LaplaceSLkernel is the kernel for the single layer potential of
64
+ the Laplace equation $ \Delta u = 0 \,.$ */
65
+ template <int DIM> class LaplaceSLKernel;
66
+
67
+ /** LaplaceSLkernel in 3D reads
68
+ $$ G(x-y) = \frac{1}{4\,\pi \, | x-y| }, \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
69
+ template<>
70
+ class LaplaceSLKernel<3> : public BaseKernel
71
+ {
72
+ public:
73
+ LaplaceSLKernel<3> () = default;
74
+ typedef double value_type;
75
+ static string Name() { return "LaplaceSL"; }
76
+ static auto Shape() { return IVec<2>(1,1); }
77
+
78
+ template <typename T>
79
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
80
+ {
81
+ T norm = L2Norm(x-y);
82
+ // return 1.0 / (4 * M_PI * norm);
83
+ return Vec<1,T> (1.0 / (4 * M_PI * norm));
84
+ }
85
+
86
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
87
+
88
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
89
+ {
90
+ return make_shared<SingularMLExpansion<Complex>> (c, r, 1e-16);
91
+ }
92
+
93
+ auto CreateLocalExpansion (Vec<3> c, double r) const
94
+ {
95
+ return make_shared<RegularMLExpansion<Complex>> (c, r, 1e-16);
96
+ }
97
+
98
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
99
+ {
100
+ mp.AddCharge (pnt, val(0));
101
+ }
102
+
103
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
104
+ {
105
+ val(0) = Real(mp.Evaluate (pnt));
106
+ }
107
+ };
108
+
109
+
110
+ /** LaplaceDLkernel is the kernel for the double layer potential of
111
+ the Laplace equation $ \Delta u = 0 \,.$ */
112
+ template <int DIM> class LaplaceDLKernel;
113
+
114
+ /** LaplaceDLkernel in 3D reads
115
+ $$ \frac{\partial }{ \partial n_y} G(x-y) = \frac{1}{4\,\pi} \,
116
+ \frac{ \langle n(y), x-y\rangle }{ | x-y|^3 },
117
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
118
+ template<>
119
+ class LaplaceDLKernel<3> : public BaseKernel
120
+ {
121
+ public:
122
+ typedef double value_type;
123
+ static string Name() { return "LaplaceDL"; }
124
+ static auto Shape() { return IVec<2>(1,1); }
125
+
126
+ template <typename T>
127
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
128
+ {
129
+ T norm = L2Norm(x-y);
130
+ T nxy = InnerProduct(ny, (x-y));
131
+ // return nxy / (4 * M_PI * norm*norm*norm);
132
+ return Vec<1,T> (nxy / (4 * M_PI * norm*norm*norm));
133
+ }
134
+
135
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
136
+
137
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
138
+ {
139
+ return make_shared<SingularMLExpansion<Complex>> (c, r, 1e-16);
140
+ }
141
+
142
+ auto CreateLocalExpansion (Vec<3> c, double r) const
143
+ {
144
+ return make_shared<RegularMLExpansion<Complex>> (c, r, 1e-16);
145
+ }
146
+
147
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
148
+ {
149
+ mp.AddDipole(pnt, -nv, val(0));
150
+ }
151
+
152
+ void AddSourceTrans(SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
153
+ {
154
+ mp.AddCharge(pnt, val(0));
155
+ }
156
+
157
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
158
+ {
159
+ val(0) = Real(mp.Evaluate (pnt));
160
+ }
161
+
162
+ void EvaluateMPTrans(RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
163
+ {
164
+ val(0) = Real(mp.EvaluateDirectionalDerivative(pnt, nv));
165
+ }
166
+ };
167
+
168
+
169
+ template <int DIM> class LaplaceHSKernel;
170
+
171
+ template<>
172
+ class LaplaceHSKernel<3> : public BaseKernel
173
+ {
174
+ public:
175
+ typedef double value_type;
176
+ static string Name() { return "LaplaceHL"; }
177
+ static auto Shape() { return IVec<2>(3,3); }
178
+
179
+ template <typename T>
180
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
181
+ {
182
+ T norm = L2Norm(x-y);
183
+ // return 1.0 / (4 * M_PI * norm);
184
+ return Vec<1,T> (1.0 / (4 * M_PI * norm));
185
+ }
186
+
187
+ Array<KernelTerm> terms =
188
+ {
189
+ KernelTerm{1.0, 0, 0, 0},
190
+ KernelTerm{1.0, 0, 1, 1},
191
+ KernelTerm{1.0, 0, 2, 2},
192
+ };
193
+
194
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
195
+ {
196
+ return make_shared<SingularMLExpansion<Vec<3,Complex>>> (c, r, 1e-16);
197
+ }
198
+
199
+ auto CreateLocalExpansion (Vec<3> c, double r) const
200
+ {
201
+ return make_shared<RegularMLExpansion<Vec<3,Complex>>> (c, r, 1e-16);
202
+ }
203
+
204
+ void AddSource (SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
205
+ {
206
+ mp.AddCharge(pnt, val);
207
+ }
208
+
209
+ void EvaluateMP (RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
210
+ {
211
+ val = Real(mp.Evaluate (pnt));
212
+ }
213
+ };
214
+
215
+
216
+ /** HelmholtzSLkernel is the kernel for the double layer potential of the
217
+ Helmholtz equation $ -\Delta u - \kappa^2 u = 0, \; \kappa>0\,. $ */
218
+ template <int DIM> class HelmholtzSLKernel;
219
+
220
+ /** HelmholtzSLkernel in 3D reads
221
+ $$ G(x-y) = \frac{1 }{4\,\pi} \,\frac{e^{i\,\kappa \, |x-y| }{|x-y|} \,
222
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
223
+ template<>
224
+ class HelmholtzSLKernel<3> : public BaseKernel
225
+ {
226
+ double kappa;
227
+ public:
228
+ typedef Complex value_type;
229
+ static string Name() { return "HelmholtzSL"; }
230
+ static auto Shape() { return IVec<2>(1,1); }
231
+
232
+ /** Construction of the kernel specifies the wavenumber $\kappa$. */
233
+ HelmholtzSLKernel (double _kappa) : kappa(_kappa) { }
234
+
235
+ template <typename T>
236
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
237
+ {
238
+ T norm = L2Norm(x-y);
239
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
240
+ // return kern;
241
+ return Vec<1,decltype(kern)> (kern);
242
+ }
243
+ double GetKappa() const { return kappa; }
244
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
245
+
246
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
247
+ {
248
+ return make_shared<SingularMLExpansion<Complex>> (c, r, kappa);
249
+ }
250
+
251
+ auto CreateLocalExpansion (Vec<3> c, double r) const
252
+ {
253
+ return make_shared<RegularMLExpansion<Complex>> (c, r, kappa);
254
+ }
255
+
256
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
257
+ {
258
+ mp.AddCharge(pnt, val(0));
259
+ }
260
+
261
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
262
+ {
263
+ val(0) = mp.Evaluate (pnt);
264
+ }
265
+ };
266
+
267
+
268
+ /** HelmholtzDLkernel is the kernel for the double layer potential of
269
+ the Helmholtz equation $ -\Delta u - \kappa^2 u = 0, \; \kappa>0\,.$ */
270
+ template <int DIM> class HelmholtzDLKernel;
271
+
272
+ /** HelmholtzDLkernel in 3D reads
273
+ $$ \frac{\partial }{ \partial n_y} G(x-y) = \frac{1}{4\,\pi} \, \frac{e^{i\,\kappa\,|x-y|}}{|x-y|^3} \,
274
+ \langle n(y), x-y\rangle \cdot \left( 1 - i\,\kappa\, | x-y| \right),
275
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
276
+ template<>
277
+ class HelmholtzDLKernel<3> : public BaseKernel
278
+ {
279
+ double kappa;
280
+ public:
281
+ typedef Complex value_type;
282
+ static string Name() { return "HelmholtzDL"; }
283
+ static auto Shape() { return IVec<2>(1,1); }
284
+
285
+ HelmholtzDLKernel (double _kappa) : kappa(_kappa) { }
286
+
287
+ template <typename T>
288
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
289
+ {
290
+ T norm = L2Norm(x-y);
291
+ T nxy = InnerProduct(ny, (x-y));
292
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm*norm*norm)
293
+ * nxy * (Complex(1,0)*T(1.) - Complex(0,kappa)*norm);
294
+ // return kern;
295
+ return Vec<1,decltype(kern)> (kern);
296
+ }
297
+ double GetKappa() const { return kappa; }
298
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
299
+
300
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
301
+ {
302
+ return make_shared<SingularMLExpansion<Complex>> (c, r, kappa);
303
+ }
304
+
305
+ auto CreateLocalExpansion (Vec<3> c, double r) const
306
+ {
307
+ return make_shared<RegularMLExpansion<Complex>> (c, r, kappa);
308
+ }
309
+
310
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
311
+ {
312
+ mp.AddDipole(pnt, -nv, val(0));
313
+ }
314
+
315
+ void AddSourceTrans(SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
316
+ {
317
+ mp.AddCharge(pnt, val(0));
318
+ }
319
+
320
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
321
+ {
322
+ val(0) = mp.Evaluate (pnt);
323
+ }
324
+
325
+ void EvaluateMPTrans(RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
326
+ {
327
+ val(0) = mp.EvaluateDirectionalDerivative(pnt, nv);
328
+ }
329
+ };
330
+
331
+
332
+ template <int DIM> class HelmholtzSLVecKernel;
333
+
334
+ template<>
335
+ class HelmholtzSLVecKernel<3> : public BaseKernel
336
+ {
337
+ double kappa;
338
+ public:
339
+ typedef Complex value_type;
340
+ static string Name() { return "HelmholtzSLVec"; }
341
+ static auto Shape() { return IVec<2>(3,3); }
342
+
343
+ HelmholtzSLVecKernel (double _kappa) : kappa(_kappa) { }
344
+
345
+ template <typename T>
346
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
347
+ {
348
+ T norm = L2Norm(x-y);
349
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
350
+ return Vec<1,decltype(kern)> (kern);
351
+ }
352
+ double GetKappa() const { return kappa; }
353
+ Array<KernelTerm> terms =
354
+ {
355
+ KernelTerm{1.0, 0, 0, 0},
356
+ KernelTerm{1.0, 0, 1, 1},
357
+ KernelTerm{1.0, 0, 2, 2},
358
+ };
359
+
360
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
361
+ {
362
+ return make_shared<SingularMLExpansion<Vec<3,Complex>>> (c, r, kappa);
363
+ }
364
+
365
+ auto CreateLocalExpansion (Vec<3> c, double r) const
366
+ {
367
+ return make_shared<RegularMLExpansion<Vec<3,Complex>>> (c, r, kappa);
368
+ }
369
+
370
+ void AddSource (SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
371
+ {
372
+ mp.AddCharge(pnt, val);
373
+ }
374
+
375
+ void EvaluateMP (RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
376
+ {
377
+ val = mp.Evaluate (pnt);
378
+ }
379
+ };
380
+
381
+
382
+ template <int DIM> class HelmholtzHSKernel;
383
+
384
+ template<>
385
+ class HelmholtzHSKernel<3> : public BaseKernel
386
+ {
387
+ double kappa;
388
+ public:
389
+ typedef Complex value_type;
390
+ static string Name() { return "HelmholtzHS"; }
391
+ static auto Shape() { return IVec<2>(4,4); }
392
+
393
+ HelmholtzHSKernel (double _kappa) : kappa(_kappa) { }
394
+ template <typename T>
395
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
396
+ {
397
+ T norm = L2Norm(x-y);
398
+ T nxny = InnerProduct(nx, ny);
399
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
400
+ auto kernnxny = -kappa * kappa * kern * nxny;
401
+ // return kern;
402
+ return Vec<2,decltype(kern)> ({kern, kernnxny});
403
+ }
404
+ double GetKappa() const { return kappa; }
405
+ Array<KernelTerm> terms =
406
+ {
407
+ KernelTerm{1.0, 0, 0, 0},
408
+ KernelTerm{1.0, 0, 1, 1},
409
+ KernelTerm{1.0, 0, 2, 2},
410
+ KernelTerm{1.0, 1, 3, 3},
411
+ };
412
+
413
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
414
+ {
415
+ return make_shared<SingularMLExpansion<Vec<6,Complex>>> (c, r, kappa);
416
+ }
417
+
418
+ auto CreateLocalExpansion (Vec<3> c, double r) const
419
+ {
420
+ return make_shared<RegularMLExpansion<Vec<6,Complex>>> (c, r, kappa);
421
+ }
422
+
423
+ void AddSource (SingularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
424
+ {
425
+ Vec<6,Complex> charge;
426
+ charge.Range(0,3) = val.Range(0,3);
427
+ charge.Range(3,6) = -kappa * kappa * val(3) * nv;
428
+ mp.AddCharge(pnt, charge);
429
+ }
430
+
431
+ void EvaluateMP (RegularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
432
+ {
433
+ Vec<6,Complex> eval = mp.Evaluate (pnt);
434
+ val.Range(0,3) = eval.Range(0,3);
435
+ val(3) = InnerProduct(eval.Range(3,6), nv);
436
+ }
437
+ };
438
+
439
+
440
+
441
+
442
+
443
+
444
+ /** CombinedFieldKernel is a kernel for the combined field integral equation
445
+ is considered for the Helmholtz equation. */
446
+ template <int DIM> class CombinedFieldKernel;
447
+
448
+ /** CombinedFieldKernel in 3D reads
449
+ $$ G(x-y) = \frac{1}{4\,\pi} \, \frac{e^{i\,\kappa\,|x-y|}}{|x-y|^3} \,
450
+ \left( \langle n_y, x-y\rangle (1- i\,\kappa\, | x-y|) - i\,\kappa\,|x-y|^2 \right),
451
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
452
+ template<>
453
+ class CombinedFieldKernel<3> : public BaseKernel
454
+ {
455
+ double kappa;
456
+ public:
457
+ typedef Complex value_type;
458
+ static string Name() { return "Helmholtz Combined Field"; }
459
+ static auto Shape() { return IVec<2>(1,1); }
460
+
461
+ CombinedFieldKernel (double _kappa) : kappa(_kappa) { }
462
+
463
+ template <typename T>
464
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
465
+ {
466
+ T norm = L2Norm(x-y);
467
+ T nxy = InnerProduct(ny, (x-y));
468
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm*norm*norm)
469
+ * ( nxy * (Complex(1,0)*T(1.) - Complex(0,kappa)*norm) - Complex(0,kappa)*norm*norm);
470
+ // return kern;
471
+ return Vec<1,decltype(kern)> (kern);
472
+ }
473
+ double GetKappa() const { return kappa; }
474
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
475
+
476
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
477
+ {
478
+ return make_shared<SingularMLExpansion<Complex>> (c, r, kappa);
479
+ }
480
+
481
+ auto CreateLocalExpansion (Vec<3> c, double r) const
482
+ {
483
+ return make_shared<RegularMLExpansion<Complex>> (c, r, kappa);
484
+ }
485
+
486
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
487
+ {
488
+ // mp.AddCharge(pnt, Complex(0, -kappa)*val(0));
489
+ // mp.AddDipole(pnt, -nv, val(0));
490
+
491
+ mp.AddChargeDipole (pnt, Complex(0, -kappa)*val(0), -nv, val(0));
492
+ }
493
+
494
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
495
+ {
496
+ val(0) = mp.Evaluate (pnt);
497
+ }
498
+ };
499
+
500
+
501
+
502
+
503
+
504
+ template <int D> class MaxwellSLKernel;
505
+
506
+ template<>
507
+ class MaxwellSLKernel<3> : public BaseKernel
508
+ {
509
+ double kappa;
510
+ public:
511
+ typedef Complex value_type;
512
+ static string Name() { return "MaxwellSL"; }
513
+ static auto Shape() { return IVec<2>(4,4); }
514
+
515
+ MaxwellSLKernel (const MaxwellSLKernel&) = default;
516
+ MaxwellSLKernel (MaxwellSLKernel&&) = default;
517
+ MaxwellSLKernel (double _kappa) : kappa(_kappa)
518
+ {
519
+ for (size_t i = 0; i < 3; i++)
520
+ terms += KernelTerm { kappa, 0, i, i };
521
+ terms += KernelTerm { -1.0/kappa, 0, 3, 3 };
522
+ }
523
+
524
+ template <typename T>
525
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
526
+ {
527
+ T norm = L2Norm(x-y);
528
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
529
+ return Vec<1,decltype(kern)> (kern);
530
+ }
531
+ double GetKappa() const { return kappa; }
532
+ Array<KernelTerm> terms;
533
+
534
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
535
+ {
536
+ return make_shared<SingularMLExpansion<Vec<4,Complex>>> (c, r, kappa);
537
+ }
538
+
539
+ auto CreateLocalExpansion (Vec<3> c, double r) const
540
+ {
541
+ return make_shared<RegularMLExpansion<Vec<4,Complex>>> (c, r, kappa);
542
+ }
543
+
544
+ void AddSource (SingularMLExpansion<Vec<4,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
545
+ {
546
+ Vec<4,Complex> charge;
547
+ charge.Range(0,3) = kappa * val.Range(0, 3);
548
+ charge(3) = -1.0/kappa * val(3);
549
+ mp.AddCharge(pnt, charge);
550
+ }
551
+
552
+ void EvaluateMP (RegularMLExpansion<Vec<4,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
553
+ {
554
+ val = mp.Evaluate (pnt);
555
+ }
556
+ };
557
+
558
+
559
+
560
+
561
+
562
+
563
+ template <int D> class MaxwellDLKernel;
564
+
565
+ // https://weggler.github.io/ngbem/short_and_sweet/Maxwell_Formulations.html
566
+ /** MaxwellDLkernel for 3D in matrix representation reads
567
+ $$ \left( \begin{array}{ccc} 0 & -\frac{\partial G_\kappa(x-y)}{\partial x_3} & \frac{\partial G_\kappa(x-y)}{\partial x_2} \\ \frac{\partial G_\kappa(x-y)}{\partial x_3} & 0 & -\frac{\partial G_\kappa(x-y)}{\partial x_1} \\ -\frac{\partial G_\kappa(x-y)}{\partial x_2} & \frac{\partial G_\kappa(x-y)}{\partial x_1} & 0 \end{array}\right)\,,$$ with
568
+ $$ G_\kappa(x-y) = \frac{1}{4\,\pi} \, \frac{e^{i\,\kappa\,|x-y|}}{|x-y|^3} \,
569
+ \langle n(y), x-y\rangle \cdot \left( 1 - i\,\kappa\, | x-y| \right),
570
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
571
+ template<>
572
+ class MaxwellDLKernel<3> : public BaseKernel
573
+ {
574
+ double kappa;
575
+ public:
576
+ typedef Complex value_type;
577
+ static string Name() { return "MaxwellDL"; }
578
+ static auto Shape() { return IVec<2>(3,3); }
579
+
580
+ MaxwellDLKernel (double _kappa) : kappa(_kappa) { }
581
+
582
+ template <typename T>
583
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
584
+ {
585
+ T norm = L2Norm(x-y);
586
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm*norm*norm)
587
+ * (Complex(0,kappa)*norm - Complex(1,0)*T(1.)) * (x-y);
588
+ return kern;
589
+ }
590
+ double GetKappa() const { return kappa; }
591
+ Array<KernelTerm> terms =
592
+ {
593
+ KernelTerm{ 1.0, 0, 1, 2}, // factor, comp, trial, test
594
+ KernelTerm{-1.0, 0, 2, 1},
595
+ KernelTerm{ 1.0, 1, 2, 0},
596
+ KernelTerm{-1.0, 1, 0, 2},
597
+ KernelTerm{ 1.0, 2, 0, 1},
598
+ KernelTerm{-1.0, 2, 1, 0},
599
+ };
600
+
601
+ auto CreateMultipoleExpansion (Vec<3> c, double r) const
602
+ {
603
+ return make_shared<SingularMLExpansion<Vec<3,Complex>>> (c, r, kappa);
604
+ }
605
+
606
+ auto CreateLocalExpansion (Vec<3> c, double r) const
607
+ {
608
+ return make_shared<RegularMLExpansion<Vec<3,Complex>>> (c, r, kappa);
609
+ }
610
+
611
+ void AddSource (SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
612
+ {
613
+ Vec<3,Complex> n_cross_m = val.Range(0, 3);
614
+ for (int k = 0; k < 3; k++)
615
+ {
616
+ Vec<3> ek{0.0}; ek(k) = 1;
617
+ Vec<3> n_cross_m_real = Real(n_cross_m);
618
+ Vec<3> n_cross_m_imag = Imag(n_cross_m);
619
+ mp.AddDipole(pnt, Cross(n_cross_m_real, ek), ek);
620
+ mp.AddDipole(pnt, Cross(n_cross_m_imag, ek), Complex(0,1)*ek);
621
+ }
622
+ }
623
+
624
+ void AddSourceTrans(SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
625
+ {
626
+ Vec<3,Complex> n_cross_m = val.Range(0, 3);
627
+ for (int k = 0; k < 3; k++)
628
+ {
629
+ Vec<3> ek{0.0}; ek(k) = 1;
630
+ Vec<3> n_cross_m_real = Real(n_cross_m);
631
+ Vec<3> n_cross_m_imag = Imag(n_cross_m);
632
+ mp.AddDipole(pnt, Cross(n_cross_m_real, ek), ek);
633
+ mp.AddDipole(pnt, Cross(n_cross_m_imag, ek), Complex(0,1)*ek);
634
+ }
635
+ }
636
+
637
+ void EvaluateMP (RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
638
+ {
639
+ val = mp.Evaluate (pnt);
640
+ }
641
+
642
+ void EvaluateMPTrans(RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
643
+ {
644
+ val = mp.Evaluate (pnt);
645
+ }
646
+ };
647
+
648
+
649
+ }
650
+
651
+
652
+ #endif
653
+