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,10 @@
1
+ #include <bla.hpp>
2
+
3
+ namespace ngsbem
4
+ {
5
+ using namespace ngbla;
6
+
7
+ NGS_DLL_HEADER double LaplaceSL_Triangle (Vec<3> a, Vec<3> b, Vec<3> c, Vec<3> x);
8
+ NGS_DLL_HEADER double LaplaceDL_Triangle (Vec<3> a, Vec<3> b, Vec<3> c, Vec<3> x);
9
+ }
10
+
@@ -106,6 +106,12 @@ namespace ngla
106
106
  Mult (v, res);
107
107
  return res;
108
108
  }
109
+ virtual AutoVector EvaluateTrans(BaseVector & v) const
110
+ {
111
+ auto res = CreateRowVector();
112
+ MultTrans (v, res);
113
+ return res;
114
+ }
109
115
 
110
116
  /// y = matrix * x.
111
117
  virtual void Mult (const BaseVector & x, BaseVector & y) const;
@@ -229,6 +229,26 @@ namespace ngfem
229
229
  Cast(fel).CalcMappedDShape (mip, Trans(mat));
230
230
  }
231
231
 
232
+
233
+ static int DimRef() { return D-1; }
234
+
235
+ template <typename IP, typename MAT>
236
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
237
+ MAT && mat, LocalHeap & lh)
238
+ {
239
+ Cast(fel).CalcDShape (ip, Trans(mat));
240
+ }
241
+
242
+ template <typename MIP, typename MAT>
243
+ static void CalcTransformationMatrix (const MIP & mip,
244
+ MAT & mat, LocalHeap & lh)
245
+ {
246
+ mat = Trans(static_cast<const MappedIntegrationPoint<D-1,D>&>(mip).GetJacobianInverse());
247
+ }
248
+
249
+
250
+
251
+
232
252
  static void GenerateMatrixSIMDIR (const FiniteElement & fel,
233
253
  const SIMD_BaseMappedIntegrationRule & mir,
234
254
  BareSliceMatrix<SIMD<double>> mat)
@@ -2324,6 +2344,39 @@ namespace ngfem
2324
2344
  mat.Rows(DIM_SPC*i, DIM_SPC*(i+1)).Cols(fel.GetRange(i)) = Trans(hmat);
2325
2345
  }
2326
2346
 
2347
+ static int DimRef() { return DIM_SPC*DIM_ELEMENT; }
2348
+
2349
+ template <typename IP, typename MAT>
2350
+ static void GenerateMatrixRef (const FiniteElement & bfel, const IP & ip,
2351
+ MAT && mat, LocalHeap & lh)
2352
+ {
2353
+ HeapReset hr(lh);
2354
+ auto & fel = static_cast<const VectorFiniteElement&> (bfel);
2355
+ auto & feli = static_cast<const ScalarFiniteElement<DIM_ELEMENT>&> (fel[0]);
2356
+ FlatMatrix<> hmat(feli.GetNDof(), DIM_ELEMENT, lh);
2357
+ feli.CalcDShape(ip, hmat);
2358
+ int ndof = feli.GetNDof();
2359
+ mat.Rows(DIM_SPACE*DIM_ELEMENT).Cols(DIM_SPC*ndof) = 0.0;
2360
+ for (int i = 0; i < DIM_SPACE; i++)
2361
+ mat.Rows(i*DIM_ELEMENT, (i+1)*DIM_ELEMENT).Cols(i*ndof,(i+1)*ndof)
2362
+ = Trans(hmat);
2363
+ }
2364
+
2365
+ template <typename MIP, typename MAT>
2366
+ static void CalcTransformationMatrix (const MIP & mip,
2367
+ MAT & mat, LocalHeap & lh)
2368
+ {
2369
+ FlatMatrix<> hmat(DIM_SPC, DIM_ELEMENT, lh);
2370
+ hmat = Trans(static_cast<const MappedIntegrationPoint<DIM_ELEMENT,DIM_SPC>&>(mip).GetJacobianInverse());
2371
+ mat.Rows(DIM_DMAT).Cols(DIM_ELEMENT*DIM_SPC) = 0.0;
2372
+ for (int i = 0; i < DIM_SPACE; i++)
2373
+ mat.Rows(i*DIM_SPC, (i+1)*DIM_SPC).Cols(i*DIM_ELEMENT, (i+1)*DIM_ELEMENT) = hmat;
2374
+ }
2375
+
2376
+
2377
+
2378
+
2379
+
2327
2380
 
