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
@@ -89,6 +89,7 @@ namespace ngcomp
89
89
  shared_ptr<CoefficientFunction> cf;
90
90
  shared_ptr<FESpace> fes;
91
91
  Array<ProxyFunction*> trial_proxies;
92
+ Array<CoefficientFunction*> cf_gridfunctions;
92
93
  bool deformed;
93
94
 
94
95
  public:
@@ -123,6 +124,9 @@ namespace ngcomp
123
124
  shared_ptr<CoefficientFunction> cf;
124
125
  shared_ptr<FESpace> fes;
125
126
  Array<ProxyFunction*> trial_proxies, test_proxies;
127
+ Array<CoefficientFunction*> cf_gridfunctions;
128
+ Array<shared_ptr<CoefficientFunction>> dcf_dtest; // derivatives by test-functions
129
+ Matrix<shared_ptr<CoefficientFunction>> ddcf_dtest_dtrial; // derivatives by test- and trial-functions
126
130
  bool deformed;
127
131
  public:
128
132
  ContactIntegrator(shared_ptr<CoefficientFunction> _cf,
@@ -187,6 +191,10 @@ namespace ngcomp
187
191
  const auto& GetIntegrators(bool def) const { return def ? deformed_integrators : undeformed_integrators; }
188
192
  shared_ptr<FESpace> GetFESpace() const { return fes; }
189
193
  tuple<FlatArray<Vec<3>>, FlatArray<Vec<3>>> GetDrawingPairs() { return {primary_points, secondary_points}; }
194
+ auto GetCArgs() {
195
+ return std::make_tuple(master, other, draw_pairs, volume, element_boundary);
196
+ }
197
+ void DoArchive(Archive& ar);
190
198
  };
191
199
 
192
200
  template<int DIM>
@@ -47,6 +47,10 @@ namespace ngla
47
47
  Mult (v, res);
48
48
  return res;
49
49
  }
50
+ AutoVector EvaluateTrans(BaseVector & v) const override
51
+ {
52
+ return this->Evaluate(v);
53
+ }
50
54
 
51
55
  };
52
56
 
@@ -144,6 +148,8 @@ namespace ngla
144
148
 
145
149
  FlatTensor<3> GetBlockDiag () const { return blockdiag; }
146
150
  FlatMatrix<bool> GetNonZeroPattern() const { return nonzero; }
151
+ FlatTable<int> GetSparseMatrix() const { return sparse; }
152
+ FlatTable<int> GetSparseMatrixTrans() const { return sparseT; }
147
153
  };
148
154
 
149
155
  }
@@ -312,10 +312,12 @@ namespace ngfem
312
312
 
313
313
  template <typename DIFFOP>
314
314
  void T_DifferentialOperator<DIFFOP> ::
