1 #ifndef AMREX_SLOPES_K_H_
2 #define AMREX_SLOPES_K_H_
3 #include <AMReX_Config.H>
15 Real dl = 2.0_rt*(q(i ,j,k,n) - q(i-1,j,k,n));
16 Real dr = 2.0_rt*(q(i+1,j,k,n) - q(i ,j,k,n));
17 Real dc = 0.5_rt*(q(i+1,j,k,n) - q(i-1,j,k,n));
22 }
else if (order == 4) {
24 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
30 dlft = qm - q(i-2,j,k,n);
32 dcen = 0.5_rt*(dlft+drgt);
33 dsgn = std::copysign(1.e0_rt, dcen);
38 drgt = q(i+2,j,k,n) -
qp;
39 dcen = 0.5_rt*(dlft+drgt);
40 dsgn = std::copysign(1.e0_rt, dcen);
46 dcen = 0.5_rt*(dlft+drgt);
47 dsgn = std::copysign(1.e0_rt, dcen);
50 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
62 bool edlo,
bool edhi,
int domlo,
int domhi) noexcept
66 Real dl = 2.0_rt*(q(i ,j,k,n) - q(i-1,j,k,n));
67 Real dr = 2.0_rt*(q(i+1,j,k,n) - q(i ,j,k,n));
68 Real dc = 0.5_rt*(q(i+1,j,k,n) - q(i-1,j,k,n));
70 if (edlo && i == domlo) {
71 dc = (q(i+1,j,k,n)+3.0_rt*q(i,j,k,n)-4.0_rt*q(i-1,j,k,n))/3.0_rt;
72 }
else if (edhi && i == domhi) {
73 dc = (4.0_rt*q(i+1,j,k,n)-3.0_rt*q(i,j,k,n)-q(i-1,j,k,n))/3.0_rt;
80 }
else if (order == 4) {
82 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh, dsgnsh;
88 dlft = qm - q(i-2,j,k,n);
90 dcen = 0.5_rt*(dlft+drgt);
91 dsgn = std::copysign(1.e0_rt, dcen);
96 drgt = q(i+2,j,k,n) -
qp;
97 dcen = 0.5_rt*(dlft+drgt);
98 dsgn = std::copysign(1.e0_rt, dcen);
104 dcen = 0.5_rt*(dlft+drgt);
105 dsgn = std::copysign(1.e0_rt, dcen);
108 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
110 if (edlo && i == domlo) {
111 dtemp = -16._rt/15._rt*q(i-1,j,k,n) + .5_rt*q(i,j,k,n) + 2._rt/3._rt*q(i+1,j,k,n) - 0.1_rt*q(i+2,j,k,n);
112 dlft = 2._rt*(q(i ,j,k,n)-q(i-1,j,k,n));
113 drgt = 2._rt*(q(i+1,j,k,n)-q(i ,j,k,n));
115 dsgn = std::copysign(1.e0_rt, dtemp);
116 }
else if (edlo && i == domlo+1) {
117 dfm = -16._rt/15._rt*q(domlo-1,j,k,n) + .5_rt*q(domlo,j,k,n) + 2._rt/3._rt*q(domlo+1,j,k,n) - 0.1_rt*q(domlo+2,j,k,n);
118 dlft = 2._rt*(q(domlo ,j,k,n)-q(domlo-1,j,k,n));
119 drgt = 2._rt*(q(domlo+1,j,k,n)-q(domlo ,j,k,n));
121 dsgnsh = std::copysign(1.e0_rt, dfm);
123 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
126 if (edhi && i == domhi) {
127 dtemp = 16._rt/15._rt*q(i+1,j,k,n) - .5_rt*q(i,j,k,n) - 2._rt/3._rt*q(i-1,j,k,n) + 0.1_rt*q(i-2,j,k,n);
128 dlft = 2._rt*(q(i ,j,k,n)-q(i-1,j,k,n));
129 drgt = 2._rt*(q(i+1,j,k,n)-q(i ,j,k,n));
131 dsgn = std::copysign(1.e0_rt, dtemp);
132 }
else if (edhi && i == domhi-1) {
133 dfp = 16._rt/15._rt*q(domhi+1,j,k,n) - .5_rt*q(domhi,j,k,n) - 2._rt/3._rt*q(domhi-1,j,k,n) + 0.1_rt*q(domhi-2,j,k,n);
134 dlft = 2._rt*(q(domhi ,j,k,n)-q(domhi-1,j,k,n));
135 drgt = 2._rt*(q(domhi+1,j,k,n)-q(domhi ,j,k,n));
137 dsgnsh = std::copysign(1.e0_rt, dfp);
139 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
156 Real dl = 2.0_rt*(q(i,j ,k,n) - q(i,j-1,k,n));
157 Real dr = 2.0_rt*(q(i,j+1,k,n) - q(i,j ,k,n));
158 Real dc = 0.5_rt*(q(i,j+1,k,n) - q(i,j-1,k,n));
163 }
else if (order == 4) {
165 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
171 dlft = qm - q(i,j-2,k,n);
173 dcen = 0.5_rt*(dlft+drgt);
174 dsgn = std::copysign(1.e0_rt, dcen);
179 drgt = q(i,j+2,k,n) -
qp;
180 dcen = 0.5_rt*(dlft+drgt);
181 dsgn = std::copysign(1.e0_rt, dcen);
187 dcen = 0.5_rt*(dlft+drgt);
188 dsgn = std::copysign(1.e0_rt, dcen);
191 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
202 bool edlo,
bool edhi,
int domlo,
int domhi) noexcept
206 Real dl = 2.0_rt*(q(i,j ,k,n) - q(i,j-1,k,n));
207 Real dr = 2.0_rt*(q(i,j+1,k,n) - q(i,j ,k,n));
208 Real dc = 0.5_rt*(q(i,j+1,k,n) - q(i,j-1,k,n));
209 if (edlo && j == domlo) {
210 dc = (q(i,j+1,k,n)+3.0_rt*q(i,j,k,n)-4.0_rt*q(i,j-1,k,n))/3.0_rt;
211 }
else if (edhi && j == domhi) {
212 dc = (4.0_rt*q(i,j+1,k,n)-3.0_rt*q(i,j,k,n)-q(i,j-1,k,n))/3.0_rt;
218 }
else if (order == 4) {
220 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh,dsgnsh;
226 dlft = qm - q(i,j-2,k,n);
228 dcen = 0.5_rt*(dlft+drgt);
229 dsgn = std::copysign(1.e0_rt, dcen);
234 drgt = q(i,j+2,k,n) -
qp;
235 dcen = 0.5_rt*(dlft+drgt);
236 dsgn = std::copysign(1.e0_rt, dcen);
242 dcen = 0.5_rt*(dlft+drgt);
243 dsgn = std::copysign(1.e0_rt, dcen);
246 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
248 if (edlo && j == domlo) {
249 dtemp = -16._rt/15._rt*q(i,j-1,k,n) + .5_rt*q(i,j,k,n) + 2._rt/3._rt*q(i,j+1,k,n) - 0.1_rt*q(i,j+2,k,n);
250 dlft = 2._rt*(q(i ,j,k,n)-q(i,j-1,k,n));
251 drgt = 2._rt*(q(i,j+1,k,n)-q(i ,j,k,n));
253 dsgn = std::copysign(1.e0_rt, dtemp);
254 }
else if (edlo && j == domlo+1) {
255 dfm = -16._rt/15._rt*q(i,domlo-1,k,n) + .5_rt*q(i,domlo,k,n) + 2._rt/3._rt*q(i,domlo+1,k,n) - 0.1_rt*q(i,domlo+2,k,n);
256 dlft = 2._rt*(q(i ,domlo,k,n)-q(i,domlo-1,k,n));
257 drgt = 2._rt*(q(i,domlo+1,k,n)-q(i ,domlo,k,n));
259 dsgnsh = std::copysign(1.e0_rt, dfm);
261 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
264 if (edhi && j == domhi) {
265 dtemp = 16._rt/15._rt*q(i,j+1,k,n) - .5_rt*q(i,j,k,n) - 2._rt/3._rt*q(i,j-1,k,n) + 0.1_rt*q(i,j-2,k,n);
266 dlft = 2._rt*(q(i ,j,k,n)-q(i,j-1,k,n));
267 drgt = 2._rt*(q(i,j+1,k,n)-q(i ,j,k,n));
269 dsgn = std::copysign(1.e0_rt, dtemp);
270 }
else if (edhi && j == domhi-1) {
271 dfp = 16._rt/15._rt*q(i,domhi+1,k,n) - .5_rt*q(i,domhi,k,n) - 2._rt/3._rt*q(i,domhi-1,k,n) + 0.1_rt*q(i,domhi-2,k,n);
272 dlft = 2._rt*(q(i ,domhi,k,n)-q(i,domhi-1,k,n));
273 drgt = 2._rt*(q(i,domhi+1,k,n)-q(i ,domhi,k,n));
275 dsgnsh = std::copysign(1.e0_rt, dfp);
277 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
287 #if (AMREX_SPACEDIM == 3)
289 Real amrex_calc_zslope (
int i,
int j,
int k,
int n,
int order,
294 Real dl = 2.0_rt*(q(i,j,k ,n) - q(i,j,k-1,n));
295 Real dr = 2.0_rt*(q(i,j,k+1,n) - q(i,j,k ,n));
296 Real dc = 0.5_rt*(q(i,j,k+1,n) - q(i,j,k-1,n));
301 }
else if (order == 4) {
303 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
309 dlft = qm - q(i,j,k-2,n);
311 dcen = 0.5_rt*(dlft+drgt);
312 dsgn = std::copysign(1.e0_rt, dcen);
317 drgt = q(i,j,k+2,n) -
qp;
318 dcen = 0.5_rt*(dlft+drgt);
319 dsgn = std::copysign(1.e0_rt, dcen);
325 dcen = 0.5_rt*(dlft+drgt);
326 dsgn = std::copysign(1.e0_rt, dcen);
329 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
338 Real amrex_calc_zslope_extdir (
int i,
int j,
int k,
int n,
int order,
340 bool edlo,
bool edhi,
int domlo,
int domhi) noexcept
345 Real dl = 2.0_rt*(q(i,j,k ,n) - q(i,j,k-1,n));
346 Real dr = 2.0_rt*(q(i,j,k+1,n) - q(i,j,k ,n));
347 Real dc = 0.5_rt*(q(i,j,k+1,n) - q(i,j,k-1,n));
348 if (edlo && k == domlo) {
349 dc = (q(i,j,k+1,n)+3.0_rt*q(i,j,k,n)-4.0_rt*q(i,j,k-1,n))/3.0_rt;
350 }
else if (edhi && k == domhi) {
351 dc = (4.0_rt*q(i,j,k+1,n)-3.0_rt*q(i,j,k,n)-q(i,j,k-1,n))/3.0_rt;
357 }
else if (order == 4) {
359 Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh, dsgnsh;
365 dlft = qm - q(i,j,k-2,n);
367 dcen = 0.5_rt*(dlft+drgt);
368 dsgn = std::copysign(1.e0_rt, dcen);
373 drgt = q(i,j,k+2,n) -
qp;
374 dcen = 0.5_rt*(dlft+drgt);
375 dsgn = std::copysign(1.e0_rt, dcen);
381 dcen = 0.5_rt*(dlft+drgt);
382 dsgn = std::copysign(1.e0_rt, dcen);
385 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
387 if (edlo && k == domlo) {
388 dtemp = -16._rt/15._rt*q(i,j,k-1,n) + .5_rt*q(i,j,k,n) + 2._rt/3._rt*q(i,j,k+1,n) - 0.1_rt*q(i,j,k+2,n);
389 dlft = 2._rt*(q(i ,j,k,n)-q(i,j,k-1,n));
390 drgt = 2._rt*(q(i,j,k+1,n)-q(i ,j,k,n));
392 dsgn = std::copysign(1.e0_rt, dtemp);
393 }
else if (edlo && k == domlo+1) {
394 dfm = -16._rt/15._rt*q(i,j,domlo-1,n) + .5_rt*q(i,j,domlo,n) + 2._rt/3._rt*q(i,j,domlo+1,n) - 0.1_rt*q(i,j,domlo+2,n);
395 dlft = 2._rt*(q(i ,j,domlo,n)-q(i,j,domlo-1,n));
396 drgt = 2._rt*(q(i,j,domlo+1,n)-q(i ,j,domlo,n));
398 dsgnsh = std::copysign(1.e0_rt, dfm);
400 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
403 if (edhi && k == domhi) {
404 dtemp = 16._rt/15._rt*q(i,j,k+1,n) - .5_rt*q(i,j,k,n) - 2._rt/3._rt*q(i,j,k-1,n) + 0.1_rt*q(i,j,k-2,n);
405 dlft = 2._rt*(q(i ,j,k,n)-q(i,j,k-1,n));
406 drgt = 2._rt*(q(i,j,k+1,n)-q(i ,j,k,n));
408 dsgn = std::copysign(1.e0_rt, dtemp);
409 }
else if (edhi && k == domhi-1) {
410 dfp = 16._rt/15._rt*q(i,j,domhi+1,n) - .5_rt*q(i,j,domhi,n) - 2._rt/3._rt*q(i,j,domhi-1,n) + 0.1_rt*q(i,j,domhi-2,n);
411 dlft = 2._rt*(q(i ,j,domhi,n)-q(i,j,domhi-1,n));
412 drgt = 2._rt*(q(i,j,domhi+1,n)-q(i ,j,domhi,n));
414 dsgnsh = std::copysign(1.e0_rt, dfp);
416 dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
Array4< Real > slope
Definition: AMReX_InterpFaceRegister.cpp:91
Definition: AMReX_Amr.cpp:49
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
Definition: AMReX_Slopes_K.H:200
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real amrex_calc_yslope(int i, int j, int k, int n, int order, amrex::Array4< Real const > const &q) noexcept
Definition: AMReX_Slopes_K.H:151
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T abs(const GpuComplex< T > &a_z) noexcept
Return the absolute value of a complex number.
Definition: AMReX_GpuComplex.H:356
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
Definition: AMReX_Slopes_K.H:60
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real amrex_calc_xslope(int i, int j, int k, int n, int order, amrex::Array4< Real const > const &q) noexcept
Definition: AMReX_Slopes_K.H:10
integer, parameter qp
Definition: AMReX_SDCquadrature.F90:7
Definition: AMReX_Array4.H:61