|
|
|
@ -3,24 +3,45 @@ |
|
|
|
HYPRE.jl wraps most of HYPREs [ParCSR solvers and |
|
|
|
HYPRE.jl wraps most of HYPREs [ParCSR solvers and |
|
|
|
preconditioners](https://hypre.readthedocs.io/en/latest/api-sol-parcsr.html). |
|
|
|
preconditioners](https://hypre.readthedocs.io/en/latest/api-sol-parcsr.html). |
|
|
|
|
|
|
|
|
|
|
|
The synopsis for HYPRE.jl's wrappers is the same for all solvers: |
|
|
|
The synopsis for creating and using HYPRE.jl's solver wrappers is the same for all solvers: |
|
|
|
|
|
|
|
1. Set up the linear system (see [Matrix/vector representation](@ref)) |
|
|
|
|
|
|
|
2. (Optional) Configure a preconditioner |
|
|
|
|
|
|
|
3. Configure a solver |
|
|
|
|
|
|
|
4. Use [`HYPRE.solve`](@ref) or [`HYPRE.solve!`](@ref) to solve the system |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Here is the corresponding pseudo-code: |
|
|
|
```julia |
|
|
|
```julia |
|
|
|
# Setup up linear system (see previous section) |
|
|
|
# 1. Setup up linear system |
|
|
|
A = HYPREMatrix(...) |
|
|
|
A = HYPREMatrix(...) |
|
|
|
b = HYPREVector(...) |
|
|
|
b = HYPREVector(...) |
|
|
|
|
|
|
|
|
|
|
|
# Create a solver |
|
|
|
# 2. Configure a preconditioner |
|
|
|
solver = HYPRESolver(; settings...) |
|
|
|
precond = HYPRESolver(; settings...) |
|
|
|
|
|
|
|
|
|
|
|
# Solve A x = b |
|
|
|
# 3. Configure a solver |
|
|
|
|
|
|
|
solver = HYPRESolver(; Precond = precond, settings...) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 4. Solve the system |
|
|
|
x = HYPRE.solve(solver, A, b) |
|
|
|
x = HYPRE.solve(solver, A, b) |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following solvers/preconditioners are currently available: |
|
|
|
|
|
|
|
- [`HYPRE.BiCGSTAB`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.BoomerAMG`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.FlexGMRES`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.GMRES`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.Hybrid`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.ILU`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.ParaSails`](@ref) |
|
|
|
|
|
|
|
- [`HYPRE.PCG`](@ref) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Solver configuration |
|
|
|
|
|
|
|
|
|
|
|
Settings are passed as keyword arguments, with the names matching directly to |
|
|
|
Settings are passed as keyword arguments, with the names matching directly to |
|
|
|
`HYPRE_SolverSetXXX` calls from the HYPRE C API (see example below). Most settings are |
|
|
|
`HYPRE_SolverSet*` calls from the HYPRE C API (see example below). Most settings are passed |
|
|
|
passed directly to HYPRE, for example `Tol = 1e-9` would be passed directly to |
|
|
|
directly to HYPRE, for example `Tol = 1e-9` would be passed directly to `HYPRE_SolverSetTol` |
|
|
|
`HYPRE_SolverSetTol` for the correponding solver. |
|
|
|
for the correponding solver. |
|
|
|
|
|
|
|
|
|
|
|
Setting a preconditioner can be done by passing a `HYPRESolver` directly with the `Precond` |
|
|
|
Setting a preconditioner can be done by passing a `HYPRESolver` directly with the `Precond` |
|
|
|
keyword argument, without any need to also pass the corresponding `HYPRE_SolverSetup` and |
|
|
|
keyword argument, without any need to also pass the corresponding `HYPRE_SolverSetup` and |
|
|
|
@ -30,6 +51,7 @@ settings when used as a preconditioner will have those applied automatically. |
|
|
|
HYPRE.jl adds finalizers to the solvers, which takes care of calling the their respective |
|
|
|
HYPRE.jl adds finalizers to the solvers, which takes care of calling the their respective |
|
|
|
`HYPRE_SolverDestroy` function when the solver is garbage collected. |
|
|
|
`HYPRE_SolverDestroy` function when the solver is garbage collected. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Example: Conjugate gradient with algebraic multigrid preconditioner |
|
|
|
#### Example: Conjugate gradient with algebraic multigrid preconditioner |
|
|
|
|
|
|
|
|
|
|
|
Here is an example of creating a `PCG` (conjugate gradient) solver with `BoomerAMG` |
|
|
|
Here is an example of creating a `PCG` (conjugate gradient) solver with `BoomerAMG` |
|
|
|
@ -55,7 +77,8 @@ preconditioner. These settings are added automatically since it is passed as a |
|
|
|
preconditioner to the `PCG` solver. |
|
|
|
preconditioner to the `PCG` solver. |
|
|
|
|
|
|
|
|
|
|
|
!!! not "Corresponding C code" |
|
|
|
!!! not "Corresponding C code" |
|
|
|
For comparison, here is the corresponding C code for setting up the solver above: |
|
|
|
For comparison between the APIs, here is the corresponding C code for setting up the |
|
|
|
|
|
|
|
solver above: |
|
|
|
```c |
|
|
|
```c |
|
|
|
/* Setup linear system */ |
|
|
|
/* Setup linear system */ |
|
|
|
HYPRE_IJMatrix A; |
|
|
|
HYPRE_IJMatrix A; |
|
|
|
|