ngsolve 6.2.2504.post44.dev0__cp311-cp311-win_amd64.whl → 6.2.2601__cp311-cp311-win_amd64.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.
Files changed (94) hide show
  1. netgen/include/analytic_integrals.hpp +10 -0
  2. netgen/include/basematrix.hpp +6 -0
  3. netgen/include/bdbequations.hpp +55 -0
  4. netgen/include/bem_diffops.hpp +475 -0
  5. netgen/include/bilinearform.hpp +4 -1
  6. netgen/include/bspline.hpp +2 -0
  7. netgen/include/code_generation.hpp +2 -2
  8. netgen/include/complex_wrapper.hpp +30 -2
  9. netgen/include/contact.hpp +8 -0
  10. netgen/include/diagonalmatrix.hpp +6 -0
  11. netgen/include/diffop_impl.hpp +3 -1
  12. netgen/include/diffopwithfactor.hpp +123 -0
  13. netgen/include/elementbyelement.hpp +9 -3
  14. netgen/include/expr.hpp +45 -7
  15. netgen/include/fespace.hpp +9 -2
  16. netgen/include/gridfunction.hpp +3 -3
  17. netgen/include/h1amg.hpp +24 -1
  18. netgen/include/h1lumping.hpp +6 -0
  19. netgen/include/hcurl_equations.hpp +29 -0
  20. netgen/include/hcurlcurlfe.hpp +20 -0
  21. netgen/include/hdivfe_utils.hpp +1 -0
  22. netgen/include/hdivhofespace.hpp +2 -0
  23. netgen/include/kernels.hpp +724 -0
  24. netgen/include/l2hofe.hpp +1 -0
  25. netgen/include/matrix.hpp +8 -3
  26. netgen/include/meshaccess.hpp +1 -1
  27. netgen/include/mp_coefficient.hpp +24 -19
  28. netgen/include/mptools.hpp +1255 -237
  29. netgen/include/mycomplex.hpp +1 -1
  30. netgen/include/ngblas.hpp +116 -7
  31. netgen/include/potentialtools.hpp +2 -2
  32. netgen/include/preconditioner.hpp +2 -2
  33. netgen/include/prolongation.hpp +6 -3
  34. netgen/include/recursive_pol.hpp +63 -11
  35. netgen/include/simd_complex.hpp +45 -0
  36. netgen/include/sparsecholesky.hpp +6 -2
  37. netgen/include/sparsefactorization_interface.hpp +159 -0
  38. netgen/include/sparsematrix.hpp +21 -7
  39. netgen/include/sparsematrix_dyn.hpp +2 -2
  40. netgen/include/sparsematrix_impl.hpp +100 -33
  41. netgen/include/statushandler.hpp +8 -8
  42. netgen/include/thdivfe_impl.hpp +66 -0
  43. netgen/include/tscalarfe.hpp +1 -1
  44. netgen/include/vector.hpp +272 -47
  45. netgen/lib/libngsolve.lib +0 -0
  46. netgen/libngsolve.dll +0 -0
  47. netgen/ngscxx.bat +1 -1
  48. netgen/ngsld.bat +1 -1
  49. ngsolve/cmake/NGSolveConfig.cmake +8 -8
  50. ngsolve/cmake/ngsolve-targets.cmake +17 -10
  51. ngsolve/config/config.py +8 -8
  52. ngsolve/demos/intro/cmagnet.py +19 -22
  53. ngsolve/directsolvers.py +9 -21
  54. ngsolve/krylovspace.py +172 -3
  55. ngsolve/ngslib.pyd +0 -0
  56. ngsolve/nonlinearsolvers.py +2 -2
  57. ngsolve/solve_implementation.py +14 -1
  58. ngsolve/{solvers.py → solvers/__init__.py} +1 -1
  59. ngsolve/solvers/cudss.py +112 -0
  60. ngsolve/webgui.py +1 -0
  61. {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/METADATA +2 -2
  62. {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/RECORD +94 -88
  63. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/Scripts/ngsolve.tcl +0 -0
  64. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.geo +0 -0
  65. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.vol +0 -0
  66. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.in2d +0 -0
  67. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.vol +0 -0
  68. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.geo +0 -0
  69. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.vol +0 -0
  70. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.geo +0 -0
  71. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.vol +0 -0
  72. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.geo +0 -0
  73. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.vol +0 -0
  74. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -0
  75. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d11_chip_nitsche.pde +0 -0
  76. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d1_square.pde +0 -0
  77. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d2_chip.pde +0 -0
  78. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d3_helmholtz.pde +0 -0
  79. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d4_cube.pde +0 -0
  80. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d5_beam.pde +0 -0
  81. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d6_shaft.pde +0 -0
  82. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d7_coil.pde +0 -0
  83. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d8_coilshield.pde +0 -0
  84. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d9_hybridDG.pde +0 -0
  85. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.in2d +0 -0
  86. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.vol +0 -0
  87. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  88. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.geo +0 -0
  89. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.vol +0 -0
  90. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.in2d +0 -0
  91. {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.vol +0 -0
  92. {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/LICENSE +0 -0
  93. {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/WHEEL +0 -0
  94. {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,724 @@
1
+ #ifndef KERNELS_hpp
2
+ #define KERNELS_hpp
3
+
4
+ #include "mptools.hpp"
5
+ #include <type_traits>
6
+
7
+
8
+ // **************************** The kernels **********************************
9
+
10
+ namespace ngsbem
11
+ {
12
+
13
+ struct KernelTerm
14
+ {
15
+ double fac;
16
+ size_t kernel_comp;
17
+ size_t trial_comp;
18
+ size_t test_comp;
19
+ };
20
+
21
+
22
+ class BaseKernel
23
+ {
24
+ public:
25
+ shared_ptr<SingularMLExpansion<Complex>> CreateMultipoleExpansion (Vec<3> c, double r) const
26
+ {
27
+ throw Exception("Create Multipole Expansion not implemented");
28
+ }
29
+
30
+ shared_ptr<RegularMLExpansion<Complex>> CreateLocalExpansion (Vec<3> c, double r) const
31
+ {
32
+ throw Exception("Create Local Expansion not implemented");
33
+ }
34
+
35
+ template <typename TV>
36
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
37
+ {
38
+ throw Exception("Addsource not implemented");
39
+ }
40
+
41
+ template <typename entry, typename TV>
42
+ void AddSourceTrans(SingularMLExpansion<entry> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
43
+ {
44
+ throw Exception("AddSourceTrans not implemented");
45
+ }
46
+
47
+ template <typename TV>
48
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
49
+ {
50
+ throw Exception("Evaluate not implemented");
51
+ }
52
+
53
+ template <typename entry, typename TV>
54
+ void EvaluateMPTrans(RegularMLExpansion<entry> & mp, Vec<3> pnt, Vec<3> nv, const TV & val) const
55
+ {
56
+ throw Exception("EvaluateMPTrans not implemented");
57
+ }
58
+ };
59
+
60
+
61
+
62
+
63
+
64
+ /** LaplaceSLkernel is the kernel for the single layer potential of
65
+ the Laplace equation $ \Delta u = 0 \,.$ */
66
+ template <int DIM, int COMPS=1> class LaplaceSLKernel;
67
+
68
+ /** LaplaceSLkernel in 3D reads
69
+ $$ G(x-y) = \frac{1}{4\,\pi \, | x-y| }, \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
70
+ template<int COMPS>
71
+ class LaplaceSLKernel<3, COMPS> : public BaseKernel
72
+ {
73
+ public:
74
+ LaplaceSLKernel<3,COMPS>()
75
+ {
76
+ for (size_t i = 0; i < COMPS; i++)
77
+ terms += {1.0, 0, i, i};
78
+ };
79
+ typedef double value_type;
80
+ using mp_type = typename std::conditional<COMPS == 1,
81
+ Complex,
82
+ Vec<COMPS, Complex>>::type;
83
+
84
+ static string Name() { return "LaplaceSL"; }
85
+ static auto Shape() { return IVec<2>(COMPS,COMPS); }
86
+
87
+ template <typename T>
88
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
89
+ {
90
+ T norm = L2Norm(x-y);
91
+ // return 1.0 / (4 * M_PI * norm);
92
+ return Vec<1,T> (1.0 / (4 * M_PI * norm));
93
+ }
94
+
95
+ Array<KernelTerm> terms;
96
+
97
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
98
+ {
99
+ return make_shared<SingularMLExpansion<mp_type>> (c, r, 1e-16, fmm_params);
100
+ }
101
+
102
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
103
+ {
104
+ return make_shared<RegularMLExpansion<mp_type>> (c, r, 1e-16, fmm_params);
105
+ }
106
+
107
+ void AddSource (SingularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
108
+ {
109
+ if constexpr (COMPS == 1)
110
+ mp.AddCharge (pnt, val(0));
111
+ else
112
+ mp.AddCharge (pnt, val);
113
+ }
114
+
115
+ void EvaluateMP (RegularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
116
+ {
117
+ if constexpr (COMPS == 1)
118
+ val(0) = Real(mp.Evaluate (pnt));
119
+ else
120
+ val = Real(mp.Evaluate (pnt));
121
+ }
122
+ };
123
+
124
+
125
+ /** LaplaceDLkernel is the kernel for the double layer potential of
126
+ the Laplace equation $ \Delta u = 0 \,.$ */
127
+ template <int DIM, int COMPS=1> class LaplaceDLKernel;
128
+
129
+ /** LaplaceDLkernel in 3D reads
130
+ $$ \frac{\partial }{ \partial n_y} G(x-y) = \frac{1}{4\,\pi} \,
131
+ \frac{ \langle n(y), x-y\rangle }{ | x-y|^3 },
132
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
133
+ template<int COMPS>
134
+ class LaplaceDLKernel<3, COMPS> : public BaseKernel
135
+ {
136
+ public:
137
+ LaplaceDLKernel<3,COMPS>()
138
+ {
139
+ for (size_t i = 0; i < COMPS; i++)
140
+ terms += {1.0, 0, i, i};
141
+ };
142
+ typedef double value_type;
143
+ using mp_type = typename std::conditional<COMPS == 1,
144
+ Complex,
145
+ Vec<COMPS, Complex>>::type;
146
+ static string Name() { return "LaplaceDL"; }
147
+ static auto Shape() { return IVec<2>(COMPS,COMPS); }
148
+
149
+ template <typename T>
150
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
151
+ {
152
+ T norm = L2Norm(x-y);
153
+ T nxy = InnerProduct(ny, (x-y));
154
+ // return nxy / (4 * M_PI * norm*norm*norm);
155
+ return Vec<1,T> (nxy / (4 * M_PI * norm*norm*norm));
156
+ }
157
+
158
+ Array<KernelTerm> terms;
159
+
160
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
161
+ {
162
+ return make_shared<SingularMLExpansion<mp_type>> (c, r, 1e-16, fmm_params);
163
+ }
164
+
165
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
166
+ {
167
+ return make_shared<RegularMLExpansion<mp_type>> (c, r, 1e-16, fmm_params);
168
+ }
169
+
170
+ void AddSource (SingularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
171
+ {
172
+ if constexpr (COMPS == 1)
173
+ mp.AddDipole(pnt, -nv, val(0));
174
+ else
175
+ mp.AddDipole(pnt, -nv, val);
176
+ }
177
+
178
+ void AddSourceTrans(SingularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
179
+ {
180
+ if constexpr (COMPS == 1)
181
+ mp.AddCharge (pnt, val(0));
182
+ else
183
+ mp.AddCharge (pnt, val);
184
+ }
185
+
186
+ void EvaluateMP (RegularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
187
+ {
188
+ if constexpr (COMPS == 1)
189
+ val(0) = Real(mp.Evaluate (pnt));
190
+ else
191
+ val = Real(mp.Evaluate (pnt));
192
+ }
193
+
194
+ void EvaluateMPTrans(RegularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
195
+ {
196
+ if constexpr (COMPS == 1)
197
+ val(0) = Real(mp.EvaluateDirectionalDerivative(pnt, nv));
198
+ else
199
+ val = Real(mp.EvaluateDirectionalDerivative(pnt, nv));
200
+ }
201
+ };
202
+
203
+
204
+ /** HelmholtzSLkernel is the kernel for the double layer potential of the
205
+ Helmholtz equation $ -\Delta u - \kappa^2 u = 0, \; \kappa>0\,. $ */
206
+ template <int DIM, int COMPS=1> class HelmholtzSLKernel;
207
+
208
+ /** HelmholtzSLkernel in 3D reads
209
+ $$ G(x-y) = \frac{1 }{4\,\pi} \,\frac{e^{i\,\kappa \, |x-y| }{|x-y|} \,
210
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
211
+ template<int COMPS>
212
+ class HelmholtzSLKernel<3, COMPS> : public BaseKernel
213
+ {
214
+ double kappa;
215
+ public:
216
+ typedef Complex value_type;
217
+ using mp_type = typename std::conditional<COMPS == 1,
218
+ Complex,
219
+ Vec<COMPS, Complex>>::type;
220
+ static string Name() { return "HelmholtzSL"; }
221
+ static auto Shape() { return IVec<2>(COMPS,COMPS); }
222
+
223
+ /** Construction of the kernel specifies the wavenumber $\kappa$. */
224
+ HelmholtzSLKernel (double _kappa) : kappa(_kappa) {
225
+ for (size_t i = 0; i < COMPS; i++)
226
+ terms += {1.0, 0, i, i};
227
+ }
228
+
229
+ template <typename T>
230
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
231
+ {
232
+ T norm = L2Norm(x-y);
233
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
234
+ // return kern;
235
+ return Vec<1,decltype(kern)> (kern);
236
+ }
237
+ double GetKappa() const { return kappa; }
238
+ Array<KernelTerm> terms;
239
+
240
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
241
+ {
242
+ return make_shared<SingularMLExpansion<mp_type>> (c, r, kappa, fmm_params);
243
+ }
244
+
245
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
246
+ {
247
+ return make_shared<RegularMLExpansion<mp_type>> (c, r, kappa, fmm_params);
248
+ }
249
+
250
+ void AddSource (SingularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
251
+ {
252
+ if constexpr (COMPS == 1)
253
+ mp.AddCharge (pnt, val(0));
254
+ else
255
+ mp.AddCharge (pnt, val);
256
+ }
257
+
258
+ void EvaluateMP (RegularMLExpansion<mp_type> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
259
+ {
260
+ if constexpr (COMPS == 1)
261
+ val(0) = mp.Evaluate (pnt);
262
+ else
263
+ val = 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, FMM_Parameters fmm_params) const
301
+ {
302
+ return make_shared<SingularMLExpansion<Complex>> (c, r, kappa, fmm_params);
303
+ }
304
+
305
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
306
+ {
307
+ return make_shared<RegularMLExpansion<Complex>> (c, r, kappa, fmm_params);
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 HelmholtzHSKernel;
333
+
334
+ template<>
335
+ class HelmholtzHSKernel<3> : public BaseKernel
336
+ {
337
+ double kappa;
338
+ public:
339
+ typedef Complex value_type;
340
+ static string Name() { return "HelmholtzHS"; }
341
+ static auto Shape() { return IVec<2>(4,4); }
342
+
343
+ HelmholtzHSKernel (double _kappa) : kappa(_kappa) { }
344
+ template <typename T>
345
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
346
+ {
347
+ T norm = L2Norm(x-y);
348
+ T nxny = InnerProduct(nx, ny);
349
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
350
+ auto kernnxny = -kappa * kappa * kern * nxny;
351
+ // return kern;
352
+ return Vec<2,decltype(kern)> ({kern, kernnxny});
353
+ }
354
+ double GetKappa() const { return kappa; }
355
+ Array<KernelTerm> terms =
356
+ {
357
+ KernelTerm{1.0, 0, 0, 0},
358
+ KernelTerm{1.0, 0, 1, 1},
359
+ KernelTerm{1.0, 0, 2, 2},
360
+ KernelTerm{1.0, 1, 3, 3},
361
+ };
362
+
363
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
364
+ {
365
+ return make_shared<SingularMLExpansion<Vec<6,Complex>>> (c, r, kappa, fmm_params);
366
+ }
367
+
368
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
369
+ {
370
+ return make_shared<RegularMLExpansion<Vec<6,Complex>>> (c, r, kappa, fmm_params);
371
+ }
372
+
373
+ void AddSource (SingularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
374
+ {
375
+ Vec<6,Complex> charge;
376
+ charge.Range(0,3) = val.Range(0,3);
377
+ charge.Range(3,6) = -kappa * kappa * val(3) * nv;
378
+ mp.AddCharge(pnt, charge);
379
+ }
380
+
381
+ void EvaluateMP (RegularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
382
+ {
383
+ Vec<6,Complex> eval = mp.Evaluate (pnt);
384
+ val.Range(0,3) = eval.Range(0,3);
385
+ val(3) = InnerProduct(eval.Range(3,6), nv);
386
+ }
387
+ };
388
+
389
+
390
+
391
+
392
+
393
+
394
+ /** CombinedFieldKernel is a kernel for the combined field integral equation
395
+ is considered for the Helmholtz equation. */
396
+ template <int DIM> class CombinedFieldKernel;
397
+
398
+ /** CombinedFieldKernel in 3D reads
399
+ $$ G(x-y) = \frac{1}{4\,\pi} \, \frac{e^{i\,\kappa\,|x-y|}}{|x-y|^3} \,
400
+ \left( \langle n_y, x-y\rangle (1- i\,\kappa\, | x-y|) - i\,\kappa\,|x-y|^2 \right),
401
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
402
+ template<>
403
+ class CombinedFieldKernel<3> : public BaseKernel
404
+ {
405
+ double kappa;
406
+ public:
407
+ typedef Complex value_type;
408
+ static string Name() { return "Helmholtz Combined Field"; }
409
+ static auto Shape() { return IVec<2>(1,1); }
410
+
411
+ CombinedFieldKernel (double _kappa) : kappa(_kappa) { }
412
+
413
+ template <typename T>
414
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
415
+ {
416
+ T norm = L2Norm(x-y);
417
+ T nxy = InnerProduct(ny, (x-y));
418
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm*norm*norm)
419
+ * ( nxy * (Complex(1,0)*T(1.) - Complex(0,kappa)*norm) - Complex(0,kappa)*norm*norm);
420
+ // return kern;
421
+ return Vec<1,decltype(kern)> (kern);
422
+ }
423
+ double GetKappa() const { return kappa; }
424
+ Array<KernelTerm> terms = { KernelTerm{1.0, 0, 0, 0}, };
425
+
426
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
427
+ {
428
+ return make_shared<SingularMLExpansion<Complex>> (c, r, kappa, fmm_params);
429
+ }
430
+
431
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
432
+ {
433
+ return make_shared<RegularMLExpansion<Complex>> (c, r, kappa, fmm_params);
434
+ }
435
+
436
+ void AddSource (SingularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
437
+ {
438
+ // mp.AddCharge(pnt, Complex(0, -kappa)*val(0));
439
+ // mp.AddDipole(pnt, -nv, val(0));
440
+
441
+ mp.AddChargeDipole (pnt, Complex(0, -kappa)*val(0), -nv, val(0));
442
+ }
443
+
444
+ void EvaluateMP (RegularMLExpansion<Complex> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
445
+ {
446
+ val(0) = mp.Evaluate (pnt);
447
+ }
448
+ };
449
+
450
+
451
+
452
+
453
+
454
+ template <int D> class MaxwellSLKernel;
455
+
456
+ template<>
457
+ class MaxwellSLKernel<3> : public BaseKernel
458
+ {
459
+ double kappa;
460
+ public:
461
+ typedef Complex value_type;
462
+ static string Name() { return "MaxwellSL"; }
463
+ static auto Shape() { return IVec<2>(4,4); }
464
+
465
+ MaxwellSLKernel (const MaxwellSLKernel&) = default;
466
+ MaxwellSLKernel (MaxwellSLKernel&&) = default;
467
+ MaxwellSLKernel (double _kappa) : kappa(_kappa)
468
+ {
469
+ for (size_t i = 0; i < 3; i++)
470
+ terms += KernelTerm { kappa, 0, i, i };
471
+ terms += KernelTerm { -1.0/kappa, 0, 3, 3 };
472
+ }
473
+
474
+ template <typename T>
475
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
476
+ {
477
+ T norm = L2Norm(x-y);
478
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm);
479
+ return Vec<1,decltype(kern)> (kern);
480
+ }
481
+ double GetKappa() const { return kappa; }
482
+ Array<KernelTerm> terms;
483
+
484
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
485
+ {
486
+ return make_shared<SingularMLExpansion<Vec<4,Complex>>> (c, r, kappa, fmm_params);
487
+ }
488
+
489
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
490
+ {
491
+ return make_shared<RegularMLExpansion<Vec<4,Complex>>> (c, r, kappa, fmm_params);
492
+ }
493
+
494
+ void AddSource (SingularMLExpansion<Vec<4,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
495
+ {
496
+ Vec<4,Complex> charge;
497
+ charge.Range(0,3) = kappa * val.Range(0, 3);
498
+ charge(3) = -1.0/kappa * val(3);
499
+ mp.AddCharge(pnt, charge);
500
+ }
501
+
502
+ void EvaluateMP (RegularMLExpansion<Vec<4,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
503
+ {
504
+ val = mp.Evaluate (pnt);
505
+ }
506
+ };
507
+
508
+
509
+
510
+
511
+
512
+
513
+ template <int D> class MaxwellDLKernel;
514
+
515
+ // https://weggler.github.io/ngbem/short_and_sweet/Maxwell_Formulations.html
516
+ /** MaxwellDLkernel for 3D in matrix representation reads
517
+ $$ \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
518
+ $$ G_\kappa(x-y) = \frac{1}{4\,\pi} \, \frac{e^{i\,\kappa\,|x-y|}}{|x-y|^3} \,
519
+ \langle n(y), x-y\rangle \cdot \left( 1 - i\,\kappa\, | x-y| \right),
520
+ \quad x, y \in \mathbb R^3, \; x\not=y\,. $$ */
521
+ template<>
522
+ class MaxwellDLKernel<3> : public BaseKernel
523
+ {
524
+ double kappa;
525
+ public:
526
+ typedef Complex value_type;
527
+ static string Name() { return "MaxwellDL"; }
528
+ static auto Shape() { return IVec<2>(3,3); }
529
+
530
+ MaxwellDLKernel (double _kappa) : kappa(_kappa) { }
531
+
532
+ template <typename T>
533
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
534
+ {
535
+ T norm = L2Norm(x-y);
536
+ auto kern = exp(Complex(0,kappa)*norm) / (4 * M_PI * norm*norm*norm)
537
+ * (Complex(0,kappa)*norm - Complex(1,0)*T(1.)) * (x-y);
538
+ return kern;
539
+ }
540
+ double GetKappa() const { return kappa; }
541
+ Array<KernelTerm> terms =
542
+ {
543
+ KernelTerm{ 1.0, 0, 1, 2}, // factor, comp, trial, test
544
+ KernelTerm{-1.0, 0, 2, 1},
545
+ KernelTerm{ 1.0, 1, 2, 0},
546
+ KernelTerm{-1.0, 1, 0, 2},
547
+ KernelTerm{ 1.0, 2, 0, 1},
548
+ KernelTerm{-1.0, 2, 1, 0},
549
+ };
550
+
551
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
552
+ {
553
+ return make_shared<SingularMLExpansion<Vec<3,Complex>>> (c, r, kappa, fmm_params);
554
+ }
555
+
556
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
557
+ {
558
+ return make_shared<RegularMLExpansion<Vec<3,Complex>>> (c, r, kappa, fmm_params);
559
+ }
560
+
561
+ void AddSource (SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
562
+ {
563
+ Vec<3,Complex> n_cross_m = val.Range(0, 3);
564
+ for (int k = 0; k < 3; k++)
565
+ {
566
+ Vec<3> ek{0.0}; ek(k) = 1;
567
+ Vec<3> n_cross_m_real = Real(n_cross_m);
568
+ Vec<3> n_cross_m_imag = Imag(n_cross_m);
569
+ mp.AddDipole(pnt, Cross(n_cross_m_real, ek), ek);
570
+ mp.AddDipole(pnt, Cross(n_cross_m_imag, ek), Complex(0,1)*ek);
571
+ }
572
+ }
573
+
574
+ void AddSourceTrans(SingularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
575
+ {
576
+ Vec<3,Complex> n_cross_m = val.Range(0, 3);
577
+ for (int k = 0; k < 3; k++)
578
+ {
579
+ Vec<3> ek{0.0}; ek(k) = 1;
580
+ Vec<3> n_cross_m_real = Real(n_cross_m);
581
+ Vec<3> n_cross_m_imag = Imag(n_cross_m);
582
+ mp.AddDipole(pnt, Cross(n_cross_m_real, ek), ek);
583
+ mp.AddDipole(pnt, Cross(n_cross_m_imag, ek), Complex(0,1)*ek);
584
+ }
585
+ }
586
+
587
+ void EvaluateMP (RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
588
+ {
589
+ val = mp.Evaluate (pnt);
590
+ }
591
+
592
+ void EvaluateMPTrans(RegularMLExpansion<Vec<3,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<Complex> val) const
593
+ {
594
+ val = mp.Evaluate (pnt);
595
+ }
596
+ };
597
+
598
+
599
+
600
+
601
+
602
+ /*
603
+ Dissertation Guenther Of
604
+ "BETI–Gebietszerlegungsmethoden
605
+ mit schnellen Randelementverfahren
606
+ und Anwendungen"
607
+ page 85
608
+ */
609
+
610
+ template <int D> class LameSLKernel;
611
+
612
+ template<>
613
+ class LameSLKernel<3> : public BaseKernel
614
+ {
615
+ double E, nu;
616
+ double alpha;
617
+ public:
618
+ typedef double value_type;
619
+
620
+ static string Name() { return "LameSL"; }
621
+ static auto Shape() { return IVec<2>(3,3); }
622
+
623
+ LameSLKernel (const LameSLKernel&) = default;
624
+ LameSLKernel (LameSLKernel&&) = default;
625
+ LameSLKernel (double _E, double _nu) : E(_E), nu(_nu)
626
+ {
627
+ alpha = (1+nu)/((1-nu)*2*E);
628
+
629
+ terms += { 3-4*nu, 0, 0, 0 };
630
+ terms += { 3-4*nu, 0, 1, 1 };
631
+ terms += { 3-4*nu, 0, 2, 2 };
632
+
633
+ terms += { 1, 1, 0, 0 };
634
+ terms += { 1, 2, 0, 1 };
635
+ terms += { 1, 2, 1, 0 };
636
+
637
+ terms += { 1, 3, 0, 2 };
638
+ terms += { 1, 3, 2, 0 };
639
+ terms += { 1, 4, 1, 1 };
640
+
641
+ terms += { 1, 5, 1, 2 };
642
+ terms += { 1, 5, 2, 1 };
643
+ terms += { 1, 6, 2, 2 };
644
+ }
645
+
646
+ Array<KernelTerm> terms;
647
+
648
+ template <typename T>
649
+ auto Evaluate (Vec<3,T> x, Vec<3,T> y, Vec<3,T> nx, Vec<3,T> ny) const
650
+ {
651
+ T norm = L2Norm(x-y);
652
+ auto lapkern = alpha / (4 * M_PI * norm); // lapkern times factor
653
+
654
+ return Vec<7,T> { lapkern,
655
+ (x(0)-y(0))*(x(0)-y(0))/sqr(norm) * lapkern,
656
+ (x(0)-y(0))*(x(1)-y(1))/sqr(norm) * lapkern,
657
+ (x(0)-y(0))*(x(2)-y(2))/sqr(norm) * lapkern,
658
+ (x(1)-y(1))*(x(1)-y(1))/sqr(norm) * lapkern,
659
+ (x(1)-y(1))*(x(2)-y(2))/sqr(norm) * lapkern,
660
+ (x(2)-y(2))*(x(2)-y(2))/sqr(norm) * lapkern
661
+ };
662
+ }
663
+
664
+
665
+ auto CreateMultipoleExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
666
+ {
667
+ return make_shared<SingularMLExpansion<Vec<6,Complex>>> (c, r, 1e-16, fmm_params);
668
+ }
669
+
670
+ auto CreateLocalExpansion (Vec<3> c, double r, FMM_Parameters fmm_params) const
671
+ {
672
+ return make_shared<RegularMLExpansion<Vec<6,Complex>>> (c, r, 1e-16, fmm_params);
673
+ }
674
+
675
+
676
+ void AddSource (SingularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
677
+ {
678
+ Vec<6> charge = 0.0;
679
+ charge.Range(0,3) = val;
680
+ mp.AddCharge(pnt, charge); // Row 1+2
681
+
682
+ Mat<3,3> jacobi = OuterProduct(pnt, val) + InnerProduct(pnt, val) * Id<3>();
683
+
684
+ for (int k = 0; k < 3; k++)
685
+ {
686
+ Vec<6> dipole_charge = 0.0;
687
+ dipole_charge.Range(3,6) = jacobi.Col(k);
688
+
689
+ auto ek = UnitVec<3>(k);
690
+ mp.AddDipole(pnt, -ek, dipole_charge);
691
+ }
692
+ }
693
+
694
+ void EvaluateMP (RegularMLExpansion<Vec<6,Complex>> & mp, Vec<3> pnt, Vec<3> nv, BareSliceVector<double> val) const
695
+ {
696
+ Vec<6> mpval = Real(mp.Evaluate (pnt));
697
+ val.Range(0,3) = 0;
698
+ val += (3-4*nu)*alpha * mpval.Range(0,3); // Row 1
699
+
700
+ val -= alpha/2 * mpval.Range(3,6); // Row 3
701
+
702
+ // Row 2
703
+ Mat<3,3> jacobi = 0.0;
704
+ for (int k = 0; k < 3; k++)
705
+ {
706
+ auto ek = UnitVec<3>(k);
707
+ jacobi.Col(k) = Real(mp.EvaluateDirectionalDerivative(pnt, ek).Range(0,3));
708
+ }
709
+
710
+ val -= alpha/2 * ( Trans(jacobi) * pnt + Trace(jacobi) * pnt);
711
+ }
712
+ };
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+ }
721
+
722
+
723
+ #endif
724
+