This patch adds the functions
`HYPRE.GetFinalRelativeResidualNorm(::HYPRESolver)` and
`HYPRE.GetNumIterations(::HYPRESolver)` for querying final residual norm
and number of iterations from solvers. These functions dispatches on the
solver to the corresponding C API wrappers
`LibHYPRE.HYPRE_${Solver}GetFinalRelativeResidualNorm` and
`LibHYPRE.HYPRE_${Solver}GetNumIterations`, respectively.
This patch adds methods for `Base.unsafe_convert` for `HYPREMatrix`,
`HYPREVector`, and `HYPRESolver`. This means that those objects can be
passed directly to `ccall` and be "converted" (i.e. extracting the
pointer that is stored in the structs) to the appropriate type expected
by the HYPRE C-library. The advantage is that `ccall` then guarantees
that the objects are kept alive for the duration of the call.
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 fixes the buffer length in to_hypre_data(::MatrixAssembler).
Previously the buffer was always too long, which was not problematic for
correctness, but it is unnecessary. This patch also adds some assertions
to check the internal consistency of the buffer lengths.
This patch adds an assembler interface such that it is possible to
directly assemble HYPRE(Vector|Matrix) without going through a sparse
matrix datastructure in Julia. This is done as follows:
1. Create a new (empty) matrix/vector using the constructor.
2. Create an assembler and initialize the assembly using
HYPRE.start_assemble!.
3. Assemble all contributions using HYPRE.assemble!.
4. Finalize the assembly using HYPRE.finish_assemble!.
HYPRE.start_assemble!
The assembler caches some buffers that are (re)used by every call to
HYPRE.assemble! so this should be efficient. All MPI communication
should happen in the finalization step.
This patch updates the MPI.jl compat to allow 0.20. In addition, the Clang.jl generator is
updated to filter out all unnecessary bindings (e.g. MPI related) and instead bring in constants
from MPI.jl. This should make sure that those are synced, since everything now uses MPIPreferences.
Co-authored-by: Dennis Ogiermann <termi-official@users.noreply.github.com>
Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
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.