Block-Structured AMR Software Framework
AMReX_HypreMLABecLap.H
Go to the documentation of this file.
1 #ifndef AMREX_HYPRE_ML_ABECLAP_H_
2 #define AMREX_HYPRE_ML_ABECLAP_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Geometry.H>
6 #include <AMReX_LO_BCTYPES.H>
7 #include <AMReX_MLMGBndry.H>
8 #include <AMReX_MultiFab.H>
9 #include <AMReX_MultiMask.H>
10 
11 #include <HYPRE_sstruct_ls.h>
12 
13 #include <limits>
14 #include <utility>
15 
16 namespace amrex {
17 
18 enum struct HypreSolverID {
20 };
21 
22 // single component only, cell centered only
23 
25 {
26 public:
27  HypreMLABecLap (HypreMLABecLap const&) = delete;
31 
33  Vector<BoxArray> a_grids,
35  HypreSolverID a_hypre_solver_id,
36  std::string a_parmparse_prefix = "hypre_mlabeclap");
37 
38  ~HypreMLABecLap ();
39 
40  void setVerbose (int v) { m_verbose = v; }
41  void setMaxIter (int v) { m_maxiter = v; }
42  void setIsSingular (bool v) { m_is_singular = v; }
43 
44  void setup (Real a_ascalar, Real a_bscalar,
45  Vector<MultiFab const*> const& a_acoefs,
49  Vector<MultiFab const*> const& a_levelbcdata,
50  std::pair<MultiFab const*, IntVect> const& a_coarse_bc = {nullptr, IntVect(0)});
51 
52  void solve (Vector<MultiFab*> const& a_sol, Vector<MultiFab const*> const& a_rhs,
53  Real a_reltol, Real a_abstol);
54 
55  // update? updateDirichleBC? or updateCoeffs?
56 
57  // public for cuda
58 
59  void commBCoefs (int flev, Array<MultiFab const*,AMREX_SPACEDIM> const& a_bcoefs);
60  void commBCoefs_local (int flev, Array<MultiFab const*,AMREX_SPACEDIM> const& a_bcoefs,
61  Vector<FabArrayBase::CopyComTag> const& tags);
62 
63 private:
64 
66 
67  int m_verbose = 0;
68  int m_maxiter = 200;
69  bool m_is_singular = false;
70 
74  std::string m_parmparse_prefix;
75  int m_nlevels = 0;
77 
79 
83  LinOpBCType::bogus,
84  LinOpBCType::bogus)};
86  LinOpBCType::bogus,
87  LinOpBCType::bogus)};
88 
93 
94  // For coarse cells at coarse/fine interface. The vector is for AMR
95  // levels.
96  Vector<iMultiFab> m_c2f_offset_from; // offset for sparse coarse from-cells
97  Vector<LayoutData<int>> m_c2f_total_from; // # of coarse from-cells w/ c2f entries
98  Vector<iMultiFab> m_c2f_nentries; // # of non-stencil entries
99  Vector<iMultiFab> m_c2f_offset_to; // offset for sparse to-cells, including fine (and coarse in 3d) cells
100  Vector<LayoutData<int>> m_c2f_total_to; // total sum of non-stencil entries in a Box
101 
102  // B coefficients at coarse/fine interface
105 
106 #ifdef AMREX_USE_GPU
107  template <class T> using HostVector = Gpu::PinnedVector<T>;
108 #else
109  template <class T> using HostVector = Vector<T>;
110 #endif
111 
112  // For fine cells at coarse/fine interface. The non-stencil entries are
113  // from fine to coarse. The outer vector is for AMR levels.
114  Vector<HostVector<int>> m_f2c_bno; // local box number
116  Vector<Vector<HYPRE_Int>> m_f2c_nentries; // # of non-stencil entries
117  Vector<HostVector<std::size_t>> m_f2c_offset; // offset into m_f2c_values
118  Vector<HostVector<Real>> m_f2c_values; // values for non-stencil entries
119 
120  HYPRE_SStructGrid m_ss_grid = nullptr;
121  HYPRE_SStructStencil m_ss_stencil = nullptr;
122  HYPRE_SStructGraph m_ss_graph = nullptr;
123  HYPRE_SStructSolver m_ss_solver = nullptr;
124  HYPRE_SStructSolver m_ss_precond = nullptr;
125  HYPRE_SStructMatrix m_ss_A = nullptr;
126  HYPRE_SStructVector m_ss_x = nullptr;
127  HYPRE_SStructVector m_ss_b = nullptr;
128 
129  HYPRE_Solver m_solver = nullptr;
130 
132  HYPRE_Int m_hypre_object_type = HYPRE_PARCSR;
133 };
134 
135 }
136 
137 #endif
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
int MPI_Comm
Definition: AMReX_ccse-mpi.H:47
static constexpr int MPI_COMM_NULL
Definition: AMReX_ccse-mpi.H:55
Definition: AMReX_HypreMLABecLap.H:25
HypreMLABecLap & operator=(HypreMLABecLap const &)=delete
Vector< LayoutData< int > > m_c2f_total_to
Definition: AMReX_HypreMLABecLap.H:100
void addNonStencilEntriesToGraph()
Definition: AMReX_HypreMLABecLap.cpp:200
Vector< std::unique_ptr< BndryRegister > > m_bndry_rhs
Definition: AMReX_HypreMLABecLap.H:90
Array< LinOpBCType, AMREX_SPACEDIM > m_hibc
Definition: AMReX_HypreMLABecLap.H:85
HYPRE_SStructStencil m_ss_stencil
Definition: AMReX_HypreMLABecLap.H:121
void solve(Vector< MultiFab * > const &a_sol, Vector< MultiFab const * > const &a_rhs, Real a_reltol, Real a_abstol)
Definition: AMReX_HypreMLABecLap.cpp:907
void setMaxIter(int v)
Definition: AMReX_HypreMLABecLap.H:41
HYPRE_SStructGraph m_ss_graph
Definition: AMReX_HypreMLABecLap.H:122
HypreMLABecLap(HypreMLABecLap const &)=delete
Vector< iMultiFab > m_c2f_offset_from
Definition: AMReX_HypreMLABecLap.H:96
HYPRE_Solver m_solver
Definition: AMReX_HypreMLABecLap.H:129
void commBCoefs_local(int flev, Array< MultiFab const *, AMREX_SPACEDIM > const &a_bcoefs, Vector< FabArrayBase::CopyComTag > const &tags)
Definition: AMReX_HypreMLABecLap.cpp:1440
Vector< DistributionMapping > m_dmap
Definition: AMReX_HypreMLABecLap.H:73
Vector< HostVector< Real > > m_f2c_values
Definition: AMReX_HypreMLABecLap.H:118
Real m_ascalar
Definition: AMReX_HypreMLABecLap.H:80
void setVerbose(int v)
Definition: AMReX_HypreMLABecLap.H:40
HYPRE_Int m_hypre_object_type
Definition: AMReX_HypreMLABecLap.H:132
Vector< iMultiFab > m_c2f_offset_to
Definition: AMReX_HypreMLABecLap.H:99
std::string m_parmparse_prefix
Definition: AMReX_HypreMLABecLap.H:74
HYPRE_SStructSolver m_ss_solver
Definition: AMReX_HypreMLABecLap.H:123
~HypreMLABecLap()
Definition: AMReX_HypreMLABecLap.cpp:167
Vector< Array< iMultiFab, AMREX_SPACEDIM > > m_offset_cf_bcoefs
Definition: AMReX_HypreMLABecLap.H:103
Vector< std::unique_ptr< MLMGBndry > > m_bndry
Definition: AMReX_HypreMLABecLap.H:89
Vector< IntVect > m_ref_ratio
Definition: AMReX_HypreMLABecLap.H:78
HYPRE_SStructGrid m_ss_grid
Definition: AMReX_HypreMLABecLap.H:120
Vector< iMultiFab > m_crse_masks
Definition: AMReX_HypreMLABecLap.H:92
bool m_is_singular
Definition: AMReX_HypreMLABecLap.H:69
int m_nlevels
Definition: AMReX_HypreMLABecLap.H:75
Vector< HostVector< IntVect > > m_f2c_cell
Definition: AMReX_HypreMLABecLap.H:115
HYPRE_SStructSolver m_ss_precond
Definition: AMReX_HypreMLABecLap.H:124
Vector< LayoutData< int > > m_c2f_total_from
Definition: AMReX_HypreMLABecLap.H:97
Vector< HostVector< std::size_t > > m_f2c_offset
Definition: AMReX_HypreMLABecLap.H:117
void setIsSingular(bool v)
Definition: AMReX_HypreMLABecLap.H:42
int m_verbose
Definition: AMReX_HypreMLABecLap.H:67
Real m_bscalar
Definition: AMReX_HypreMLABecLap.H:81
void commBCoefs(int flev, Array< MultiFab const *, AMREX_SPACEDIM > const &a_bcoefs)
Definition: AMReX_HypreMLABecLap.cpp:1127
Vector< Geometry > m_geom
Definition: AMReX_HypreMLABecLap.H:71
MPI_Comm m_comm
Definition: AMReX_HypreMLABecLap.H:76
Vector< HostVector< int > > m_f2c_bno
Definition: AMReX_HypreMLABecLap.H:114
Vector< Vector< HYPRE_Int > > m_f2c_nentries
Definition: AMReX_HypreMLABecLap.H:116
void setup(Real a_ascalar, Real a_bscalar, Vector< MultiFab const * > const &a_acoefs, Vector< Array< MultiFab const *, AMREX_SPACEDIM >> const &a_bcoefs, Array< LinOpBCType, AMREX_SPACEDIM > const &a_lobc, Array< LinOpBCType, AMREX_SPACEDIM > const &a_hibc, Vector< MultiFab const * > const &a_levelbcdata, std::pair< MultiFab const *, IntVect > const &a_coarse_bc={nullptr, IntVect(0)})
Definition: AMReX_HypreMLABecLap.cpp:487
HYPRE_SStructVector m_ss_x
Definition: AMReX_HypreMLABecLap.H:126
HypreMLABecLap(HypreMLABecLap &&)=delete
Vector< Array< LayoutData< std::unique_ptr< Gpu::DeviceVector< Real > > >, AMREX_SPACEDIM > > m_cf_bcoefs
Definition: AMReX_HypreMLABecLap.H:104
Array< LinOpBCType, AMREX_SPACEDIM > m_lobc
Definition: AMReX_HypreMLABecLap.H:82
Vector< BoxArray > m_grids
Definition: AMReX_HypreMLABecLap.H:72
HypreSolverID m_hypre_solver_id
Definition: AMReX_HypreMLABecLap.H:131
Vector< iMultiFab > m_c2f_nentries
Definition: AMReX_HypreMLABecLap.H:98
Vector< iMultiFab > m_fine_masks
Definition: AMReX_HypreMLABecLap.H:91
HYPRE_SStructVector m_ss_b
Definition: AMReX_HypreMLABecLap.H:127
HYPRE_SStructMatrix m_ss_A
Definition: AMReX_HypreMLABecLap.H:125
int m_maxiter
Definition: AMReX_HypreMLABecLap.H:68
Definition: AMReX_PODVector.H:246
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
@ max
Definition: AMReX_ParallelReduce.H:17
Definition: AMReX_Amr.cpp:49
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
HypreSolverID
Definition: AMReX_HypreMLABecLap.H:18
std::array< T, N > Array
Definition: AMReX_Array.H:24