315
- CalcTransformationMatrix (const BaseMappedIntegrationPoint & mip,
315
+ CalcTransformationMatrix (const BaseMappedIntegrationPoint & bmip,
316
316
  SliceMatrix<double> trans,
317
317
  LocalHeap & lh) const
318
318
  {
319
+ const MappedIntegrationPoint<DIM_ELEMENT,DIM_SPACE> & mip =
320
+ static_cast<const MappedIntegrationPoint<DIM_ELEMENT,DIM_SPACE>&> (bmip);
319
321
  DIFFOP::CalcTransformationMatrix(mip, trans, lh);
320
322
  }
321
323
 
@@ -0,0 +1,123 @@
1
+ #ifndef DIFFOPWITHFACTOR_HPP
2
+ #define DIFFOPWITHFACTOR_HPP
3
+
4
+
5
+
6
+ namespace ngsbem
7
+ {
8
+ using namespace ngfem;
9
+
10
+ class DifferentialOperatorWithFactor : public DifferentialOperator
11
+ {
12
+ shared_ptr<DifferentialOperator> diffop;
13
+ shared_ptr<CoefficientFunction> factor;
14
+
15
+ public:
16
+ DifferentialOperatorWithFactor (shared_ptr<DifferentialOperator> adiffop,
17
+ shared_ptr<CoefficientFunction> afactor)
18
+ : DifferentialOperator(afactor->Dimensions()[0], 1, adiffop->VB(), adiffop->DiffOrder()),
19
+ diffop(adiffop), factor(afactor)
20
+ {
21
+ ;
22
+ }
23
+
24
+ int DimRef() const override { return diffop->DimRef(); }
25
+
26
+ virtual IntRange UsedDofs(const FiniteElement & fel) const override { return diffop->UsedDofs(fel); }
27
+
28
+ auto BaseDiffOp() const { return diffop; }
29
+
30
+ void CalcMatrix (const FiniteElement & fel,
31
+ const BaseMappedIntegrationPoint & mip,
32
+ BareSliceMatrix<double,ColMajor> mat,
33
+ LocalHeap & lh) const override
34
+ {
35
+ FlatMatrix<double,ColMajor> hmat(diffop->Dim(), fel.GetNDof(), lh);
36
+ diffop -> CalcMatrix (fel, mip, hmat, lh);
37
+
38
+ auto dims = factor->Dimensions();
39
+ FlatMatrix<double> factorx(dims[0], dims[1], lh);
40
+ factor->Evaluate (mip, factorx.AsVector());
41
+
42
+ IntRange used = diffop->UsedDofs(fel);
43
+ mat.Cols(used) = factorx * hmat.Cols(used);
44
+ }
45
+
46
+ void CalcMatrix (const FiniteElement & fel,
47
+ const SIMD_BaseMappedIntegrationRule & mir,
48
+ BareSliceMatrix<SIMD<double>> mat) const override
49
+ {
50
+ // *testout << "CalcMatrix SIMD" << endl;
51
+ Matrix<SIMD<double>> hmat (fel.GetNDof()*diffop->Dim(), mir.Size());
52
+ // hmat = SIMD<double>(0.0);
53
+ diffop -> CalcMatrix (fel, mir, hmat);
54
+
55
+ Matrix<SIMD<double>> fac(factor->Dimension(), mir.Size());
56
+ factor -> Evaluate (mir, fac);
57
+
58
+ auto dims = factor -> Dimensions();
59
+
60
+ mat.Rows(fel.GetNDof()*dims[1]).Cols(mir.Size()) = SIMD<double>(0.0);
61
+
62
+ for (size_t i = 0; i < mir.Size(); i++)
63
+ for (size_t j = 0; j < dims[0]; j++)
64
+ for (size_t k = 0; k < dims[1]; k++)
65
+ mat.Col(i).Slice(j,dims[0]) += fac(j*dims[1]+k, i) * hmat.Col(i).Slice(k, dims[1]);
66
+ }
67
+
68
+
69
+ void CalcMatrix (const FiniteElement & fel,
70
+ const IntegrationPoint & ip,
71
+ BareSliceMatrix<double,ColMajor> mat,
72
+ LocalHeap & lh) const override
73
+ {
74
+ diffop -> CalcMatrix(fel, ip, mat, lh);
75
+ /*
76
+ *testout << "calcmatrix mip" << endl
77
+ << mat.Rows(Dim()).Cols(fel.GetNDof()) << endl;
78
+ */
79
+ }
80
+
81
+ void CalcTransformationMatrix (const BaseMappedIntegrationPoint & mip,
82
+ SliceMatrix<double> trans,
83
+ LocalHeap & lh) const override
84
+ {
85
+ HeapReset hr(lh);
86
+ auto dims = factor->Dimensions();
87
+
88
+ FlatMatrix<double> factorx(dims[0], dims[1], lh);
89
+ factor->Evaluate (mip, factorx.AsVector());
90
+
91
+ FlatMatrix<double> basetrans(diffop->Dim(), diffop->DimRef(), lh);
92
+ diffop -> CalcTransformationMatrix(mip, basetrans, lh);
93
+
94
+ trans = factorx * basetrans;
95
+ // *testout << "trans = " << trans << endl;
96
+ }
97
+
98
+
99
+ void Apply (const FiniteElement & fel,
100
+ const SIMD_BaseMappedIntegrationRule & mir,
101
+ BareSliceVector<double> x,
102
+ BareSliceMatrix<SIMD<double>> flux) const override
103
+ {
104
+ auto dims = factor->Dimensions();
105
+
106
+ Matrix<SIMD<double>> tmpflux(dims[1], mir.Size());
107
+ Matrix<SIMD<double>> factorx(dims[0]*dims[1], mir.Size());
108
+
109
+ diffop -> Apply (fel, mir, x, tmpflux);
110
+ factor -> Evaluate (mir, factorx);
111
+ flux.Rows(0, dims[0]).Cols(0, mir.Size()) = SIMD<double>(0.0);
112
+ for (int i = 0; i < dims[0]; i++)
113
+ for (int j = 0; j < dims[1]; j++)
114
+ flux.Row(i).Range(mir.Size()) += pw_mult(factorx.Row(i*dims[1]+j), tmpflux.Row(j));
115
+ }
116
+
117
+
118
+ };
119
+
120
+
121
+ }
122
+
123
+ #endif
@@ -131,10 +131,13 @@ namespace ngla
131
131
  {
132
132
  size_t h, w;
133
133
  Matrix<SCAL> matrix;
134
- Table<int> col_dnums;
135
- Table<int> row_dnums;
134
+ Table<int> col_dnums; // output
135
+ Table<int> row_dnums; // input
136
136
  bool disjoint_rows, disjoint_cols;
137
137
  Table<int> row_coloring, col_coloring;
138
+ bool output_onto = false;
139
+ bool output_matrix = false;
140
+ bool output_matrix_trans = false;
138
141
  public:
139
142
  ConstantElementByElementMatrix (size_t ah, size_t aw, Matrix<SCAL> amatrix,
140
143
  Table<int> acol_dnums, Table<int> arow_dnums);
@@ -157,7 +160,10 @@ namespace ngla
157
160
  FlatTable<int> GetColDNums() const { return col_dnums; }
158
161
 
159
162
  FlatTable<int> GetRowColoring() const { return row_coloring; }
160
- FlatTable<int> GetColColoring() const { return col_coloring; }
163
+ FlatTable<int> GetColColoring() const { return col_coloring; }
164
+
165
+ bool OutputMatrix() const { return output_matrix; }
166
+ bool OutputMatrixTrans() const { return output_matrix_trans; }
161
167
  };
162
168
 
163
169
  class NGS_DLL_HEADER StructuredElementByElementMatrix : public BaseMatrix
netgen/include/expr.hpp CHANGED
@@ -291,9 +291,9 @@ namespace ngbla
291
291
  struct undefined_size
292
292
  {
293
293
  undefined_size() = default;
294
- undefined_size(size_t s) { }
294
+ INLINE undefined_size(size_t s) { }
295
295
  template <int S>
296
- explicit constexpr undefined_size(IC<S> s) { }
296
+ INLINE explicit constexpr undefined_size(IC<S> s) { }
297
297
  };
298
298
 
299
299
  inline ostream & operator<< (ostream & ost, undefined_size s) { ost << "undefined"; return ost; }
@@ -515,7 +515,7 @@ namespace ngbla
515
515
  }