2328
2381
  static void GenerateMatrixSIMDIR (const FiniteElement & bfel,
2329
2382
  const SIMD_BaseMappedIntegrationRule & mir,
@@ -2730,9 +2783,11 @@ namespace ngfem
2730
2783
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradVectorH1<2> >;
2731
2784
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradVectorH1<3> >;
2732
2785
 
2786
+ extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradientBoundary<1> >;
2733
2787
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradientBoundary<2> >;
2734
2788
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradientBoundary<3> >;
2735
2789
 
2790
+ extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradBoundaryVectorH1<1> >;
2736
2791
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradBoundaryVectorH1<2> >;
2737
2792
  extern template class NGS_DLL_HEADER T_DifferentialOperator<DiffOpGradBoundaryVectorH1<3> >;
2738
2793
 
@@ -0,0 +1,475 @@
1
+ #ifndef DIFFOPS_HPP
2
+ #define DIFFOPS_HPP
3
+
4
+ #include <bla.hpp>
5
+ #include <scalarfe.hpp>
6
+ #include <hcurlfe.hpp>
7
+ #include <hdivfe.hpp>
8
+ #include <diffop_impl.hpp>
9
+
10
+
11
+ namespace ngsbem
12
+ {
13
+ using namespace ngbla;
14
+ using namespace ngfem;
15
+
16
+
17
+ class DiffOpBoundaryRot : public DiffOp<DiffOpBoundaryRot>
18
+ {
19
+ public:
20
+ enum { DIM = 1 };
21
+ enum { DIM_SPACE = 3 };
22
+ enum { DIM_ELEMENT = 2 };
23
+ enum { DIM_DMAT = 3 };
24
+ enum { DIFFORDER = 1 };
25
+
26
+ static bool SupportsVB (VorB checkvb) { return checkvb==BND; }
27
+
28
+ static string Name() { return "boundaryrot"; }
29
+
30
+ static const ScalarFiniteElement<2> & Cast (const FiniteElement & fel)
31
+ { return static_cast<const ScalarFiniteElement<2>&> (fel); }
32
+
33
+ ///
34
+ // mat is 3 x ndof
35
+ template <typename AFEL, typename MIP, typename MAT>
36
+ static void GenerateMatrix (const AFEL & fel, const MIP & mip,
37
+ MAT & mat, LocalHeap & lh)
38
+ {
39
+ Cast(fel).CalcMappedDShape (mip, Trans(mat));
40
+ for (int i = 0; i < fel.GetNDof(); i++)
41
+ {
42
+ Vec<3> grad = mat.Col(i);
43
+ mat.Col(i) = Cross(mip.GetNV(), grad);
44
+ }
45
+ }
46
+
47
+ static int DimRef() { return 2; }
48
+
49
+ template <typename IP, typename MAT>
50
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
51
+ MAT && mat, LocalHeap & lh)
52
+ {
53
+ Cast(fel).CalcDShape (ip, Trans(mat));
54
+ }
55
+
56
+ template <typename MIP, typename MAT>
57
+ static void CalcTransformationMatrix (const MIP & bmip,
58
+ MAT & mat, LocalHeap & lh)
59
+ {
60
+ auto & mip = static_cast<const MappedIntegrationPoint<2,3>&>(bmip);
61
+ Vec<3> nv = mip.GetNV();
62
+ mat = Trans(mip.GetJacobianInverse());
63
+
64
+ for (int j = 0; j < 2; j++)
65
+ mat.Col(j) = Cross(nv, Vec<3> (mat.Col(j)));
66
+ }
67
+
68
+
69
+ /// mat is (ndof*3) x mip.Size()
70
+ static void GenerateMatrixSIMDIR (const FiniteElement & fel,
71
+ const SIMD_BaseMappedIntegrationRule & mir,
72
+ BareSliceMatrix<SIMD<double>> mat)
73
+ {
74
+ Cast(fel).CalcMappedDShape (mir, mat);
75
+
76
+ for (int j = 0; j < mir.Size(); j++)
77
+ {
78
+ Vec<3,SIMD<double>> nv = static_cast<const SIMD<ngfem::MappedIntegrationPoint<3,3>>&>(mir[j]).GetNV();
79
+ for (int i = 0; i < fel.GetNDof(); i++)
80
+ {
81
+ Vec<3,SIMD<double>> grad = mat.Col(j).Range(3*i, 3*i+3);
82
+ mat.Col(j).Range(3*i,3*i+3) = Cross(nv, grad);
83
+ }
84
+ }
85
+ }
86
+ };
87
+
88
+
89
+
90
+
91
+ class DiffOpRotatedTrace : public DiffOp<DiffOpRotatedTrace>
92
+ {
93
+ public:
94
+ enum { DIM = 1 };
95
+ enum { DIM_SPACE = 3 };
96
+ enum { DIM_ELEMENT = 2 };
97
+ enum { DIM_DMAT = 3 };
98
+ enum { DIFFORDER = 1 };
99
+
100
+ static string Name() { return "rotatedtrace"; }
101
+ static int DimRef() { return 2; }
102
+
103
+ static const HCurlFiniteElement<2> & Cast (const FiniteElement & fel)
104
+ { return static_cast<const HCurlFiniteElement<2>&> (fel); }
105
+
106
+ // mat is 2 x ndof
107
+ template <typename IP, typename MAT>
108
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
109
+ MAT && mat, LocalHeap & lh)
110
+ {
111
+ Cast(fel).CalcShape (ip, Trans(mat));
112
+ }
113
+
114
+ ///
115
+ // mat is 3 x ndof
116
+ template <typename AFEL, typename MIP, typename MAT>
117
+ static void GenerateMatrix (const AFEL & fel, const MIP & mip,
118
+ MAT & mat, LocalHeap & lh)
119
+ {
120
+ Cast(fel).CalcMappedShape (mip, Trans(mat));
121
+ for (int i = 0; i < fel.GetNDof(); i++)
122
+ {
123
+ Vec<3> shape = mat.Col(i);
124
+ mat.Col(i) = Cross(mip.GetNV(), shape);
125
+ }
126
+ }
127
+
128
+ // mat is 3 x 2
129
+ template <typename MIP, typename MAT>
130
+ static void CalcTransformationMatrix (const MIP & bmip,
131
+ MAT & mat, LocalHeap & lh)
132
+ {
133
+ auto & mip = static_cast<const MappedIntegrationPoint<2,3>&>(bmip);
134
+ Vec<3> nv = mip.GetNV();
135
+ mat = Trans(mip.GetJacobianInverse());
136
+
137
+ for (int j = 0; j < 2; j++)
138
+ mat.Col(j) = Cross(nv, Vec<3> (mat.Col(j)));
139
+ }
140
+
141
+ /// mat is (ndof*3) x mip.Size()
142
+ static void GenerateMatrixSIMDIR (const FiniteElement & fel,
143
+ const SIMD_BaseMappedIntegrationRule & mir,
144
+ BareSliceMatrix<SIMD<double>> mat)
145
+ {
146
+ Cast(fel).CalcMappedShape (mir, mat);
147
+
148
+ for (int j = 0; j < mir.Size(); j++)
149
+ {
150
+ Vec<3,SIMD<double>> nv = static_cast<const SIMD<ngfem::MappedIntegrationPoint<2,3>>&>(mir[j]).GetNV();
151
+ for (int i = 0; i < fel.GetNDof(); i++)
152
+ {
153
+ Vec<3,SIMD<double>> shape = mat.Col(j).Range(3*i, 3*i+3);
154
+ mat.Col(j).Range(3*i,3*i+3) = Cross(nv, shape);
155
+ }
156
+ }
157
+ }
158
+ };
159
+
160
+ // rotated + scalar
161
+ class DiffOpHelmholtz : public DiffOp<DiffOpHelmholtz>
162
+ {
163
+ public:
164
+ enum { DIM = 1 };
165
+ enum { DIM_SPACE = 3 };
166
+ enum { DIM_ELEMENT = 2 };
167
+ enum { DIM_DMAT = 4 };
168
+ enum { DIFFORDER = 1 };
169
+
170
+ static string Name() { return "Helmholtz"; }
171
+ static int DimRef() { return 3; }
172
+
173
+ static const ScalarFiniteElement<2> & Cast (const FiniteElement & fel)
174
+ { return static_cast<const ScalarFiniteElement<2>&> (fel); }
175
+
176
+ // mat is 3xndof
177
+ template <typename IP, typename MAT>
178
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
179
+ MAT && mat, LocalHeap & lh)
180
+ {
181
+ auto matvec = mat.Rows(0,2);
182
+ Cast(fel).CalcDShape (ip, Trans(matvec));
183
+ Cast(fel).CalcShape(ip, mat.Row(2));
184
+ }
185
+
186
+ ///
187
+ // mat is 4 x ndof
188
+ template <typename AFEL, typename MIP, typename MAT>
189
+ static void GenerateMatrix (const AFEL & fel, const MIP & mip,
190
+ MAT & mat, LocalHeap & lh)
191
+ {
192
+ // mat.AddSize(4, fel.GetNDof()) = 0.0;
193
+ auto matvec = mat.Rows(0,3);
194
+ Cast(fel).CalcMappedDShape (mip, Trans(matvec));
195
+ for (int i = 0; i < fel.GetNDof(); i++)
196
+ {
197
+ Vec<3> grad = matvec.Col(i);
198
+ matvec.Col(i) = Cross(mip.GetNV(), grad);
199
+ }
200
+ // *testout << "mat1 = " << mat << endl;
201
+ // mat.AddSize(4, fel.GetNDof()) = 0.0;
202
+ Cast(fel).CalcShape(mip.IP(), mat.Row(3));
203
+ // *testout << "scalar mat = " << endl << mat << mat;
204
+ // *testout << "mat2 = " << mat << endl;
205
+ }
206
+
207
+ // mat is 4x3
208
+ template <typename MIP, typename MAT>
209
+ static void CalcTransformationMatrix (const MIP & bmip,
210
+ MAT & mat, LocalHeap & lh)
211
+ {
212
+ auto & mip = static_cast<const MappedIntegrationPoint<2,3>&>(bmip);
213
+ Vec<3> nv = mip.GetNV();
214
+ mat = 0.0;
215
+ mat.Rows(0,3).Cols(0,2) = Trans(mip.GetJacobianInverse());
216
+ auto gradmat = mat.Rows(0,3).Cols(0,2);
217
+ for (int j = 0; j < 2; j++)
218
+ gradmat.Col(j) = Cross(nv, Vec<3> (gradmat.Col(j)));
219
+
220
+ mat(3,2) = 1.0;
221
+ }
222
+
223
+ /// mat is (ndof*4) x mip.Size()
224
+ static void GenerateMatrixSIMDIR (const FiniteElement & fel,
225
+ const SIMD_BaseMappedIntegrationRule & mir,
226
+ BareSliceMatrix<SIMD<double>> mat)
227
+ {
228
+ Cast(fel).CalcMappedDShape (mir, mat.Rows(0, 3*fel.GetNDof()));
229
+
230
+ for (int j = 0; j < mir.Size(); j++)
231
+ {
232
+ Vec<3,SIMD<double>> nv = static_cast<const SIMD<ngfem::MappedIntegrationPoint<3,3>>&>(mir[j]).GetNV();
233
+ for (int i = fel.GetNDof()-1; i >= 0; i--)
234
+ {
235
+ Vec<3,SIMD<double>> grad = mat.Col(j).Range(3*i, 3*i+3);
236
+ mat.Col(j).Range(4*i,4*i+3) = Cross(nv, grad);
237
+ }
238
+ }
239
+ // *testout << "simd mat1 = " << endl << mat.AddSize(4*fel.GetNDof(), mir.Size()) << endl;
240
+ // mat.AddSize(4*fel.GetNDof(), mir.Size()) = SIMD<double>(0.0);
241
+ Cast(fel).CalcShape (mir.IR(), mat.RowSlice(3,4));
242
+ }
243
+ };
244
+
245
+
246
+
247
+ // rotated
248
+ class DiffOpMaxwell : public DiffOp<DiffOpMaxwell>
249
+ {
250
+ public:
251
+ enum { DIM = 1 };
252
+ enum { DIM_SPACE = 3 };
253
+ enum { DIM_ELEMENT = 2 };
254
+ enum { DIM_DMAT = 4 };
255
+ enum { DIFFORDER = 1 };
256
+
257
+ static string Name() { return "Maxwell"; }
258
+ static int DimRef() { return 3; }
259
+
260
+ static const HCurlFiniteElement<2> & Cast (const FiniteElement & fel)
261
+ { return static_cast<const HCurlFiniteElement<2>&> (fel); }
262
+
263
+ // mat is 3 x ndof
264
+ template <typename IP, typename MAT>
265
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
266
+ MAT && mat, LocalHeap & lh)
267
+ {
268
+ // auto matvec = mat.Rows(0,2);
269
+ Cast(fel).CalcShape (ip, Trans(mat));
270
+ Cast(fel).CalcCurlShape(ip, Trans(mat.Rows(2,3)));
271
+ }
272
+
273
+ ///
274
+ // mat is 4 x ndof
275
+ template <typename AFEL, typename MIP, typename MAT>
276
+ static void GenerateMatrix (const AFEL & fel, const MIP & mip,
277
+ MAT & mat, LocalHeap & lh)
278
+ {
279
+ // mat.AddSize(4, fel.GetNDof()) = 0.0;
280
+ auto matvec = mat.Rows(0,3);
281
+ Cast(fel).CalcMappedShape (mip, Trans(matvec));
282
+ for (int i = 0; i < fel.GetNDof(); i++)
283
+ {
284
+ Vec<3> shape = matvec.Col(i);
285
+ matvec.Col(i) = Cross(mip.GetNV(), shape);
286
+ }
287
+ // *testout << "mat1 = " << mat << endl;
288
+ // mat.AddSize(4, fel.GetNDof()) = 0.0;
289
+ mat.Row(3) =
290
+ 1.0/mip.GetJacobiDet() *
291
+ Cast(fel).GetCurlShape(mip.IP(),lh).Col(0);
292
+ // *testout << "scalar mat = " << endl << mat << mat;
293
+ // *testout << "mat2 = " << mat << endl;
294
+ }
295
+
296
+ // mat is 4x3
297
+ template <typename MIP, typename MAT>
298
+ static void CalcTransformationMatrix (const MIP & bmip,
299
+ MAT & mat, LocalHeap & lh)
300
+ {
301
+ auto & mip = static_cast<const MappedIntegrationPoint<2,3>&>(bmip);
302
+ Vec<3> nv = mip.GetNV();
303
+ mat = 0.0;
304
+ mat.Rows(0,3).Cols(0,2) = Trans(mip.GetJacobianInverse());
305
+ auto matvec = mat.Rows(0,3).Cols(0,2);
306
+ for (int j = 0; j < 2; j++)
307
+ matvec.Col(j) = Cross(nv, Vec<3> (matvec.Col(j)));
308
+
309
+ mat(3,2) = 1.0 / mip.GetJacobiDet();
310
+ }
311
+
312
+ /// mat is (ndof*4) x mip.Size()
313
+ static void GenerateMatrixSIMDIR (const FiniteElement & fel,
314
+ const SIMD_BaseMappedIntegrationRule & mir,
315
+ BareSliceMatrix<SIMD<double>> mat)
316
+ {
317
+ Cast(fel).CalcMappedShape (mir, mat.Rows(0, 3*fel.GetNDof()));
318
+ for (int j = 0; j < mir.Size(); j++)
319
+ {
320
+ Vec<3,SIMD<double>> nv = static_cast<const SIMD<ngfem::MappedIntegrationPoint<2,3>>&>(mir[j]).GetNV();
321
+ for (int i = fel.GetNDof()-1; i >= 0; i--)
322
+ {
323
+ Vec<3,SIMD<double>> shape = mat.Col(j).Range(3*i, 3*i+3);
324
+ mat.Col(j).Range(4*i,4*i+3) = Cross(nv, shape);
325
+ // mat.Col(j).Range(4*i+3,4*i+4) = SIMD<double>(0.0);
326
+ }
327
+ }
328
+ // *testout << "simd mat1 = " << endl << mat.AddSize(4*fel.GetNDof(), mir.Size()) << endl;
329
+ // mat.AddSize(4*fel.GetNDof(), mir.Size()) = SIMD<double>(0.0);
330
+
331
+ constexpr size_t BS=16;
332
+ LocalHeapMem<BS*SIMD<double>::Size()*sizeof(SIMD<MappedIntegrationPoint<2,2>>)+64> lh("genmatlh");
333
+ FE_ElementTransformation<2,2> trafo2d(fel.ElementType());
334
+ for (size_t first = 0; first < mir.Size(); first += BS)
335
+ {
336
+ HeapReset hr(lh);
337
+ size_t next = std::min(first+BS, mir.Size());
338
+ SIMD_MappedIntegrationRule<2,2> mir2d(mir.IR().Range(first, next), trafo2d, lh);
339
+ Cast(fel).CalcMappedCurlShape (mir2d, mat.RowSlice(3,4).Cols(first, next));
340
+ }
341
+ for (size_t i = 0; i < mir.Size(); i++)
342
+ mat.Col(i).Slice(3,4).Range(fel.GetNDof()) *= 1.0 / mir[i].GetJacobiDet();
343
+ // *testout << "simd mat2 = " << endl << mat.AddSize(4*fel.GetNDof(), mir.Size()) << endl;
344
+ }
345
+
346
+ using DiffOp<DiffOpMaxwell>::ApplySIMDIR;
347
+ static void ApplySIMDIR (const FiniteElement & fel, const SIMD_BaseMappedIntegrationRule & mir,
348
+ BareSliceVector<Complex> x, BareSliceMatrix<SIMD<Complex>> y)
349
+ {
350
+ Cast(fel).Evaluate (mir, x, y.Rows(3));
351
+ for (int j = 0; j < mir.Size(); j++)
352
+ {
353
+ Vec<3,SIMD<double>> nv = static_cast<const SIMD<ngfem::MappedIntegrationPoint<2,3>>&>(mir[j]).GetNV();
354
+ Vec<3,SIMD<Complex>> shape = y.Col(j).Range(0,3);
355
+ y.Col(j).Range(0,3) = Cross(nv, shape);
356
+ }
357
+ y.Row(3).Range(mir.Size()) = SIMD<Complex>(0.0);
358
+ // TODO: curl part
359
+ }
360
+ };
361
+
362
+
363
+
364
+
365
+
366
+
367
+ // copied from ngsolve/fem/hdiv_equations.hpp, DiffOpIdHDivSurface
368
+ class DiffOpMaxwellNew : public DiffOp<DiffOpMaxwellNew>
369
+ {
370
+ public:
371
+ enum { DIM = 1 };
372
+ enum { DIM_SPACE = 3 };
373
+ enum { DIM_ELEMENT = 2 };
374
+ enum { DIM_DMAT = 4 };
375
+ enum { DIFFORDER = 1 };
376
+
377
+ static string Name() { return "Maxwell"; }
378
+ static int DimRef() { return 3; }
379
+
380
+ static const HDivFiniteElement<2> & Cast (const FiniteElement & fel)
381
+ { return static_cast<const HDivFiniteElement<2>&> (fel); }
382
+
383
+ // mat is 3xndof
384
+ template<typename IP, typename MAT>
385
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
386
+ MAT && mat, LocalHeap & lh)
387
+ {
388
+ auto matvec = mat.Rows(0,2); // 2D vector field
389
+ Cast(fel).CalcShape (ip, Trans(matvec));
390
+ Cast(fel).CalcDivShape (ip, mat.Row(2)); //divergence
391
+ }
392
+
393
+ ///
394
+ // mat is 4 x ndof
395
+ template <typename AFEL, typename MIP, typename MAT>
396
+ static void GenerateMatrix (const AFEL & fel, const MIP & mip,
397
+ MAT & mat, LocalHeap & lh)
398
+ {
399
+ auto matvec = mat.Rows(0,3);
400
+ matvec = (1.0 / mip.GetJacobiDet()) *mip.GetJacobian () *
401
+ Trans (Cast(fel).GetShape(mip.IP(),lh));
402
+
403
+ mat.Row(3) =
404
+ 1.0/mip.GetJacobiDet() *
405
+ Cast(fel).GetDivShape(mip.IP(),lh).Col(0);
406
+ }
407
+
408
+ // mat is 4x3
409
+ template <typename MIP, typename MAT>
410
+ static void CalcTransformationMatrix (const MIP & bmip,
411
+ MAT & mat, LocalHeap & lh)
412
+ {
413
+ auto & mip = static_cast<const MappedIntegrationPoint<2,3>&>(bmip);
414
+ mat = 0.0;
415
+ mat.Rows(0,3).Cols(0,2) = (1.0 / mip.GetJacobiDet()) * mip.GetJacobian();
416
+ mat(3,2) = 1.0 / mip.GetJacobiDet();
417
+ }
418
+
419
+ /// mat is (ndof*4) x mip.Size()
420
+ static void GenerateMatrixSIMDIR (const FiniteElement & fel,
421
+ const SIMD_BaseMappedIntegrationRule & mir,
422
+ BareSliceMatrix<SIMD<double>> mat)
423
+ {
424
+ Cast(fel).CalcMappedShape (mir, mat.Rows(0, 3*fel.GetNDof()));
425
+ for (int j = 0; j < mir.Size(); j++)
426
+ {
427
+ for (int i = fel.GetNDof()-1; i >= 0; i--)
428
+ {
429
+ Vec<3,SIMD<double>> shape = mat.Col(j).Range(3*i, 3*i+3);
430
+ mat.Col(j).Range(4*i,4*i+3) = shape;
431
+ }
432
+ }
433
+
434
+ Cast(fel).CalcMappedDivShape (mir, mat.RowSlice(3, 4));
435
+ /*
436
+ constexpr size_t BS=16;
437
+ LocalHeapMem<BS*SIMD<double>::Size()*sizeof(SIMD<MappedIntegrationPoint<2,2>>)+64> lh("genmatlh");
438
+ FE_ElementTransformation<2,2> trafo2d(fel.ElementType());
439
+ for (size_t first = 0; first < mir.Size(); first += BS)
440
+ {
441
+ HeapReset hr(lh);
442
+ size_t next = std::min(first+BS, mir.Size());
443
+ SIMD_MappedIntegrationRule<2,2> mir2d(mir.IR().Range(first, next), trafo2d, lh);
444
+ Cast(fel).CalcMappedDivShape (mir2d, mat.RowSlice(3,4).Cols(first, next));
445
+ }
446
+ for (size_t i = 0; i < mir.Size(); i++)
447
+ mat.Col(i).Slice(3,4).Range(fel.GetNDof()) *= 1.0 / mir[i].GetJacobiDet();
448
+ */
449
+ }
450
+
451
+ using DiffOp<DiffOpMaxwellNew>::ApplySIMDIR;
452
+ static void ApplySIMDIR (const FiniteElement & fel, const SIMD_BaseMappedIntegrationRule & mir,
453
+ BareSliceVector<Complex> x, BareSliceMatrix<SIMD<Complex>> y)
454
+ {
455
+ Vector<> xr(fel.GetNDof()), xi(fel.GetNDof());
456
+ Matrix<SIMD<double>> valr(3,mir.Size()), vali(3, mir.Size());
457
+
458
+ xr = Real(x);
459
+ xi = Imag(x);
460
+ Cast(fel).Evaluate (mir, xr, valr);
461
+ Cast(fel).Evaluate (mir, xi, vali);
462
+
463
+ for (int j = 0; j < mir.Size(); j++)
464
+ for (int k = 0; k < 3; k ++)
465
+ y(k,j) = SIMD<Complex> (valr(k,j), vali(k,j));
466
+ y.Row(3).Range(mir.Size()) = SIMD<Complex>(0.0);
467
+ }
468
+ };
469
+
470
+
471
+
472
+ }
473
+
474
+
475
+ #endif
@@ -915,7 +915,7 @@ namespace ngcomp
915
915
  };
