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
@@ -235,6 +235,7 @@ namespace ngfem
235
235
  CalcMappedDivShape (const SIMD_BaseMappedIntegrationRule & bmir,
236
236
  BareSliceMatrix<SIMD<double>> divshapes) const
237
237
  {
238
+ /*
238
239
  auto & mir = static_cast<const SIMD_MappedIntegrationRule<DIM,DIM>&> (bmir);
239
240
  for (size_t i = 0; i < mir.Size(); i++)
240
241
  {
@@ -246,6 +247,29 @@ namespace ngfem
246
247
  divshapesi(j) = val;
247
248
  }));
248
249
  }
250
+ */
251
+ Iterate<4-DIM>
252
+ ([this,&bmir,divshapes](auto CODIM)
253
+ {
254
+ constexpr int DIMSPACE = DIM+CODIM.value;
255
+ if (bmir.DimSpace() == DIMSPACE)
256
+ {
257
+ // cout << "use new div, dim " << DIMSPACE << endl;
258
+ auto & mir = static_cast<const SIMD_MappedIntegrationRule<DIM,DIMSPACE>&> (bmir);
259
+ for (size_t i = 0; i < mir.Size(); i++)
260
+ {
261
+ auto divshapesi = divshapes.Col(i);
262
+ auto invJ = 1.0/mir[i].GetJacobiDet();
263
+ static_cast<const FEL*> (this) ->
264
+ T_CalcShape (GetTIPGrad<DIM>(mir[i].IP()),
265
+ SBLambda ([divshapesi,invJ] (size_t j, THDiv2DivShape<DIM,SIMD<double>> val)
266
+ {
267
+ divshapesi(j) = invJ*val.Get();
268
+ }));
269
+ }
270
+ }
271
+ });
272
+
249
273
  }
250
274
 
251
275
  template <class FEL, ELEMENT_TYPE ET>
@@ -384,6 +408,8 @@ namespace ngfem
384
408
  EvaluateDiv (const SIMD_BaseMappedIntegrationRule & bmir, BareSliceVector<> coefs,
385
409
  BareVector<SIMD<double>> values) const
386
410
  {
411
+ /*
412
+ cout << "evaldiv, simd" << endl
387
413
  auto & mir = static_cast<const SIMD_MappedIntegrationRule<DIM,DIM>&> (bmir);
388
414
  for (size_t i = 0; i < mir.Size(); i++)
389
415
  {
@@ -399,6 +425,46 @@ namespace ngfem
399
425
  }));
400
426
  values(i) = sum;
401
427
  }
428
+ */
429
+
430
+ /*
431
+ Iterate<4-DIM>
432
+ ([this,&bmir,coefs,values](auto CODIM)
433
+ {
434
+ constexpr int DIMSPACE = DIM+CODIM.value;
435
+ if (bmir.DimSpace() == DIMSPACE)
436
+ {
437
+ auto & mir = static_cast<const SIMD_MappedIntegrationRule<DIM,DIMSPACE>&> (bmir);
438
+ for (size_t i = 0; i < mir.Size(); i++)
439
+ {
440
+ SIMD<double> sum(0.0);
441
+ static_cast<const FEL*> (this) ->
442
+ T_CalcShape (GetTIPGrad<DIM>(mir[i].IP()),
443
+ SBLambda ([=,&sum] (size_t j, THDiv2DivShape<DIM,SIMD<double>> divshape)
444
+ {
445
+ // auto vshape = HDiv2DivShapeNew (s);
446
+ // shapesi.Range(j*vshape.Size(), (j+1)*vshape.Size()) = vshape;
447
+ // divshapesi(j) = HDiv2DivShapeNew (s);
448
+ sum += coefs(j) * divshape.Get();
449
+ }));
450
+ values(i) = 1/mir[i].GetJacobiDet() * sum;
451
+ }
452
+ }
453
+ });
454
+ */
455
+
456
+ auto & mir = bmir;
457
+ for (size_t i = 0; i < mir.Size(); i++)
458
+ {
459
+ SIMD<double> sum(0.0);
460
+ static_cast<const FEL*> (this) ->
461
+ T_CalcShape (GetTIPGrad<DIM>(mir[i].IP()),
462
+ SBLambda ([=,&sum] (size_t j, THDiv2DivShape<DIM,SIMD<double>> divshape)
463
+ {
464
+ sum += coefs(j) * divshape.Get();
465
+ }));
466
+ values(i) = 1/mir[i].GetJacobiDet() * sum;
467
+ }
402
468
  }