516
516
 
517
517
 
518
- if (TB::IsLinear())
518
+ if constexpr (TB::IsLinear())
519
519
  {
520
520
  if (T::IsLinear())
521
521
  {
@@ -573,9 +573,6 @@ namespace ngbla
573
573
 
574
574
  enum { COL_MAJOR = 0 }; // matrix is stored col-major
575
575
 
576
- void Dump (ostream & ost) const { ost << "Matrix"; }
577
-
578
-
579
576
 
580
577
  template<typename TOP, typename TB>
581
578
  INLINE auto & Assign (const Expr<TB> & v)
@@ -735,6 +732,11 @@ namespace ngbla
735
732
  {
736
733
  return (*this) *= (1./s);
737
734
  }
735
+
736
+
737
+ void Dump (ostream & ost) const
738
+ { ost << "Matexpr (h=" << Height() << ", w=" << Width() << ")"; }
739
+
738
740
  };
739
741
 
740
742
 
@@ -838,6 +840,7 @@ namespace ngbla
838
840
  {
839
841
  TA a;
840
842
  public:
843
+ MinusExpr (const MinusExpr&) = default;
841
844
  MinusExpr (TA aa) : a(aa) { ; }
842
845
 
843
846
  template <typename ...I>
@@ -850,7 +853,10 @@ namespace ngbla
850
853
  INLINE auto Width() const { return a.Width(); }
851
854
  INLINE TA A() const { return a; }
852
855
 
853
- static constexpr bool IsLinear() { return TA::IsLinear(); }
856
+ static constexpr bool IsLinear() { return TA::IsLinear(); }
857
+ void Dump (ostream & ost) const
858
+ { ost << "-("; a.Dump(ost); ost << ")"; }
859
+
854
860
  };
855
861
 
856
862
  template <typename TA>
@@ -934,6 +940,7 @@ namespace ngbla
934
940
  public:
935
941
  static constexpr bool IsLinear() { return TA::IsLinear(); }
936
942
 
943
+ ScaleExpr (const ScaleExpr&) = default;
937
944
  INLINE ScaleExpr (TA aa, TS as) : a(aa), s(as) { ; }
938
945
 
939
946
  // INLINE auto operator() (size_t i) const { return s * a(i); }
@@ -1492,8 +1499,39 @@ namespace ngbla
1492
1499
  }