916
916
 
917
917
 
918
-
918
+ // template <int DIM_ELEMENT, int DIM_SPACE>
919
919
  class ApplyIntegrationPoints : public BaseMatrix
920
920
  {
921
921
  Array<shared_ptr<CoefficientFunction>> coefs;
@@ -952,6 +952,9 @@ namespace ngcomp
952
952
  size_t GetDimX() const { return dimx; }
953
953
  size_t GetDimY() const { return dimy; }
954
954
  size_t GetNIP() const { return nip; }
955
+
956
+ FlatMatrix<double> GetPoints() const { return points; }
957
+ FlatMatrix<double> GetNormals() const { return normals; }
955
958
  };
956
959
 
957
960
 
@@ -13,6 +13,7 @@ namespace ngstd
13
13
 
14
14
  class BSpline
15
15
  {
16
+ shared_ptr<BSpline> diff = nullptr;
16
17
  int order;
17
18
  Array<double> t;
18
19
  Array<double> c;
@@ -48,6 +49,7 @@ namespace ngstd
48
49
  NGS_DLL_HEADER SIMD<double> operator() (SIMD<double> x) const;
49
50
  // NGS_DLL_HEADER SIMD<Complex> operator() (SIMD<Complex> x) const;
50
51
 
52
+ int GetOrder() const { return order; }
51
53
  friend ostream & operator<< (ostream & ost, const BSpline & sp);
52
54
  };
