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
@@ -76,7 +76,7 @@ INLINE const T arg(const MyComplex<T> &A)
76
76
  }
77
77
 
78
78
  template <class T>
79
- const MyComplex<T> conj(const MyComplex<T> &A)
79
+ INLINE const MyComplex<T> conj(const MyComplex<T> &A)
80
80
  {
81
81
  return MyComplex<T>(A.a, -A.b);
82
82
  }
netgen/include/ngblas.hpp CHANGED
@@ -412,10 +412,10 @@ namespace ngbla
412
412
 
413
413
 
414
414
  template <bool ADD, bool POS, ORDERING orda, ORDERING ordb>
415
- void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double> c);
415
+ INLINE void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double> c);
416
416
 
417
417
  template <bool ADD, bool POS, ORDERING orda, ORDERING ordb>
418
- void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double,ColMajor> c);
418
+ INLINE void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double,ColMajor> c);
419
419
 
420
420
 
421
421
 
@@ -428,7 +428,7 @@ namespace ngbla
428
428
  // t t C += A*B
429
429
 
430
430
  template <bool ADD, bool POS, ORDERING orda, ORDERING ordb>
431
- inline void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double> c)
431
+ INLINE void NgGEMM (SliceMatrix<double,orda> a, SliceMatrix<double, ordb> b, SliceMatrix<double> c)
432
432
  {
433
433
  // static Timer t("generic MM, add/pos/ord="+ToString(ADD)+ToString(POS)+ToString(orda)+ToString(ordb));
434
434
  // RegionTimer r(t);
@@ -584,12 +584,31 @@ namespace ngbla
584
584
  }
585
585
  }
586
586
 
587
- template <typename TM, typename TVX, typename TVY>
588
- extern void TestFunc (TM m, TVX x, TVY y);
589
-
587
+ // template <typename TM, typename TVX, typename TVY>
588
+ // extern void TestFunc (TM m, TVX x, TVY y);
589
+
590
+
591
+ template <typename TS, typename T> constexpr bool IsVec = false;
592
+ template <typename TS, int S> constexpr bool IsVec<TS, Vec<S,TS>> = true;
593
+
590
594
  template <bool ADD, bool POS, typename TM, ORDERING ORD, typename TX, typename TY>
591
595
  INLINE void NgGEMV (BareSliceMatrix<TM,ORD> a, FlatVector<const TX> x, FlatVector<TY> y)
