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>
72 [[nodiscard]] HYPRE_IJMatrix
A() {
return m_mat; }
75 [[nodiscard]] HYPRE_IJVector
b() {
return m_rhs; }
78 [[nodiscard]] HYPRE_IJVector
x() {
return m_sln; }
91 void init_preconditioner(
const std::string& prefix,
const std::string& name);
92 void init_solver(
const std::string& prefix,
const std::string& name);
95 void run_hypre_setup();
96 void run_hypre_solve();
99 void boomeramg_precond_configure(
const std::string& prefix);
100 void euclid_precond_configure(
const std::string& prefix);
101 void ilu_precond_configure(
const std::string& prefix);
104 void boomeramg_solver_configure(
const std::string& prefix);
105 void gmres_solver_configure(
const std::string& prefix);
106 void cogmres_solver_configure(
const std::string& prefix);
107 void lgmres_solver_configure(
const std::string& prefix);
108 void flex_gmres_solver_configure(
const std::string& prefix);
109 void bicgstab_solver_configure(
const std::string& prefix);
110 void pcg_solver_configure(
const std::string& prefix);
111 void hybrid_solver_configure(
const std::string& prefix);
116 HYPRE_IJMatrix m_mat{
nullptr};
117 HYPRE_IJVector m_rhs{
nullptr};
118 HYPRE_IJVector m_sln{
nullptr};
120 HYPRE_ParCSRMatrix m_parA{
nullptr};
121 HYPRE_ParVector m_parRhs{
nullptr};
122 HYPRE_ParVector m_parSln{
nullptr};
124 HYPRE_Solver m_solver{
nullptr};
125 HYPRE_Solver m_precond{
nullptr};
127 HypreIntType (*m_solverDestroyPtr)(HYPRE_Solver){
nullptr};
129 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
131 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
134 HYPRE_PtrToParSolverFcn,
135 HYPRE_PtrToParSolverFcn,
136 HYPRE_Solver){
nullptr};
138 HypreIntType (*m_precondDestroyPtr)(HYPRE_Solver){
nullptr};
140 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
142 HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector){
nullptr};
156 std::string m_solver_name{
"BoomerAMG"};
157 std::string m_preconditioner_name{
"none"};
158 std::string m_file_prefix{
"IJ"};
160 std::string m_euclid_file;
165 unsigned int m_write_counter{0};
168 bool m_has_preconditioner{
false};
171 bool m_need_setup{
true};
175 bool m_recompute_preconditioner{
true};
178 bool m_adjust_singular_matrix{
false};
181 bool m_write_files{
false};
184 bool m_overwrite_files{
true};
Convenience interface for configuring and invoking HYPRE IJ solvers.
Definition AMReX_HypreIJIface.H:25
void parse_inputs(const std::string &prefix="hypre")
Parse runtime options (solver, preconditioner, tolerances).
Definition AMReX_HypreIJIface.cpp:248
~HypreIJIface()
Definition AMReX_HypreIJIface.cpp:157
HYPRE_IJMatrix A()
IJ matrix instance.
Definition AMReX_HypreIJIface.H:72
HYPRE_IJVector b()
Right hand side IJ vector instance.
Definition AMReX_HypreIJIface.H:75
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:81
HYPRE_Int HypreIntType
Definition AMReX_HypreIJIface.H:27
HypreIJIface(HypreIJIface &&)=delete
HypreIJIface & operator=(HypreIJIface const &)=delete
bool adjustSingularMatrix() const
Definition AMReX_HypreIJIface.H:86
HypreRealType getFinalResidualNorm() const
Final residual norm after a linear solve.
Definition AMReX_HypreIJIface.H:84
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:88
HYPRE_IJVector x()
Solution IJ vector instance.
Definition AMReX_HypreIJIface.H:78
void solve(HypreRealType rel_tol, HypreRealType abs_tol, HypreIntType max_iter)
Solve the linear system using the configured solver/preconditioner.
Definition AMReX_HypreIJIface.cpp:197
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