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.
- netgen/include/analytic_integrals.hpp +10 -0
- netgen/include/basematrix.hpp +6 -0
- netgen/include/bdbequations.hpp +55 -0
- netgen/include/bem_diffops.hpp +475 -0
- netgen/include/bilinearform.hpp +4 -1
- netgen/include/bspline.hpp +2 -0
- netgen/include/code_generation.hpp +2 -2
- netgen/include/complex_wrapper.hpp +30 -2
- netgen/include/contact.hpp +8 -0
- netgen/include/diagonalmatrix.hpp +6 -0
- netgen/include/diffop_impl.hpp +3 -1
- netgen/include/diffopwithfactor.hpp +123 -0
- netgen/include/elementbyelement.hpp +9 -3
- netgen/include/expr.hpp +45 -7
- netgen/include/fespace.hpp +9 -2
- netgen/include/gridfunction.hpp +3 -3
- netgen/include/h1amg.hpp +24 -1
- netgen/include/h1lumping.hpp +6 -0
- netgen/include/hcurl_equations.hpp +29 -0
- netgen/include/hcurlcurlfe.hpp +20 -0
- netgen/include/hdivfe_utils.hpp +1 -0
- netgen/include/hdivhofespace.hpp +2 -0
- netgen/include/kernels.hpp +724 -0
- netgen/include/l2hofe.hpp +1 -0
- netgen/include/matrix.hpp +8 -3
- netgen/include/meshaccess.hpp +1 -1
- netgen/include/mp_coefficient.hpp +24 -19
- netgen/include/mptools.hpp +1255 -237
- netgen/include/mycomplex.hpp +1 -1
- netgen/include/ngblas.hpp +116 -7
- netgen/include/potentialtools.hpp +2 -2
- netgen/include/preconditioner.hpp +2 -2
- netgen/include/prolongation.hpp +6 -3
- netgen/include/recursive_pol.hpp +63 -11
- netgen/include/simd_complex.hpp +45 -0
- netgen/include/sparsecholesky.hpp +6 -2
- netgen/include/sparsefactorization_interface.hpp +159 -0
- netgen/include/sparsematrix.hpp +21 -7
- netgen/include/sparsematrix_dyn.hpp +2 -2
- netgen/include/sparsematrix_impl.hpp +100 -33
- netgen/include/statushandler.hpp +8 -8
- netgen/include/thdivfe_impl.hpp +66 -0
- netgen/include/tscalarfe.hpp +1 -1
- netgen/include/vector.hpp +272 -47
- netgen/lib/libngsolve.lib +0 -0
- netgen/libngsolve.dll +0 -0
- netgen/ngscxx.bat +1 -1
- netgen/ngsld.bat +1 -1
- ngsolve/cmake/NGSolveConfig.cmake +8 -8
- ngsolve/cmake/ngsolve-targets.cmake +17 -10
- ngsolve/config/config.py +8 -8
- ngsolve/demos/intro/cmagnet.py +19 -22
- ngsolve/directsolvers.py +9 -21
- ngsolve/krylovspace.py +172 -3
- ngsolve/ngslib.pyd +0 -0
- ngsolve/nonlinearsolvers.py +2 -2
- ngsolve/solve_implementation.py +14 -1
- ngsolve/{solvers.py → solvers/__init__.py} +1 -1
- ngsolve/solvers/cudss.py +112 -0
- ngsolve/webgui.py +1 -0
- {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/METADATA +2 -2
- {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/RECORD +94 -88
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/Scripts/ngsolve.tcl +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.geo +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/beam.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.in2d +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/chip.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.geo +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coil.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.geo +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/coilshield.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.geo +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/cube.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d11_chip_nitsche.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d1_square.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d2_chip.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d3_helmholtz.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d4_cube.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d5_beam.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d6_shaft.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d7_coil.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d8_coilshield.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/d9_hybridDG.pde +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.in2d +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/doubleglazing.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.geo +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/shaft.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.in2d +0 -0
- {ngsolve-6.2.2504.post44.dev0.data → ngsolve-6.2.2601.data}/data/share/ngsolve/square.vol +0 -0
- {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/LICENSE +0 -0
- {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/WHEEL +0 -0
- {ngsolve-6.2.2504.post44.dev0.dist-info → ngsolve-6.2.2601.dist-info}/top_level.txt +0 -0
ngsolve/config/config.py
CHANGED
|
@@ -15,7 +15,7 @@ USE_MUMPS = _cmake_to_bool("OFF")
|
|
|
15
15
|
USE_PARDISO = _cmake_to_bool("OFF")
|
|
16
16
|
USE_UMFPACK = _cmake_to_bool("OFF")
|
|
17
17
|
|
|
18
|
-
NETGEN_DIR = "C:/gitlabci/tools/builds/
|
|
18
|
+
NETGEN_DIR = "C:/gitlabci/tools/builds/3zsqG5ns9/0/ngsolve/venv_ngs/Lib/site-packages"
|
|
19
19
|
|
|
20
20
|
NGSOLVE_COMPILE_DEFINITIONS = "HAVE_NETGEN_SOURCES;USE_TIMEOFDAY;TCL;LAPACK;USE_PARDISO;NGS_PYTHON"
|
|
21
21
|
NGSOLVE_COMPILE_DEFINITIONS_PRIVATE = "USE_MKL"
|
|
@@ -29,21 +29,21 @@ NGSOLVE_INSTALL_DIR_INCLUDE = "netgen/include"
|
|
|
29
29
|
NGSOLVE_INSTALL_DIR_CMAKE = "ngsolve/cmake"
|
|
30
30
|
NGSOLVE_INSTALL_DIR_RES = "share"
|
|
31
31
|
|
|
32
|
-
NGSOLVE_VERSION = "6.2.
|
|
33
|
-
NGSOLVE_VERSION_GIT = "v6.2.
|
|
34
|
-
NGSOLVE_VERSION_PYTHON = "6.2.
|
|
32
|
+
NGSOLVE_VERSION = "6.2.2601"
|
|
33
|
+
NGSOLVE_VERSION_GIT = "v6.2.2601-0-g3a3ce7f49"
|
|
34
|
+
NGSOLVE_VERSION_PYTHON = "6.2.2601"
|
|
35
35
|
|
|
36
36
|
NGSOLVE_VERSION_MAJOR = "6"
|
|
37
37
|
NGSOLVE_VERSION_MINOR = "2"
|
|
38
|
-
NGSOLVE_VERSION_TWEAK = "
|
|
39
|
-
NGSOLVE_VERSION_PATCH = "
|
|
40
|
-
NGSOLVE_VERSION_HASH = "
|
|
38
|
+
NGSOLVE_VERSION_TWEAK = "0"
|
|
39
|
+
NGSOLVE_VERSION_PATCH = "2601"
|
|
40
|
+
NGSOLVE_VERSION_HASH = "g3a3ce7f49"
|
|
41
41
|
|
|
42
42
|
CMAKE_CXX_COMPILER = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe"
|
|
43
43
|
CMAKE_CUDA_COMPILER = ""
|
|
44
44
|
CMAKE_C_COMPILER = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe"
|
|
45
45
|
CMAKE_LINKER = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/link.exe"
|
|
46
|
-
CMAKE_INSTALL_PREFIX = "C:/gitlabci/tools/builds/
|
|
46
|
+
CMAKE_INSTALL_PREFIX = "C:/gitlabci/tools/builds/3zsqG5ns9/0/ngsolve/ngsolve/_skbuild/win-amd64-3.11/cmake-install"
|
|
47
47
|
CMAKE_CXX_COMPILER_LAUNCHER = ""
|
|
48
48
|
|
|
49
49
|
version = NGSOLVE_VERSION_GIT
|
ngsolve/demos/intro/cmagnet.py
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
from netgen.
|
|
1
|
+
from netgen.occ import *
|
|
2
2
|
from ngsolve import *
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def MakeGeometry():
|
|
6
|
-
|
|
7
|
-
box =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
ngmesh = MakeGeometry().GenerateMesh(maxh=0.5)
|
|
25
|
-
ngmesh.Save("coil.vol")
|
|
26
|
-
mesh = Mesh(ngmesh)
|
|
6
|
+
box = Box((-1,-1,-1), (2,1,2))
|
|
7
|
+
box.faces.name = "outer"
|
|
8
|
+
core = Box((0,-0.05,0), (0.8,0.05,1)) - \
|
|
9
|
+
Box((0.1,-1,0.1), (0.7,1,0.9)) - \
|
|
10
|
+
Box((0.5,-1,0.4), (1,1,0.6))
|
|
11
|
+
core.solids.name = "core"
|
|
12
|
+
core.solids.maxh = 0.03
|
|
13
|
+
|
|
14
|
+
coil = Cylinder((0.05,0,0.3), (0,0,1), 0.3, 0.4) - \
|
|
15
|
+
Cylinder((0.05,0,0.3), (0,0,1), 0.15, 0.4)
|
|
16
|
+
coil.solids.name = "coil"
|
|
17
|
+
air = box - core - coil
|
|
18
|
+
air.solids.name = "air"
|
|
19
|
+
return Glue([core, coil, air])
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
mesh = MakeGeometry().GenerateMesh(maxh=0.5)
|
|
27
24
|
|
|
28
25
|
# curve elements for geometry approximation
|
|
29
26
|
mesh.Curve(5)
|
ngsolve/directsolvers.py
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
from ngsolve import BaseMatrix, BitArray, BilinearForm, BaseVector
|
|
2
|
+
import ngsolve
|
|
2
3
|
|
|
3
|
-
class SuperLU(
|
|
4
|
-
|
|
5
|
-
def __init__(self, a, freedofs: BitArray = None):
|
|
6
|
-
super().__init__()
|
|
7
|
-
self.a = a
|
|
8
|
-
self.freedofs = freedofs
|
|
9
|
-
|
|
10
|
-
def Update(self):
|
|
4
|
+
class SuperLU(ngsolve.la.SparseFactorizationInterface):
|
|
5
|
+
def Factor(self):
|
|
11
6
|
import scipy.sparse as sp
|
|
12
7
|
import scipy.sparse.linalg as spla
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
self.lu = spla.factorized(sp.csc_matrix(mat))
|
|
8
|
+
vals, rows, cols = self.GetInnerMatrix().CSR()
|
|
9
|
+
self.inv_mat = spla.factorized(sp.csr_matrix((vals, rows, cols)))
|
|
10
|
+
|
|
11
|
+
def Solve(self, rhs, sol):
|
|
12
|
+
sol.FV().NumPy()[:] = self.inv_mat(rhs.FV().NumPy())
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
if not hasattr(self, "lu"):
|
|
22
|
-
self.Update()
|
|
23
|
-
if self.freedofs is not None:
|
|
24
|
-
y.FV().NumPy()[self.fd] = self.lu(x.FV().NumPy()[self.fd])
|
|
25
|
-
else:
|
|
26
|
-
y.FV().NumPy()[:] = self.lu(x.FV().NumPy())
|
|
14
|
+
ngsolve.la.RegisterInverseType("superlu", SuperLU)
|
ngsolve/krylovspace.py
CHANGED
|
@@ -292,6 +292,10 @@ def CG(mat, rhs, pre=None, sol=None, tol=1e-12, maxsteps = 100, printrates = Tru
|
|
|
292
292
|
solver.Solve(rhs=rhs, sol=sol, initialize=initialize)
|
|
293
293
|
return solver.sol
|
|
294
294
|
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
295
299
|
class QMRSolver(LinearSolver):
|
|
296
300
|
"""Quasi Minimal Residuum method
|
|
297
301
|
|
|
@@ -310,13 +314,15 @@ ep : double
|
|
|
310
314
|
name = "QMR"
|
|
311
315
|
|
|
312
316
|
def __init__(self, *args, pre2 : Preconditioner = None,
|
|
317
|
+
matT = None,
|
|
313
318
|
ep : float = 1., **kwargs):
|
|
314
319
|
super().__init__(*args, **kwargs)
|
|
315
320
|
self.pre2 = pre2
|
|
316
321
|
self.ep = ep
|
|
322
|
+
self.matT = matT if matT is not None else self.mat.T
|
|
317
323
|
|
|
318
324
|
def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
|
|
319
|
-
u, mat, ep, pre1, pre2 = sol, self.mat, self.ep, self.pre, self.pre2
|
|
325
|
+
u, mat, matT, ep, pre1, pre2 = sol, self.mat, self.matT, self.ep, self.pre, self.pre2
|
|
320
326
|
r = rhs.CreateVector()
|
|
321
327
|
v = rhs.CreateVector()
|
|
322
328
|
v_tld = rhs.CreateVector()
|
|
@@ -399,7 +405,7 @@ ep : double
|
|
|
399
405
|
rho = InnerProduct(y,y)
|
|
400
406
|
rho = sqrt(rho)
|
|
401
407
|
|
|
402
|
-
w_tld.data =
|
|
408
|
+
w_tld.data = matT * q
|
|
403
409
|
w_tld.data -= beta * w
|
|
404
410
|
|
|
405
411
|
z.data = pre2.T * w_tld if pre2 else w_tld
|
|
@@ -498,6 +504,169 @@ def QMR(mat, rhs, fdofs, pre1=None, pre2=None, sol=None, maxsteps = 100, printra
|
|
|
498
504
|
|
|
499
505
|
|
|
500
506
|
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
class TFQMRSolver(LinearSolver):
|
|
511
|
+
"""Transpose-Free Quasi Minimal Residuum method
|
|
512
|
+
|
|
513
|
+
Parameters
|
|
514
|
+
----------
|
|
515
|
+
|
|
516
|
+
""" + linear_solver_param_doc + """
|
|
517
|
+
|
|
518
|
+
"""
|
|
519
|
+
|
|
520
|
+
name = "TFQMR"
|
|
521
|
+
|
|
522
|
+
def __init__(self, *args, pre2 : Preconditioner = None,
|
|
523
|
+
matT = None,
|
|
524
|
+
ep : float = 1., **kwargs):
|
|
525
|
+
super().__init__(*args, **kwargs)
|
|
526
|
+
|
|
527
|
+
def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
|
|
528
|
+
# following implementation from scipy
|
|
529
|
+
mat,pre,tol = self.mat, self.pre, self.tol
|
|
530
|
+
|
|
531
|
+
r = rhs.CreateVector()
|
|
532
|
+
u = rhs.CreateVector()
|
|
533
|
+
v = rhs.CreateVector()
|
|
534
|
+
w = rhs.CreateVector()
|
|
535
|
+
uhat = rhs.CreateVector()
|
|
536
|
+
uNext = rhs.CreateVector()
|
|
537
|
+
rstar = rhs.CreateVector()
|
|
538
|
+
d = rhs.CreateVector()
|
|
539
|
+
x = rhs.CreateVector()
|
|
540
|
+
z = rhs.CreateVector()
|
|
541
|
+
tmp = rhs.CreateVector()
|
|
542
|
+
d[:] = 0
|
|
543
|
+
|
|
544
|
+
if Norm(rhs)==0:
|
|
545
|
+
sol.data = 0
|
|
546
|
+
return
|
|
547
|
+
|
|
548
|
+
x.data = sol
|
|
549
|
+
r.data = rhs - mat*sol
|
|
550
|
+
|
|
551
|
+
u.data = r
|
|
552
|
+
w.data = r
|
|
553
|
+
rstar.data = r
|
|
554
|
+
|
|
555
|
+
v.data = pre@mat * r
|
|
556
|
+
uhat.data = v
|
|
557
|
+
|
|
558
|
+
theta = eta = 0
|
|
559
|
+
|
|
560
|
+
rho = InnerProduct(rstar, r)
|
|
561
|
+
rhoLast = rho
|
|
562
|
+
r0norm = sqrt(rho)
|
|
563
|
+
|
|
564
|
+
tau = r0norm
|
|
565
|
+
if r0norm == 0:
|
|
566
|
+
return
|
|
567
|
+
|
|
568
|
+
for iter in range(0,self.maxiter):
|
|
569
|
+
even = iter%2 == 0
|
|
570
|
+
if (even):
|
|
571
|
+
vtrstar = InnerProduct(rstar, v)
|
|
572
|
+
if vtrstar==0:
|
|
573
|
+
return
|
|
574
|
+
|
|
575
|
+
alpha = rho/vtrstar
|
|
576
|
+
uNext.data = u-alpha*v
|
|
577
|
+
|
|
578
|
+
w -= alpha*uhat
|
|
579
|
+
d *= theta**2/alpha*eta
|
|
580
|
+
d += u
|
|
581
|
+
theta = Norm(w)/tau
|
|
582
|
+
c = sqrt(1/(1+theta**2))
|
|
583
|
+
tau *= theta*c
|
|
584
|
+
|
|
585
|
+
eta = c**2 * alpha
|
|
586
|
+
z.data = pre*d
|
|
587
|
+
x += eta*z
|
|
588
|
+
|
|
589
|
+
# callback ...
|
|
590
|
+
|
|
591
|
+
if self.CheckResidual(tau):
|
|
592
|
+
sol.data = x
|
|
593
|
+
return
|
|
594
|
+
# if tau < tol:
|
|
595
|
+
# return
|
|
596
|
+
|
|
597
|
+
if not even:
|
|
598
|
+
rho = InnerProduct(rstar, w)
|
|
599
|
+
beta = rho/rhoLast
|
|
600
|
+
u *= beta
|
|
601
|
+
u += w
|
|
602
|
+
v *= beta**2
|
|
603
|
+
v += beta*uhat
|
|
604
|
+
# uhat.data = pre@mat * u
|
|
605
|
+
tmp.data = mat*u
|
|
606
|
+
uhat.data = pre*tmp
|
|
607
|
+
v += uhat
|
|
608
|
+
else:
|
|
609
|
+
# uhat.data = pre@mat * uNext
|
|
610
|
+
tmp.data = mat*uNext
|
|
611
|
+
uhat.data = pre*tmp
|
|
612
|
+
u.data = uNext
|
|
613
|
+
rhoLast = rho
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def TFQMR(mat, rhs, pre=None, sol=None, maxsteps = 100, printrates = True, initialize = True, tol = 1e-7):
|
|
617
|
+
"""Quasi Minimal Residuum method
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
Parameters
|
|
621
|
+
----------
|
|
622
|
+
|
|
623
|
+
mat : Matrix
|
|
624
|
+
The left hand side of the equation to solve
|
|
625
|
+
|
|
626
|
+
rhs : Vector
|
|
627
|
+
The right hand side of the equation.
|
|
628
|
+
|
|
629
|
+
fdofs : BitArray
|
|
630
|
+
BitArray of free degrees of freedoms.
|
|
631
|
+
|
|
632
|
+
pre : Preconditioner
|
|
633
|
+
preconditioner if provided
|
|
634
|
+
|
|
635
|
+
sol : Vector
|
|
636
|
+
Start vector for QMR method, if initialize is set False. Gets overwritten by the solution vector. If sol = None then a new vector is created.
|
|
637
|
+
|
|
638
|
+
maxsteps : int
|
|
639
|
+
Number of maximal steps for QMR. If the maximal number is reached before the tolerance is reached QMR stops.
|
|
640
|
+
|
|
641
|
+
printrates : bool
|
|
642
|
+
If set to True then the error of the iterations is displayed.
|
|
643
|
+
|
|
644
|
+
initialize : bool
|
|
645
|
+
If set to True then the initial guess for the QMR method is set to zero. Otherwise the values of the vector sol, if provided, is used.
|
|
646
|
+
|
|
647
|
+
tol : double
|
|
648
|
+
Tolerance of the residuum. QMR stops if tolerance is reached.
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
Returns
|
|
652
|
+
-------
|
|
653
|
+
(vector)
|
|
654
|
+
Solution vector of the QMR method.
|
|
655
|
+
|
|
656
|
+
"""
|
|
657
|
+
# backwards compatibility, but freedofs are not needed then.
|
|
658
|
+
return TFQMRSolver(mat=mat, pre=pre,
|
|
659
|
+
maxiter=maxsteps,
|
|
660
|
+
printrates=printrates,
|
|
661
|
+
tol=tol).Solve(rhs=rhs, sol=sol, initialize=initialize)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
501
670
|
#Source: Michael Kolmbauer https://www.numa.uni-linz.ac.at/Teaching/PhD/Finished/kolmbauer-diss.pdf
|
|
502
671
|
class MinResSolver(LinearSolver):
|
|
503
672
|
"""Minimal Residuum method
|
|
@@ -803,7 +972,7 @@ restart : int = None
|
|
|
803
972
|
h[:] = 0
|
|
804
973
|
for i in range(k+1):
|
|
805
974
|
h[i] = innerproduct(Q[i],q)
|
|
806
|
-
q
|
|
975
|
+
q -= h[i] * Q[i]
|
|
807
976
|
h[k+1] = norm(q)
|
|
808
977
|
if abs(h[k+1]) < 1e-12:
|
|
809
978
|
return h, None
|
ngsolve/ngslib.pyd
CHANGED
|
Binary file
|
ngsolve/nonlinearsolvers.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ngsolve.la import InnerProduct
|
|
1
|
+
from ngsolve.la import InnerProduct, SparseFactorizationInterface
|
|
2
2
|
from math import sqrt
|
|
3
3
|
from ngsolve import Projector, Norm
|
|
4
4
|
from .utils import TimeFunction
|
|
@@ -97,7 +97,7 @@ class NewtonSolver:
|
|
|
97
97
|
else:
|
|
98
98
|
self.inv.Update()
|
|
99
99
|
else:
|
|
100
|
-
if self.inverse == "sparsecholesky"
|
|
100
|
+
if self.inv is not None and (self.inverse == "sparsecholesky" or isinstance(self.inv, SparseFactorizationInterface)):
|
|
101
101
|
self.inv.Update()
|
|
102
102
|
else:
|
|
103
103
|
self.inv = self.a.mat.Inverse(self.freedofs,
|
ngsolve/solve_implementation.py
CHANGED
|
@@ -51,10 +51,23 @@ class NonLinearApplication(Application):
|
|
|
51
51
|
if rhs is not None and rhs != 0:
|
|
52
52
|
rhs.Assemble()
|
|
53
53
|
solver_args["rhs"] = rhs
|
|
54
|
+
if "freedofs" in kwargs:
|
|
55
|
+
solver_args["freedofs"] = kwargs.pop("freedofs")
|
|
56
|
+
if "inverse" in kwargs:
|
|
57
|
+
solver_args["inverse"] = kwargs.pop("inverse")
|
|
54
58
|
solver = NewtonSolver(self.a, self.gf, **solver_args)
|
|
55
59
|
if dirichlet is not None:
|
|
56
60
|
dirichlet_gf = GridFunction(self.gf.space)
|
|
57
|
-
if isinstance(dirichlet,
|
|
61
|
+
if isinstance(dirichlet, list):
|
|
62
|
+
for i in range(len(dirichlet)):
|
|
63
|
+
if dirichlet[i] is not None:
|
|
64
|
+
if isinstance(dirichlet[i], Dirichlet):
|
|
65
|
+
dirichlet_gf.components[i].Set(
|
|
66
|
+
dirichlet[i].cf, definedon=dirichlet[i].region
|
|
67
|
+
)
|
|
68
|
+
else:
|
|
69
|
+
dirichlet_gf.components[i].Set(dirichlet[i], BND)
|
|
70
|
+
elif isinstance(dirichlet, Dirichlet):
|
|
58
71
|
dirichlet_gf.Set(dirichlet.cf, definedon=dirichlet.region)
|
|
59
72
|
else:
|
|
60
73
|
dirichlet_gf.Set(dirichlet, BND)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ngsolve.eigenvalues import PINVIT, LOBPCG
|
|
2
|
-
from ngsolve.krylovspace import CG, QMR, MinRes, PreconditionedRichardson, GMRes
|
|
2
|
+
from ngsolve.krylovspace import CG, QMR, TFQMR, MinRes, PreconditionedRichardson, GMRes
|
|
3
3
|
from ngsolve.krylovspace import CGSolver
|
|
4
4
|
from ngsolve.nonlinearsolvers import Newton, NewtonMinimization
|
|
5
5
|
from ngsolve.bvp import BVP
|
ngsolve/solvers/cudss.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
try:
|
|
2
|
+
import nvmath.sparse.advanced as nvs
|
|
3
|
+
from nvmath.internal import utils
|
|
4
|
+
from nvmath.internal.tensor_ifc_numpy import NumpyTensor
|
|
5
|
+
except ImportError:
|
|
6
|
+
raise ImportError("CUDSS solver requires nvmath-python module.")
|
|
7
|
+
|
|
8
|
+
import ngsolve.la as ngla
|
|
9
|
+
import scipy.sparse as sp
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
from ngsolve import TimeFunction
|
|
13
|
+
|
|
14
|
+
class CudssSolver(ngla.SparseFactorizationInterface):
|
|
15
|
+
solver: nvs.DirectSolver = None
|
|
16
|
+
|
|
17
|
+
@TimeFunction
|
|
18
|
+
def Analyze(self):
|
|
19
|
+
if hasattr(self, "solver") and self.solver is not None:
|
|
20
|
+
self.solver.free()
|
|
21
|
+
del self.solver
|
|
22
|
+
|
|
23
|
+
csr = sp.csr_matrix(self.GetInnerMatrix().CSR())
|
|
24
|
+
|
|
25
|
+
options = make_directsolver_options()
|
|
26
|
+
self.extract_symmetric = (csr != csr.T).nnz == 0
|
|
27
|
+
if self.extract_symmetric:
|
|
28
|
+
csr = sp.triu(csr, format="csr")
|
|
29
|
+
options.sparse_system_type = nvs.DirectSolverMatrixType.SYMMETRIC
|
|
30
|
+
options.sparse_system_view = nvs.DirectSolverMatrixViewType.UPPER
|
|
31
|
+
|
|
32
|
+
tmp = np.empty(csr.shape[1], dtype=csr.dtype)
|
|
33
|
+
self.solver = nvs.DirectSolver(csr, tmp, options=options)
|
|
34
|
+
self.solver.plan()
|
|
35
|
+
self._is_first_factor_call = True
|
|
36
|
+
|
|
37
|
+
@TimeFunction
|
|
38
|
+
def Factor(self):
|
|
39
|
+
if not self._is_first_factor_call:
|
|
40
|
+
mat = self.GetInnerMatrix()
|
|
41
|
+
if self.extract_symmetric:
|
|
42
|
+
csr = sp.csr_matrix(mat.CSR())
|
|
43
|
+
csr = sp.triu(csr, format="csr")
|
|
44
|
+
values = csr.data
|
|
45
|
+
else:
|
|
46
|
+
values = mat.AsVector().FV().NumPy()
|
|
47
|
+
stream_holder = utils.get_or_create_stream(self.solver.device_id, None, self.solver.rhs_package)
|
|
48
|
+
values_tensor = NumpyTensor(values)
|
|
49
|
+
self.solver.a.values.copy_(values_tensor, stream_holder)
|
|
50
|
+
self.solver.factorize()
|
|
51
|
+
self._is_first_factor_call = False
|
|
52
|
+
|
|
53
|
+
@TimeFunction
|
|
54
|
+
def Solve(self, b, sol):
|
|
55
|
+
stream_holder = utils.get_or_create_stream(self.solver.device_id, None, self.solver.rhs_package)
|
|
56
|
+
self.solver.b.copy_(NumpyTensor(b.FV().NumPy()), stream_holder)
|
|
57
|
+
sol.FV().NumPy()[:] = self.solver.solve()
|
|
58
|
+
|
|
59
|
+
def __del__(self):
|
|
60
|
+
if self.solver is not None:
|
|
61
|
+
self.solver.free()
|
|
62
|
+
del self.solver
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
ngla.RegisterInverseType("cudss", CudssSolver)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# find cudss multithreading lib from installed distribution
|
|
69
|
+
|
|
70
|
+
import os, pathlib
|
|
71
|
+
from importlib import util as importlib_util
|
|
72
|
+
from importlib import metadata as importlib_metadata
|
|
73
|
+
|
|
74
|
+
def _from_dist_files():
|
|
75
|
+
# Use the wheel’s file manifest (most reliable)
|
|
76
|
+
candidates = []
|
|
77
|
+
# for dist_name in ("nvidia-cudss-cu12", "nvidia_cudss_cu12", "nvidia-cudss"): # try common variants
|
|
78
|
+
for dist_name in ("nvidia-cudss-cu12", "nvidia_cudss_cu12", "nvidia-cudss",
|
|
79
|
+
"nvidia-cudss-cu13", "nvidia_cudss_cu13"): # try common variants
|
|
80
|
+
try:
|
|
81
|
+
dist = importlib_metadata.distribution(dist_name)
|
|
82
|
+
except importlib_metadata.PackageNotFoundError:
|
|
83
|
+
continue
|
|
84
|
+
for f in dist.files or []:
|
|
85
|
+
name = f.name.lower()
|
|
86
|
+
# check for name ends in .so or .so.*
|
|
87
|
+
endwith_so = name.endswith(".so") or (".so." in name and name.rsplit(".so.", 1)[1].replace(".", "").isdigit())
|
|
88
|
+
if name.startswith("libcudss_mtlayer_") and endwith_so:
|
|
89
|
+
candidates.append(dist.locate_file(f))
|
|
90
|
+
if name.startswith("cudss_mtlayer_") and name.endswith(".dll"):
|
|
91
|
+
candidates.append(dist.locate_file(f))
|
|
92
|
+
if candidates:
|
|
93
|
+
# Prefer anything in bin/ or lib/ if multiple
|
|
94
|
+
candidates.sort(key=lambda p: ("bin" not in str(p) and "lib" not in str(p), str(p)))
|
|
95
|
+
return str(candidates[0])
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def make_directsolver_options():
|
|
100
|
+
# Helpful on Windows (Python 3.8+): ensure DLL deps can be found
|
|
101
|
+
if os.name == "nt":
|
|
102
|
+
for var in ("CUDA_PATH", "CUDSS_PATH", "CONDA_PREFIX"):
|
|
103
|
+
base = os.environ.get(var)
|
|
104
|
+
if base:
|
|
105
|
+
p = pathlib.Path(base) / "bin"
|
|
106
|
+
if p.exists():
|
|
107
|
+
try:
|
|
108
|
+
os.add_dll_directory(str(p))
|
|
109
|
+
except Exception:
|
|
110
|
+
pass
|
|
111
|
+
mtlib = _from_dist_files()
|
|
112
|
+
return nvs.DirectSolverOptions(multithreading_lib=mtlib)
|
ngsolve/webgui.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ngsolve
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.2601
|
|
4
4
|
Summary: NGSolve
|
|
5
5
|
Author: The NGSolve team
|
|
6
6
|
License: LGPL2.1
|
|
7
7
|
License-File: LICENSE
|
|
8
|
-
Requires-Dist: netgen-mesher==6.2.
|
|
8
|
+
Requires-Dist: netgen-mesher==6.2.2601
|
|
9
9
|
Requires-Dist: mkl
|
|
10
10
|
|