You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify documentation: remove STRUMPACK and GPU content
- Delete guide/strumpack.md and remove from navigation
- Remove iterative solver, preconditioner, and GPU content from guides
- Simplify solvers.md to focus on direct solvers only
- SafePETSc uses direct solvers configured automatically by Init()
Copy file name to clipboardExpand all lines: docs/src/guide/matrices.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Matrices
2
2
3
-
SafePETSc provides distributed matrices through the `Mat{T,Prefix}` type, which wraps PETSc's distributed matrix functionality with GPU-friendly operations and automatic memory management.
3
+
SafePETSc provides distributed matrices through the `Mat{T,Prefix}` type, which wraps PETSc's distributed matrix functionality with automatic memory management.
4
4
5
5
## Creating Matrices
6
6
@@ -488,9 +488,8 @@ x = A \ b
488
488
489
489
1.**Use Native Operations**: Prefer PETSc operations over element access
490
490
2.**Batch Assembly**: Build sparse matrices locally, then sum once
491
-
3.**Appropriate Matrix Type**: Use dense vs. sparse based on structure
492
-
4.**Reuse KSP Objects**: Create `KSP` once, reuse for multiple solves
493
-
5.**GPU Configuration**: Set PETSc options for GPU matrices
491
+
3.**Appropriate Matrix Type**: Use sparse (default) for systems with few nonzeros per row; dense for full matrices
492
+
4.**Reuse Factorizations**: Use `inv(A)` or `KSP(A)` once, reuse for multiple solves with the same matrix
SafePETSc provides linear solver functionality through PETSc's KSP (Krylov Subspace) interface, wrapped with automatic memory management.
3
+
SafePETSc provides linear solver functionality through PETSc's KSP interface, using direct (sparse LU factorization) solvers.
4
4
5
-
!!! note "Sparse Matrices"
6
-
The default direct solvers (MUMPS/STRUMPACK) are designed for **sparse matrices**. The coefficient matrix `A` should be sparse (MPIAIJ). Dense coefficient matrices are not supported by the sparse direct solvers.
5
+
!!! note "Direct Solvers"
6
+
SafePETSc uses **direct solvers** (sparse LU factorization), not iterative methods. This means:
7
+
- No convergence parameters to tune
8
+
- No preconditioner selection needed
9
+
- Exact solutions (up to floating-point precision)
10
+
- The coefficient matrix `A` should be sparse (MPIAIJ prefix, which is the default)
# (In practice, use PETSc's built-in convergence monitoring)
225
167
```
226
168
227
-
### Iterative KSP with Monitoring
228
-
229
-
```julia
230
-
using SafePETSc
231
-
232
-
SafePETSc.Init()
233
-
234
-
# Configure solver
235
-
petsc_options_insert_string("-ksp_type cg")
236
-
petsc_options_insert_string("-ksp_rtol 1e-10")
237
-
petsc_options_insert_string("-ksp_monitor")
238
-
petsc_options_insert_string("-pc_type jacobi")
239
-
240
-
# Build system (e.g., Laplacian)
241
-
n =1000
242
-
diag =Vec_uniform(2.0*ones(n))
243
-
off =Vec_uniform(-1.0*ones(n-1))
244
-
A =spdiagm(-1=> off, 0=> diag, 1=> off)
245
-
246
-
b =Vec_uniform(ones(n))
247
-
248
-
# Solve (will print iteration info)
249
-
x = A \ b
250
-
```
251
-
252
169
### Multiple Solves
253
170
254
171
```julia
@@ -294,17 +211,9 @@ X = A \ B
294
211
295
212
## Performance Tips
296
213
297
-
1.**Reuse KSP Objects**: Create `KSP` once for multiple solves
298
-
2.**Choose Appropriate Method**: Direct for small problems, iterative for large
299
-
3.**Tune Preconditioner**: Can dramatically affect convergence
300
-
4.**Monitor Convergence**: Use `-ksp_monitor` to tune parameters
301
-
5.**GPU Acceleration**: Set PETSc options for GPU execution
214
+
1.**Reuse Factorizations**: Use `inv(A)` or `KSP(A)` when solving multiple systems with the same matrix. The expensive factorization happens once and is reused for each solve.
0 commit comments