1#ifndef AMREX_HYPRE_ML_ABECLAP_H_
2#define AMREX_HYPRE_ML_ABECLAP_H_
3#include <AMReX_Config.H>
13#include <HYPRE_sstruct_ls.h>
16#include <unordered_map>
58 std::string a_parmparse_prefix =
"hypre_mlabeclap");
81 [[nodiscard]]
int getNumIters () const noexcept {
return m_num_iters; }
102 std::pair<MultiFab const*, IntVect>
const& a_coarse_bc = {
nullptr,
IntVect(0)});
112 void solve (Vector<MultiFab*>
const& a_sol, Vector<MultiFab const*>
const& a_rhs,
134 Vector<FabArrayBase::CopyComTag>
const& tags);
140 void solveIJ (Vector<MultiFab*>
const& a_sol, Vector<MultiFab const*>
const& a_rhs,
145 void addNonStencilEntriesToGraph ();
149 [[nodiscard]]
Long cellId (
int lev,
IntVect const& iv)
const;
153 bool m_is_singular =
false;
155 Vector<Geometry> m_geom;
156 Vector<BoxArray> m_grids;
157 Vector<DistributionMapping> m_dmap;
158 std::string m_parmparse_prefix;
162 Vector<IntVect> m_ref_ratio;
164 Real m_ascalar = std::numeric_limits<Real>::max();
165 Real m_bscalar = std::numeric_limits<Real>::max();
173 Vector<std::unique_ptr<MLMGBndry>> m_bndry;
174 Vector<std::unique_ptr<BndryRegister>> m_bndry_rhs;
175 Vector<iMultiFab> m_fine_masks;
176 Vector<iMultiFab> m_crse_masks;
180 Vector<iMultiFab> m_c2f_offset_from;
181 Vector<LayoutData<int>> m_c2f_total_from;
182 Vector<iMultiFab> m_c2f_nentries;
183 Vector<iMultiFab> m_c2f_offset_to;
184 Vector<LayoutData<int>> m_c2f_total_to;
187 Vector<Array<iMultiFab,AMREX_SPACEDIM>> m_offset_cf_bcoefs;
188 Vector<Array<LayoutData<std::unique_ptr<Gpu::DeviceVector<Real>>>,AMREX_SPACEDIM>> m_cf_bcoefs;
193 template <
class T>
using HostVector = Vector<T>;
198 Vector<HostVector<int>> m_f2c_bno;
199 Vector<HostVector<IntVect>> m_f2c_cell;
200 Vector<Vector<HYPRE_Int>> m_f2c_nentries;
201 Vector<HostVector<std::size_t>> m_f2c_offset;
202 Vector<HostVector<Real>> m_f2c_values;
204 HYPRE_SStructGrid m_ss_grid =
nullptr;
205 HYPRE_SStructStencil m_ss_stencil =
nullptr;
206 HYPRE_SStructGraph m_ss_graph =
nullptr;
207 HYPRE_SStructSolver m_ss_solver =
nullptr;
208 HYPRE_SStructSolver m_ss_precond =
nullptr;
209 HYPRE_SStructMatrix m_ss_A =
nullptr;
210 HYPRE_SStructVector m_ss_x =
nullptr;
211 HYPRE_SStructVector m_ss_b =
nullptr;
213 HYPRE_Solver m_solver =
nullptr;
217 std::unique_ptr<HypreIJIface> m_ij_solver;
221 bool m_use_ij =
false;
222 bool m_reuse_setup =
false;
223 bool m_throw_exception =
false;
224 Vector<Vector<Long>> m_box_offset;
226 Long m_ij_upper = -1;
228 std::unordered_map<Long,Vector<Long>> m_ns_targets;
232 Vector<std::unique_ptr<FabArray<BaseFab<Long>>>> m_cell_id;
233 Vector<LayoutData<Gpu::DeviceVector<HYPRE_BigInt>>> m_c2f_targets;
234 Vector<Gpu::DeviceVector<HYPRE_BigInt>> m_f2c_rows;
235 Vector<Gpu::DeviceVector<HYPRE_BigInt>> m_f2c_cols;
241 enum class Backend { hypre, algmg };
242 Backend m_backend = Backend::hypre;
244 Real m_final_res = 0.0;
245 Vector<Long> m_rank_offset;
246 composite::OwnedCSR m_csr;
247 std::unique_ptr<SpMatrix<Real>> m_spA;
248 std::unique_ptr<AlgMG<Real>> m_algmg;
258 std::string m_dump_prefix;
259 Long m_dump_gather_max = 50000000;
262 void fail (std::string
const& msg)
const;
265 HYPRE_Int m_hypre_object_type = HYPRE_PARCSR;
Problem-domain geometry: maps between index space and physical space.
Constants describing linear-operator boundary condition types.
MultiFab-style container that stores Mask objects per grid.
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
void solveIJ(Vector< MultiFab * > const &a_sol, Vector< MultiFab const * > const &a_rhs, Real a_reltol, Real a_abstol)
Solve with the IJ system (see m_use_ij); public for cuda.
Definition AMReX_HypreMLABecLap.cpp:1543
void solve(Vector< MultiFab * > const &a_sol, Vector< MultiFab const * > const &a_rhs, Real a_reltol, Real a_abstol)
Solve the assembled system with HYPRE (single-component).
Definition AMReX_HypreMLABecLap.cpp:1209
void setMaxIter(int v)
Override the maximum number of HYPRE iterations (v).
Definition AMReX_HypreMLABecLap.H:65
void setReuseSolverSetup(bool v)
IJ mode only: let setup() be called again with new coefficients (same grids), updating the matrix val...
Definition AMReX_HypreMLABecLap.H:75
HypreMLABecLap(HypreMLABecLap const &)=delete
void commBCoefs_local(int flev, Array< MultiFab const *, 3 > const &a_bcoefs, Vector< FabArrayBase::CopyComTag > const &tags)
Local portion of commBCoefs used to issue device-friendly copies.
Definition AMReX_HypreMLABecLap.cpp:2079
void resetSolverSetup()
IJ mode only: redo the solver/preconditioner setup at the next solve.
Definition AMReX_HypreMLABecLap.H:77
void setVerbose(int v)
Set HYPRE's logging verbosity (v).
Definition AMReX_HypreMLABecLap.H:63
~HypreMLABecLap()
Definition AMReX_HypreMLABecLap.cpp:248
void commBCoefs(int flev, Array< MultiFab const *, 3 > const &a_bcoefs)
Communicate b coefficients needed by level flev at coarse/fine interfaces.
Definition AMReX_HypreMLABecLap.cpp:1752
int getNumIters() const noexcept
Iterations and final relative residual of the last solve.
Definition AMReX_HypreMLABecLap.H:81
void setIsSingular(bool v)
Flag whether the assembled operator is singular (v).
Definition AMReX_HypreMLABecLap.H:67
void setup(Real a_ascalar, Real a_bscalar, Vector< MultiFab const * > const &a_acoefs, Vector< Array< MultiFab const *, 3 > > const &a_bcoefs, Array< LinOpBCType, 3 > const &a_lobc, Array< LinOpBCType, 3 > const &a_hibc, Vector< MultiFab const * > const &a_levelbcdata, std::pair< MultiFab const *, IntVect > const &a_coarse_bc={nullptr, IntVect(0)})
Assemble the HYPRE operators/storage for the provided coefficients.
Definition AMReX_HypreMLABecLap.cpp:586
HypreMLABecLap(HypreMLABecLap &&)=delete
void buildIJMaps()
Build the device maps of the IJ assembly; public for cuda.
Definition AMReX_HypreMLABecLap.cpp:1445
Real getFinalResidualNorm() const noexcept
Definition AMReX_HypreMLABecLap.H:82
void setThrowException(bool t) noexcept
Throw std::runtime_error instead of aborting when the solve fails.
Definition AMReX_HypreMLABecLap.H:79
HypreMLABecLap & operator=(HypreMLABecLap const &)=delete
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
amrex_long Long
Definition AMReX_INT.H:30
PODVector< T, PinnedArenaAllocator< T > > PinnedVector
A PODVector that uses the pinned memory arena.
Definition AMReX_GpuContainers.H:48
std::array< T, N > Array
Definition AMReX_Array.H:31
PODVector< T, ArenaAllocator< T > > DeviceVector
A PODVector that uses the standard memory Arena. Note that the memory might or might not be managed d...
Definition AMReX_GpuContainers.H:24
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
@ bogus
Definition AMReX_LO_BCTYPES.H:39
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
HypreSolverID
Definition AMReX_HypreMLABecLap.H:28
@ BoomerAMG
Definition AMReX_HypreMLABecLap.H:29
@ SSAMG
Definition AMReX_HypreMLABecLap.H:29