592
596
  {
597
+ if constexpr (std::is_same<TM,double>() && std::is_same<TX,TY>() && IsVec<Complex,TX>)
598
+ {
599
+ FlatMatrix<double> mx(x.Size(), sizeof(TX)/sizeof(double), (double*)(void*)x.Addr(0));
600
+ FlatMatrix<double> my(y.Size(), sizeof(TX)/sizeof(double), (double*)(void*)y.Addr(0));
601
+ NgGEMM<ADD,POS> (a.AddSize(y.Size(), x.Size()),make_SliceMatrix(mx), make_SliceMatrix(my));
602
+ return;
603
+ }
604
+ if constexpr (std::is_same<TM,Complex>() && std::is_same<TX,TY>() && IsVec<Complex,TX>)
605
+ {
606
+ FlatMatrix<Complex> mx(x.Size(), sizeof(TX)/sizeof(Complex), &const_cast<Complex&>(*(x.Data()->Data())));
607
+ FlatMatrix<Complex> my(y.Size(), sizeof(TX)/sizeof(Complex), y.Data()->Data());
608
+ NgGEMM<ADD,POS> (a.AddSize(y.Size(), x.Size()),make_SliceMatrix(mx), make_SliceMatrix(my));
609
+ return;
610
+ }
611
+
593
612
  if (!ADD)
594
613
  {
595
614
  if (!POS)
@@ -635,6 +654,16 @@ namespace ngbla
635
654
  extern NGS_DLL_HEADER
636
655
  void NgGEMV (double s, BareSliceMatrix<double,ord> a, SliceVector<double> x, SliceVector<double> y) NETGEN_NOEXCEPT;
637
656
  */
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+ /* *********************** GEMV - SliceVector **************************** */
665
+
666
+
638
667
 
639
668
  template <bool ADD, ORDERING ord>
640
669
  extern NGS_DLL_HEADER
@@ -714,7 +743,30 @@ namespace ngbla
714
743
  }
715
744
 
716
745
 
717
-
746
+
747
+
748
+ template <bool ADD, bool POS, typename TM, ORDERING ORD, typename TX, typename TY>
749
+ INLINE void NgGEMV (BareSliceMatrix<TM,ORD> a, SliceVector<TX> x, SliceVector<TY> y)
750
+ {
751
+ if constexpr (std::is_same<TM,double>() && std::is_same<TX,TY>() && IsVec<Complex,TX>)
752
+ {
753
+ constexpr int VS = sizeof(TX)/sizeof(double);
754
+ SliceMatrix<double> mx(x.Size(), VS, x.Dist()*VS, (double*)(void*)x.Addr(0));
755
+ SliceMatrix<double> my(y.Size(), VS, y.Dist()*VS, (double*)(void*)y.Addr(0));
756
+ NgGEMM<ADD,POS> (a.AddSize(y.Size(), x.Size()),make_SliceMatrix(mx), make_SliceMatrix(my));
757
+ return;
758
+ }
759
+ else if constexpr (std::is_same<TM,Complex>() && std::is_same<TX,TY>() && IsVec<Complex,TX>)
760
+ {
761
+ constexpr int VS = sizeof(TX)/sizeof(Complex);
762
+ SliceMatrix<Complex> mx(x.Size(), VS, x.Dist()*VS, &const_cast<Complex&>(*(x.Data()->Data())));
763
+ SliceMatrix<Complex> my(y.Size(), VS, y.Dist()*VS, y.Data()->Data());
764
+ NgGEMM<ADD,POS> (a.AddSize(y.Size(), x.Size()),make_SliceMatrix(mx), make_SliceMatrix(my));
765
+ return;
766
+ }
767
+ else
768
+ NgGEMV<ADD> (POS ? 1.0 : -1.0, a, x, y);
769
+ }
718
770
 
719
771
 
720
772
 
@@ -880,9 +932,14 @@ namespace ngbla
880
932
  FlatVector<const TB>(prod.View().B().Range(0,w)),
881
933
  FlatVector<T>(self.Spec().Range(0,h)));
882
934
  else
935
+ NgGEMV<ADD,POS> (make_BareSliceMatrix(prod.View().A()),
936
+ SliceVector<TB>(prod.View().B().Range(0,w)),
937
+ SliceVector<T>(self.Spec().Range(0,h)));
938
+ /*
883
939
  NgGEMV<ADD> (POS ? 1.0 : -1.0, make_BareSliceMatrix(prod.View().A()),
884
940
  SliceVector<TB>(prod.View().B().Range(0,w)),
885
941
  SliceVector<T>(self.Spec().Range(0,h)));
942
+ */
886
943
  return self.Spec();
887
944
  }
888
945
  };
@@ -1099,8 +1156,60 @@ namespace ngbla
1099
1156
  }
1100
1157
  };
1101
1158
 
1159
+ // typedef void (*pmatmatcRR)(size_t, size_t, BareSliceMatrix<Complex,RowMajor>, BareSliceMatrix<Complex,RowMajor>,BareSliceMatrix<Complex,RowMajor>);
1160
+
1161
+ template <ORDERING OA, ORDERING OB>
1162
+ using pmatmatc = void (*)(size_t, size_t, BareSliceMatrix<Complex, OA>, BareSliceMatrix<Complex,OB>,BareSliceMatrix<Complex,RowMajor>);
1163
+ template <bool ADD, bool POS, ORDERING OA, ORDERING OB>
1164
+ extern NGS_DLL_HEADER pmatmatc<OA,OB> dispatch_matmatc[9];
1165
+
1166
+ template <bool ADD, bool POS, ORDERING OA, ORDERING OB>
1167
+ extern NGS_DLL_HEADER void NgGEMMBare (size_t ah, size_t aw, size_t bw, BareSliceMatrix<Complex,OA> a, BareSliceMatrix<Complex,OB> b, BareSliceMatrix<Complex,RowMajor> c);
1102
1168
 
1103
1169
 
