1#ifndef AMREX_HYPREIJIFACE_H
2#define AMREX_HYPREIJIFACE_H
3#include <AMReX_Config.H>
8#include <HYPRE_parcsr_ls.h>
9#include <HYPRE_parcsr_mv.h>
76 [[nodiscard]] HYPRE_IJMatrix
A() {
return m_mat; }
79 [[nodiscard]] HYPRE_IJVector
b() {
return m_rhs; }
82 [[nodiscard]] HYPRE_IJVector
x() {
return m_sln; }
95 void init_preconditioner(
const std::string& prefix,
const std::string& name);
96 void init_solver(
const std::string& prefix,
const std::string& name);
99 void run_hypre_setup();
100 void run_hypre_solve();
102 void report_failure (
const std::string& msg)
const;
105 void boomeramg_precond_configure(
const std::string& prefix);
106 void euclid_precond_configure(
const std::string& prefix);
107 void ilu_precond_configure(
const std::string& prefix);
110 void boomeramg_solver_configure(
const std::string& prefix);
111 void gmres_solver_configure(
const std::string& prefix);
112 void cogmres_solver_configure(
const std::string& prefix);
113 void lgmres_solver_configure(
const std::string& prefix);
114 void flex_gmres_solver_configure(
const std::string& prefix);
115 void bicgstab_solver_configure(
const std::string& prefix);
116 void pcg_solver_configure(
const std::string& prefix);
117 void hybrid_solver_configure(
const std::string& prefix);
122 HYPRE_IJMatrix m_mat{
nullptr};
123 HYPRE_IJVector m_rhs{
nullptr};
124 HYPRE_IJVector m_sln{
nullptr};
126 HYPRE_ParCSRMatrix m_parA{
nullptr};
127 HYPRE_ParVector m_parRhs{
nullptr};
128 HYPRE_ParVector m_parSln{
nullptr};
130 HYPRE_Solver m_solver{
nullptr};
131 HYPRE_Solver m_precond{
nullptr};
133 HypreIntType (*m_solverDestroyPtr)(HYPRE_Solver){
nullptr};
135 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
137 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
140 HYPRE_PtrToParSolverFcn,
141 HYPRE_PtrToParSolverFcn,
142 HYPRE_Solver){
nullptr};
144 HypreIntType (*m_precondDestroyPtr)(HYPRE_Solver){
nullptr};
146 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
148 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
162 std::string m_solver_name{
"BoomerAMG"};
163 std::string m_preconditioner_name{
"none"};
164 std::string m_file_prefix{
"IJ"};
166 std::string m_euclid_file;
171 unsigned int m_write_counter{0};
174 bool m_has_preconditioner{
false};
177 bool m_need_setup{
true};
181 bool m_recompute_preconditioner{
true};
184 bool m_adjust_singular_matrix{
false};
187 bool m_abort_on_hypre_error{
true};
190 bool m_throw_exception{
false};
193 bool m_write_files{
false};
196 bool m_overwrite_files{
true};
void parse_inputs(const std::string &prefix="hypre")
Parse runtime options (solver, preconditioner, tolerances).
Definition AMReX_HypreIJIface.cpp:310
~HypreIJIface()
Definition AMReX_HypreIJIface.cpp:195
HYPRE_IJMatrix A()
IJ matrix instance.
Definition AMReX_HypreIJIface.H:76
HYPRE_IJVector b()
Right hand side IJ vector instance.
Definition AMReX_HypreIJIface.H:79
HypreIJIface(HypreIJIface const &)=delete
void setRecomputePreconditioner(bool b) noexcept
Definition AMReX_HypreIJIface.H:69
HypreIntType getNumIters() const
Number of iterations taken by the solver to reach the desired tolerance.
Definition AMReX_HypreIJIface.H:85
HYPRE_Int HypreIntType
Definition AMReX_HypreIJIface.H:27
HypreIJIface(HypreIJIface &&)=delete
HypreIJIface & operator=(HypreIJIface const &)=delete
bool adjustSingularMatrix() const
Definition AMReX_HypreIJIface.H:90
HypreRealType getFinalResidualNorm() const
Final residual norm after a linear solve.
Definition AMReX_HypreIJIface.H:88
HYPRE_Real HypreRealType
Definition AMReX_HypreIJIface.H:28
void setNeedSetup() noexcept
Call after changing the matrix so the next solve redoes the setup.
Definition AMReX_HypreIJIface.H:65
HypreIntType ilower() const
Lowest global row id owned by this rank.
Definition AMReX_HypreIJIface.H:92
HYPRE_IJVector x()
Solution IJ vector instance.
Definition AMReX_HypreIJIface.H:82
void setThrowException(bool t) noexcept
Definition AMReX_HypreIJIface.H:73
void solve(HypreRealType rel_tol, HypreRealType abs_tol, HypreIntType max_iter)
Solve the linear system using the configured solver/preconditioner.
Definition AMReX_HypreIJIface.cpp:250
HypreIJIface(MPI_Comm comm, HypreIntType ilower, HypreIntType iupper, int verbose)
Construct an IJ interface spanning rows [ilower, iupper].
Definition AMReX_HypreIJIface.cpp:177
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
int MPI_Comm
Definition AMReX_ccse-mpi.H:51
static constexpr int MPI_COMM_NULL
Definition AMReX_ccse-mpi.H:59
Definition AMReX_Amr.cpp:50
std::string hypreErrorMessage(const std::string &where)
Definition AMReX_HypreIJIface.cpp:158