1493
1500
 
1494
1501
 
1502
+ /* ************************* OuterProduct ********************** */
1503
+
1504
+ template <class TA, class TB>
1505
+ class OuterProductExpr : public Expr<OuterProductExpr<TA,TB>>
1506
+ {
1507
+ TA a;
1508
+ TB b;
1509
+ public:
1510
+ OuterProductExpr (TA aa, TB ab) : a(aa), b(ab) { ; }
1495
1511
 
1512
+ // INLINE auto operator() (size_t i) const { return a[i] * b(i); }
1513
+ INLINE auto operator() (size_t i, size_t j) const { return a[i] * b[j]; }
1496
1514
 
1515
+ INLINE auto View() const { return *this; }
1516
+ INLINE auto Shape() const
1517
+ {
1518
+ return tuple<size_t,size_t> (a.Size(), b.Width());
1519
+ }
1520
+
1521
+ INLINE const auto A() const { return a; }
1522
+ INLINE const auto B() const { return b; }
1523
+ INLINE auto Height() const { return a.Size(); }
1524
+ INLINE auto Width() const { return b.Size(); }
1525
+
1526
+ static constexpr bool IsLinear() { return false; }
1527
+ };
1528
+
1529
+
1530
+ template <typename TA, typename TB>
1531
+ INLINE auto OuterProduct (const Expr<TA> & a, const Expr<TB> & b)
1532
+ {
1533
+ return OuterProductExpr (a.View(), b.View());
1534
+ }
1497
1535
 
1498
1536
 
1499
1537
 
@@ -448,7 +448,8 @@ ANY 1 1 1 1 | 15
448
448
  virtual void GetDofNrs (NodeId ni, Array<DofId> & dnums) const;
449
449
  BitArray GetDofs (const Region & reg) const;
450
450
  Table<int> CreateDofTable (VorB vorb) const;
451
-
451
+ virtual void SelectDofs (const string & name, BitArray & dofs) const;
452
+
452
453
  /// get coupling types of dofs
453
454
  virtual void GetDofCouplingTypes (int elnr, Array<COUPLING_TYPE> & dnums) const;
454
455
 
@@ -531,8 +532,13 @@ ANY 1 1 1 1 | 15
531
532
  void SetDefinedOnBoundary (const BitArray & defon)
532
533
  { SetDefinedOn(BND,defon); }
533
534
 
535
+ const Array<bool> & GetDefinedOn (VorB vb) const { return definedon[vb]; }
536
+
534
537
  ///
535
538
  void SetDirichletBoundaries (const BitArray & dirbnds);
539
+ const BitArray & GetDirichletBoundaries (VorB vb) const { return dirichlet_constraints[vb]; }
540
+
541
+
536
542
  /// Get reference element for tet, prism, trig, etc ..
537
543
  // const FiniteElement & GetFE (ELEMENT_TYPE type) const;
538
544
 
@@ -1141,7 +1147,8 @@ ANY 1 1 1 1 | 15
1141
1147
  void GetEdgeDofNrs (int ednr, Array<DofId> & dnums) const override;
1142
1148
  void GetFaceDofNrs (int fanr, Array<DofId> & dnums) const override;
1143
1149
  void GetInnerDofNrs (int elnr, Array<DofId> & dnums) const override;
1144
-
1150
+ void SelectDofs (const string & name, BitArray & dofs) const override;
1151
+
1145
1152
  void SolveM(CoefficientFunction * rho, BaseVector & vec, Region * definedon,
1146
1153
  LocalHeap & lh) const override;