1170
+ template <bool ADD, bool POS, ORDERING OA, ORDERING OB>
1171
+ void NgGEMM (SliceMatrix<Complex,OA> a, SliceMatrix<Complex,OB> b, SliceMatrix<Complex,RowMajor> c)
1172
+ {
1173
+ size_t ah = a.Height();
1174
+ size_t aw = a.Width();
1175
+ size_t bw = b.Width();
1176
+ if (aw < std::size(dispatch_matmatc<ADD,POS,OA,OB>))
1177
+ {
1178
+ (*dispatch_matmatc<ADD,POS,OA,OB>[aw])(ah, bw, make_BareSliceMatrix(a), make_BareSliceMatrix(b), make_BareSliceMatrix(c));
1179
+ return;
1180
+ }
1181
+
1182
+ NgGEMMBare<ADD,POS>(ah, aw, bw, make_BareSliceMatrix(a), make_BareSliceMatrix(b), make_BareSliceMatrix(c));
1183
+ }
1184
+
1185
+ template <bool ADD, bool POS, ORDERING OA, ORDERING OB>
1186
+ void NgGEMM (SliceMatrix<Complex,OA> a, SliceMatrix<Complex,OB> b, SliceMatrix<Complex,ColMajor> c)
1187
+ {
1188
+ NgGEMM<ADD,POS> (Trans(b), Trans(a), Trans(c));
1189
+ }
1190
+
1191
+ template <typename OP, typename T, typename TA, typename TB>
1192
+ class assign_trait<OP, T, MultExpr<TA, TB>,
1193
+ enable_if_t<IsConvertibleToSliceMatrix<TA,Complex>() &&
1194
+ IsConvertibleToSliceMatrix<TB,Complex>() &&
1195
+ IsConvertibleToSliceMatrix<T,Complex>(), int>>
1196
+ {
1197
+ public:
1198
+ static inline T & Assign (MatExpr<T> & self, const Expr<MultExpr<TA, TB>> & prod)
1199
+ {
1200
+ constexpr bool ADD = std::is_same<OP,typename MatExpr<T>::AsAdd>::value || std::is_same<OP,typename MatExpr<T>::AsSub>::value;
1201
+ constexpr bool POS = std::is_same<OP,typename MatExpr<T>::As>::value || std::is_same<OP,typename MatExpr<T>::AsAdd>::value;
1202
+
1203
+ size_t n = CombinedSize(prod.View().A().Height(), self.Spec().Height());
1204
+ size_t m = CombinedSize(prod.View().B().Width(), self.Spec().Width());
1205
+ size_t k = CombinedSize(prod.View().A().Width(), prod.View().B().Height());
1206
+
1207
+ NgGEMM<ADD,POS> (make_BareSliceMatrix(prod.View().A()).AddSize(n,k).RemoveConst(),
1208
+ make_BareSliceMatrix(prod.View().B()).AddSize(k,m).RemoveConst(),
1209
+ make_BareSliceMatrix(self.Spec()).AddSize(n,m));
1210
+ return self.Spec();
1211
+ }
1212
+ };
1104
1213
 
1105
1214
 
1106
1215
 
@@ -0,0 +1,22 @@
1
+ #ifndef FILE_POTENTIALS
2
+ #define FILE_POTENTIALS
3
+
4
+ /*
5
+ tools for computing with potentials using multipoles
6
+ */
7
+
8
+
9
+ #include <mptools.hpp>
10
+ #include <meshaccess.hpp>
11
+
12
+
13
+ namespace ngsbem
14
+ {
15
+
16
+ extern void AddChargeDensity (SingularMLExpansion<Complex> & mp, shared_ptr<CoefficientFunction> current, ngcomp::Region reg);
17
+
18
+ extern void AddCurrentDensity (SingularMLExpansion<Vec<3,Complex>> & mp, shared_ptr<CoefficientFunction> current, ngcomp::Region reg);
19
+
20
+ }
21
+
22
+ #endif
@@ -99,12 +99,12 @@ namespace ngcomp
99
99
  virtual void InitLevel (shared_ptr<BitArray> freedofs = NULL) { ; }
100
100
  virtual void FinalizeLevel (const ngla::BaseMatrix * mat = NULL) { ; }