403
469
 
404
470
  template <class FEL, ELEMENT_TYPE ET>
@@ -36,7 +36,7 @@ namespace ngfem
36
36
  INLINE T_ScalarFiniteElement () { ; }
37
37
  // virtual ~T_ScalarFiniteElement() { ; }
38
38
 
39
- HD virtual ELEMENT_TYPE ElementType() const final { return ET; }
39
+ HD virtual ELEMENT_TYPE ElementType() const final override { return ET; }
40
40
  // HD NGS_DLL_HEADER virtual int Dim () const override { return DIM; }
41
41
 
42
42
 
netgen/include/vector.hpp CHANGED
@@ -8,6 +8,7 @@
8
8
  /**************************************************************************/
9
9
 
10
10
  #include "expr.hpp"
11
+ #include "core/archive.hpp"
11
12
  #include <core/hashtable.hpp> // for SparseVector
12
13
 
13
14
  namespace ngbla
@@ -141,9 +142,170 @@ namespace ngbla
141
142
  {
142
143
  protected:
143
144
  typedef MatExpr<VectorView> BASE;
145
+
146
+ /*
144
147
  T * __restrict data;
145
148
  NO_UNIQUE_ADDRESS TS size;
146
149
  NO_UNIQUE_ADDRESS TDIST dist;
150
+ */
151
+
152
+
153
+ // the data ...
154
+
155
+ template <typename LT>
156
+ class Layout1
157
+ {
158
+ LT * data;
159
+ public:
160
+ Layout1() = default;
161
+ Layout1(const Layout1&) = default;
162
+ Layout1(Layout1&&) = default;
163
+
164
+ Layout1& operator= (const Layout1&) = default;
165
+ Layout1& operator= (Layout1&&) = default;
166
+
167
+ ~Layout1() = default;
168
+
169
+ INLINE Layout1 (LT * adata) : data(adata) { }
170
+ INLINE auto Data() const { return data; }
171
+ };
172
+
173
+
174
+
175
+ // add the size: variable, constant, undefined_size
176
+
177
+ template <typename LT, typename LTS>
178
+ class Layout2 : public Layout1<LT>
179
+ {
180
+ typedef Layout1<LT> BASE;
181
+ LTS size;
182
+ public:
183
+ Layout2() = default;
184
+ Layout2(const Layout2&) = default;
185
+ Layout2(Layout2&&) = default;
186
+
187
+ Layout2& operator= (const Layout2&) = default;
188
+ Layout2& operator= (Layout2&&) = default;
189
+ ~Layout2() = default;
190
+
191
+ INLINE Layout2 (LT * adata, LTS asize)
192
+ : BASE(adata), size(asize) { }
193
+ INLINE Layout2 (LT * adata)
194
+ : BASE(adata) { }
195
+
196
+
197
+ INLINE auto Size() const { return size; }
198
+ using BASE::Data;
199
+ };
200
+
201
+
202
+ template <typename LT, int IDIST>
203
+ class Layout2<LT,IC<IDIST>> : public Layout1<LT>
204
+ {
205
+ typedef Layout1<LT> BASE;
206
+ public:
207
+ Layout2() = default;
208
+ Layout2(const Layout2&) = default;
209
+ Layout2(Layout2&&) = default;
210
+
211
+ Layout2& operator= (const Layout2&) = default;
212
+ Layout2& operator= (Layout2&&) = default;
213
+ ~Layout2() = default;
214
+
215
+ INLINE Layout2 (LT * adata, IC<IDIST> asize)
216
+ : BASE(adata) { }
217
+ INLINE Layout2 (LT * adata)
218
+ : BASE(adata) { }
219
+
220
+ INLINE auto Size() const { return IC<IDIST>(); }
221
+ using BASE::Data;
222
+ };
223
+
224
+
225
+ #if !defined(NETGEN_ENABLE_CHECK_RANGE)
226
+
227
+ template <typename LT>
228
+ class Layout2<LT,undefined_size> : public Layout1<LT>
229
+ {
230
+ typedef Layout1<LT> BASE;
231
+ public:
232
+ Layout2() = default;
233
+ Layout2(const Layout2&) = default;
234
+ Layout2(Layout2&&) = default;
235
+
236
+ Layout2& operator= (const Layout2&) = default;
237
+ Layout2& operator= (Layout2&&) = default;
238
+ ~Layout2() = default;
239
+
240
+ INLINE Layout2 (LT * adata, undefined_size asize)
241
+ : BASE(adata) { }
242
+ INLINE Layout2 (LT * adata)
243
+ : BASE(adata) { }
244
+
245
+ INLINE auto Size() const { return undefined_size(); }
246
+ using BASE::Data;
247
+ };
248
+
249
+ #endif
250
+
251
+
252
+ // add the distance: variable, constant
253
+
254
+ template <typename LT, typename LTS, typename LTDIST>
255
+ class Layout : public Layout2<LT,LTS>
256
+ {
257
+ typedef Layout2<LT,LTS> BASE;
258
+ LTDIST dist;
259
+ public:
260
+ Layout() = default;
261
+ Layout(const Layout&) = default;
262
+ Layout(Layout&&) = default;
263
+
264
+ Layout& operator= (const Layout&) = default;
265
+ Layout& operator= (Layout&&) = default;
266
+ ~Layout() = default;
267
+
268
+ INLINE Layout (LT * adata, LTS asize, LTDIST adist)
269
+ : BASE(adata,asize), dist{adist} { }
270
+ INLINE Layout (LT * adata, LTS asize)
271
+ : BASE(adata,asize) { }
272
+ INLINE Layout (LT * adata)
273
+ : BASE(adata) { }
274
+
275
+ INLINE auto Dist() const { return dist; }
276
+ using BASE::Data;
277
+ using BASE::Size;
278
+ };
279
+
280
+
281
+ template <typename LT, typename LTS, int IDIST>
282
+ class Layout<LT, LTS, IC<IDIST>> : public Layout2<LT,LTS>
283
+ {
284
+ typedef Layout2<LT,LTS> BASE;
285
+ public:
286
+ Layout() = default;
287
+ Layout(const Layout&) = default;
288
+ Layout(Layout&&) = default;
289
+
290
+ Layout& operator= (const Layout&) = default;
291
+ Layout& operator= (Layout&&) = default;
292
+ ~Layout() = default;
293
+
294
+ INLINE Layout (LT * adata, LTS asize, IC<IDIST> adist)
295
+ : BASE(adata,asize) { }
296
+ INLINE Layout (LT * adata, LTS asize)
297
+ : BASE(adata,asize) { }
298
+ INLINE Layout (LT * adata)
299
+ : BASE(adata) { }
300
+
301
+ INLINE auto Dist() const { return IC<IDIST>(); }
302
+ using BASE::Data;
303
+ using BASE::Size;
304
+ };
305
+
306
+ Layout<T,TS,TDIST> layout;
307
+
308
+
147
309
  public:
148
310
  typedef T TELEM;
149
311
  typedef typename mat_traits<T>::TSCAL TSCAL;
@@ -152,33 +314,38 @@ namespace ngbla
152
314
  /// linear element access ?
153
315
  static constexpr bool IsLinear() { return std::is_same<type_dist,IC<1>>(); }
154
316
 
155
- INLINE VectorView () = default;
156
- INLINE VectorView (const VectorView&) = default;
157
- INLINE VectorView (VectorView&&) = default;
317
+ VectorView () = default;
318
+ VectorView (const VectorView&) = default;
319
+ VectorView (VectorView&&) = default;
158
320
 
159
321
  template <typename T2, typename TS2, typename TDIST2,
160
322
  enable_if_t<is_convertible<T2*,T*>::value, int> =0,
161
323
  enable_if_t<is_constructible<TS,TS2>::value, int> =0,
162
324
  enable_if_t<is_constructible<TDIST,TDIST2>::value, int> =0>
163
325
  INLINE VectorView (const VectorView<T2,TS2,TDIST2> & v2)
164
- : data{v2.Data()}, size{TS(v2.Size())}, dist{TDIST(v2.Dist())} { }
326
+ : layout(v2.Data(), TS(v2.Size()), TDIST(v2.Dist())) { }
327
+ // : data{v2.Data()}, size{TS(v2.Size())}, dist{TDIST(v2.Dist())} { }
165
328
 
166
329
  INLINE explicit VectorView (T * adata)
167
- : data(adata)
330
+ // : data(adata)
331
+ : layout(adata)
168
332
  {
169
333
  ; // static_assert(std::is_same<type_dist,IC<1>>());
170
334
  }
171
335
  INLINE VectorView (TS asize, T * adata)
172
- : data(adata), size(asize)
336
+ // : data(adata), size(asize)
337
+ : layout(adata, asize)
173
338
  {
174
339
  static_assert(std::is_same<type_dist,IC<1>>());
175
340
  }
176
341
  INLINE VectorView (TS asize, TDIST adist, T * adata)
177
- : data(adata), size(asize), dist(adist) { }
342
+ // : data(adata), size(asize), dist(adist) { }
343
+ : layout(adata, asize, adist) { }
178
344
 
179
345
  /// allocate FlatVector on local heap
180
346
  INLINE VectorView (size_t as, LocalHeap & lh)
181
- : data(lh.Alloc<T> (as)), size(as), dist(IC<1>()) { }
347
+ // : data(lh.Alloc<T> (as)), size(as), dist(IC<1>()) { }
348
+ : layout(lh.Alloc<T> (as), as, IC<1>()) { }
182
349
 
183
350
  template <typename EXPR>
184
351
  INLINE VectorView(LocalHeapExpr<EXPR>&& lhe)
@@ -191,7 +358,8 @@ namespace ngbla
191
358
 
192
359
  template <int S>
193
360
  INLINE VectorView (Vec<S,T> & v)
194
- : data(v.Data()), size(v.Size()), dist(IC<1>()) { }
361
+ // : data(v.Data()), size(v.Size()), dist(IC<1>()) { }
362
+ : layout{v.Data(), TS(v.Size()), (TDIST)IC<1>()} {}
195
363
 
196
364
 
197
365
  /*
@@ -201,7 +369,8 @@ namespace ngbla
201
369
  */
202
370
  template <int S>
203
371
  INLINE VectorView (const Vec<S,T> & v)
204
- : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
372
+ // : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
373
+ : layout(const_cast<T*>(v.Data()), v.Size(), IC<1>()) { }
205
374
  /*
206
375
  template <int S>
207
376
  INLINE VectorView (Vec<S,const T> & v)
@@ -211,38 +380,46 @@ namespace ngbla
211
380
  : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
212
381
  */
213
382
 
214
- INLINE auto Size() const { return size; }
215
- INLINE auto Dist() const { return dist; }
216
- INLINE auto Shape() const { return tuple(size); }
383
+ INLINE auto Size() const { return layout.Size(); }
384
+ INLINE auto Dist() const { return layout.Dist(); }
385
+ INLINE auto Shape() const { return tuple(layout.Size()); }
217
386
 
218
387
 
219
- INLINE auto Height () const { return size; }
388
+ INLINE auto Height () const { return layout.Size(); }
220
389
  INLINE auto Width () const { return IC<1>(); }
221
390
 
222
- INLINE auto Range () const { return IntRange (0, size); }
391
+ INLINE auto Range () const { return IntRange (0, layout.Size()); }
223
392
 
224
- INLINE T * Addr(size_t i) const { return data+i*dist; }
225
- INLINE T * Data() const { return data; }
393
+ INLINE T * Addr(size_t i) const { return layout.Data()+i*layout.Dist(); }
394
+ INLINE T * Data() const { return layout.Data(); }
226
395
 
227
396
  INLINE auto View() const { return VectorView(*this); }
228
397
  INLINE auto ViewRW() { return this->View(); }
229
398
 
399
+ void Dump (ostream & ost) const
400
+ { ost << "VectorView (size=" << Size() << ", dist=" << Dist() << ")"; }
230
401
 
231
402
 
232
403
  /// assign memory for vector on local heap
233
404
  INLINE void AssignMemory (size_t as, LocalHeap & lh)
234
405
  {
406
+ /*
235
407
  size = as;
236
408
  dist = IC<1>();
237
409
  data = lh.Alloc<T>(size);
410
+ */
411
+ layout = { lh.Alloc<T>(as), as, IC<1>() };
238
412
  }
239
413
 
240
414
  /// assign memory for vector
241
415
  void AssignMemory (size_t as, T * mem)
242
416
  {
417
+ /*
243
418
  size = as;
244
419
  dist = IC<1>();
245
420
  data = mem;
421
+ */
422
+ layout = { mem, as, IC<1>() };
246
423
  }
247
424
 
248
425
  INLINE auto & operator= (const VectorView & v)
@@ -295,7 +472,7 @@ namespace ngbla
295
472
  {
296
473
  NETGEN_CHECK_RANGE(D,0,Size()+1);
297
474
  for (int i = 0; i < D; i++)
298
- data[i*dist] = v(i);
475
+ Data()[i*Dist()] = v(i);
299
476
  return *this;
300
477
  }
301
478
 
@@ -303,13 +480,13 @@ namespace ngbla
303
480
  INLINE TELEM & operator[] (size_t i)
304
481
  {
305
482
  NETGEN_CHECK_RANGE(i,0,Size());
306
- return data[i*dist];
483
+ return Data()[i*Dist()];
307
484
  }
308
485
 
309
486
  INLINE const TELEM & operator[] (size_t i) const
310
487
  {
311
488
  NETGEN_CHECK_RANGE(i,0,Size());
312
- return data[i*dist];
489
+ return Data()[i*Dist()];
313
490
  }
314
491
 
315
492
 
@@ -319,14 +496,14 @@ namespace ngbla
319
496
  INLINE TELEM & operator() (I i) const
320
497
  {
321
498
  NETGEN_CHECK_RANGE(i,0,Size());
322
- return data[i*dist];
499
+ return Data()[i*Dist()];
323
500
  }
324
501
 
325
502
  /// element access. index j is ignored
326
503
  INLINE TELEM & operator() (size_t i, size_t j) const
327
504
  {
328
505
  NETGEN_CHECK_RANGE(i,0,Size());
329
- return data[i*dist];
506
+ return Data()[i*Dist()];
330
507
  }
331
508
 
332
509
  RowsArrayExpr<VectorView> operator() (FlatArray<int> rows) const
@@ -337,7 +514,7 @@ namespace ngbla
337
514
  INLINE auto Range (size_t first, size_t next) const
338
515
  {
339
516
  NETGEN_CHECK_RANGE(next,first,Size()+1);
340
- return VectorView<T,size_t,TDIST> (next-first, dist, data+first*dist);
517
+ return VectorView<T,size_t,TDIST> (next-first, Dist(), Data()+first*Dist());
341
518
  }
342
519
 
343
520
  INLINE auto Range (size_t next) const
@@ -353,7 +530,7 @@ namespace ngbla
353
530
  INLINE auto RangeN (size_t first, size_t n) const
354
531
  {
355
532
  NETGEN_CHECK_RANGE(first+n,first,Size()+1);
356
- return VectorView<T,size_t,TDIST> (n, dist, data+first*dist);
533
+ return VectorView<T,size_t,TDIST> (n, Dist(), Data()+first*Dist());
357
534
  }
358
535
 
359
536
 
@@ -369,7 +546,7 @@ namespace ngbla
369
546
  INLINE auto Slice(size_t first, size_t dist2) const
370
547
  {
371
548
  // return VectorView<T,decltype(declval<TS>()/size_t()), decltype(declval<TDIST>()*size_t())> (size/dist2, dist2*dist, Addr(first));
372
- return VectorView<T,decltype(declval<TS>()/size_t()), decltype(declval<TDIST>()*size_t())> ( (size-first+dist2-1)/dist2, dist2*dist, Addr(first));
549
+ return VectorView<T,decltype(declval<TS>()/size_t()), decltype(declval<TDIST>()*size_t())> ( (Size()-first+dist2-1)/dist2, dist2*Dist(), Addr(first));
373
550
  }
374
551
 
375
552
  INLINE auto Reversed() const
@@ -378,15 +555,15 @@ namespace ngbla
378
555
  return VectorView<T,TS,decltype(-declval<TDIST>())> { Size(), -Dist(), Addr(Size()-1) };
379
556
  }