1147
1154
  void ApplyM(CoefficientFunction * rho, BaseVector & vec, Region * definedon,
@@ -157,16 +157,16 @@ namespace ngcomp
157
157
  int GetMultiDim () const { return multidim; }
158
158
 
159
159
  /// increase multidim and copy vec to new component
160
- void AddMultiDimComponent (BaseVector & vec);
160
+ void AddMultiDimComponent (BaseVector & vec, bool copy = true);
161
161
 
162
162
  int GetLevelUpdated() const { return level_updated; }
163
163
  ///
164
164
 
165
165
  // const FESpace & GetFESpace() const { return *fespace; }
166
166
  ///
167
- shared_ptr<FESpace> GetFESpace() const { return fespace; }
167
+ const shared_ptr<FESpace> & GetFESpace() const { return fespace; }
168
168
  ///
169
- shared_ptr<MeshAccess> GetMeshAccess() const { return fespace->GetMeshAccess(); }
169
+ const shared_ptr<MeshAccess> & GetMeshAccess() const { return fespace->GetMeshAccess(); }
170
170
  ///
171
171
  virtual string GetClassName () const
172
172
  {
netgen/include/h1amg.hpp CHANGED
@@ -9,6 +9,20 @@
9
9
  namespace ngcomp
10
10
  {
11
11
  using namespace ngla;
12
+
13
+
14
+
15
+ struct H1AMG_Parameters
16
+ {
17
+ int verbose = 0;
18
+ int smoothing_steps = 3;
19
+ int coarsenings_per_level = 3; // number of binary coarsenings per level
20
+ bool block_smoother = true; // block or point smoother ?
21
+ bool use_smoothed_prolongation = true;
22
+ int max_coarse = 10;
23
+ int max_level = 20;
24
+ };
25
+
12
26
 
13
27
  template <class SCAL>
14
28
  class NGS_DLL_HEADER H1AMG_Matrix : public ngla::BaseMatrix
@@ -26,6 +40,7 @@ namespace ngcomp
26
40
  ngcore::FlatArray<ngcore::IVec<2>> e2v,
27
41
  ngcore::FlatArray<double> edge_weights,
28
42
  ngcore::FlatArray<double> vertex_weights,
43
+ const H1AMG_Parameters & param,
29
44
  size_t level);
30
45
 
31
46
  virtual int VHeight() const override { return size; }
@@ -50,7 +65,9 @@ namespace ngcomp
50
65
 
51
66
  ParallelHashTable<IVec<2>,double> edge_weights_ht;
52
67
  ParallelHashTable<IVec<1>,double> vertex_weights_ht;
53
-
68
+
69
+ H1AMG_Parameters param;
70
+
54
71
  public:
55
72
 
56
73
  static shared_ptr<Preconditioner> CreateBF (shared_ptr<BilinearForm> bfa, const Flags & flags, const string & name)
@@ -71,6 +88,12 @@ namespace ngcomp
71
88
  cout << IM(3) << "Create H1AMG" << endl;
72
89
  else
73
90
  cout << IM(3) << "Create H1AMG, complex" << endl;
91
+
92
+ param.verbose = int(flags.GetNumFlag("verbose", 0));
93
+ param.smoothing_steps = int(flags.GetNumFlag("smoothingsteps", 1));
94
+ param.use_smoothed_prolongation = flags.GetDefineFlagX("smoothedprolongation").IsMaybeTrue();
95
+ param.max_coarse = int(flags.GetNumFlag("maxcoarse", 10));
96
+ param.max_level = int(flags.GetNumFlag("maxlevel", 20));
74
97
  }
75
98
 
76
99
  virtual void InitLevel (shared_ptr<BitArray> _freedofs) override
@@ -25,6 +25,12 @@ namespace ngcomp
25
25
 
26
26
 
27
27
  void GetDofNrs (ElementId ei, Array<DofId> & dnums) const override;
28
+ void GetVertexDofNrs (int vnr, Array<int> & dnums) const override;
29
+ void GetEdgeDofNrs (int ednr, Array<int> & dnums) const override;
30
+ void GetFaceDofNrs (int fanr, Array<int> & dnums) const override;
31
+ void GetInnerDofNrs (int elnr, Array<int> & dnums) const override;
32
+
33
+
28
34
 
29
35
  FiniteElement & GetFE (ElementId ei, Allocator & alloc) const override;
30
36
 
@@ -643,6 +643,17 @@ namespace ngfem
643
643
  enum { DIM_DMAT = 1 };
644
644
  enum { DIFFORDER = 1 };
645
645
 
646
+ static string Name() { return "curl"; }
647
+
648
+ static const FEL & Cast(const FiniteElement & fel)
649
+ {
650
+ return static_cast<const FEL&> (fel);
651
+ }
652
+
653
+
654
+ static int DimRef() { return 1; }
655
+
656
+
646
657
  static constexpr bool SUPPORT_PML = true;
647
658
  template <typename AFEL, typename MIP, typename MAT>
648
659
  static void GenerateMatrix (const AFEL & fel, const MIP & mip,
@@ -651,6 +662,22 @@ namespace ngfem
651
662
  mat = 1.0/mip.GetJacobiDet() *
652
663
  Trans (static_cast<const FEL&>(fel).GetCurlShape(mip.IP(),lh));
653
664
  }
665
+
666
+ template<typename IP, typename MAT>
667
+ static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
668
+ MAT && mat, LocalHeap & lh)
669
+ {
670
+ Cast(fel).CalcCurlShape (ip, Trans(mat));
671
+ }
672
+
673
+ template <typename MIP, typename MAT>
674
+ static void CalcTransformationMatrix (const MIP & mip,
675
+ MAT & mat, LocalHeap & lh)
676
+ {
677
+ // auto & mip = static_cast<const MappedIntegrationPoint<D-1,D>&>(bmip);
678
+ mat = 1./mip.GetJacobiDet();
679
+ }
680
+
654
681
 
