Skip to content

Commit 286d36e

Browse files
Sébastien LoiselSébastien Loisel
authored andcommitted
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()
1 parent ced5349 commit 286d36e

5 files changed

Lines changed: 22 additions & 198 deletions

File tree

docs/make.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ makedocs(;
2323
"Vectors" => "guide/vectors.md",
2424
"Matrices" => "guide/matrices.md",
2525
"Linear Solvers" => "guide/solvers.md",
26-
"STRUMPACK Support" => "guide/strumpack.md",
2726
"Input/Output and Display" => "guide/io.md",
2827
"MPI Programming" => "guide/mpi_programming.md",
2928
"Distributed Reference Management" => "guide/distributed_refs.md",

docs/src/guide/matrices.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Matrices
22

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.
44

55
## Creating Matrices
66

@@ -488,9 +488,8 @@ x = A \ b
488488

489489
1. **Use Native Operations**: Prefer PETSc operations over element access
490490
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
494493

495494
```julia
496495
# Good: bulk assembly

docs/src/guide/solvers.md

Lines changed: 18 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Linear Solvers
22

3-
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.
44

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)
711

812
## Basic Usage
913

@@ -128,68 +132,6 @@ X = B / A'
128132

129133
Note: `B` and `X` must be dense matrices.
130134

131-
## Configuring Solvers
132-
133-
### PETSc Options
134-
135-
Control solver behavior via PETSc options:
136-
137-
```julia
138-
# Global configuration
139-
petsc_options_insert_string("-ksp_type gmres")
140-
petsc_options_insert_string("-ksp_rtol 1e-8")
141-
petsc_options_insert_string("-pc_type bjacobi")
142-
143-
# With prefix for specific solvers
144-
# First define a custom prefix type (advanced)
145-
struct MyPrefix end
146-
SafePETSc.prefix(::Type{MyPrefix}) = "my_"
147-
148-
petsc_options_insert_string("-my_ksp_type cg")
149-
A = Mat_uniform(data; Prefix=MyPrefix)
150-
ksp = KSP(A) # Will use CG
151-
```
152-
153-
Common KSP options:
154-
- `-ksp_type`: KSP type (cg, gmres, bcgs, etc.)
155-
- `-ksp_rtol`: Relative tolerance
156-
- `-ksp_atol`: Absolute tolerance
157-
- `-ksp_max_it`: Maximum iterations
158-
- `-pc_type`: Preconditioner (jacobi, bjacobi, ilu, etc.)
159-
160-
### Monitoring Convergence
161-
162-
```julia
163-
petsc_options_insert_string("-ksp_monitor")
164-
petsc_options_insert_string("-ksp_converged_reason")
165-
166-
x = A \ b
167-
# PETSc will print convergence information
168-
```
169-
170-
## KSP Types
171-
172-
SafePETSc supports all PETSc KSP types. Common choices:
173-
174-
### Direct Methods
175-
```julia
176-
# For small to medium problems
177-
petsc_options_insert_string("-ksp_type preonly -pc_type lu")
178-
x = A \ b
179-
```
180-
181-
### Iterative Methods
182-
```julia
183-
# Conjugate Gradient (symmetric positive definite)
184-
petsc_options_insert_string("-ksp_type cg -pc_type jacobi")
185-
186-
# GMRES (general nonsymmetric)
187-
petsc_options_insert_string("-ksp_type gmres -ksp_gmres_restart 30")
188-
189-
# BiCGStab
190-
petsc_options_insert_string("-ksp_type bcgs")
191-
```
192-
193135
## Examples
194136

195137
### Basic Linear System
@@ -224,31 +166,6 @@ r = b - A * x
224166
# (In practice, use PETSc's built-in convergence monitoring)
225167
```
226168

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-
252169
### Multiple Solves
253170

254171
```julia
@@ -294,17 +211,9 @@ X = A \ B
294211

295212
## Performance Tips
296213

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.
302215

303-
```julia
304-
# GPU configuration example
305-
petsc_options_insert_string("-mat_type aijcusparse")
306-
petsc_options_insert_string("-vec_type cuda")
307-
```
216+
2. **Use Sparse Matrices**: Direct solvers are designed for sparse matrices. Dense coefficient matrices will be slow and memory-intensive.
308217

309218
## KSP Properties
310219

@@ -320,38 +229,19 @@ n = size(ksp, 2) # Columns
320229

321230
## Troubleshooting
322231

323-
### Convergence Issues
324-
325-
```julia
326-
# Increase iterations
327-
petsc_options_insert_string("-ksp_max_it 10000")
328-
329-
# Relax tolerance
330-
petsc_options_insert_string("-ksp_rtol 1e-6")
331-
332-
# Try different solver/preconditioner
333-
petsc_options_insert_string("-ksp_type gmres -pc_type asm")
232+
### Singular Matrix
334233

335-
# View solver details
336-
petsc_options_insert_string("-ksp_view")
337-
```
338-
339-
### Memory Issues
340-
341-
```julia
342-
# Use iterative method instead of direct
343-
petsc_options_insert_string("-ksp_type cg")
344-
345-
# Reduce GMRES restart
346-
petsc_options_insert_string("-ksp_gmres_restart 10")
347-
```
234+
If the direct solver fails, the matrix may be singular or nearly singular. Check:
235+
- Matrix has full rank
236+
- No zero rows or columns
237+
- Appropriate scaling
348238

349-
### Assertion Failures
239+
### Dimension Mismatch
350240

351241
Ensure:
352-
- Matrix is square for `\` operator
353-
- Partitions match (A.row_partition == b.row_partition)
354-
- Same prefix on all objects
242+
- Matrix `A` is square for `\` operator
243+
- Vector `b` has same row partition as `A`
244+
- For `inv(A) * B`, columns of `B` match rows of `A`
355245

356246
## See Also
357247

docs/src/guide/strumpack.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/src/guide/vectors.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,7 @@ v = Vec_sum(sparsevec(indices, values, n); own_rank_only=true)
361361

362362
1. **Use Broadcasting**: In-place broadcasting (`y .= ...`) avoids allocations
363363
2. **Batch Operations**: Combine multiple operations in one broadcast
364-
3. **Avoid Extraction**: Keep data in distributed vectors; don't extract to Julia arrays
365-
4. **GPU-Aware**: Set PETSc options for GPU execution
364+
3. **Avoid Extraction**: Keep data in distributed vectors; don't extract to Julia arrays unless necessary
366365

367366
```julia
368367
# Good: in-place, batched

0 commit comments

Comments
 (0)