380
557
 
381
- INLINE auto operator+(int i) const { return VectorView(size-i, dist, data+i*dist); }
558
+ INLINE auto operator+(int i) const { return VectorView(Size()-i, Dist(), Data()+i*Dist()); }
382
559
 
383
- INLINE auto RemoveConst() const { return VectorView<typename remove_const<T>::type,TS,TDIST>(size, dist, const_cast<typename remove_const<T>::type*> (data)); }
560
+ INLINE auto RemoveConst() const { return VectorView<typename remove_const<T>::type,TS,TDIST>(Size(), Dist(), const_cast<typename remove_const<T>::type*> (Data())); }
384
561
 
385
562
  INLINE auto AsMatrix (size_t h, size_t w) const
386
563
  {
387
564
  // todo: checking
388
565
  static_assert(std::is_same<TDIST,IC<1>>());
389
- return FlatMatrix<T> (h,w, data);
566
+ return FlatMatrix<T> (h,w, Data());
390
567
  }
391
568
 
392
569
  class Iterator
@@ -404,7 +581,7 @@ namespace ngbla
404
581
  };
405
582
 
406
583
  INLINE Iterator begin() const { return Iterator (*this, 0); }
407
- INLINE Iterator end() const { return Iterator (*this, size); }
584
+ INLINE Iterator end() const { return Iterator (*this, Size()); }
408
585
 