53
55
 
@@ -57,7 +57,7 @@ namespace ngfem
57
57
 
58
58
  string pointer;
59
59
 
60
- NGS_DLL_HEADER string AddPointer(const void *p );
60
+ NGS_DLL_HEADER string AddPointer(const void *p, string name = "", string type = "void *", string qualifiers = "");
61
61
 
62
62
  void AddLinkFlag(string flag);
63
63
 
@@ -287,7 +287,7 @@ namespace ngfem
287
287
  }
288
288
 
289
289
  std::filesystem::path CreateTempDir();
290
- unique_ptr<SharedLibrary> CompileCode(const std::vector<std::variant<filesystem::path, string>> &codes, const std::vector<string> &link_flags, bool keep_files = false );
290
+ unique_ptr<SharedLibrary> CompileCode(const std::vector<std::variant<filesystem::path, string>> &codes, const std::vector<string> &link_flags, bool keep_files = false, optional<string> compiler = nullopt, optional<string> linker = nullopt);
291
291
  namespace detail {
292
292
  string GenerateL2ElementCode(int order);
293
293
  }
@@ -1,15 +1,17 @@
1
1
  #ifndef COMPLEX_WRAPPER
2
2
  #define COMPLEX_WRAPPER
3
3
 
4
+
5
+
4
6
  #include <complex>
