openseespy_solvers.cupy.precond¶
CUDA built-in preconditioners for iterative cupyx.scipy.sparse.linalg solvers.
Pass these callables through the M= keyword of cg, gmres, or lobpcg. When M is
callable, the solver calls it as M(A) after OpenSeesPy supplies the assembled matrix.
Preconditioners¶
| Preconditioner | Description |
|---|---|
jacobi |
Diagonal/Jacobi preconditioner on CUDA |
ilu |
Incomplete LU preconditioner |
direct |
Direct-solver preconditioner |
Usage¶
from openseespy_solvers.cupy import cg
from openseespy_solvers.cupy import precond
solver = cg(rtol=1e-8, M=precond.jacobi)
ops.system("PythonSparse", solver.to_openseespy())
Function Reference¶
Preconditioner factories for the cupy backend.
These callables are intended for the M argument of :func:cg,
:func:gmres, and :func:lobpcg. Each factory accepts the assembled sparse
matrix from OpenSees and returns a preconditioner on device.
jacobi
¶
Return a Jacobi (diagonal) preconditioner on GPU.
Computes M = diag(1 / diag(A)). Zero diagonal entries are left as 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
spmatrix
|
System matrix assembled by OpenSees on device. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
M |
LinearOperator
|
Diagonal preconditioner ( |
See Also
direct ilu openseespy_solvers.cupy.cg openseespy_solvers.cupy.lobpcg openseespy_solvers.scipy.precond.jacobi
Examples:
>>> from openseespy_solvers.cupy import cg, lobpcg, precond
>>> cg(M=precond.jacobi)
>>> lobpcg(M=precond.jacobi)
Source code in src/openseespy_solvers/cupy/precond.py
ilu
¶
Return an incomplete LU preconditioner as a LinearOperator on GPU.
By default fill_factor=1, which triggers cupy's GPU ILU path with no
fill-in and no pivoting. See
:func:cupyx.scipy.sparse.linalg.spilu — only fill_factor=1 runs the
factorization on GPU; other settings delegate to scipy.sparse.linalg on CPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
spmatrix
|
System matrix assembled by OpenSees on device. |
required |
**opts
|
Any
|
Keyword arguments forwarded to
:func: |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
M |
LinearOperator
|
Preconditioner implementing |
See Also
cupyx.scipy.sparse.linalg.spilu jacobi direct openseespy_solvers.scipy.precond.ilu
Notes
With fill_factor=1, factorization and application stay on the GPU but
the pattern is restricted to the sparsity structure of A (ILU(0)-like,
no fill-in).
Examples:
Source code in src/openseespy_solvers/cupy/precond.py
direct
¶
Return a callable M(A) that approximates A^{-1} via a direct solver.
Intended primarily for :func:~openseespy_solvers.cupy.lobpcg as M= on
stiffness K. The first application factors A; later applications in
the same eigen solve reuse the factorization when the matrix is unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solver
|
LinearSolver
|
Direct solver for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
preconditioner |
callable
|
Function |
See Also
jacobi ilu openseespy_solvers.nvmath.direct_solver openseespy_solvers.cupy.lobpcg openseespy_solvers.hybrid
Examples:
>>> from openseespy_solvers.cupy import lobpcg, precond, spsolve
>>> eigsolver = lobpcg(M=precond.direct(spsolve()), tol=1e-8)