Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
8namespace amrex
9{
10
11namespace openbc {
12
14
15 static constexpr int M = 7; // highest order of moments
16 static constexpr int P = 3;
17
18 struct Moments
19 {
20 using array_type = GpuArray<Real,(M+2)*(M+1)/2>;
21 array_type mom;
22 Real x, y, z;
23 Orientation face;
24 };
25
26 struct MomTag
27 {
28 Array4<Real const> gp;
29 Box b2d;
30 Orientation face;
31 int offset;
32 };
33
35
36 std::ostream& operator<< (std::ostream& os, Moments const& mom);
37}
38
39#if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
40template<>
41struct Gpu::SharedMemory<openbc::Moments::array_type>
42{
43 AMREX_GPU_DEVICE openbc::Moments::array_type* dataPtr () noexcept {
44 AMREX_HIP_OR_CUDA(HIP_DYNAMIC_SHARED(openbc::Moments::array_type,amrex_openbc_momarray);,
45 extern __shared__ openbc::Moments::array_type amrex_openbc_momarray[];)
46 return amrex_openbc_momarray;
47 }
48};
49#endif
50
63{
64public:
65 OpenBCSolver () = default;
66
67 OpenBCSolver (const Vector<Geometry>& a_geom,
68 const Vector<BoxArray>& a_grids,
69 const Vector<DistributionMapping>& a_dmap,
70 const LPInfo& a_info = LPInfo());
71
72 ~OpenBCSolver () = default;
73
74 OpenBCSolver (const OpenBCSolver&) = delete;
78
79 void define (const Vector<Geometry>& a_geom,
80 const Vector<BoxArray>& a_grids,
81 const Vector<DistributionMapping>& a_dmap,
82 const LPInfo& a_info = LPInfo());
83
84 void setVerbose (int v) noexcept;
85 void setBottomVerbose (int v) noexcept;
86
87 void useHypre (bool use_hypre) noexcept;
88
89 Real solve (const Vector<MultiFab*>& a_sol, const Vector<MultiFab const*>& a_rhs,
90 Real a_tol_rel, Real a_tol_abs);
91
92// public for cuda
93
97
98private:
99
100#ifdef AMREX_USE_MPI
101 void bcast_moments (Gpu::DeviceVector<openbc::Moments>& moments);
102#endif
103
104 int m_verbose = 0;
105 int m_bottom_verbose = 0;
106 Vector<Geometry> m_geom;
107 Vector<BoxArray> m_grids;
109 LPInfo m_info;
110 std::unique_ptr<MLPoisson> m_poisson_1;
111 std::unique_ptr<MLPoisson> m_poisson_2;
112 std::unique_ptr<MLMG> m_mlmg_1;
113 std::unique_ptr<MLMG> m_mlmg_2;
114 BottomSolver m_bottom_solver_type = BottomSolver::bicgstab;
115
116 int m_coarsen_ratio = 0;
119#ifdef AMREX_USE_GPU
121 Gpu::PinnedVector<int> m_ngpublocks_h;
122 Gpu::DeviceVector<int> m_ngpublocks_d;
123 int m_nthreads_momtag;
124#endif
125
126 int m_nblocks_local = 0;
127 int m_nblocks = 0;
128#ifdef AMREX_USE_MPI
129 Vector<int> m_countvec;
130 Vector<int> m_offset;
131#endif
132
133 IntVect m_ngrowdomain;
134 MultiFab m_crse_grown_faces_phi;
135 MultiFab m_phind;
136 BoxArray m_bag;
137
138 Vector<IntVect> m_box_offset;
139 Vector<BoxArray> m_ba_all;
141 Vector<Geometry> m_geom_all;
142};
143
144}
145
146#endif
#define AMREX_HIP_OR_CUDA(a, b)
Definition AMReX_GpuControl.H:21
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1089
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:567
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
Open Boundary Poisson Solver.
Definition AMReX_OpenBC.H:63
~OpenBCSolver()=default
OpenBCSolver()=default
OpenBCSolver & operator=(const OpenBCSolver &)=delete
void interpolate_potential(MultiFab &solg)
Definition AMReX_OpenBC.cpp:790
void setVerbose(int v) noexcept
Definition AMReX_OpenBC.cpp:184
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
OpenBCSolver(const OpenBCSolver &)=delete
void compute_potential(Gpu::DeviceVector< openbc::Moments > const &moments)
Definition AMReX_OpenBC.cpp:725
OpenBCSolver(OpenBCSolver &&)=delete
void compute_moments(Gpu::DeviceVector< openbc::Moments > &moments)
Definition AMReX_OpenBC.cpp:383
void setBottomVerbose(int v) noexcept
Definition AMReX_OpenBC.cpp:189
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
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
std::array< T, N > Array
Definition AMReX_Array.H:26
std::ostream & operator<<(std::ostream &os, Moments const &mom)
Definition AMReX_OpenBC.cpp:867
Definition AMReX_Amr.cpp:49
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
BottomSolver
Definition AMReX_MLLinOp.H:31
__device__ openbc::Moments::array_type * dataPtr() noexcept
Definition AMReX_OpenBC.H:43
Definition AMReX_GpuMemory.H:125
Definition AMReX_MLLinOp.H:36