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>
73 {
return m_need_setup || m_recompute_preconditioner; }
80 [[nodiscard]] HYPRE_IJMatrix
A() {
return m_mat; }
83 [[nodiscard]] HYPRE_IJVector
b() {
return m_rhs; }
86 [[nodiscard]] HYPRE_IJVector
x() {
return m_sln; }
99 void init_preconditioner(
const std::string& prefix,
const std::string& name);
100 void init_solver(
const std::string& prefix,
const std::string& name);
103 void run_hypre_setup();
104 void run_hypre_solve();
106 void report_failure (
const std::string& msg)
const;
109 void boomeramg_precond_configure(
const std::string& prefix);
110 void euclid_precond_configure(
const std::string& prefix);
111 void ilu_precond_configure(
const std::string& prefix);
114 void boomeramg_solver_configure(
const std::string& prefix);
115 void gmres_solver_configure(
const std::string& prefix);
116 void cogmres_solver_configure(
const std::string& prefix);
117 void lgmres_solver_configure(
const std::string& prefix);
118 void flex_gmres_solver_configure(
const std::string& prefix);
119 void bicgstab_solver_configure(
const std::string& prefix);
120 void pcg_solver_configure(
const std::string& prefix);
121 void hybrid_solver_configure(
const std::string& prefix);
126 HYPRE_IJMatrix m_mat{
nullptr};
127 HYPRE_IJVector m_rhs{
nullptr};
128 HYPRE_IJVector m_sln{
nullptr};
130 HYPRE_ParCSRMatrix m_parA{
nullptr};
131 HYPRE_ParVector m_parRhs{
nullptr};
132 HYPRE_ParVector m_parSln{
nullptr};
134 HYPRE_Solver m_solver{
nullptr};
135 HYPRE_Solver m_precond{
nullptr};
137 HypreIntType (*m_solverDestroyPtr)(HYPRE_Solver){
nullptr};
139 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
141 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
144 HYPRE_PtrToParSolverFcn,
145 HYPRE_PtrToParSolverFcn,
146 HYPRE_Solver){
nullptr};
148 HypreIntType (*m_precondDestroyPtr)(HYPRE_Solver){
nullptr};
150 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
152 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
166 std::string m_solver_name{
"BoomerAMG"};
167 std::string m_preconditioner_name{
"none"};
168 std::string m_file_prefix{
"IJ"};
170 std::string m_euclid_file;
175 unsigned int m_write_counter{0};
178 bool m_has_preconditioner{
false};
181 bool m_need_setup{
true};
185 bool m_recompute_preconditioner{
true};
188 bool m_adjust_singular_matrix{
false};
191 bool m_abort_on_hypre_error{
true};
194 bool m_throw_exception{
false};
197 bool m_write_files{
false};
200 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
bool setupPending() const noexcept
Will the next solve do the solver/preconditioner setup?
Definition AMReX_HypreIJIface.H:72
HYPRE_IJMatrix A()
IJ matrix instance.
Definition AMReX_HypreIJIface.H:80
HYPRE_IJVector b()
Right hand side IJ vector instance.
Definition AMReX_HypreIJIface.H:83
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:89
HYPRE_Int HypreIntType
Definition AMReX_HypreIJIface.H:27
HypreIJIface(HypreIJIface &&)=delete
HypreIJIface & operator=(HypreIJIface const &)=delete
bool adjustSingularMatrix() const
Definition AMReX_HypreIJIface.H:94
HypreRealType getFinalResidualNorm() const
Final residual norm after a linear solve.
Definition AMReX_HypreIJIface.H:92
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:96
HYPRE_IJVector x()
Solution IJ vector instance.
Definition AMReX_HypreIJIface.H:86
void setThrowException(bool t) noexcept
Definition AMReX_HypreIJIface.H:77
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