409
586
  };
410
587
 
@@ -445,8 +622,11 @@ namespace ngbla
445
622
  }
446
623
 
447
624
  Vector (Vector && v2)
448
- : FlatVector<T> (v2.size, v2.data)
449
- { v2.data = nullptr; v2.size = 0; }
625
+ : FlatVector<T> (v2.Size(), v2.Data())
626
+ {
627
+ v2.layout = { nullptr, 0 };
628
+ // v2.data = nullptr; v2.size = 0;
629
+ }
450
630
 
451
631
  /// allocate and compute
452
632
  template<typename TB>
@@ -467,7 +647,7 @@ namespace ngbla
467
647
 
468
648
 
469
649
  /// deallocate vector
470
- ~Vector() { delete [] this->data; }
650
+ ~Vector() { delete [] this->Data(); }
471
651
 
472
652
  /// set vector to constant values
473
653
  Vector & operator= (TSCAL scal)
@@ -479,6 +659,7 @@ namespace ngbla
479
659
  /// set vector size
480
660
  void SetSize(size_t as)
481
661
  {
662
+ /*
482
663
  if (this->size == as) return;
483
664
  delete [] this->data;
484
665
  this->size = as;
@@ -486,6 +667,10 @@ namespace ngbla
486
667
  this->data = new T[this->size];
487
668
  else
488
669
  this->data = nullptr;
670
+ */
671
+ if (this->Size() == as) return;
672
+ delete [] this->Data();
673
+ this->layout = { (as != 0) ? new T[as] : nullptr , as, IC<1>() };
489
674
  }
