diff --git a/Src/LinearSolvers/OpenBC/AMReX_OpenBC.H b/Src/LinearSolvers/OpenBC/AMReX_OpenBC.H index d07c26a9fb3..00d589e34b4 100644 --- a/Src/LinearSolvers/OpenBC/AMReX_OpenBC.H +++ b/Src/LinearSolvers/OpenBC/AMReX_OpenBC.H @@ -78,6 +78,9 @@ public: const LPInfo& a_info = LPInfo()); void setVerbose (int v) noexcept; + void setBottomVerbose (int v) noexcept; + + void useHypre (bool use_hypre) noexcept; Real solve (const Vector& a_sol, const Vector& a_rhs, Real a_tol_rel, Real a_tol_abs); @@ -95,6 +98,7 @@ private: #endif int m_verbose = 0; + int m_bottom_verbose = 0; Vector m_geom; Vector m_grids; Vector m_dmap; @@ -103,6 +107,7 @@ private: std::unique_ptr m_poisson_2; std::unique_ptr m_mlmg_1; std::unique_ptr m_mlmg_2; + BottomSolver m_bottom_solver_type = BottomSolver::bicgstab; int m_coarsen_ratio = 0; Array m_dpdn; diff --git a/Src/LinearSolvers/OpenBC/AMReX_OpenBC.cpp b/Src/LinearSolvers/OpenBC/AMReX_OpenBC.cpp index 429d4e79141..778f3ce3830 100644 --- a/Src/LinearSolvers/OpenBC/AMReX_OpenBC.cpp +++ b/Src/LinearSolvers/OpenBC/AMReX_OpenBC.cpp @@ -173,6 +173,22 @@ void OpenBCSolver::setVerbose (int v) noexcept m_verbose = v; } +void OpenBCSolver::setBottomVerbose (int v) noexcept +{ + m_bottom_verbose = v; +} + +void OpenBCSolver::useHypre (bool use_hypre) noexcept +{ + if (use_hypre) { + m_bottom_solver_type = BottomSolver::hypre; + m_info.setMaxCoarseningLevel(0); +#ifndef AMREX_USE_HYPRE + amrex::Abort("OpenBCSolver: Must enable Hypre support to use it."); +#endif + } +} + Real OpenBCSolver::solve (const Vector& a_sol, const Vector& a_rhs, Real a_tol_rel, Real a_tol_abs) @@ -201,6 +217,13 @@ Real OpenBCSolver::solve (const Vector& a_sol, m_mlmg_1 = std::make_unique(*m_poisson_1); m_mlmg_1->setVerbose(m_verbose); + m_mlmg_1->setBottomVerbose(m_bottom_verbose); + m_mlmg_1->setBottomSolver(m_bottom_solver_type); +#ifdef AMREX_USE_HYPRE + if (m_bottom_solver_type == BottomSolver::hypre) { + m_mlmg_1->setHypreInterface(Hypre::Interface::structed); + } +#endif } m_mlmg_1->solve(a_sol, a_rhs, a_tol_rel, a_tol_abs); @@ -289,6 +312,14 @@ Real OpenBCSolver::solve (const Vector& a_sol, m_mlmg_2 = std::make_unique(*m_poisson_2); m_mlmg_2->setVerbose(m_verbose); + m_mlmg_2->setBottomVerbose(m_bottom_verbose); + m_mlmg_2->setBottomSolver(m_bottom_solver_type); + if (m_bottom_solver_type == BottomSolver::hypre) { +#ifdef AMREX_USE_HYPRE + m_mlmg_2->setHypreInterface(Hypre::Interface::structed); +#else +#endif + } } Vector solv_all = a_sol; Vector rhsv_all = a_rhs;