Block-Structured AMR Software Framework
AMReX_OpenBC.H
Go to the documentation of this file.
1 #ifndef AMREX_OPENBC_H_
2 #define AMREX_OPENBC_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_MLMG.H>
6 #include <AMReX_MLPoisson.H>
7 
8 namespace amrex
9 {
10 
11 namespace openbc {
12 
13  static constexpr int M = 7; // highest order of moments
14  static constexpr int P = 3;
15 
16  struct Moments
17  {
18  using array_type = GpuArray<Real,(M+2)*(M+1)/2>;
20  Real x, y, z;
22  };
23 
24  struct MomTag
25  {
29  int offset;
30  };
31 
32  std::ostream& operator<< (std::ostream& os, Moments const& mom);
33 }
34 
35 #if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
36 template<>
37 struct Gpu::SharedMemory<openbc::Moments::array_type>
38 {
40  AMREX_HIP_OR_CUDA(HIP_DYNAMIC_SHARED(openbc::Moments::array_type,amrex_openbc_momarray);,
41  extern __shared__ openbc::Moments::array_type amrex_openbc_momarray[];)
42  return amrex_openbc_momarray;
43  }
44 };
45 #endif
46 
59 {
60 public:
61  OpenBCSolver () = default;
62 
63  OpenBCSolver (const Vector<Geometry>& a_geom,
64  const Vector<BoxArray>& a_grids,
65  const Vector<DistributionMapping>& a_dmap,
66  const LPInfo& a_info = LPInfo());
67 
68  ~OpenBCSolver () = default;
69 
70  OpenBCSolver (const OpenBCSolver&) = delete;
71  OpenBCSolver (OpenBCSolver&&) = delete;
74 
75  void define (const Vector<Geometry>& a_geom,
76  const Vector<BoxArray>& a_grids,
77  const Vector<DistributionMapping>& a_dmap,
78  const LPInfo& a_info = LPInfo());
79 
80  void setVerbose (int v) noexcept;
81  void setBottomVerbose (int v) noexcept;
82 
83  void useHypre (bool use_hypre) noexcept;
84 
85  Real solve (const Vector<MultiFab*>& a_sol, const Vector<MultiFab const*>& a_rhs,
86  Real a_tol_rel, Real a_tol_abs);
87 
88 // public for cuda
89 
92  void interpolate_potential (MultiFab& solg);
93 
94 private:
95 
96 #ifdef AMREX_USE_MPI
98 #endif
99 
100  int m_verbose = 0;
106  std::unique_ptr<MLPoisson> m_poisson_1;
107  std::unique_ptr<MLPoisson> m_poisson_2;
108  std::unique_ptr<MLMG> m_mlmg_1;
109  std::unique_ptr<MLMG> m_mlmg_2;
111 
115 #ifdef AMREX_USE_GPU
120 #endif
121 
123  int m_nblocks = 0;
124 #ifdef AMREX_USE_MPI
127 #endif
128 
133 
138 };
139 
140 }
141 
142 #endif
#define AMREX_HIP_OR_CUDA(a, b)
Definition: AMReX_GpuControl.H:21
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Open Boundary Poisson Solver.
Definition: AMReX_OpenBC.H:59
Vector< BoxArray > m_grids
Definition: AMReX_OpenBC.H:103
~OpenBCSolver()=default
Gpu::DeviceVector< int > m_ngpublocks_d
Definition: AMReX_OpenBC.H:118
Vector< Geometry > m_geom_all
Definition: AMReX_OpenBC.H:137
int m_verbose
Definition: AMReX_OpenBC.H:100
OpenBCSolver()=default
Vector< Geometry > m_geom
Definition: AMReX_OpenBC.H:102
int m_nblocks
Definition: AMReX_OpenBC.H:123
MultiFab m_crse_grown_faces_phi
Definition: AMReX_OpenBC.H:130
Vector< int > m_offset
Definition: AMReX_OpenBC.H:126
std::unique_ptr< MLPoisson > m_poisson_2
Definition: AMReX_OpenBC.H:107
IntVect m_ngrowdomain
Definition: AMReX_OpenBC.H:129
int m_coarsen_ratio
Definition: AMReX_OpenBC.H:112
Vector< DistributionMapping > m_dm_all
Definition: AMReX_OpenBC.H:136
Gpu::DeviceVector< openbc::MomTag > m_momtags_d
Definition: AMReX_OpenBC.H:116
MultiFab m_phind
Definition: AMReX_OpenBC.H:131
BoxArray m_bag
Definition: AMReX_OpenBC.H:132
int m_nthreads_momtag
Definition: AMReX_OpenBC.H:119
void interpolate_potential(MultiFab &solg)
Definition: AMReX_OpenBC.cpp:790
Gpu::PinnedVector< openbc::MomTag > m_momtags_h
Definition: AMReX_OpenBC.H:114
void setVerbose(int v) noexcept
Definition: AMReX_OpenBC.cpp:184
BottomSolver m_bottom_solver_type
Definition: AMReX_OpenBC.H:110
Real solve(const Vector< MultiFab * > &a_sol, const Vector< MultiFab const * > &a_rhs, Real a_tol_rel, Real a_tol_abs)
Definition: AMReX_OpenBC.cpp:205
void useHypre(bool use_hypre) noexcept
Definition: AMReX_OpenBC.cpp:194
std::unique_ptr< MLPoisson > m_poisson_1
Definition: AMReX_OpenBC.H:106
Gpu::PinnedVector< int > m_ngpublocks_h
Definition: AMReX_OpenBC.H:117
std::unique_ptr< MLMG > m_mlmg_2
Definition: AMReX_OpenBC.H:109
OpenBCSolver & operator=(const OpenBCSolver &)=delete
OpenBCSolver(const OpenBCSolver &)=delete
Vector< DistributionMapping > m_dmap
Definition: AMReX_OpenBC.H:104
int m_bottom_verbose
Definition: AMReX_OpenBC.H:101
void compute_potential(Gpu::DeviceVector< openbc::Moments > const &moments)
Definition: AMReX_OpenBC.cpp:725
int m_nblocks_local
Definition: AMReX_OpenBC.H:122
void bcast_moments(Gpu::DeviceVector< openbc::Moments > &moments)
Definition: AMReX_OpenBC.cpp:673
OpenBCSolver(OpenBCSolver &&)=delete
void compute_moments(Gpu::DeviceVector< openbc::Moments > &moments)
Definition: AMReX_OpenBC.cpp:383
Vector< int > m_countvec
Definition: AMReX_OpenBC.H:125
Array< MultiFab, AMREX_SPACEDIM > m_dpdn
Definition: AMReX_OpenBC.H:113
void setBottomVerbose(int v) noexcept
Definition: AMReX_OpenBC.cpp:189
Vector< BoxArray > m_ba_all
Definition: AMReX_OpenBC.H:135
LPInfo m_info
Definition: AMReX_OpenBC.H:105
Vector< IntVect > m_box_offset
Definition: AMReX_OpenBC.H:134
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo())
Definition: AMReX_OpenBC.cpp:16
std::unique_ptr< MLMG > m_mlmg_1
Definition: AMReX_OpenBC.H:108
Encapsulation of the Orientation of the Faces of a Box.
Definition: AMReX_Orientation.H:29
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
std::ostream & operator<<(std::ostream &os, Moments const &mom)
Definition: AMReX_OpenBC.cpp:867
static constexpr int M
Definition: AMReX_OpenBC.H:13
static constexpr int P
Definition: AMReX_OpenBC.H:14
Definition: AMReX_Amr.cpp:49
BottomSolver
Definition: AMReX_MLLinOp.H:30
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_Array4.H:61
AMREX_GPU_DEVICE openbc::Moments::array_type * dataPtr() noexcept
Definition: AMReX_OpenBC.H:39
Definition: AMReX_GpuMemory.H:125
Definition: AMReX_MLLinOp.H:35
Definition: AMReX_OpenBC.H:25
int offset
Definition: AMReX_OpenBC.H:29
Array4< Real const > gp
Definition: AMReX_OpenBC.H:26
Orientation face
Definition: AMReX_OpenBC.H:28
Box b2d
Definition: AMReX_OpenBC.H:27
Definition: AMReX_OpenBC.H:17
Real z
Definition: AMReX_OpenBC.H:20
array_type mom
Definition: AMReX_OpenBC.H:19
Orientation face
Definition: AMReX_OpenBC.H:21
Real y
Definition: AMReX_OpenBC.H:20
Real x
Definition: AMReX_OpenBC.H:20