AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
hydro_godunov_plm.H
Go to the documentation of this file.
1 /**
2  * \file hydro_godunov_plm.H
3  *
4  * \addtogroup Godunov
5  * @{
6  */
7 
8 #ifndef HYDRO_PLM_GODUNOV_H
9 #define HYDRO_PLM_GODUNOV_H
10 
11 #include <AMReX_Slopes_K.H>
12 #include <AMReX_Gpu.H>
13 #include <AMReX_FArrayBox.H>
14 #include <AMReX_BCRec.H>
15 #include <AMReX_BC_TYPES.H>
16 #include <AMReX_Array.H>
17 #include <iomanip>
18 #include <hydro_constants.H>
19 
20 namespace PLM {
21 
22 void PredictVelOnXFace ( amrex::Box const& xebox, int ncomp,
26  const amrex::Geometry& geom,
27  amrex::Real dt,
28  amrex::Vector<amrex::BCRec> const& h_bcrec,
29  amrex::BCRec const* pbc);
30 
31 void PredictVelOnYFace ( amrex::Box const& yebox, int ncomp,
35  const amrex::Geometry& geom,
36  amrex::Real dt,
37  amrex::Vector<amrex::BCRec> const& h_bcrec,
38  amrex::BCRec const* pbc);
39 
40 #if (AMREX_SPACEDIM==3)
41 void PredictVelOnZFace ( amrex::Box const& zebox, int ncomp,
45  const amrex::Geometry& geom,
46  amrex::Real dt,
47  amrex::Vector<amrex::BCRec> const& h_bcrec,
48  amrex::BCRec const* pbc);
49 #endif
50 
51 
53 void PredictStateOnXFace ( const int i, const int j, const int k, const int n,
54  const amrex::Real dt, const amrex::Real dx,
55  amrex::Real& Im, amrex::Real& Ip,
57  const amrex::Real& umac,
58  const amrex::BCRec bc,
59  const int domain_ilo, const int domain_ihi,
60  const bool is_velocity )
61 {
62  using namespace amrex;
63  {
64  bool extdir_or_ho_ilo = (bc.lo(0) == BCType::ext_dir) ||
65  (bc.lo(0) == BCType::hoextrap);
66  bool extdir_or_ho_ihi = (bc.hi(0) == BCType::ext_dir) ||
67  (bc.hi(0) == BCType::hoextrap);
68 
69  Real upls, umns;
70 
71  int order = 4;
72 
73  if (i == domain_ilo && (bc.lo(0) == BCType::ext_dir))
74  {
75  umns = S(i-1,j,k,n);
76 
77  if ( n==XVEL && is_velocity )
78  {
79  upls = S(i-1,j,k,n);
80  }
81  else
82  {
83  upls = S(i ,j,k,n) + Real(0.5) * (-Real(1.0) - umac * dt/dx) *
84  amrex_calc_xslope_extdir(i ,j,k,n,order,S, extdir_or_ho_ilo, extdir_or_ho_ihi, domain_ilo, domain_ihi);
85  }
86 
87  }
88  else if (i == domain_ihi+1 && (bc.hi(0) == BCType::ext_dir))
89  {
90  upls = S(i ,j,k,n);
91 
92  if ( n==XVEL && is_velocity )
93  {
94  umns = S(i,j,k,n);
95  }
96  else
97  {
98  umns = S(i-1,j,k,n) + Real(0.5) * ( Real(1.0) - umac * dt/dx) *
99  amrex_calc_xslope_extdir(i-1,j,k,n,order,S, extdir_or_ho_ilo, extdir_or_ho_ihi, domain_ilo, domain_ihi);
100  }
101  }
102  else
103  {
104  // Note that we still call the "extdir version" here because interior cells one
105  // away from the boundary will still see the boundary condition in the 4th order
106  // slope
107  upls = S(i ,j,k,n) + Real(0.5) * (-Real(1.0) - umac * dt/dx) *
108  amrex_calc_xslope_extdir(i ,j,k,n,order,S, extdir_or_ho_ilo, extdir_or_ho_ihi, domain_ilo, domain_ihi);
109  umns = S(i-1,j,k,n) + Real(0.5) * ( Real(1.0) - umac * dt/dx) *
110  amrex_calc_xslope_extdir(i-1,j,k,n,order,S, extdir_or_ho_ilo, extdir_or_ho_ihi, domain_ilo, domain_ihi);
111  }
112 
113  Ip = umns;
114  Im = upls;
115  }
116 }
117 
118 
120 void PredictStateOnYFace ( const int i, const int j, const int k, const int n,
121  const amrex::Real dt, const amrex::Real dy,
122  amrex::Real& Im, amrex::Real& Ip,
124  const amrex::Real& vmac,
125  const amrex::BCRec bc,
126  const int domain_jlo, const int domain_jhi,
127  const bool is_velocity )
128 {
129  using namespace amrex;
130  {
131  bool extdir_or_ho_jlo = (bc.lo(1) == BCType::ext_dir) ||
132  (bc.lo(1) == BCType::hoextrap);
133  bool extdir_or_ho_jhi = (bc.hi(1) == BCType::ext_dir) ||
134  (bc.hi(1) == BCType::hoextrap);
135 
136  Real vpls, vmns;
137 
138  int order = 4;
139 
140  if (j == domain_jlo && (bc.lo(1) == BCType::ext_dir))
141  {
142  vmns = S(i,j-1,k,n);
143  if ( n==YVEL && is_velocity )
144  {
145  vpls = S(i,j-1,k,n);
146  }
147  else
148  {
149  vpls = S(i,j ,k,n) + Real(0.5) * (-Real(1.0) - vmac * dt/dy) *
150  amrex_calc_yslope_extdir(i,j ,k,n,order,S, extdir_or_ho_jlo, extdir_or_ho_jhi, domain_jlo, domain_jhi);
151  }
152  }
153  else if (j == domain_jhi+1 && (bc.hi(1) == BCType::ext_dir))
154  {
155  vpls = S(i,j ,k,n);
156  if ( n==YVEL && is_velocity )
157  {
158  vmns = S(i,j ,k,n);
159  }
160  else
161  {
162  vmns = S(i,j-1,k,n) + Real(0.5) * ( Real(1.0) - vmac * dt/dy) *
163  amrex_calc_yslope_extdir(i,j-1,k,n,order,S, extdir_or_ho_jlo, extdir_or_ho_jhi, domain_jlo, domain_jhi);
164  }
165  }
166  else
167  {
168  // Note that we still call the "extdir version" here because interior cells one
169  // away from the boundary will still see the boundary condition in the 4th order
170  // slope
171  vpls = S(i,j ,k,n) + Real(0.5) * (-Real(1.0) - vmac * dt/dy) *
172  amrex_calc_yslope_extdir(i,j ,k,n,order,S, extdir_or_ho_jlo, extdir_or_ho_jhi, domain_jlo, domain_jhi);
173  vmns = S(i,j-1,k,n) + Real(0.5) * ( Real(1.0) - vmac * dt/dy) *
174  amrex_calc_yslope_extdir(i,j-1,k,n,order,S, extdir_or_ho_jlo, extdir_or_ho_jhi, domain_jlo, domain_jhi);
175  }
176 
177  Ip = vmns;
178  Im = vpls;
179  }
180 }
181 
182 #if (AMREX_SPACEDIM==3)
183 
185 void PredictStateOnZFace ( const int i, const int j, const int k, const int n,
186  const amrex::Real dt, const amrex::Real dz,
187  amrex::Real& Im, amrex::Real& Ip,
189  const amrex::Real& wmac,
190  const amrex::BCRec bc,
191  const int domain_klo, const int domain_khi,
192  const bool is_velocity )
193 {
194  using namespace amrex;
195  {
196  bool extdir_or_ho_klo = (bc.lo(2) == BCType::ext_dir) ||
197  (bc.lo(2) == BCType::hoextrap);
198  bool extdir_or_ho_khi = (bc.hi(2) == BCType::ext_dir) ||
199  (bc.hi(2) == BCType::hoextrap);
200 
201  Real wpls, wmns;
202 
203  int order = 4;
204 
205  if (k == domain_klo && (bc.lo(2) == BCType::ext_dir))
206  {
207  wmns = S(i,j,k-1,n);
208  if ( n == ZVEL && is_velocity )
209  {
210  wpls = S(i,j,k-1,n);
211  }
212  else
213  {
214  wpls = S(i,j,k ,n) + Real(0.5) * (-Real(1.0) - wmac * dt/dz) *
215  amrex_calc_zslope_extdir(i,j,k ,n,order,S, extdir_or_ho_klo, extdir_or_ho_khi, domain_klo, domain_khi);
216  }
217  }
218  else if (k == domain_khi+1 && (bc.hi(2) == BCType::ext_dir))
219  {
220  wpls = S(i,j,k ,n);
221  if ( n == ZVEL && is_velocity )
222  {
223  wmns = S(i,j,k ,n);
224  }
225  else
226  {
227  wmns = S(i,j,k-1,n) + Real(0.5) * ( Real(1.0) - wmac * dt/dz) *
228  amrex_calc_zslope_extdir(i,j,k-1,n,order,S, extdir_or_ho_klo, extdir_or_ho_khi, domain_klo, domain_khi);
229  }
230  }
231  else
232  {
233  // Note that we still call the "extdir version" here because interior cells one
234  // away from the boundary will still see the boundary condition in the 4th order
235  // slope
236  wpls = S(i,j,k ,n) + Real(0.5) * (-Real(1.0) - wmac * dt/dz) *
237  amrex_calc_zslope_extdir(i,j,k ,n,order,S, extdir_or_ho_klo, extdir_or_ho_khi, domain_klo, domain_khi);
238  wmns = S(i,j,k-1,n) + Real(0.5) * ( Real(1.0) - wmac * dt/dz) *
239  amrex_calc_zslope_extdir(i,j,k-1,n,order,S, extdir_or_ho_klo, extdir_or_ho_khi, domain_klo, domain_khi);
240  }
241 
242  Ip = wmns;
243  Im = wpls;
244  }
245 }
246 #endif
247 
248 }
249 #endif
250 /** @} */
#define AMREX_FORCE_INLINE
#define AMREX_GPU_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * hi() const &noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * lo() const &noexcept
#define YVEL
Definition: hydro_constants.H:29
#define XVEL
Definition: hydro_constants.H:28
#define ZVEL
Definition: hydro_constants.H:30
Definition: hydro_godunov_plm.H:20
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void PredictStateOnYFace(const int i, const int j, const int k, const int n, const amrex::Real dt, const amrex::Real dy, amrex::Real &Im, amrex::Real &Ip, const amrex::Array4< const amrex::Real > &S, const amrex::Real &vmac, const amrex::BCRec bc, const int domain_jlo, const int domain_jhi, const bool is_velocity)
Definition: hydro_godunov_plm.H:120
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void PredictStateOnXFace(const int i, const int j, const int k, const int n, const amrex::Real dt, const amrex::Real dx, amrex::Real &Im, amrex::Real &Ip, const amrex::Array4< const amrex::Real > &S, const amrex::Real &umac, const amrex::BCRec bc, const int domain_ilo, const int domain_ihi, const bool is_velocity)
Definition: hydro_godunov_plm.H:53
void PredictVelOnYFace(amrex::Box const &yebox, int ncomp, amrex::Array4< amrex::Real > const &Imy, amrex::Array4< amrex::Real > const &Ipy, amrex::Array4< amrex::Real const > const &q, amrex::Array4< amrex::Real const > const &vcc, const amrex::Geometry &geom, amrex::Real dt, amrex::Vector< amrex::BCRec > const &h_bcrec, amrex::BCRec const *pbc)
void PredictVelOnXFace(amrex::Box const &xebox, int ncomp, amrex::Array4< amrex::Real > const &Imx, amrex::Array4< amrex::Real > const &Ipx, amrex::Array4< amrex::Real const > const &q, amrex::Array4< amrex::Real const > const &vcc, const amrex::Geometry &geom, amrex::Real dt, amrex::Vector< amrex::BCRec > const &h_bcrec, amrex::BCRec const *pbc)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real amrex_calc_yslope_extdir(int i, int j, int k, int n, int order, amrex::Array4< Real const > const &q, bool edlo, bool edhi, int domlo, int domhi) noexcept
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real amrex_calc_xslope_extdir(int i, int j, int k, int n, int order, amrex::Array4< Real const > const &q, bool edlo, bool edhi, int domlo, int domhi) noexcept