101
101
  virtual void AddElementMatrix (FlatArray<int> dnums,
102
- const FlatMatrix<double> & elmat,
102
+ FlatMatrix<double> elmat,
103
103
  ElementId ei,
104
104
  LocalHeap & lh) { ; }
105
105
 
106
106
  virtual void AddElementMatrix (FlatArray<int> dnums,
107
- const FlatMatrix<Complex> & elmat,
107
+ FlatMatrix<Complex> elmat,
108
108
  ElementId ei,
109
109
  LocalHeap & lh) { ; }
110
110
 
@@ -186,12 +186,12 @@ namespace ngcomp
186
186
  static DocInfo GetDocu ();
187
187
 
188
188
  ///
189
- virtual bool IsComplex() const { return jacobi->IsComplex(); }
189
+ virtual bool IsComplex() const override { return jacobi->IsComplex(); }
190
190
 
191
191
  ///
192
- virtual void FinalizeLevel (const BaseMatrix * mat);
192
+ virtual void FinalizeLevel (const BaseMatrix * mat) override;
193
193
 
194
- virtual void Update ()
194
+ virtual void Update () override
195
195
  {
196
196
  if (GetTimeStamp() < bfa->GetTimeStamp())
197
197
  FinalizeLevel (&bfa->GetMatrix());
@@ -201,14 +201,14 @@ namespace ngcomp
201
201
 
202
202
 
203
203
  ///
204
- virtual const BaseMatrix & GetMatrix() const
204
+ virtual const BaseMatrix & GetMatrix() const override
205
205
  {
206
206
  if (!jacobi)
207
207
  ThrowPreconditionerNotReady();
208
208
  return *jacobi;
209
209
  }
210
210
 
211
- virtual shared_ptr<BaseMatrix> GetMatrixPtr()
211
+ virtual shared_ptr<BaseMatrix> GetMatrixPtr() override
212
212
  {
213
213
  if (!jacobi)
214
214
  ThrowPreconditionerNotReady();
@@ -216,12 +216,12 @@ namespace ngcomp
216
216
  }
217
217
 
218
218
  ///
219
- virtual const BaseMatrix & GetAMatrix() const
219
+ virtual const BaseMatrix & GetAMatrix() const override
220
220
  {
221
221
  return bfa->GetMatrix();
222
222
  }
223
223
  ///
224
- virtual const char * ClassName() const
224
+ virtual const char * ClassName() const override
225
225
  { return "Local Preconditioner"; }
226
226
  void LocPrecTest () const;
227
227
  };
@@ -258,29 +258,29 @@ namespace ngcomp
258
258
  ; // delete pre;
259
259
  }
260
260
 
261
- virtual void InitLevel (shared_ptr<BitArray> _freedofs);
261
+ virtual void InitLevel (shared_ptr<BitArray> _freedofs) override;
262
262
 
263
- virtual void FinalizeLevel (const BaseMatrix *);
263
+ virtual void FinalizeLevel (const BaseMatrix *) override;
264
264
  virtual void AddElementMatrix (FlatArray<int> dnums,
265
- const FlatMatrix<SCAL> & elmat,
265
+ FlatMatrix<SCAL> elmat,
266
266
  ElementId id,
267
- LocalHeap & lh);
267
+ LocalHeap & lh) override;
268
268
 
269
- virtual void Update ()
269
+ virtual void Update () override
270
270
  {
271
271
  if (timestamp < bfa->GetTimeStamp())
272
272
  throw Exception("A BDDC preconditioner must be defined before assembling");
273
273
  }
274
274
 
275
- virtual const BaseMatrix & GetAMatrix() const
275
+ virtual const BaseMatrix & GetAMatrix() const override
276
276
  {
277
277
  return bfa->GetMatrix();
278
278
  }
279
279
 
280
- virtual const BaseMatrix & GetMatrix() const;
281
- virtual shared_ptr<BaseMatrix> GetMatrixPtr();
280
+ virtual const BaseMatrix & GetMatrix() const override;
281
+ virtual shared_ptr<BaseMatrix> GetMatrixPtr() override;
282
282
 