490
675
 
491
676
  /// evaluate matrix expression
@@ -505,8 +690,9 @@ namespace ngbla
505
690
 
506
691
  Vector & operator= (Vector && v2)
507
692
  {
508
- this->size = v2.size;
509
- Swap (this->data, v2.data);
693
+ // this->size = v2.size;
694
+ // Swap (this->data, v2.data);
695
+ Swap (this->layout, v2.layout);
510
696
  return *this;
511
697
  }
512
698
 
@@ -545,7 +731,7 @@ namespace ngbla
545
731
  &mem[0] : new T[as]) { ; }
546
732
 
547
733
  /// deallocates dynamic memory
548
- INLINE ~VectorMem() { if (this->Size() > S) delete [] this->data; }
734
+ INLINE ~VectorMem() { if (this->Size() > S) delete [] this->Data(); }
549
735
 
550
736
  /// assigns constant value
551
737
  INLINE VectorMem & operator= (TSCAL scal)
@@ -701,7 +887,8 @@ namespace ngbla
701
887
  */
702
888
 
703
889
  Vec (const Vec &) = default;
704
- auto & HTData() const { return data; }
890
+ auto & HTData() { return data; }
891
+ const auto & HTData() const { return data; }
705
892
  template <typename T2>
706
893
  Vec (const Vec<S,T2> & v2) : data(v2.HTData()) { ; }
