Skip to content

Commit

Permalink
Add hypre as an option for OpenBCSolver (AMReX-Codes#2931)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Aug 30, 2022
1 parent 3d29fd7 commit acc223f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Src/LinearSolvers/OpenBC/AMReX_OpenBC.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<MultiFab*>& a_sol, const Vector<MultiFab const*>& a_rhs,
Real a_tol_rel, Real a_tol_abs);
Expand All @@ -95,6 +98,7 @@ private:
#endif

int m_verbose = 0;
int m_bottom_verbose = 0;
Vector<Geometry> m_geom;
Vector<BoxArray> m_grids;
Vector<DistributionMapping> m_dmap;
Expand All @@ -103,6 +107,7 @@ private:
std::unique_ptr<MLPoisson> m_poisson_2;
std::unique_ptr<MLMG> m_mlmg_1;
std::unique_ptr<MLMG> m_mlmg_2;
BottomSolver m_bottom_solver_type = BottomSolver::bicgstab;

int m_coarsen_ratio = 0;
Array<MultiFab,AMREX_SPACEDIM> m_dpdn;
Expand Down
31 changes: 31 additions & 0 deletions Src/LinearSolvers/OpenBC/AMReX_OpenBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MultiFab*>& a_sol,
const Vector<MultiFab const*>& a_rhs,
Real a_tol_rel, Real a_tol_abs)
Expand Down Expand Up @@ -201,6 +217,13 @@ Real OpenBCSolver::solve (const Vector<MultiFab*>& a_sol,

m_mlmg_1 = std::make_unique<MLMG>(*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);

Expand Down Expand Up @@ -289,6 +312,14 @@ Real OpenBCSolver::solve (const Vector<MultiFab*>& a_sol,

m_mlmg_2 = std::make_unique<MLMG>(*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<MultiFab*> solv_all = a_sol;
Vector<MultiFab const*> rhsv_all = a_rhs;
Expand Down

0 comments on commit acc223f

Please sign in to comment.