283
- virtual void CleanUpLevel ()
283
+ virtual void CleanUpLevel () override
284
284
  {
285
285
  /*
286
286
  delete pre;
@@ -290,10 +290,10 @@ namespace ngcomp
290
290
  }
291
291
 
292
292
 
293
- virtual void Mult (const BaseVector & x, BaseVector & y) const;
294
- virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const;
293
+ virtual void Mult (const BaseVector & x, BaseVector & y) const override;
294
+ virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const override;
295
295
 
296
- virtual const char * ClassName() const
296
+ virtual const char * ClassName() const override
297
297
  { return "BDDC Preconditioner"; }
298
298
  };
299
299
 
@@ -414,7 +414,7 @@ namespace ngcomp
414
414
  ///
415
415
  // MGPreconditioner * low_order_preconditioner;
416
416
  ///
417
- shared_ptr<Preconditioner> coarse_pre;
417
+ shared_ptr<BaseMatrix> coarse_pre;
418
418
  ///
419
419
  int finesmoothingsteps;
420
420
  ///
@@ -462,7 +462,7 @@ namespace ngcomp
462
462
  void MgTest () const;
463
463
 
464
464
  void SetDirectSolverCluster(shared_ptr<Array<int>> cluster);
465
- void SetCoarsePreconditioner(shared_ptr<Preconditioner> prec);
465
+ void SetCoarsePreconditioner(shared_ptr<BaseMatrix> prec);
466
466
  };
467
467
 
468
468
  class CommutingAMGPreconditioner : public Preconditioner
@@ -67,6 +67,11 @@ namespace ngmg
67
67
  y = tmp.Range(0, VWidth());
68
68
  }
69
69
 
70
+ shared_ptr<BaseSparseMatrix> CreateSparseMatrix() const override
71
+ {
72
+ return prol->CreateProlongationMatrix(level);
73
+ }
74
+
70
75
  AutoVector CreateRowVector() const override { return make_unique<VVector<double>> (VWidth()); }
71
76
  AutoVector CreateColVector() const override { return make_unique<VVector<double>> (VHeight()); }
72
77
  };
@@ -219,9 +224,7 @@ namespace ngmg
219
224
  }
220
225
 
221
226
  ///
222
- virtual shared_ptr<SparseMatrix< double >> CreateProlongationMatrix( int finelevel ) const override
223
- { return NULL; }
224
-
227
+ shared_ptr<SparseMatrix< double >> CreateProlongationMatrix( int finelevel ) const override;
225
228
 
226
229
  ///
227
230
  virtual void ProlongateInline (int finelevel, BaseVector & v) const override;
@@ -233,12 +236,14 @@ namespace ngmg
233
236
  class NGS_DLL_HEADER HarmonicProlongation : public Prolongation
234
237
  {
235
238
  shared_ptr<Prolongation> baseprol;
236
- shared_ptr<BilinearForm> bfa;
239
+ weak_ptr<BilinearForm> wbfa;
237
240
  Array<shared_ptr<BaseMatrix>> innerinverses;
238
- Array<size_t> edges_on_level;
241
+ Array<size_t> facets_on_level;
242
+ Array<shared_ptr<BitArray>> freedofs;
243
+ string inverse;
239
244
  public:
240
245
  HarmonicProlongation (shared_ptr<Prolongation> abaseprol,
241
- shared_ptr<BilinearForm> abfa);
246
+ shared_ptr<BilinearForm> abfa, string ainverse);
242
247
 
243
248
  virtual void Update (const FESpace & fes) override;
244
249
 
@@ -248,6 +253,127 @@ namespace ngmg
248
253
  virtual void ProlongateInline (int finelevel, BaseVector & v) const override;
249
254
  virtual void RestrictInline (int finelevel, BaseVector & v) const override;
250
255
  };
256
+
257
+
258
+
259
+
260
+
261
+ template <int DIM>
262
+ class FacetProlongation : public Prolongation
263
+ {
264
+ protected:
265
+ shared_ptr<MeshAccess> ma;
266
+
267
+ int dofs_per_facet = -1;
268
+ Array<Array<int>> first_dofs;
269
+ Array<int> prol_class; // which prol to use ?
270
+ Array<size_t> facets_on_level;
271
+
272
+ static constexpr int NUMPROL = (DIM==2) ? 2 : 32;
273
+ array<Matrix<double>,NUMPROL> facetprol;
274
+
275
+ bool haveprols = false;
276
+
277
+ public:
278
+ FacetProlongation (shared_ptr<MeshAccess> ama)
279
+ : ma(ama) { }
280
+
281
+
282
+ virtual shared_ptr<SparseMatrix< double >> CreateProlongationMatrix( int finelevel ) const override
283
+ {
284
+ return nullptr; // or NULL ?
285
+ }
286
+
287
+
288
+ virtual void ProlongateInline (int finelevel, BaseVector & v) const override
289
+ {
290
+ auto fv = v.FV<double>();
291
+ Matrix<double> tmp(facets_on_level[finelevel], dofs_per_facet);
292
+ tmp = 0.0;
293
+
294
+ for (size_t i = 0; i < first_dofs[finelevel-1].Size()-1; i++)
295
+ {
296
+ IntRange r(first_dofs[finelevel-1][i], first_dofs[finelevel-1][i+1]);
297
+ if (r.Size() > 0)
298
+ tmp.Row(i) = fv.Range(r);
299
+ }
300
+
301
+ if constexpr (DIM==2)
302
+ {
303
+ for (int i = facets_on_level[finelevel-1]; i < facets_on_level[finelevel]; i++)
304
+ if (auto parents = get<1>(ma->GetParentEdges(i)); parents[1] == -1)
305
+ {
306
+ int pe = parents[0];
307
+ tmp.Row(i) = facetprol[prol_class[i]] * tmp.Row(pe);
308
+ }
309
+ }
310
+ else
311
+ {
312
+ for (int i = facets_on_level[finelevel-1]; i < facets_on_level[finelevel]; i++)
313
+ if (auto parents = get<1>(ma->GetParentFaces(i)); parents[1] == -1)
314
+ {
315
+ int pe = parents[0];
316
+ tmp.Row(i) = facetprol[prol_class[i]] * tmp.Row(pe);
317
+ }
318
+ }
319
+
320
+ for (size_t i = 0; i < first_dofs[finelevel].Size()-1; i++)
321
+ {
322
+ IntRange r(first_dofs[finelevel][i], first_dofs[finelevel][i+1]);
323
+ if (r.Size() > 0)
324
+ fv.Range(r) = tmp.Row(i);
325
+ }
326
+ }
327
+
328
+ virtual void RestrictInline (int finelevel, BaseVector & v) const override
329
+ {
330
+ auto fv = v.FV<double>();
331
+ Matrix<double> tmp(facets_on_level[finelevel], dofs_per_facet);
332
+ tmp = 0.0;
333
+
334
+ for (size_t i = 0; i < first_dofs[finelevel].Size()-1; i++)
335
+ {
336
+ IntRange r(first_dofs[finelevel][i], first_dofs[finelevel][i+1]);
337
+ if (r.Size() > 0)
338
+ tmp.Row(i) = fv.Range(r);
339
+ }
340
+
341
+
342
+ if constexpr (DIM==2)
343
+ {
344
+ for (int i = facets_on_level[finelevel-1]; i < facets_on_level[finelevel]; i++)
345
+ if (auto parents = get<1>(ma->GetParentEdges(i)); parents[1] == -1)
346
+ {
347
+ int pe = parents[0];
348
+ tmp.Row(pe) += Trans(facetprol[prol_class[i]]) * tmp.Row(i);
349
+ }
350
+ }
351
+ else
352
+ {
353
+ // for (int i = facets_on_level[finelevel-1]; i < facets_on_level[finelevel]; i++)
354
+ for (int i = facets_on_level[finelevel]-1; i >= facets_on_level[finelevel-1]; i--)
355
+ if (auto parents = get<1>(ma->GetParentFaces(i)); parents[1] == -1)
356
+ {
357
+ int pe = parents[0];
358
+ tmp.Row(pe) += Trans(facetprol[prol_class[i]]) * tmp.Row(i);
359
+ tmp.Row(i) = 0.0; // optional, for testing
360
+ }
361
+ }
362
+
363
+ fv = 0.0;
364
+ for (size_t i = 0; i < first_dofs[finelevel-1].Size()-1; i++)
365
+ {
366
+ IntRange r(first_dofs[finelevel-1][i], first_dofs[finelevel-1][i+1]);
367
+ if (r.Size() > 0)
368
+ fv.Range(r) = tmp.Row(i);
369
+ }
370
+
371
+ }
372
+
373
+ };
374
+
375
+
376
+
251
377
  }
252
378
 
253
379
 
@@ -1507,9 +1507,24 @@ namespace ngfem
1507
1507
  class NormalizedLegendreFunctions : public RecursivePolynomialNonStatic<NormalizedLegendreFunctions>
1508
1508
  {
1509
1509
  int m;
1510
+ static Matrix<double,ColMajor> matA, matB;
1510
1511
  public:
1511
1512
  NormalizedLegendreFunctions (size_t _m) : m(_m) { }
1512
1513
 
1514
+
1515
+ static void Calc(int mmax)
1516
+ {
1517
+ if (matA.Height() >= mmax+1) return;
1518
+ matA.SetSize(mmax+1, mmax+1);
1519
+ matB.SetSize(mmax+1, mmax+1);
1520
+ for (int m = 0; m <= mmax; m++)
1521
+ for (int n = m+2; n <= mmax; n++)
1522
+ {
1523
+ matA(n,m) = (2*n-1) / sqrt((n-m+0.0)*(n+m));
1524
+ matB(n,m) = sqrt((n+m-1.0)*(n-m-1.0)) / sqrt((n-m+0.0)*(n+m));
1525
+ }
1526
+ }
1527
+
1513
1528
  template <typename T, typename S>
1514
1529
  NormalizedLegendreFunctions (size_t mmax, size_t nmax, T x, S && values)
1515
1530
  {
@@ -1524,23 +1539,60 @@ namespace ngfem
1524
1539
  auto y = Trans(values);
1525
1540
 
1526
1541
  y = 0.0;
1527
- double u = -sqrt((1-x)*(1+x));
1542
+ T u = -sqrt((1-x)*(1+x));
1528
1543
  y(0,0)=1;
1529
-
1530
- for (double m = 0; m <= mmax; m++)
1544
+
1545
+ if (mmax+1 > matA.Height() || nmax > matA.Width())
1546
+ {
1547
+ for (int m = 0; m <= mmax; m++)
1548
+ {
1549
+ if (m > 0)
1550
+ y(m,m)=y(m-1,m-1)*u*sqrt((2*m-1.0)/(2*m));
1551
+ if (m < nmax)
1552
+ y(m+1,m)=x*y(m,m)*sqrt(2*m+1.0);
1553
+ for (int n = m+2; n <= nmax; n++)
1554
+ y(n,m)=((2*n-1)*x*y(n-1,m) -
1555
+ sqrt((n+m-1.0)*(n-m-1.0))*y(n-2,m))
1556
+ /sqrt((n-m+0.0)*(n+m));
1557
+ }
1558
+ }
1559
+ else
1531
1560
  {
1532
- if (m > 0)
1533
- y(m,m)=y(m-1,m-1)*u*sqrt((2*m-1.0)/(2*m));
1534
- if (m < nmax)
1535
- y(m+1,m)=x*y(m,m)*sqrt(2*m+1.0);
1536
- for (int n = m+2; n <= nmax; n++)
1537
- y(n,m)=((2*n-1)*x*y(n-1,m) -
1538
- sqrt((n+m-1.0)*(n-m-1.0))*y(n-2,m))
1539
- /sqrt((n-m+0.0)*(n+m));
1561
+ for (int m = 0; m <= mmax; m++)
1562
+ {
1563
+ if (m > 0)
1564
+ y(m,m)=y(m-1,m-1)*u*sqrt((2*m-1.0)/(2*m));
1565
+ if (m < nmax)
1566
+ {
1567
+ T valold = y(m,m);
1568
+
1569
+ T val = x*valold*sqrt(2*m+1.0);
1570
+ y(m+1,m)=val;
1571
+
1572
+ auto coefsA = matA.Col(m);
1573
+ auto coefsB = matB.Col(m);
1574
+
1575
+ for (int n = m+2; n <= nmax; n++)
1576
+ {
1577
+ T valnew = coefsA(n) * x * val - coefsB(n) * valold;
1578
+ y(n,m) = valnew;
1579
+ valold = val;
1580
+ val = valnew;
1581
+ }
1582
+ }
1583
+ /*
1584
+ for (int n = m+2; n <= nmax; n++)
1585
+ y(n,m) = matA(n,m) * x * y(n-1,m) - matB(n,m) * y(n-2,m);
1586
+ */
1587
+ }
1540
1588
  }