5
7
 
8
+
6
9
  #ifdef USE_MYCOMPLEX
7
10
  #include <mycomplex.hpp>
8
11
  #endif
9
12
 
10
13
 
11
14
 
12
-
13
15
  // #ifdef __clang__
14
16
  #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
15
17
  namespace std
@@ -25,18 +27,44 @@ namespace std
25
27
 
26
28
 
27
29
 
30
+
28
31
  namespace ngcore
29
32
  {
33
+
30
34
  #ifdef USE_MYCOMPLEX
31
35
  typedef ngstd::MyComplex<double> Complex;
32
36
  using std::fabs;
33
- inline double fabs (Complex v) { return ngstd::abs (v); }
37
+ INLINE double fabs (Complex v) { return ngstd::abs (v); }
34
38
  #else
35
39
  typedef std::complex<double> Complex;
36
40
  using std::fabs;
37
41
  inline double fabs (Complex v) { return std::abs (v); }
38
42
  #endif
43
+
44
+ }
45
+
46
+
47
+ #if defined(__CUDA_ARCH__)
48
+ namespace ngcore
49
+ {
50
+ __device__ inline Complex conj(Complex a)
51
+ {
52
+ return Complex (a.real(), -a.imag());
53
+ }
54
+
55
+ __device__ inline Complex operator+ (Complex a, Complex b) {
56
+ return Complex(a.real()+b.real(), a.imag()+b.imag());
57
+ }
58
+ __device__ inline Complex& operator+= (Complex& a, Complex b) {
59
+ a = a+b;
60
+ return a;
61
+ }
39
62
  }
63
+ #endif
64
+
65
+
66
+
67
+
40
68
 
41
69
 
42
70