707
894
 
@@ -845,6 +1032,12 @@ namespace ngbla
845
1032
  INLINE /* const */ FlatVector<T> Range(size_t first, size_t next)
846
1033
  { return FlatVector<T> (next-first, data+first); }
847
1034
 
1035
+ void DoArchive(Archive & ar)
1036
+ {
1037
+ for (size_t i = 0; i < S; i++)
1038
+ ar & data[i];
1039
+ }
1040
+
848
1041
  const T * begin() const { return data.Ptr(); }
849
1042
  const T * end() const { return data.Ptr()+S; }
850
1043
  T * begin() { return data.Ptr(); }
@@ -977,8 +1170,13 @@ namespace ngbla
977
1170
  }
978
1171
 
979
1172
 
980
-
981
-
1173
+ template <int S, typename T = double>
1174
+ auto UnitVec(size_t i)
1175
+ {
1176
+ Vec<S,T> ei = T(0.0);
1177
+ ei(i) = T(1.0);
1178
+ return ei;
1179
+ }
982
1180
 
983
1181
  template <class TV, class TSCAL> class Scalar2ElemVector
984
1182
  {
@@ -1196,24 +1394,51 @@ namespace ngbla
1196
1394
  for (int i = 0; i < DIM; i++)
1197
1395
  AtomicAdd (x(i), y(i));
1198
1396
  }