655
682
  static void GenerateMatrixSIMDIR (const FiniteElement & fel,
656
683
  const SIMD_BaseMappedIntegrationRule & mir,
@@ -701,6 +728,8 @@ public:
701
728
  enum { DIM_DMAT = 3 };
702
729
  enum { DIFFORDER = 1 };
703
730
 
731
+ static string Name() { return "curl"; }
732
+
704
733
  static constexpr bool SUPPORT_PML = true;
705
734
  static const FEL & Cast (const FiniteElement & fel)
706
735
  { return static_cast<const FEL&> (fel); }
@@ -88,6 +88,9 @@ namespace ngfem
88
88
  BareSliceVector<> coefs) const = 0;
89
89
 
90
90
 
91
+ virtual void CalcMappedShape (const SIMD<BaseMappedIntegrationPoint> & bmip,
92
+ BareSliceMatrix<SIMD<double>> shapes) const = 0;
93
+
91
94
  virtual void CalcMappedShape (const SIMD_BaseMappedIntegrationRule & bmir,
92
95
  BareSliceMatrix<SIMD<double>> shapes) const = 0;
93
96
 
@@ -931,6 +934,23 @@ namespace ngfem
931
934
  else
932
935
  throw Exception("HCurlCurl::CalcMappedCurlShape implemented only for TRIG and TET");
933
936
  }
937
+
938
+
939
+ virtual void CalcMappedShape (const SIMD<BaseMappedIntegrationPoint> & bmip,
940
+ BareSliceMatrix<SIMD<double>> shape) const override
941
+ {
942
+ Switch<4-DIM>
943
+ (bmip.DimSpace()-DIM,[this, &bmip, shape](auto CODIM)
944
+ {
945
+ constexpr auto DIMSPACE = DIM+CODIM.value;
946
+ auto & mip = static_cast<const SIMD<MappedIntegrationPoint<DIM,DIM+CODIM.value>>&> (bmip);
947
+ this->Cast() -> T_CalcShape (GetTIP(mip),
948
+ SBLambda ([shape,DIMSPACE] (size_t j, auto val)
949
+ {
950
+ shape.Rows(j*sqr(DIMSPACE), (j+1)*sqr(DIMSPACE)).Col(0).Range(0,sqr(DIMSPACE)) = val.Value().AsVector();
951
+ }));
952
+ });
953
+ }
934
954
 
935
955
  virtual void CalcMappedShape (const SIMD_BaseMappedIntegrationRule & bmir,
936
956
  BareSliceMatrix<SIMD<double>> shapes) const override
@@ -563,6 +563,7 @@ namespace ngfem
563
563
  {
564
564
  public:
565
565
  INLINE operator SCAL () const { return SCAL(0.0); }
566
+ INLINE SCAL Get() const { return SCAL(0.0); }
566
567
  };
567
568
 
568
569
  template <typename SCAL> class THDiv2DivShape<2,SCAL>
@@ -143,6 +143,8 @@ namespace ngcomp
143
143
  }
144
144
  }
145
145
 
146
+ void SelectDofs (const string & name, BitArray & dofs) const override;
147
+
146
148
  int GetFirstInnerDof(int elnr) const { return(first_inner_dof[elnr]);};
147
149
  // virtual int LowOrderDof() const { if(discont) return(0); else return(1);}
148
150