Block-Structured AMR Software Framework
AMReX_Slopes_K.H
Go to the documentation of this file.
1 #ifndef AMREX_SLOPES_K_H_
2 #define AMREX_SLOPES_K_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_BaseFab.H>
6 
7 namespace amrex {
8 
10 Real amrex_calc_xslope (int i, int j, int k, int n, int order,
11  amrex::Array4<Real const> const& q) noexcept
12 {
13  if (order == 2)
14  {
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));
18  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
19  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
20  return (dc > 0.0_rt) ? slope : -slope;
21 
22  } else if (order == 4) {
23 
24  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
25  Real qm, qp, qi;
26  qi = q(i,j,k,n);
27  qm = q(i-1,j,k,n);
28  qp = q(i+1,j,k,n);
29 
30  dlft = qm - q(i-2,j,k,n);
31  drgt = qi - qm;
32  dcen = 0.5_rt*(dlft+drgt);
33  dsgn = std::copysign(1.e0_rt, dcen);
34  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
35  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
36 
37  dlft = qp - qi;
38  drgt = q(i+2,j,k,n) - qp;
39  dcen = 0.5_rt*(dlft+drgt);
40  dsgn = std::copysign(1.e0_rt, dcen);
41  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
42  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
43 
44  dlft = qi - qm;
45  drgt = qp - qi;
46  dcen = 0.5_rt*(dlft+drgt);
47  dsgn = std::copysign(1.e0_rt, dcen);
48  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
49 
50  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
51 
52  return dsgn*amrex::min(dlim, std::abs(dtemp));
53 
54  } else {
55  return 0._rt;
56  }
57 }
58 
60 Real amrex_calc_xslope_extdir (int i, int j, int k, int n, int order,
62  bool edlo, bool edhi, int domlo, int domhi) noexcept
63 {
64  if (order == 2)
65  {
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));
69 
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;
74  }
75 
76  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
77  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
78  return (dc > 0.0_rt) ? slope : -slope;
79 
80  } else if (order == 4) {
81 
82  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh, dsgnsh;
83  Real qm, qp, qi;
84  qi = q(i,j,k,n);
85  qm = q(i-1,j,k,n);
86  qp = q(i+1,j,k,n);
87 
88  dlft = qm - q(i-2,j,k,n);
89  drgt = qi - qm;
90  dcen = 0.5_rt*(dlft+drgt);
91  dsgn = std::copysign(1.e0_rt, dcen);
92  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
93  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
94 
95  dlft = qp - qi;
96  drgt = q(i+2,j,k,n) - qp;
97  dcen = 0.5_rt*(dlft+drgt);
98  dsgn = std::copysign(1.e0_rt, dcen);
99  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
100  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
101 
102  dlft = qi - qm;
103  drgt = qp - qi;
104  dcen = 0.5_rt*(dlft+drgt);
105  dsgn = std::copysign(1.e0_rt, dcen);
106  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
107 
108  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
109 
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));
114  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
120  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
121  dsgnsh = std::copysign(1.e0_rt, dfm);
122  dfm = dsgnsh*amrex::min(dlimsh, std::abs(dfm));
123  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
124  }
125 
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));
130  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
136  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
137  dsgnsh = std::copysign(1.e0_rt, dfp);
138  dfp = dsgnsh*amrex::min(dlimsh, std::abs(dfp));
139  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
140  }
141 
142  return dsgn*amrex::min(dlim, std::abs(dtemp));
143 
144  } else {
145  return 0._rt;
146  }
147 
148 }
149 
151 Real amrex_calc_yslope (int i, int j, int k, int n, int order,
152  amrex::Array4<Real const> const& q) noexcept
153 {
154  if (order == 2)
155  {
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));
159  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
160  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
161  return (dc > 0.0_rt) ? slope : -slope;
162 
163  } else if (order == 4) {
164 
165  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
166  Real qm, qp, qj;
167  qj = q(i,j,k,n);
168  qm = q(i,j-1,k,n);
169  qp = q(i,j+1,k,n);
170 
171  dlft = qm - q(i,j-2,k,n);
172  drgt = qj - qm;
173  dcen = 0.5_rt*(dlft+drgt);
174  dsgn = std::copysign(1.e0_rt, dcen);
175  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
176  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
177 
178  dlft = qp - qj;
179  drgt = q(i,j+2,k,n) - qp;
180  dcen = 0.5_rt*(dlft+drgt);
181  dsgn = std::copysign(1.e0_rt, dcen);
182  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
183  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
184 
185  dlft = qj - qm;
186  drgt = qp - qj;
187  dcen = 0.5_rt*(dlft+drgt);
188  dsgn = std::copysign(1.e0_rt, dcen);
189  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
190 
191  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
192  return dsgn*amrex::min(dlim, std::abs(dtemp));
193 
194  } else {
195  return 0._rt;
196  }
197 }
198 
200 Real amrex_calc_yslope_extdir (int i, int j, int k, int n, int order,
201  amrex::Array4<Real const> const& q,
202  bool edlo, bool edhi, int domlo, int domhi) noexcept
203 {
204  if (order == 2)
205  {
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;
213  }
214  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
215  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
216  return (dc > 0.0_rt) ? slope : -slope;
217 
218  } else if (order == 4) {
219 
220  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh,dsgnsh;
221  Real qm, qp, qj;
222  qj = q(i,j,k,n);
223  qm = q(i,j-1,k,n);
224  qp = q(i,j+1,k,n);
225 
226  dlft = qm - q(i,j-2,k,n);
227  drgt = qj - qm;
228  dcen = 0.5_rt*(dlft+drgt);
229  dsgn = std::copysign(1.e0_rt, dcen);
230  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
231  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
232 
233  dlft = qp - qj;
234  drgt = q(i,j+2,k,n) - qp;
235  dcen = 0.5_rt*(dlft+drgt);
236  dsgn = std::copysign(1.e0_rt, dcen);
237  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
238  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
239 
240  dlft = qj - qm;
241  drgt = qp - qj;
242  dcen = 0.5_rt*(dlft+drgt);
243  dsgn = std::copysign(1.e0_rt, dcen);
244  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
245 
246  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
247 
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));
252  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
258  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
259  dsgnsh = std::copysign(1.e0_rt, dfm);
260  dfm = dsgnsh*amrex::min(dlimsh, std::abs(dfm));
261  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
262  }
263 
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));
268  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
274  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
275  dsgnsh = std::copysign(1.e0_rt, dfp);
276  dfp = dsgnsh*amrex::min(dlimsh, std::abs(dfp));
277  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
278  }
279 
280  return dsgn*amrex::min(dlim, std::abs(dtemp));
281 
282  } else {
283  return 0._rt;
284  }
285 }
286 
287 #if (AMREX_SPACEDIM == 3)
289 Real amrex_calc_zslope (int i, int j, int k, int n, int order,
290  amrex::Array4<Real const> const& q) noexcept
291 {
292  if (order == 2)
293  {
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));
297  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
298  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
299  return (dc > 0.0_rt) ? slope : -slope;
300 
301  } else if (order == 4) {
302 
303  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp;
304  Real qm, qp, qk;
305  qk = q(i,j,k,n);
306  qm = q(i,j,k-1,n);
307  qp = q(i,j,k+1,n);
308 
309  dlft = qm - q(i,j,k-2,n);
310  drgt = qk - qm;
311  dcen = 0.5_rt*(dlft+drgt);
312  dsgn = std::copysign(1.e0_rt, dcen);
313  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
314  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
315 
316  dlft = qp - qk;
317  drgt = q(i,j,k+2,n) - qp;
318  dcen = 0.5_rt*(dlft+drgt);
319  dsgn = std::copysign(1.e0_rt, dcen);
320  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
321  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
322 
323  dlft = qk - qm;
324  drgt = qp - qk;
325  dcen = 0.5_rt*(dlft+drgt);
326  dsgn = std::copysign(1.e0_rt, dcen);
327  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
328 
329  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
330  return dsgn*amrex::min(dlim, std::abs(dtemp));
331 
332  } else {
333  return 0._rt;
334  }
335 }
336 
338 Real amrex_calc_zslope_extdir (int i, int j, int k, int n, int order,
339  amrex::Array4<Real const> const& q,
340  bool edlo, bool edhi, int domlo, int domhi) noexcept
341 {
342  if (order == 2)
343  {
344 
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;
352  }
353  Real slope = amrex::min(std::abs(dl),std::abs(dc),std::abs(dr));
354  slope = (dr*dl > 0.0_rt) ? slope : 0.0_rt;
355  return (dc > 0.0_rt) ? slope : -slope;
356 
357  } else if (order == 4) {
358 
359  Real dlft, drgt, dcen, dfm, dfp, dlim, dsgn, dtemp, dlimsh, dsgnsh;
360  Real qm, qp, qk;
361  qk = q(i,j,k,n);
362  qm = q(i,j,k-1,n);
363  qp = q(i,j,k+1,n);
364 
365  dlft = qm - q(i,j,k-2,n);
366  drgt = qk - qm;
367  dcen = 0.5_rt*(dlft+drgt);
368  dsgn = std::copysign(1.e0_rt, dcen);
369  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
370  dfm = dsgn*amrex::min(dlim, std::abs(dcen));
371 
372  dlft = qp - qk;
373  drgt = q(i,j,k+2,n) - qp;
374  dcen = 0.5_rt*(dlft+drgt);
375  dsgn = std::copysign(1.e0_rt, dcen);
376  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
377  dfp = dsgn*amrex::min(dlim, std::abs(dcen));
378 
379  dlft = qk - qm;
380  drgt = qp - qk;
381  dcen = 0.5_rt*(dlft+drgt);
382  dsgn = std::copysign(1.e0_rt, dcen);
383  dlim = (dlft*drgt >= 0.0_rt) ? 2.0_rt*amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
384 
385  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
386 
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));
391  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
397  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
398  dsgnsh = std::copysign(1.e0_rt, dfm);
399  dfm = dsgnsh*amrex::min(dlimsh, std::abs(dfm));
400  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
401  }
402 
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));
407  dlim = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
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));
413  dlimsh = (dlft*drgt >= 0.0_rt) ? amrex::min(std::abs(dlft), std::abs(drgt)) : 0.0_rt;
414  dsgnsh = std::copysign(1.e0_rt, dfp);
415  dfp = dsgnsh*amrex::min(dlimsh, std::abs(dfp));
416  dtemp = 4.0_rt/3.0_rt*dcen - 1.0_rt/6.0_rt*(dfp + dfm);
417  }
418  return dsgn*amrex::min(dlim, std::abs(dtemp));
419 
420  } else {
421  return 0._rt;
422  }
423 }
424 #endif
425 
426 }
427 #endif
#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