1199
-
1200
1397
 
1201
- }
1202
1398
 
1203
- namespace ngstd
1204
- {
1205
- template <typename ARCHIVE, int S, typename T>
1206
- inline auto & operator& (ARCHIVE & ar, ngbla::Vec<S,T> & v)
1399
+ template <typename T, typename TS, typename TDIST, typename TB>
1400
+ inline void AtomicAdd (VectorView<T,TS,TDIST> v, const Expr<TB> & v2)
1207
1401
  {
1208
- for (int i = 0; i < S; i++)
1209
- ar & v(i);
1210
- return ar;
1402
+ auto viewv2 = v2.View();
1403
+ auto combsize = CombinedSize(v.Size(), v2.Height());
1404
+ for (size_t i = 0; i < combsize; i++)
1405
+ AtomicAdd (v(i), viewv2(i));
1211
1406
  }
1407
+
1408
+
1212
1409
  }
1213
1410
 
1214
1411
 
1215
1412
  namespace ngcore
1216
1413
  {
1414
+
1415
+ template <typename T, size_t S> class MakeSimdCl;
1416
+
1417
+ template <typename T, size_t S, int VS>
1418
+ class MakeSimdCl<ngbla::Vec<VS,T>,S>
1419
+ {
1420
+ std::array<ngbla::Vec<VS,T>,S> a;
1421
+ public:
1422
+ MakeSimdCl (std::array<ngbla::Vec<VS,T>,S> aa) : a(aa) { ; }
1423
+
1424
+ auto Get() const
1425
+ {
1426
+ std::array<T,S> ai;
1427
+ ngbla::Vec<VS, decltype(MakeSimd(ai))> res;
1428
+ for (int i = 0; i < VS; i++)
1429
+ {
1430
+ for (int j = 0; j < S; j++)
1431
+ ai[j] = a[j](i);
1432
+ res(i) = MakeSimd(ai);
1433
+ }
1434
+ return res;
1435
+ }
1436
+ };
1437
+
1438
+
1439
+
1440
+
1441
+
1217
1442
  template<typename T> struct MPI_typetrait;
1218
1443
 
1219
1444
  template<int S, typename T>
netgen/lib/libngsolve.lib CHANGED
Binary file
netgen/libngsolve.dll CHANGED
Binary file
netgen/ngscxx.bat CHANGED
@@ -1,4 +1,4 @@
1
1
  set NGSCXX_DIR=%~dp0
2
2
  call "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat" amd64
3
3
 
4
- cl /c /O2 /Ob2 /DNDEBUG /DWIN32 /D_WINDOWS /GR /EHsc /DHAVE_NETGEN_SOURCES /DUSE_TIMEOFDAY /DTCL /DLAPACK /DUSE_PARDISO /DNGS_PYTHON /DNETGEN_PYTHON /DNG_PYTHON /DPYBIND11_SIMPLE_GIL_MANAGEMENT /D_WIN32_WINNT=0x1000 /DWNT /DWNT_WINDOW /DNOMINMAX /DMSVC_EXPRESS /D_CRT_SECURE_NO_WARNINGS /DHAVE_STRUCT_TIMESPEC /DWIN32 /DPARALLEL /DNG_MPI_WRAPPER /std:c++17 /bigobj /wd4068 -DMAX_SYS_DIM=3 /arch:AVX2 /bigobj /I"C:/gitlabci/tools/builds/3zsqG5ns/0/ngsolve/venv_ngs/Library/include" /I"C:/Python311/include" /I"%NGSCXX_DIR%/include" /I"%NGSCXX_DIR%/include/include" %*
4
+ cl /c /O2 /Ob2 /DNDEBUG /DWIN32 /D_WINDOWS /GR /EHsc /DHAVE_NETGEN_SOURCES /DUSE_TIMEOFDAY /DTCL /DLAPACK /DUSE_PARDISO /DNGS_PYTHON /DNETGEN_PYTHON /DNG_PYTHON /DPYBIND11_SIMPLE_GIL_MANAGEMENT /D_WIN32_WINNT=0x1000 /DWNT /DWNT_WINDOW /DNOMINMAX /DMSVC_EXPRESS /D_CRT_SECURE_NO_WARNINGS /DHAVE_STRUCT_TIMESPEC /DWIN32 /DPARALLEL /DNG_MPI_WRAPPER /std:c++17 /bigobj /wd4068 -DMAX_SYS_DIM=3 /arch:AVX2 /bigobj /MD /I"C:/gitlabci/tools/builds/3zsqG5ns9/0/ngsolve/venv_ngs/Library/include" /I"C:/Python311/include" /I"%NGSCXX_DIR%/include" /I"%NGSCXX_DIR%/include/include" %*
netgen/ngsld.bat CHANGED
@@ -3,4 +3,4 @@ call "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build
3
3
 
4
4
  for /f %%a in ('python -c "import sys,os; print(os.path.join(sys.base_prefix, 'libs'))"') do set PYTHON_LIBDIR="%%a"
5
5
 
6
- link /DLL %* -LC:/gitlabci/tools/builds/3zsqG5ns/0/ngsolve/venv_ngs/Library/lib -l_rt /LIBPATH:"%NGSCXX_DIR%/lib" nglib.lib ngcore.lib libngsolve.lib /LIBPATH:"%PYTHON_LIBDIR%"
6
+ link /DLL %* -LC:/gitlabci/tools/builds/3zsqG5ns9/0/ngsolve/venv_ngs/Library/lib -l_rt /LIBPATH:"%NGSCXX_DIR%/lib" nglib.lib ngcore.lib libngsolve.lib /LIBPATH:"%PYTHON_LIBDIR%"
ngsolve/__init__.py CHANGED
@@ -75,6 +75,7 @@ from .utils import x, y, z, dx, ds, grad, Grad, curl, div, Deviator, PyId, PyTra
75
75
  from . import solvers
76
76
  from . import preconditioners
77
77
  from . import timestepping
78
+ from .solve_implementation import Solve
78
79
 
79
80
  try:
80
81
  from netgen.occ import unit_square, unit_cube