1589
+
1541
1590
  for (int n = 0; n <= nmax; n++)
1591
+ y.Row(n).Range(0,n+1) *= sqrt(2*n+1.0);
1592
+ /*
1542
1593
  for (int m = 0; m <= n; m++)
1543
1594
  y(n,m)=y(n,m)*sqrt(2*n+1.0);
1595
+ */
1544
1596
  }
1545
1597
 
1546
1598
  template <class S>
@@ -56,6 +56,17 @@ namespace ngcore
56
56
  auto & imag() { return im; }
57
57
 
58
58
 
59
+ auto Lo() const
60
+ {
61
+ if constexpr (N == 2) return Complex(re.Lo(), im.Lo());
62
+ else return SIMD<Complex,N/2> (re.Lo(), im.Lo());
63
+ }
64
+ auto Hi() const
65
+ {
66
+ if constexpr (N == 2) return Complex(re.Hi(), im.Hi());
67
+ else return SIMD<Complex,N/2> (re.Hi(), im.Hi());
68
+ }
69
+
59
70
  // Numbers in SIMD structure are not necessarily in same order as in memory
60
71
  // for instance:
61
72
  // [x0,y0,x1,y1,x2,y2,x3,y3] -> [x0,x2,x1,x3,y0,y2,y1,y3]
