ngsolve 6.2.2502__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 (107) 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/blockjacobi.hpp +17 -5
  7. netgen/include/bspline.hpp +2 -0
  8. netgen/include/cholesky.hpp +2 -2
  9. netgen/include/code_generation.hpp +2 -2
  10. netgen/include/complex_wrapper.hpp +30 -2
  11. netgen/include/contact.hpp +8 -0
  12. netgen/include/diagonalmatrix.hpp +6 -0
  13. netgen/include/diffop_impl.hpp +3 -1
  14. netgen/include/diffopwithfactor.hpp +123 -0
  15. netgen/include/elementbyelement.hpp +9 -3
  16. netgen/include/expr.hpp +45 -7
  17. netgen/include/fespace.hpp +12 -4
  18. netgen/include/gridfunction.hpp +3 -3
  19. netgen/include/h1amg.hpp +85 -2
  20. netgen/include/h1lumping.hpp +6 -0
  21. netgen/include/hcurl_equations.hpp +29 -0
  22. netgen/include/hcurlcurlfe.hpp +20 -0
  23. netgen/include/hdiv_equations.hpp +15 -0
  24. netgen/include/hdivfe_utils.hpp +1 -0
  25. netgen/include/hdivhofespace.hpp +2 -0
  26. netgen/include/integrator.hpp +4 -16
  27. netgen/include/intrule.hpp +2 -1
  28. netgen/include/intrules_SauterSchwab.hpp +25 -0
  29. netgen/include/jacobi.hpp +35 -18
  30. netgen/include/kernels.hpp +724 -0
  31. netgen/include/l2hofe.hpp +1 -0
  32. netgen/include/matrix.hpp +8 -3
  33. netgen/include/meshaccess.hpp +4 -3
  34. netgen/include/mp_coefficient.hpp +145 -0
  35. netgen/include/mptools.hpp +1331 -368
  36. netgen/include/mycomplex.hpp +1 -1
  37. netgen/include/ngblas.hpp +116 -7
  38. netgen/include/potentialtools.hpp +22 -0
  39. netgen/include/preconditioner.hpp +23 -23
  40. netgen/include/prolongation.hpp +132 -6
  41. netgen/include/recursive_pol.hpp +63 -11
  42. netgen/include/simd_complex.hpp +45 -0
  43. netgen/include/sparsecholesky.hpp +6 -2
  44. netgen/include/sparsefactorization_interface.hpp +159 -0
  45. netgen/include/sparsematrix.hpp +21 -7
  46. netgen/include/sparsematrix_dyn.hpp +6 -7
  47. netgen/include/sparsematrix_impl.hpp +175 -40
  48. netgen/include/special_matrix.hpp +2 -0
  49. netgen/include/statushandler.hpp +8 -8
  50. netgen/include/symbolicintegrator.hpp +2 -1
  51. netgen/include/tangentialfacetfespace.hpp +7 -22
  52. netgen/include/thdivfe_impl.hpp +66 -0
  53. netgen/include/tscalarfe.hpp +1 -1
  54. netgen/include/vector.hpp +272 -47
  55. netgen/lib/libngsolve.lib +0 -0
  56. netgen/libngsolve.dll +0 -0
  57. netgen/ngscxx.bat +1 -1
  58. netgen/ngsld.bat +1 -1
  59. ngsolve/__init__.py +1 -0
  60. ngsolve/cmake/NGSolveConfig.cmake +8 -8
  61. ngsolve/cmake/ngsolve-targets.cmake +24 -18
  62. ngsolve/config/config.py +7 -7
  63. ngsolve/demos/intro/cmagnet.py +19 -22
  64. ngsolve/directsolvers.py +9 -21
  65. ngsolve/krylovspace.py +172 -3
  66. ngsolve/ngslib.lib +0 -0
  67. ngsolve/ngslib.pyd +0 -0
  68. ngsolve/nonlinearsolvers.py +2 -2
  69. ngsolve/preconditioners.py +1 -0
  70. ngsolve/solve_implementation.py +168 -0
  71. ngsolve/{solvers.py → solvers/__init__.py} +1 -1
  72. ngsolve/solvers/cudss.py +112 -0
  73. ngsolve/webgui.py +2 -0
  74. {ngsolve-6.2.2502.dist-info → ngsolve-6.2.2601.dist-info}/METADATA +2 -2
  75. {ngsolve-6.2.2502.dist-info → ngsolve-6.2.2601.dist-info}/RECORD +107 -97
  76. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/Scripts/ngsolve.tcl +0 -0
  77. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.geo +0 -0
  78. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.vol +0 -0
  79. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.in2d +0 -0
  80. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.vol +0 -0
  81. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.geo +0 -0
  82. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.vol +0 -0
  83. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.geo +0 -0
  84. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.vol +0 -0
  85. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.geo +0 -0
  86. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.vol +0 -0
  87. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -0
  88. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d11_chip_nitsche.pde +0 -0
  89. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d1_square.pde +0 -0
  90. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d2_chip.pde +0 -0
  91. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d3_helmholtz.pde +0 -0
  92. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d4_cube.pde +0 -0
  93. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d5_beam.pde +0 -0
  94. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d6_shaft.pde +0 -0
  95. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d7_coil.pde +0 -0
  96. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d8_coilshield.pde +0 -0
  97. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d9_hybridDG.pde +0 -0
  98. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.in2d +0 -0
  99. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.vol +0 -0
  100. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  101. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.geo +0 -0
  102. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.vol +0 -0
  103. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.in2d +0 -0
  104. {ngsolve-6.2.2502.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.vol +0 -0
  105. {ngsolve-6.2.2502.dist-info → ngsolve-6.2.2601.dist-info}/LICENSE +0 -0
  106. {ngsolve-6.2.2502.dist-info → ngsolve-6.2.2601.dist-info}/WHEEL +0 -0
  107. {ngsolve-6.2.2502.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
 
@@ -9,6 +9,7 @@
9
9
 
10
10
 
11
11
  #include "sparsematrix.hpp"
12
+ #include "jacobi.hpp"
12
13
 
13
14
  namespace ngla
14
15
  {
@@ -16,7 +17,7 @@ namespace ngla
16
17
  /**
17
18
  Base class for Block - Jacobi and Block Gauss Seidel smoother.
18
19
  */
19
- class NGS_DLL_HEADER BaseBlockJacobiPrecond : virtual public BaseMatrix
20
+ class NGS_DLL_HEADER BaseBlockJacobiPrecond : public BaseMSMPrecond
20
21
  {
21
22
  protected:
22
23
  /// the table defining the blocks
@@ -38,6 +39,17 @@ namespace ngla
38
39
  /// deletes the table
39
40
  virtual ~BaseBlockJacobiPrecond ();
40
41
 
42
+ virtual void Smooth (BaseVector & x, const BaseVector & b, int steps = 1) const override
43
+ {
44
+ GSSmooth (x, b, steps);
45
+ }
46
+ virtual void SmoothBack (BaseVector & x, const BaseVector & b, int steps = 1) const override
47
+ {
48
+ GSSmoothBack (x, b, steps);
49
+ }
50
+
51
+
52
+
41
53
  /// performs steps Gauss-Seidel steps for the equation A x = b
42
54
  virtual void GSSmooth (BaseVector & x, const BaseVector & b,
43
55
  int steps = 1) const = 0;
@@ -101,8 +113,8 @@ namespace ngla
101
113
  The blocks are specified by a table container
102
114
  */
103
115
  template <class TM, class TV_ROW, class TV_COL>
104
- class NGS_DLL_HEADER BlockJacobiPrecond : virtual public BaseBlockJacobiPrecond,
105
- virtual public S_BaseMatrix<typename mat_traits<TM>::TSCAL>
116
+ class NGS_DLL_HEADER BlockJacobiPrecond : public BaseBlockJacobiPrecond,
117
+ public S_BaseMatrix<typename mat_traits<TM>::TSCAL>
106
118
  {
107
119
  protected:
108
120
  /// a reference to the matrix
@@ -190,8 +202,8 @@ namespace ngla
190
202
  ///
191
203
  template <class TM, class TV>
192
204
  class BlockJacobiPrecondSymmetric :
193
- virtual public BaseBlockJacobiPrecond,
194
- virtual public S_BaseMatrix<typename mat_traits<TM>::TSCAL>
205
+ public BaseBlockJacobiPrecond,
206
+ public S_BaseMatrix<typename mat_traits<TM>::TSCAL>
195
207
  {
196
208
  protected:
197
209
  shared_ptr<const SparseMatrixSymmetric<TM,TV>> mat;
@@ -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
 
@@ -503,7 +503,7 @@ namespace ngbla
503
503
 
504
504
  int n = mat.Height();
505
505
  STACK_ARRAY(T, mem, n);
506
- FlatVector<T> dinv(n, &mem);
506
+ FlatVector<T> dinv(n, &mem[0]);
507
507
 
508
508
  for (size_t i = 0; i < n; i++)
509
509
  // CalcInverse (mat(i,i), dinv(i));
@@ -528,7 +528,7 @@ namespace ngbla
528
528
  {
529
529
  size_t n = mat.Height();
530
530
  STACK_ARRAY(T,mem, n);
531
- FlatVector<T> dinv(n, &mem);
531
+ FlatVector<T> dinv(n, &mem[0]);
532
532
 
533
533
  for (size_t i = 0; i < n; i++)
534
534
  {