![]() |
Block-Structured AMR Software Framework
|
Solve Ax = b using HYPRE's generic IJ matrix format where A is a sparse matrix specified using the compressed sparse row (CSR) format. More...
#include <AMReX_HypreSolver.H>
Public Member Functions | |
| template<class Marker , class Filler > | |
| HypreSolver (Vector< IndexType > const &a_index_type, IntVect const &a_nghost, Geometry const &a_geom, BoxArray const &a_grids, DistributionMapping const &a_dmap, Marker &&a_marker, Filler &&a_filler, int a_verbose=0, std::string a_options_namespace="hypre") | |
| template<class MF , std::enable_if_t< IsFabArray< MF >::value &&std::is_same_v< typename MF::value_type, HYPRE_Real >, int > = 0> | |
| void | solve (Vector< MF * > const &a_soln, Vector< MF const * > const &a_rhs, HYPRE_Real rel_tol, HYPRE_Real abs_tol, int max_iter) |
| Solve Ax=b after the constructor assembled the IJ matrix. | |
| int | getNumIters () const |
| Number of iterations from the last solve(). | |
| HYPRE_Real | getFinalResidualNorm () const |
| Final residual norm from the last solve(). | |
| HYPRE_IJMatrix | getA () const |
| Access the assembled IJ matrix handle (non-owning). | |
| HYPRE_IJVector | getb () const |
| Access the assembled IJ RHS handle (non-owning). | |
| HYPRE_IJVector | getx () const |
| Access the IJ solution handle (non-owning). | |
| template<class Marker > | |
| std::enable_if_t< IsCallable< Marker, int, int, int, int, int >::value > | fill_local_id (Marker const &marker) |
Assign local ids to each owned DOF by invoking marker. | |
| template<typename AI > | |
| void | fill_global_id () |
| Convert the local ids to globally unique ids visible to HYPRE. | |
| template<class Filler , std::enable_if_t< IsCallable< Filler, int, int, int, int, int, Array4< HYPRE_Int const > const *, HYPRE_Int &, HYPRE_Int *, HYPRE_Real * >::value, int > FOO = 0> | |
| void | fill_matrix (Filler const &filler) |
Fill each CSR row using the supplied filler functor. | |
| template<class MF , std::enable_if_t< IsFabArray< MF >::value &&std::is_same_v< typename MF::value_type, HYPRE_Real >, int > = 0> | |
| void | load_vectors (Vector< MF * > const &a_soln, Vector< MF const * > const &a_rhs) |
| Copy AMReX RHS/initial guess data into the IJ vectors. | |
| template<class MF , std::enable_if_t< IsFabArray< MF >::value &&std::is_same_v< typename MF::value_type, HYPRE_Real >, int > = 0> | |
| void | get_solution (Vector< MF * > const &a_soln) |
| Copy IJ solution entries back into AMReX storage. | |
Solve Ax = b using HYPRE's generic IJ matrix format where A is a sparse matrix specified using the compressed sparse row (CSR) format.
An example of using HypreSolver to solve Poisson's equation is located in Tests/LinearSolvers/Hypre (which exercises the HYPRE backend)
| amrex::HypreSolver< MSS >::HypreSolver | ( | Vector< IndexType > const & | a_index_type, |
| IntVect const & | a_nghost, | ||
| Geometry const & | a_geom, | ||
| BoxArray const & | a_grids, | ||
| DistributionMapping const & | a_dmap, | ||
| Marker && | a_marker, | ||
| Filler && | a_filler, | ||
| int | a_verbose = 0, |
||
| std::string | a_options_namespace = "hypre" |
||
| ) |
Constructor
| [in] | a_index_type | nodality of the data |
| [in] | a_nghost | number of ghosts cells |
| [in] | a_geom | Geometry of problem domain |
| [in] | a_grids | BoxArray of computational grids |
| [in] | a_dmap | DistributionMapping |
| [in] | a_marker | functor that returns whether the variable n at (i,j,k) in Box boxno (local index) is valid (i.e., not exactly on Dirichlet boundary). function signature: (int boxno, int i, int j, int k, int n) -> bool
|
| [in] | a_filler | functor that fills the row in the matrix A for variable n at (i,j,k) in Box boxno (local index) using the CSR format. function signature: // [in ] gid gid[n] is the id for variable n at (i,j,k)
// [out] ncols # of non-zero columns in this row.
// [out] cols array of indices of columns with a non-zero matrix element in this row.
// [out] mat array of (non-zero) matrix elements in this row.
(int boxno, int i, int j, int k, int n, Array4<HYPRE_Int const> const* gid, HYPRE_Int& ncols, HYPRE_Int* cols, HYPRE_Real* mat)
|
| [in] | a_verbose | HYPRE verbosity (default 0) |
| [in] | a_options_namespace | namespace to use when parsing runtime input parameters (default literal "hypre" used for HYPRE options) |
Convert the local ids to globally unique ids visible to HYPRE.
| std::enable_if_t< IsCallable< Marker, int, int, int, int, int >::value > amrex::HypreSolver< MSS >::fill_local_id | ( | Marker const & | marker | ) |
Assign local ids to each owned DOF by invoking marker.
| void amrex::HypreSolver< MSS >::fill_matrix | ( | Filler const & | filler | ) |
Fill each CSR row using the supplied filler functor.
| filler | Functor with signature (int boxno, int i, int j, int k, int n, Array4<HYPRE_Int const> const* gid, HYPRE_Int& ncols, HYPRE_Int* cols, HYPRE_Real* mat) that emits the nonzeros for each DOF. |
| void amrex::HypreSolver< MSS >::get_solution | ( | Vector< MF * > const & | a_soln | ) |
Copy IJ solution entries back into AMReX storage.
| a_soln | Solution MultiFabs populated in place. |
|
inline |
Access the assembled IJ matrix handle (non-owning).
|
inline |
Access the assembled IJ RHS handle (non-owning).
|
inline |
Final residual norm from the last solve().
|
inline |
Number of iterations from the last solve().
|
inline |
Access the IJ solution handle (non-owning).
| void amrex::HypreSolver< MSS >::load_vectors | ( | Vector< MF * > const & | a_soln, |
| Vector< MF const * > const & | a_rhs | ||
| ) |
Copy AMReX RHS/initial guess data into the IJ vectors.
| a_soln | Solution MultiFabs (initial guess overwritten). |
| a_rhs | RHS MultiFabs. |
| void amrex::HypreSolver< MSS >::solve | ( | Vector< MF * > const & | a_soln, |
| Vector< MF const * > const & | a_rhs, | ||
| HYPRE_Real | rel_tol, | ||
| HYPRE_Real | abs_tol, | ||
| int | max_iter | ||
| ) |
Solve Ax=b after the constructor assembled the IJ matrix.
| [out] | a_soln | Solution vectors (updated in place). |
| [in] | a_rhs | Right-hand-side vectors. |
| [in] | rel_tol | Relative convergence tolerance. |
| [in] | abs_tol | Absolute convergence tolerance. |
| [in] | max_iter | Maximum iterations. |