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 stores the MPI communicator in the solvers structs. The
default communicator is changed from COMM_WORLD to COMM_NULL, for
BiCGSTAB, GMRES, and PCG, since their respective HYPRE_Create functions
simply ignore this argument.
This patch adds HYPREError <: Exception which is thrown when a HYPRE_
function returns an error code. HYPRE_ClearAllErrors() are called just
before throwing.
Some solvers have option from the specific ParCSR solver + options for
the general solver. This updates the option generator to handle this
such that the specific method is preferred over the generic one. This
patch also include the result of the generator applied to PCG, which has
some specific options for ParCSRPCG.
This patch adds the function `HYPRE.Init()` which i) calls `MPI.Init`
(unless MPI is already initialized), ii) calls `HYPRE_Init`, and iii)
adds a Julia exit hook which calls `HYPRE_Finalize` (if the keyword
argument `finalize_atexit` is `true`).
This patch adds defaults for ilower and iupper in constructors when i)
using SparseMatrixCS(C|R) and Vector and ii) when no communicator is
passed. In this case we simply assume the users wants a single-processor
solve, and default to passing 1 and size(A, 1) as the default values.
In the future this could possibly use the HYPRE sequential compiler
flag to completely avoid MPI.
This patch changes the argument order from:
HYPREMatrix(::SparseMatrixCS(C|R), ::Integer, ::Integer, ::MPI.Comm)
HYPREVector(::Vector, ::Integer, ::Integer, ::MPI.Comm)
to:
HYPREMatrix(::MPI.Comm, ::SparseMatrixCS(C|R), ::Integer, ::Integer)
HYPREVector(::MPI.Comm, ::Vector, ::Integer, ::Integer)
to match the basic constructor. This also makes it easier to default
owned rows to the full matrix/vector for single process solves. The
methods without the communicator (added in this patch) will in the
future have this default.
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.
This patch adds the following methods:
solve( ::HYPRESolver, ::PSparseMatrix, ::PVector)
solve!(::HYPRESolver, ::PVector, ::PSparseMatrix, ::PVector)
which automatically converts to/from HYPRE(Matrix|Vector).
This patch adds a function
solve(::HYPRESolver, ::HYPREMatrix, ::HYPREVector) which initializes an
output vector initialized to 0 and pass it to solve!.
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).