This patch tracks all created HYPRE objects (`HYPREMatrix`,
`HYPREVector`, and `HYPRESolver`s) in a global `WeakKeyDict` to make
sure they are all finalized **before** MPI and/or HYPRE is finalized.
These libraries are typically finalized in Julia atexit hooks, but at
that point the object finalizers might yet not have been run. This patch
make sure to explicitly call `finalize` on any remaining HYPRE objects
before finalizing the library.
This patch wraps the HYPRE_Destroy functions for the HYPRESolvers in a
functtion that checks if the pointer is NULL before calling the Destroy
function. While this makes sense on it self, it also makes it possible
to override a finalizer by adding a second one that sets the pointer to
NULL. This is utilized in the set_precond(::Hybrid, p) function, since
the Hybrid solver currently frees the provied preconditioner too.
This patch adds the communicator and the owned rows to the
`HYPRE(Matrix|Vector)` structs. The `Internals.init_(matrix|vector)`
functions have been removed in favor of:
HYPREMatrix(::MPI.Comm, ::Integer, ::Integer, ::Integer, ::Integer)
HYPREVector(::MPI.Comm, ::Integer, ::Integer)
which more or less mirrors the `IJ(Matrix|Vector)Create` functions.
Settings are passed as keyword arguments, just like BoomerAMG. The
Precond argument (corresponding to PCGSetPrecond) is handled separately,
and lets you pass another solver directly, instead of the solver
pointer, the setup and solve functions, as in the SetPrecond C function.
Example:
precond = BoomerAMG(; options...)
solver = PCG(; Precond = precond, options...)
This commits contains the solver interface:
A = HYPREMatrix(...)
b = HYPREVector(...)
x = HYPREVector(...)
solver = HYPRESolver(; options...)
solve!(solver, x, A, b)
where the abstract type HYPRESolver is replaced by a concrete solver
implementation (this commit includes the concrete
implementation/wrapping of BoomerAMG <: HYPRESolver).
Solver settings are passed as keyword arguments to the solver
constructor, cf. SetXXX functions in HYPRE.
For example, to create a BoomerAMG solver, and setting the tolerance:
solver = BoomerAMG(Tol = 1e-7)
Keyword argument names correspond directly to the solvers SetXXX
function in HYPRE; passing Tol corresponds to
HYPRE_BoomerAMGSetTol(solver, 1e-7).
- Move LibHYPRE submodule to it's own file
- Move Internals stub module to it's own file
- Add conversions from PartitionedArrays.(PSparseMatrix|PVector)
- More tests...