@@ -266,6 +277,40 @@ namespace ngcore
266
277
  return SIMD<Complex, N> (IfPos (a.real(), b.real(), c.real()),
267
278
  IfPos (a.real(), b.imag(), c.imag()));
268
279
  }
280
+
281
+
282
+ template <int N>
283
+ INLINE SIMD<Complex, N> If (SIMD<mask64, N> a, SIMD<Complex, N> b, SIMD<Complex, N> c)
284
+ {
285
+ return SIMD<Complex, N> (If (a, b.real(), c.real()),
286
+ If (a, b.imag(), c.imag()));
287
+ }
288
+
289
+
290
+
291
+
292
+ template <typename T, size_t S> class MakeSimdCl;
293
+
294
+ template <size_t S>
295
+ class MakeSimdCl<Complex,S>
296
+ {
297
+ std::array<Complex,S> a;
298
+ public:
299
+ MakeSimdCl (std::array<Complex,S> aa) : a(aa) { ; }
300
+ auto Get() const
301
+ {
302
+ std::array<double,S> ar, ai;
303
+ for (int j = 0; j < S; j++)
304
+ {
305
+ ar[j] = ngbla::Real(a[j]);
306
+ ai[j] = ngbla::Imag(a[j]);
307
+ }
308
+
309
+ return SIMD<Complex,S> (MakeSimd(ar), MakeSimd(ai));
310
+ }
311
+ };
312
+
313
+
269
314
  }
270
315
 
271
316
 
@@ -28,10 +28,14 @@ namespace ngla
28
28
 
29
29
  public:
30
30
  SparseFactorization (shared_ptr<const BaseSparseMatrix> amatrix,
31
- shared_ptr<BitArray> ainner,
32
- shared_ptr<const Array<int>> acluster);
31
+ shared_ptr<BitArray> ainner = nullptr,
32
+ shared_ptr<const Array<int>> acluster = nullptr);
33
33
  SparseFactorization() {}
34
34
 
35
+ virtual void SetSubset
36
+ (shared_ptr<BitArray> ainner,
37
+ shared_ptr<const Array<int>> acluster=nullptr);
38
+
35
39
  void DoArchive(Archive& ar) override;
36
40
 
37
41
  // virtual bool IsComplex() const override { return matrix.lock()->IsComplex(); }