AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
Loading...
Searching...
No Matches
hydro_godunov_ppm.H
Go to the documentation of this file.
1/*
2 * \file hydro_godunov_ppm.H
3 *
4 * \addtogroup Godunov
5 * @{
6 */
7
8#ifndef HYDRO_GODUNOV_PPM_H
9#define HYDRO_GODUNOV_PPM_H
10
11#include <AMReX_MultiFab.H>
12#include <AMReX_BCRec.H>
13#include <AMReX_BC_TYPES.H>
14#include <hydro_bcs_K.H>
15#include <hydro_constants.H>
16
18void
20 const amrex::Real s0,
21 const amrex::Real sp1,
22 amrex::Real& dsm,
23 amrex::Real& dsp)
24{
25 // Calculate gradients on both sides
26 dsp = sp1 - s0;
27 dsm = s0 - sm1;
28
29 if (!(dsp * dsm < amrex::Real(0.0))) {
30 // Select the smaller slope if same sign
31 if (std::abs(dsp) < std::abs(dsm)) {
32 dsm = dsp;
33 } else {
34 dsp = dsm;
35 }
36 } else {
37 // Set to zero if opposite sign
38 dsp = amrex::Real(0.0);
39 dsm = amrex::Real(0.0);
40 }
41}
42
44void
46 const amrex::Real sm1,
47 const amrex::Real s0,
48 const amrex::Real vel_edge,
49 amrex::Real& dsm,
50 const int bclo,
51 const int domlo)
52{
53 // Ensure that left-side slope is used unchanged
54 if (n == domlo) {
55 if ( bclo == amrex::BCType::ext_dir || bclo == amrex::BCType::hoextrap ||
56 (bclo == amrex::BCType::direction_dependent && vel_edge >= amrex::Real(0.0)) )
57 {
58 dsm = s0 - sm1;
59 }
60 }
61}
62
64void
66 const amrex::Real s0,
67 const amrex::Real sp1,
68 const amrex::Real vel_edge,
69 amrex::Real& dsp,
70 const int bchi,
71 const int domhi)
72{
73 // Ensure that the right-side slope is used unchanged
74 if (n == domhi) {
75 if ( bchi == amrex::BCType::ext_dir || bchi == amrex::BCType::hoextrap ||
76 (bchi == amrex::BCType::direction_dependent && vel_edge <= amrex::Real(0.0)) )
77 {
78 dsp = sp1 - s0;
79 }
80 }
81}
82
83// Where Godunov_minmod_bc_lo/hi apply, the ghost cell holds the value on the domain face,
84// half a cell from the center of the cell next to it. Extrapolate that value linearly to
85// the center of the ghost cell, so that minmod_fn and Godunov_minmod_bc_lo/hi take their
86// differences over a whole cell.
90 const amrex::Real sm1,
91 const amrex::Real s0,
92 const amrex::Real vel_edge,
93 const int bclo,
94 const int domlo)
95{
96 if (n == domlo) {
97 if ( bclo == amrex::BCType::ext_dir || bclo == amrex::BCType::hoextrap ||
98 (bclo == amrex::BCType::direction_dependent && vel_edge >= amrex::Real(0.0)) )
99 {
100 return amrex::Real(2.0)*sm1 - s0;
101 }
102 }
103 return sm1;
104}
105
109 const amrex::Real s0,
110 const amrex::Real sp1,
111 const amrex::Real vel_edge,
112 const int bchi,
113 const int domhi)
114{
115 if (n == domhi) {
116 if ( bchi == amrex::BCType::ext_dir || bchi == amrex::BCType::hoextrap ||
117 (bchi == amrex::BCType::direction_dependent && vel_edge <= amrex::Real(0.0)) )
118 {
119 return amrex::Real(2.0)*sp1 - s0;
120 }
121 }
122 return sp1;
123}
124
125namespace PPM {
126
128
129static constexpr int default_limiter = VanLeer;
130
131struct nolimiter {
132
133 static constexpr bool do_limiting = false;
134
136 static amrex::Real
138 const amrex::Real sm1,
139 const amrex::Real s0,
140 const amrex::Real sp1,
141 const amrex::Real /*sp2*/)
142 {
143
144 amrex::Real d1 = amrex::Real(0.5) * (sp1 - sm1);
145 amrex::Real d2 = amrex::Real(0.5) * (s0 - sm2);
146
147 amrex::Real sedge = amrex::Real(0.5)*(s0 + sm1) - (amrex::Real(1)/amrex::Real(6))*(d1 - d2);
148 return sedge;
149 }
150
152 static amrex::Real
153 sedge2(const amrex::Real /*sm2*/,
154 const amrex::Real sm1,
155 const amrex::Real s0,
156 const amrex::Real sp1,
157 const amrex::Real sp2)
158 {
159 amrex::Real d1 = amrex::Real(0.5) * (sp2 - s0);
160 amrex::Real d2 = amrex::Real(0.5) * (sp1 - sm1);
161
162 amrex::Real sedge = amrex::Real(0.5)*(sp1 + s0) - (amrex::Real(1)/amrex::Real(6))*(d1 - d2);
163 return sedge;
164 }
165
168 sm_sp(const amrex::Real /*s0*/,
169 const amrex::Real sedge1,
170 const amrex::Real sedge2)
171 {
173 }
174}; // nolimiter
175
176struct vanleer {
177
178 static constexpr bool do_limiting = true;
179
181 static amrex::Real vanLeer(const amrex::Real a, const amrex::Real b, const amrex::Real c)
182 {
183 constexpr auto small_qty_sq = amrex::Real(1.e-10) * amrex::Real(1.e-10);
184
185 amrex::Real dsc = amrex::Real(0.5)*(b - c);
186 amrex::Real dsl = amrex::Real(2.0)*(a - c);
187 amrex::Real dsr = amrex::Real(2.0)*(b - a);
188 return (dsl*dsr > small_qty_sq) ?
189 std::copysign(amrex::Real(1.0), dsc)*amrex::min(amrex::Math::abs(dsc),amrex::min(amrex::Math::abs(dsl),
190 amrex::Math::abs(dsr))) : amrex::Real(0.0);
191 }
192
194 static amrex::Real
196 const amrex::Real sm1,
197 const amrex::Real s0,
198 const amrex::Real sp1,
199 const amrex::Real /*sp2*/)
200 {
201
202 amrex::Real d1 = vanLeer(s0,sp1,sm1);
203 amrex::Real d2 = vanLeer(sm1,s0,sm2);
204
205 amrex::Real sedge = amrex::Real(0.5)*(s0 + sm1) - (amrex::Real(1)/amrex::Real(6))*(d1 - d2);
206 return amrex::min(amrex::max(sedge, amrex::min(s0, sm1)),amrex::max(s0,sm1));
207
208 }
209
211 static amrex::Real
212 sedge2(const amrex::Real /*sm2*/,
213 const amrex::Real sm1,
214 const amrex::Real s0,
215 const amrex::Real sp1,
216 const amrex::Real sp2)
217 {
218
219 amrex::Real d1 = vanLeer(sp1,sp2,s0);
220 amrex::Real d2 = vanLeer(s0,sp1,sm1);
221
222 amrex::Real sedge = amrex::Real(0.5)*(sp1 + s0) - (amrex::Real(1)/amrex::Real(6))*(d1 - d2);
223 return amrex::min(amrex::max(sedge, amrex::min(s0, sp1)),amrex::max(s0,sp1));
224
225
226 }
227
231 const amrex::Real sedge1,
232 const amrex::Real sedge2)
233 {
234 amrex::Real sm_ = sedge1;
235 amrex::Real sp_ = sedge2;
236
237 if ((sedge2-s0)*(s0-sedge1) < amrex::Real(0.0)) {
238 sm_ = s0;
239 sp_ = s0;
240 } else if (amrex::Math::abs(sedge2-s0) >= amrex::Real(2.0)*amrex::Math::abs(sedge1-s0)) {
241 sp_ = amrex::Real(3)*s0 - amrex::Real(2)*sedge1;
242 } else if (amrex::Math::abs(sedge1-s0) >= amrex::Real(2.0)*amrex::Math::abs(sedge2-s0)) {
243 sm_ = amrex::Real(3)*s0 - amrex::Real(2)*sedge2;
244 }
245 return amrex::makeTuple(sm_,sp_);
246
247 // this might be the correct way to do this in case the else if are both == 0.0
248 // could also change the >= to just > for each
249// if ((sedge2-s0)*(s0-sedge1) < amrex::Real(0.0)) {
250// return amrex::makeTuple(s0,s0);
251// }
252// amrex::Real sm_ = sedge1;
253// amrex::Real sp_ = sedge2;
254// if (amrex::Math::abs(sedge2-s0) >= amrex::Real(2.0)*amrex::Math::abs(sedge1-s0)) {
255// sp_ = amrex::Real(3)*s0 - amrex::Real(2)*sedge1;
256// }
257// if (amrex::Math::abs(sedge1-s0) >= amrex::Real(2.0)*amrex::Math::abs(sedge2-s0)) {
258// sm_ = amrex::Real(3)*s0 - amrex::Real(2)*sedge2;
259// }
260// return amrex::makeTuple(sm_,sp_);
261
262 }
263}; // vanleer
264
265struct wenoz {
266
267 static constexpr bool do_limiting = false;
268
270 static amrex::Real
272 const amrex::Real sm1,
273 const amrex::Real s0,
274 const amrex::Real sp1,
275 const amrex::Real sp2)
276 {
277 constexpr auto eps = amrex::Real(1.0e-6);
278
279 const amrex::Real beta1 =
280 amrex::Real(13) / amrex::Real(12) * (sm2 - amrex::Real(2) * sm1 + s0) * (sm2 - amrex::Real(2) * sm1 + s0) +
281 amrex::Real(0.25) * (sm2 - amrex::Real(4) * sm1 + amrex::Real(3) * s0) * (sm2 - amrex::Real(4) * sm1 + amrex::Real(3) * s0);
282 const amrex::Real beta2 =
283 amrex::Real(13) / amrex::Real(12) * (sm1 - amrex::Real(2) * s0 + sp1) * (sm1 - amrex::Real(2) * s0 + sp1) +
284 amrex::Real(0.25) * (sm1 - sp1) * (sm1 - sp1);
285 const amrex::Real beta3 =
286 amrex::Real(13) / amrex::Real(12) * (s0 - amrex::Real(2) * sp1 + sp2) * (s0 - amrex::Real(2) * sp1 + sp2) +
287 amrex::Real(0.25) * (amrex::Real(3) * s0 - amrex::Real(4) * sp1 + sp2) * (amrex::Real(3) * s0 - amrex::Real(4) * sp1 + sp2);
288
289 const amrex::Real t5 = amrex::Math::abs(beta3 - beta1);
290 const amrex::Real omega1 = amrex::Real(0.1) * (amrex::Real(1) + t5 / (eps + beta1));
291 const amrex::Real omega2 = amrex::Real(0.6) * (amrex::Real(1) + t5 / (eps + beta2));
292 const amrex::Real omega3 = amrex::Real(0.3) * (amrex::Real(1) + t5 / (eps + beta3));
293
294 const amrex::Real omega = omega1 + omega2 + omega3;
295
296 const amrex::Real v_1 = amrex::Real(2) * sm2 - amrex::Real(7) * sm1 + amrex::Real(11) * s0;
297 const amrex::Real v_2 = -sm1 + amrex::Real(5) * s0 + amrex::Real(2) * sp1;
298 const amrex::Real v_3 = amrex::Real(2) * s0 + amrex::Real(5) * sp1 - sp2;
299
300 return (omega1 * v_1 + omega2 * v_2 + omega3 * v_3) / (amrex::Real(6) * omega);
301 }
302
304 static amrex::Real
306 const amrex::Real sm1,
307 const amrex::Real s0,
308 const amrex::Real sp1,
309 const amrex::Real sp2)
310 {
311 return sedge2(sp2,sp1,s0,sm1,sm2); // NOLINT(readability-suspicious-call-argument)
312 }
313
316 sm_sp(const amrex::Real /*s0*/,
317 const amrex::Real sedge1,
318 const amrex::Real sedge2)
319 {
321 }
322}; // wenoz
323
324struct weno_js {
325
326 static constexpr bool do_limiting = false;
327
329 static amrex::Real
331 const amrex::Real sm1,
332 const amrex::Real s0,
333 const amrex::Real sp1,
334 const amrex::Real sp2)
335 {
336 constexpr auto eps = amrex::Real(1.0e-6);
337
338 const amrex::Real beta1 =
339 amrex::Real(13) / amrex::Real(12) * (sm2 - amrex::Real(2) * sm1 + s0) *
340 (sm2 - amrex::Real(2) * sm1 + s0) +
341 amrex::Real(0.25) * (sm2 - amrex::Real(4) * sm1 + amrex::Real(3) * s0) *
342 (sm2 - amrex::Real(4) * sm1 + amrex::Real(3) * s0);
343 const amrex::Real beta2 =
344 amrex::Real(13) / amrex::Real(12) * (sm1 - amrex::Real(2) * s0 + sp1) *
345 (sm1 - amrex::Real(2) * s0 + sp1) +
346 amrex::Real(0.25) * (sm1 - sp1) * (sm1 - sp1);
347 const amrex::Real beta3 =
348 amrex::Real(13) / amrex::Real(12) * (s0 - amrex::Real(2) * sp1 + sp2) *
349 (s0 - amrex::Real(2) * sp1 + sp2) +
350 amrex::Real(0.25) * (amrex::Real(3) * s0 - amrex::Real(4) * sp1 + sp2) *
351 (amrex::Real(3) * s0 - amrex::Real(4) * sp1 + sp2);
352
353 const amrex::Real omega1 = amrex::Real(0.1) / (eps + beta1);
354 const amrex::Real omega2 = amrex::Real(0.6) / (eps + beta2);
355 const amrex::Real omega3 = amrex::Real(0.3) / (eps + beta3);
356
357 const amrex::Real omega = omega1 + omega2 + omega3;
358
359 const amrex::Real v_1 = amrex::Real(2) * sm2 - amrex::Real(7) * sm1 + amrex::Real(11) * s0;
360 const amrex::Real v_2 = -sm1 + amrex::Real(5) * s0 + amrex::Real(2) * sp1;
361 const amrex::Real v_3 = amrex::Real(2) * s0 + amrex::Real(5) * sp1 - sp2;
362
363 return (omega1 * v_1 + omega2 * v_2 + omega3 * v_3) / (amrex::Real(6) * omega);
364 }
365
367 static amrex::Real
369 const amrex::Real sm1,
370 const amrex::Real s0,
371 const amrex::Real sp1,
372 const amrex::Real sp2)
373 {
374 return sedge2(sp2,sp1,s0,sm1,sm2); // NOLINT(readability-suspicious-call-argument)
375 }
376
379 sm_sp(const amrex::Real /*s0*/,
380 const amrex::Real sedge1,
381 const amrex::Real sedge2)
382 {
384 }
385}; // weno_js
386
387struct upwind {
388
389 static constexpr bool do_limiting = false;
390
392 static amrex::Real
393 sedge1(const amrex::Real /*sm2*/,
394 const amrex::Real /*sm1*/,
395 const amrex::Real /*s0*/,
396 const amrex::Real /*sp1*/,
397 const amrex::Real /*sp2*/)
398 {
399 return 0;
400 }
401
403 static amrex::Real
404 sedge2(const amrex::Real /*sm2*/,
405 const amrex::Real /*sm1*/,
406 const amrex::Real /*s0*/,
407 const amrex::Real /*sp1*/,
408 const amrex::Real /*sp2*/)
409 {
410 return 0;
411 }
412
415 sm_sp(const amrex::Real /*s0*/,
416 const amrex::Real sedge1,
417 const amrex::Real sedge2)
418 {
420 }
421}; // upwind
422
423struct minmod {
424
425 static constexpr bool do_limiting = false;
426
428 static amrex::Real
429 sedge1(const amrex::Real /*sm2*/,
430 const amrex::Real /*sm1*/,
431 const amrex::Real /*s0*/,
432 const amrex::Real /*sp1*/,
433 const amrex::Real /*sp2*/)
434 {
435 return 0;
436 }
437
439 static amrex::Real
440 sedge2(const amrex::Real /*sm2*/,
441 const amrex::Real /*sm1*/,
442 const amrex::Real /*s0*/,
443 const amrex::Real /*sp1*/,
444 const amrex::Real /*sp2*/)
445 {
446 return 0;
447 }
448
451 sm_sp(const amrex::Real /*s0*/,
452 const amrex::Real sedge1,
453 const amrex::Real sedge2)
454 {
456 }
457}; // minmod
458
459template <typename Limiter>
461void SetXBCs ( const int i, const int j, const int k, const int n,
462 amrex::Real &sm, amrex::Real &sp,
463 amrex::Real &sedge1, amrex::Real &sedge2,
465 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
466 const int bclo, const int bchi,
467 const int domlo, const int domhi)
468{
469 using namespace amrex;
470
471 // Both the domlo and the domlo+1 branch below use s(domlo-1) as a face value.
472 // For direction_dependent that only holds when the domain face is inflow, so the
473 // gate is the domain-boundary velocity vel_dlo, not the velocity of the face
474 // bounding the cell being filled.
475 if ( (bclo == BCType::ext_dir) || (bclo == BCType::hoextrap) ||
476 (bclo == BCType::direction_dependent && vel_dlo >= Real(0)) )
477 {
478 if (i == domlo)
479 {
480 sedge2 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo,j, k, n)
481 +amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n);
482 if constexpr (Limiter::do_limiting) {
483 sedge2 = amrex::max(sedge2, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n)));
484 sedge2 = amrex::min(sedge2, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n)));
485 }
486
487 sm = s(domlo-1,j,k,n);
488 sp = sedge2;
489
490 } else if (i == domlo+1) {
491
492 sedge1 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo ,j,k,n)
493 + amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n);
494 if constexpr (Limiter::do_limiting) {
495 sedge1 = amrex::max(sedge1, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n)));
496 sedge1 = amrex::min(sedge1, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n)));
497 }
498
499 sp = sedge2;
500 sm = sedge1;
501
502 if constexpr (Limiter::do_limiting) {
503 if ( (sp - s(domlo+1,j,k,n))*(s(domlo+1,j,k,n) - sm) <= amrex::Real(0))
504 {
505 sp = s(domlo+1,j,k,n);
506 sm = s(domlo+1,j,k,n);
507 } else if(amrex::Math::abs(sp - s(domlo+1,j,k,n)) >= amrex::Real(2)*amrex::Math::abs(sm - s(domlo+1,j,k,n))) {
508 sp = amrex::Real(3)*s(domlo+1,j,k,n) - amrex::Real(2)*sm;
509 } else if(amrex::Math::abs(sm - s(domlo+1,j,k,n)) >= amrex::Real(2)*amrex::Math::abs(sp - s(domlo+1,j,k,n))) {
510 sm = amrex::Real(3)*s(domlo+1,j,k,n) - amrex::Real(2)*sp;
511 }
512 }
513 }
514 }
515
516 // Likewise the domhi and domhi-1 branches are gated on the hi domain face.
517 if ( (bchi == BCType::ext_dir) || (bchi == BCType::hoextrap) ||
518 (bchi == BCType::direction_dependent && vel_dhi <= Real(0)) )
519 {
520 if (i == domhi)
521 {
522 sedge1 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi,j,k, n)
523 +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n);
524 if constexpr (Limiter::do_limiting) {
525 sedge1 = amrex::max(sedge1, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n)));
526 sedge1 = amrex::min(sedge1, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n)));
527 }
528
529 sp = s(domhi+1,j,k,n);
530 sm = sedge1;
531
532 } else if (i == domhi-1) {
533
534 sedge2 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi ,j,k,n)
535 +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n);
536 if constexpr (Limiter::do_limiting) {
537 sedge2 = amrex::max(sedge2, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n)));
538 sedge2 = amrex::min(sedge2, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n)));
539 }
540
541 sp = sedge2;
542 sm = sedge1;
543
544 if constexpr (Limiter::do_limiting) {
545 if( (sp - s(domhi-1,j,k,n))*(s(domhi-1,j,k,n) - sm) <= amrex::Real(0))
546 {
547 sp = s(domhi-1,j,k,n);
548 sm = s(domhi-1,j,k,n);
549 } else if(amrex::Math::abs(sp - s(domhi-1,j,k,n)) >= amrex::Real(2.)*amrex::Math::abs(sm - s(domhi-1,j,k,n))) {
550 sp = amrex::Real(3)*s(domhi-1,j,k,n) - amrex::Real(2)*sm;
551 } else if(amrex::Math::abs(sm - s(domhi-1,j,k,n)) >= amrex::Real(2.)*amrex::Math::abs(sp - s(domhi-1,j,k,n))) {
552 sm = amrex::Real(3)*s(domhi-1,j,k,n) - amrex::Real(2)*sp;
553 }
554 }
555 }
556 }
557}
558
559template <typename Limiter>
561void SetYBCs ( const int i, const int j, const int k, const int n,
562 amrex::Real &sm, amrex::Real &sp,
563 amrex::Real &sedge1, amrex::Real &sedge2,
565 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
566 const int bclo, const int bchi,
567 const int domlo, const int domhi)
568{
569 using namespace amrex;
570
571 // Both the domlo and the domlo+1 branch below use s(domlo-1) as a face value.
572 // For direction_dependent that only holds when the domain face is inflow, so the
573 // gate is the domain-boundary velocity vel_dlo, not the velocity of the face
574 // bounding the cell being filled.
575 if ( (bclo == BCType::ext_dir) || (bclo == BCType::hoextrap) ||
576 (bclo == BCType::direction_dependent && vel_dlo >= Real(0)) )
577 {
578 if (j == domlo)
579 {
580 sedge2 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n)
581 +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n);
582 if constexpr (Limiter::do_limiting) {
583 sedge2 = amrex::max(sedge2, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n)));
584 sedge2 = amrex::min(sedge2, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n)));
585 }
586
587 sm = s(i,domlo-1,k,n);
588 sp = sedge2;
589
590 } else if (j == domlo+1) {
591
592 sedge1 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n)
593 +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n);
594 if constexpr (Limiter::do_limiting) {
595 sedge1 = amrex::max(sedge1, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n)));
596 sedge1 = amrex::min(sedge1, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n)));
597 }
598
599 sp = sedge2;
600 sm = sedge1;
601
602 if constexpr (Limiter::do_limiting) {
603 if ( (sp - s(i,domlo+1,k,n))*(s(i,domlo+1,k,n) - sm) <= amrex::Real(0))
604 {
605 sp = s(i,domlo+1,k,n);
606 sm = s(i,domlo+1,k,n);
607 } else if(amrex::Math::abs(sp - s(i,domlo+1,k,n)) >= amrex::Real(2)*amrex::Math::abs(sm - s(i,domlo+1,k,n))) {
608 sp = amrex::Real(3)*s(i,domlo+1,k,n) - amrex::Real(2)*sm;
609 } else if(amrex::Math::abs(sm - s(i,domlo+1,k,n)) >= amrex::Real(2)*amrex::Math::abs(sp - s(i,domlo+1,k,n))) {
610 sm = amrex::Real(3)*s(i,domlo+1,k,n) - amrex::Real(2)*sp;
611 }
612 }
613 }
614 }
615
616 // Likewise the domhi and domhi-1 branches are gated on the hi domain face.
617 if ( (bchi == BCType::ext_dir) || (bchi == BCType::hoextrap) ||
618 (bchi == BCType::direction_dependent && vel_dhi <= Real(0)) )
619 {
620 if (j == domhi)
621 {
622 sedge1 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n)
623 +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n);
624 if constexpr (Limiter::do_limiting) {
625 sedge1 = amrex::max(sedge1, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n)));
626 sedge1 = amrex::min(sedge1, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n)));
627 }
628
629 sp = s(i,domhi+1,k, n);
630 sm = sedge1;
631
632 } else if (j == domhi-1) {
633
634 sedge2 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n)
635 +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n);
636 if constexpr (Limiter::do_limiting) {
637 sedge2 = amrex::max(sedge2, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n)));
638 sedge2 = amrex::min(sedge2, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n)));
639 }
640
641 sp = sedge2;
642 sm = sedge1;
643
644 if constexpr (Limiter::do_limiting) {
645 if( (sp - s(i,domhi-1,k,n))*(s(i,domhi-1,k,n) - sm) <= amrex::Real(0)){
646 sp = s(i,domhi-1,k,n);
647 sm = s(i,domhi-1,k,n);
648 } else if(amrex::Math::abs(sp - s(i,domhi-1,k,n)) >= amrex::Real(2.)*amrex::Math::abs(sm - s(i,domhi-1,k,n))) {
649 sp = amrex::Real(3)*s(i,domhi-1,k,n) - amrex::Real(2)*sm;
650 } else if(amrex::Math::abs(sm - s(i,domhi-1,k,n)) >= amrex::Real(2.)*amrex::Math::abs(sp - s(i,domhi-1,k,n))) {
651 sm = amrex::Real(3)*s(i,domhi-1,k,n) - amrex::Real(2)*sp;
652 }
653 }
654 }
655 }
656}
657
658#if (AMREX_SPACEDIM==3)
659template <typename Limiter>
661void SetZBCs ( const int i, const int j, const int k, const int n,
662 amrex::Real &sm, amrex::Real &sp,
663 amrex::Real &sedge1, amrex::Real &sedge2,
665 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
666 const int bclo, const int bchi,
667 const int domlo, const int domhi)
668{
669 using namespace amrex;
670
671 // Both the domlo and the domlo+1 branch below use s(domlo-1) as a face value.
672 // For direction_dependent that only holds when the domain face is inflow, so the
673 // gate is the domain-boundary velocity vel_dlo, not the velocity of the face
674 // bounding the cell being filled.
675 if ( (bclo == BCType::ext_dir) || (bclo == BCType::hoextrap) ||
676 (bclo == BCType::direction_dependent && vel_dlo >= Real(0)) )
677 {
678 if (k == domlo)
679 {
680 sedge2 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n)
681 +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n);
682 if constexpr (Limiter::do_limiting) {
683 sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n)));
684 sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n)));
685 }
686
687 sm = s(i,j,domlo-1,n);
688 sp = sedge2;
689
690 } else if (k == domlo+1) {
691
692 sedge1 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n)
693 +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n);
694 if constexpr (Limiter::do_limiting) {
695 sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n)));
696 sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n)));
697 }
698
699 sp = sedge2;
700 sm = sedge1;
701
702 if constexpr (Limiter::do_limiting) {
703 if ( (sp - s(i,j,domlo+1,n))*(s(i,j,domlo+1,n) - sm) <= amrex::Real(0.) )
704 {
705 sp = s(i,j,domlo+1,n);
706 sm = s(i,j,domlo+1,n);
707 } else if(amrex::Math::abs(sp - s(i,j,domlo+1,n)) >= amrex::Real(2.)*amrex::Math::abs(sm - s(i,j,domlo+1,n))) {
708 sp = amrex::Real(3)*s(i,j,domlo+1,n) - amrex::Real(2)*sm;
709 } else if(amrex::Math::abs(sm - s(i,j,domlo+1,n)) >= amrex::Real(2.)*amrex::Math::abs(sp - s(i,j,domlo+1,n))) {
710 sm = amrex::Real(3)*s(i,j,domlo+1,n) - amrex::Real(2)*sp;
711 }
712 }
713 }
714 }
715
716 // Likewise the domhi and domhi-1 branches are gated on the hi domain face.
717 if ( (bchi == BCType::ext_dir) || (bchi == BCType::hoextrap) ||
718 (bchi == BCType::direction_dependent && vel_dhi <= Real(0)) )
719 {
720 if (k == domhi)
721 {
722 sedge1 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n)
723 +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n);
724 if constexpr (Limiter::do_limiting) {
725 sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n)));
726 sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n)));
727 }
728
729 sp = s(i,j,domhi+1,n);
730 sm = sedge1;
731
732 } else if (k == domhi-1) {
733
734 sedge2 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n)
735 +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n);
736 if constexpr (Limiter::do_limiting) {
737 sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n)));
738 sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n)));
739 }
740
741 sp = sedge2;
742 sm = sedge1;
743
744 if constexpr (Limiter::do_limiting) {
745 if ( (sp - s(i,j,domhi-1,n))*(s(i,j,domhi-1,n) - sm) <= amrex::Real(0.) )
746 {
747 sp = s(i,j,domhi-1,n);
748 sm = s(i,j,domhi-1,n);
749 } else if(amrex::Math::abs(sp - s(i,j,domhi-1,n)) >= amrex::Real(2.)*amrex::Math::abs(sm - s(i,j,domhi-1,n))) {
750 sp = amrex::Real(3)*s(i,j,domhi-1,n) - amrex::Real(2)*sm;
751 } else if(amrex::Math::abs(sm - s(i,j,domhi-1,n)) >= amrex::Real(2.)*amrex::Math::abs(sp - s(i,j,domhi-1,n))) {
752 sm = amrex::Real(3)*s(i,j,domhi-1,n) - amrex::Real(2)*sp;
753 }
754 }
755
756 }
757 }
758}
759#endif
760
761
762// Right now only ppm type 1 is supported on GPU
763// This version is called before the MAC projection, when we use the cell-centered velocity
764// for upwinding
765template <typename Limiter>
767void PredictVelOnXFace ( const int i, const int j, const int k, const int n,
768 const amrex::Real dtdx, const amrex::Real v_ad,
769 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
773 const amrex::BCRec bc, const int domlo, const int domhi,
774 const Limiter& /*limiter*/)
775{
776 constexpr auto half{amrex::Real(0.5)};
777 constexpr auto one{amrex::Real(1)};
778 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
779
780 const amrex::Real sm2 = S(i-2,j,k,n);
781 const amrex::Real sm1 = S(i-1,j,k,n);
782 const amrex::Real s0 = S(i ,j,k,n);
783 const amrex::Real sp1 = S(i+1,j,k,n);
784 const amrex::Real sp2 = S(i+2,j,k,n);
785
786 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
787 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
788
789 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
790
791 SetXBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
792 bc.lo(0), bc.hi(0), domlo, domhi);
793
794 const amrex::Real s6 = amrex::Real(6)*s0 - amrex::Real(3)*(sm + sp);
795
796 const amrex::Real sigma = amrex::Math::abs(v_ad)*dtdx;
797
798 if (v_ad > small_vel)
799 {
800 Ip(i,j,k,n) = sp - (half*sigma)*((sp-sm) - (one - two3rds*sigma)*s6);
801 Im(i,j,k,n) = S(i,j,k,n);
802 }
803 else if (v_ad < -small_vel)
804 {
805 Ip(i,j,k,n) = S(i,j,k,n);
806 Im(i,j,k,n) = sm + (half*sigma)*((sp-sm) + (one - two3rds*sigma)*s6);
807 } else
808 {
809 Ip(i,j,k,n) = S(i,j,k,n);
810 Im(i,j,k,n) = S(i,j,k,n);
811 }
812}
813
814template <typename Limiter>
816void PredictVelOnYFace ( const int i, const int j, const int k, const int n,
817 const amrex::Real dtdy, const amrex::Real v_ad,
818 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
822 const amrex::BCRec bc, const int domlo, const int domhi,
823 const Limiter& /*limiter*/)
824{
825 constexpr auto half{amrex::Real(0.5)};
826 constexpr auto one{amrex::Real(1)};
827 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
828
829 const amrex::Real sm2 = S(i,j-2,k,n);
830 const amrex::Real sm1 = S(i,j-1,k,n);
831 const amrex::Real s0 = S(i,j ,k,n);
832 const amrex::Real sp1 = S(i,j+1,k,n);
833 const amrex::Real sp2 = S(i,j+2,k,n);
834
835 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
836 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
837
838 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
839
840 SetYBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
841 bc.lo(1), bc.hi(1), domlo, domhi);
842
843 const amrex::Real s6 = amrex::Real(6)*s0 - amrex::Real(3)*(sm + sp);
844
845 const amrex::Real sigma = amrex::Math::abs(v_ad)*dtdy;
846
847 if (v_ad > small_vel)
848 {
849 Ip(i,j,k,n) = sp - (half*sigma)*((sp-sm) - (one - two3rds*sigma)*s6);
850 Im(i,j,k,n) = S(i,j,k,n);
851 }
852 else if (v_ad < -small_vel)
853 {
854 Ip(i,j,k,n) = S(i,j,k,n);
855 Im(i,j,k,n) = sm + (half*sigma)*((sp-sm) + (one - two3rds*sigma)*s6);
856 } else
857 {
858 Ip(i,j,k,n) = S(i,j,k,n);
859 Im(i,j,k,n) = S(i,j,k,n);
860 }
861}
862
863#if (AMREX_SPACEDIM==3)
864template <typename Limiter>
866void PredictVelOnZFace ( const int i, const int j, const int k, const int n,
867 const amrex::Real dtdz, const amrex::Real v_ad,
868 const amrex::Real vel_dlo, const amrex::Real vel_dhi,
872 const amrex::BCRec bc, const int domlo, const int domhi,
873 const Limiter& /*limiter*/)
874{
875 constexpr auto half{amrex::Real(0.5)};
876 constexpr auto one{amrex::Real(1)};
877 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
878
879 const amrex::Real sm2 = S(i,j,k-2,n);
880 const amrex::Real sm1 = S(i,j,k-1,n);
881 const amrex::Real s0 = S(i,j,k ,n);
882 const amrex::Real sp1 = S(i,j,k+1,n);
883 const amrex::Real sp2 = S(i,j,k+2,n);
884
885 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
886 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
887
888 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
889
890 SetZBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
891 bc.lo(2), bc.hi(2), domlo, domhi);
892
893 const amrex::Real s6 = amrex::Real(6)*s0 - amrex::Real(3)*(sm + sp);
894
895 const amrex::Real sigma = amrex::Math::abs(v_ad)*dtdz;
896
897 if (v_ad > small_vel)
898 {
899 Ip(i,j,k,n) = sp - (half*sigma)*((sp-sm) - (one - two3rds*sigma)*s6);
900 Im(i,j,k,n) = S(i,j,k,n);
901 }
902 else if (v_ad < -small_vel)
903 {
904 Ip(i,j,k,n) = S(i,j,k,n);
905 Im(i,j,k,n) = sm + (half*sigma)*((sp-sm) + (one - two3rds*sigma)*s6);
906 } else
907 {
908 Ip(i,j,k,n) = S(i,j,k,n);
909 Im(i,j,k,n) = S(i,j,k,n);
910 }
911}
912
913#endif
914
915// Right now only ppm type 1 is supported on GPU
916// This version is called after the MAC projection, when we use the MAC-projected velocity
917// for upwinding
918template <typename Limiter>
920void PredictStateOnXFace ( const int i, const int j, const int k, const int n,
921 const amrex::Real dt, const amrex::Real dx,
922 amrex::Real& Im, amrex::Real& Ip,
924 const amrex::Array4<const amrex::Real> &vel_edge,
925 const amrex::BCRec bc,
926 const int domlo, const int domhi,
927 const Limiter& /*limiter*/,
928 int /*unused*/)
929{
930 const amrex::Real sm1 = S(i-1,j,k,n);
931 const amrex::Real s0 = S(i ,j,k,n);
932 const amrex::Real sp1 = S(i+1,j,k,n);
933
934 constexpr auto half{amrex::Real(0.5)};
935 constexpr auto one{amrex::Real(1)};
936
937 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i+1,j,k))*dt/dx;
938 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i ,j,k))*dt/dx;
939
940 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
941
942 const amrex::Real sm2 = S(i-2,j,k,n);
943 const amrex::Real sp2 = S(i+2,j,k,n);
944
945 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
946 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
947
948 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
949
950 // SetXBCs applies its boundary stencil to both domlo and domlo+1 (domhi-1 and
951 // domhi), so for direction_dependent the gate must be the domain face, not the
952 // face bounding this cell. vel_edge carries one ghost face, so the domain face is
953 // out of reach only for a box whose valid region starts at domlo+2 (ends at
954 // domhi-2); there we fall back to this cell's face.
955 const amrex::Real vel_dlo = (i <= domlo+1 && amrex::lbound(vel_edge).x <= domlo)
956 ? vel_edge(domlo ,j,k) : vel_edge(i,j,k);
957 const amrex::Real vel_dhi = (i >= domhi-1 && amrex::ubound(vel_edge).x >= domhi+1)
958 ? vel_edge(domhi+1,j,k) : vel_edge(i+1,j,k);
959 SetXBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
960 bc.lo(0), bc.hi(0), domlo, domhi);
961
962 const amrex::Real s6 = amrex::Real(6)*s0 - amrex::Real(3)*(sm + sp);
963
964 if (vel_edge(i+1,j,k) > small_vel) {
965 Ip = sp - (half*sigmap)*((sp - sm) - (one -two3rds*sigmap)*s6);
966 } else if (i == domhi && bc.hi(0) == amrex::BCType::ext_dir) {
967 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
968 // is that value, which the ghost cell holds. Where |u| < small_vel, as on a wall, the
969 // edge-state kernels average the states from the two sides of the face, so the cell
970 // average here would put the state on the wall O(dx) off. Fluxes do not see that,
971 // since u = 0 there, but the convective form adds q div(u) with q the mean of the
972 // states on the faces of the cell (HydroUtils::ComputeConvectiveTerm), which would
973 // then be O(dx) wrong wherever div(u) != 0 next to the wall.
974 // PredictVelOn{X,Y,Z}Face does not need this: the velocity extrapolation has no
975 // q div(u) term, and its transverse terms multiply the state on a wall by the normal
976 // velocity of the cell next to it, which is O(dx), so there the cell average only
977 // adds an O(dt dx) error. That is within the accuracy of the method itself: the PPM
978 // predicted states are second order, with O(dx^2), O(dt dx) and O(dt^2) errors of
979 // their own.
980 Ip = S(i+1,j,k,n);
981 } else {
982 Ip = S(i,j,k,n);
983 }
984
985 if(vel_edge(i,j,k) < -small_vel) {
986 Im = sm + (half*sigmam)*((sp-sm) + (one - two3rds*sigmam)*s6);
987 } else if (i == domlo && bc.lo(0) == amrex::BCType::ext_dir) {
988 Im = S(i-1,j,k,n);
989 } else {
990 Im = S(i,j,k,n);
991 }
992}
993
994template <>
996void PredictStateOnXFace<PPM::upwind> ( const int i, const int j, const int k, const int n,
997 const amrex::Real /*unused*/, const amrex::Real /*unused*/,
998 amrex::Real& Im, amrex::Real& Ip,
1000 const amrex::Array4<const amrex::Real> & /*unused*/,
1001 const amrex::BCRec /*unused*/,
1002 const int /*unused*/, const int /*unused*/,
1003 const PPM::upwind& /*limiter*/,
1004 int /*unused*/)
1005{
1006 Im = S(i,j,k,n);
1007 Ip = S(i,j,k,n);
1008}
1009
1010
1011template <>
1013void PredictStateOnXFace<PPM::minmod> ( const int i, const int j, const int k, const int n,
1014 const amrex::Real dt, const amrex::Real dx,
1015 amrex::Real& Im, amrex::Real& Ip,
1017 const amrex::Array4<const amrex::Real> &vel_edge,
1018 const amrex::BCRec bc,
1019 const int domlo, const int domhi,
1020 const PPM::minmod& /*limiter*/,
1021 int /*unused*/)
1022{
1023 const amrex::Real s0 = S(i ,j,k,n);
1024 const amrex::Real sm1 = Godunov_minmod_ghost_lo(i, S(i-1,j,k,n), s0, vel_edge(i ,j,k), bc.lo(0), domlo);
1025 const amrex::Real sp1 = Godunov_minmod_ghost_hi(i, s0, S(i+1,j,k,n), vel_edge(i+1,j,k), bc.hi(0), domhi);
1026
1027 constexpr auto half{amrex::Real(0.5)};
1028 constexpr auto one{amrex::Real(1.0)};
1029
1030 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i+1,j,k))*dt/dx;
1031 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i ,j,k))*dt/dx;
1032
1033 auto dsp = amrex::Real(0.0);
1034 auto dsm = amrex::Real(0.0);
1035 minmod_fn(sm1, s0, sp1, dsm, dsp);
1036 Godunov_minmod_bc_lo(i, sm1, s0, vel_edge(i ,j,k), dsm, bc.lo(0), domlo);
1037 Godunov_minmod_bc_hi(i, s0, sp1, vel_edge(i+1,j,k), dsp, bc.hi(0), domhi);
1038
1039 if (vel_edge(i + 1, j, k) > small_vel) {
1040 Ip = s0 + half * (one - sigmap) * dsp;
1041 } else if (i == domhi && bc.hi(0) == amrex::BCType::ext_dir) {
1042 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
1043 // is that value, which the ghost cell holds (see PredictStateOnXFace)
1044 Ip = S(i+1,j,k,n);
1045 } else {
1046 Ip = S(i,j,k,n);
1047 }
1048
1049 if (vel_edge(i, j, k) < -small_vel) {
1050 Im = s0 - half * (one - sigmam) * dsm;
1051 } else if (i == domlo && bc.lo(0) == amrex::BCType::ext_dir) {
1052 Im = S(i-1,j,k,n);
1053 } else {
1054 Im = S(i,j,k,n);
1055 }
1056}
1057
1058template <typename Limiter>
1060void PredictStateOnYFace ( const int i, const int j, const int k, const int n,
1061 const amrex::Real dt, const amrex::Real dx,
1062 amrex::Real& Im, amrex::Real& Ip,
1064 const amrex::Array4<const amrex::Real> &vel_edge,
1065 const amrex::BCRec bc,
1066 const int domlo, const int domhi,
1067 const Limiter& /*limiter*/,
1068 int /*unused*/)
1069{
1070 const amrex::Real sm1 = S(i,j-1,k,n);
1071 const amrex::Real s0 = S(i,j ,k,n);
1072 const amrex::Real sp1 = S(i,j+1,k,n);
1073
1074 constexpr auto half{amrex::Real(0.5)};
1075 constexpr auto one{amrex::Real(1.0)};
1076
1077 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i,j+1,k))*dt/dx;
1078 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i,j ,k))*dt/dx;
1079
1080 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
1081
1082 const amrex::Real sm2 = S(i,j-2,k,n);
1083 const amrex::Real sp2 = S(i,j+2,k,n);
1084
1085 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
1086 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
1087
1088 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
1089
1090 // SetYBCs applies its boundary stencil to both domlo and domlo+1 (domhi-1 and
1091 // domhi), so for direction_dependent the gate must be the domain face, not the
1092 // face bounding this cell. vel_edge carries one ghost face, so the domain face is
1093 // out of reach only for a box whose valid region starts at domlo+2 (ends at
1094 // domhi-2); there we fall back to this cell's face.
1095 const amrex::Real vel_dlo = (j <= domlo+1 && amrex::lbound(vel_edge).y <= domlo)
1096 ? vel_edge(i,domlo ,k) : vel_edge(i,j,k);
1097 const amrex::Real vel_dhi = (j >= domhi-1 && amrex::ubound(vel_edge).y >= domhi+1)
1098 ? vel_edge(i,domhi+1,k) : vel_edge(i,j+1,k);
1099 SetYBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
1100 bc.lo(1), bc.hi(1), domlo, domhi);
1101
1102 const amrex::Real s6 = amrex::Real(6)*s0- amrex::Real(3)*(sm + sp);
1103
1104 if (vel_edge(i,j+1,k) > small_vel) {
1105 Ip = sp - (half*sigmap)*((sp - sm) - (one -two3rds*sigmap)*s6);
1106 } else if (j == domhi && bc.hi(1) == amrex::BCType::ext_dir) {
1107 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
1108 // is that value, which the ghost cell holds (see PredictStateOnXFace)
1109 Ip = S(i,j+1,k,n);
1110 } else {
1111 Ip = S(i,j,k,n);
1112 }
1113
1114 if (vel_edge(i,j,k) < -small_vel) {
1115 Im = sm + (half*sigmam)*((sp-sm) + (one - two3rds*sigmam)*s6);
1116 } else if (j == domlo && bc.lo(1) == amrex::BCType::ext_dir) {
1117 Im = S(i,j-1,k,n);
1118 } else {
1119 Im = S(i,j,k,n);
1120 }
1121}
1122
1123
1124template <>
1126void PredictStateOnYFace<PPM::upwind> ( const int i, const int j, const int k, const int n,
1127 const amrex::Real /*unused*/, const amrex::Real /*unused*/,
1128 amrex::Real& Im, amrex::Real& Ip,
1130 const amrex::Array4<const amrex::Real> & /*unused*/,
1131 const amrex::BCRec /*unused*/,
1132 const int /*unused*/, const int /*unused*/,
1133 const PPM::upwind& /*limiter*/,
1134 int /*unused*/)
1135{
1136 Im = S(i,j,k,n);
1137 Ip = S(i,j,k,n);
1138}
1139
1140
1141template <>
1143void PredictStateOnYFace<PPM::minmod> ( const int i, const int j, const int k, const int n,
1144 const amrex::Real dt, const amrex::Real dx,
1145 amrex::Real& Im, amrex::Real& Ip,
1147 const amrex::Array4<const amrex::Real> &vel_edge,
1148 const amrex::BCRec bc,
1149 const int domlo, const int domhi,
1150 const PPM::minmod& /*limiter*/,
1151 int /*unused*/)
1152{
1153 const amrex::Real s0 = S(i,j ,k,n);
1154 const amrex::Real sm1 = Godunov_minmod_ghost_lo(j, S(i,j-1,k,n), s0, vel_edge(i,j ,k), bc.lo(1), domlo);
1155 const amrex::Real sp1 = Godunov_minmod_ghost_hi(j, s0, S(i,j+1,k,n), vel_edge(i,j+1,k), bc.hi(1), domhi);
1156
1157 constexpr auto half{amrex::Real(0.5)};
1158 constexpr auto one{amrex::Real(1.0)};
1159
1160 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i,j+1,k))*dt/dx;
1161 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i,j ,k))*dt/dx;
1162
1163 auto dsp = amrex::Real(0.0);
1164 auto dsm = amrex::Real(0.0);
1165 minmod_fn(sm1, s0, sp1, dsm, dsp);
1166 Godunov_minmod_bc_lo(j, sm1, s0, vel_edge(i,j ,k), dsm, bc.lo(1), domlo);
1167 Godunov_minmod_bc_hi(j, s0, sp1, vel_edge(i,j+1,k), dsp, bc.hi(1), domhi);
1168
1169 if (vel_edge(i,j+1,k) > small_vel) {
1170 Ip = s0 + half * (one - sigmap) * dsp;
1171 } else if (j == domhi && bc.hi(1) == amrex::BCType::ext_dir) {
1172 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
1173 // is that value, which the ghost cell holds (see PredictStateOnXFace)
1174 Ip = S(i,j+1,k,n);
1175 } else {
1176 Ip = S(i,j,k,n);
1177 }
1178 if (vel_edge(i,j,k) < -small_vel) {
1179 Im = s0 - half * (one - sigmam) * dsm;
1180 } else if (j == domlo && bc.lo(1) == amrex::BCType::ext_dir) {
1181 Im = S(i,j-1,k,n);
1182 } else {
1183 Im = S(i,j,k,n);
1184 }
1185}
1186
1187
1188#if (AMREX_SPACEDIM==3)
1189template <typename Limiter>
1191void PredictStateOnZFace ( const int i, const int j, const int k, const int n,
1192 const amrex::Real dt, const amrex::Real dx,
1193 amrex::Real& Im, amrex::Real& Ip,
1195 const amrex::Array4<const amrex::Real> &vel_edge,
1196 const amrex::BCRec bc,
1197 const int domlo, const int domhi,
1198 const Limiter& /*limiter*/,
1199 int /*unused*/)
1200{
1201 const amrex::Real sm1 = S(i,j,k-1,n);
1202 const amrex::Real s0 = S(i,j,k ,n);
1203 const amrex::Real sp1 = S(i,j,k+1,n);
1204
1205 constexpr auto half{amrex::Real(0.5)};
1206
1207 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i,j,k+1))*dt/dx;
1208 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i,j,k ))*dt/dx;
1209
1210 constexpr auto two3rds{amrex::Real(2.0)/amrex::Real(3.0)};
1211
1212 const amrex::Real sm2 = S(i,j,k-2,n);
1213 const amrex::Real sp2 = S(i,j,k+2,n);
1214
1215 amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
1216 amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);
1217
1218 auto [sm, sp] = Limiter::sm_sp(s0, sedge1, sedge2);
1219
1220 // SetZBCs applies its boundary stencil to both domlo and domlo+1 (domhi-1 and
1221 // domhi), so for direction_dependent the gate must be the domain face, not the
1222 // face bounding this cell. vel_edge carries one ghost face, so the domain face is
1223 // out of reach only for a box whose valid region starts at domlo+2 (ends at
1224 // domhi-2); there we fall back to this cell's face.
1225 const amrex::Real vel_dlo = (k <= domlo+1 && amrex::lbound(vel_edge).z <= domlo)
1226 ? vel_edge(i,j,domlo ) : vel_edge(i,j,k);
1227 const amrex::Real vel_dhi = (k >= domhi-1 && amrex::ubound(vel_edge).z >= domhi+1)
1228 ? vel_edge(i,j,domhi+1) : vel_edge(i,j,k+1);
1229 SetZBCs<Limiter>(i, j, k, n, sm, sp, sedge1, sedge2, S, vel_dlo, vel_dhi,
1230 bc.lo(2), bc.hi(2), domlo, domhi);
1231
1232 const amrex::Real s6 = amrex::Real(6)*s0- amrex::Real(3)*(sm + sp);
1233
1234 if(vel_edge(i,j,k+1) > small_vel) {
1235 Ip = sp - (half*sigmap)*((sp-sm) - (amrex::Real(1.0) -two3rds*sigmap)*s6);
1236 } else if (k == domhi && bc.hi(2) == amrex::BCType::ext_dir) {
1237 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
1238 // is that value, which the ghost cell holds (see PredictStateOnXFace)
1239 Ip = S(i,j,k+1,n);
1240 } else {
1241 Ip = S(i,j,k,n);
1242 }
1243
1244 if(vel_edge(i,j,k) < -small_vel) {
1245 Im = sm + (half*sigmam)*((sp-sm) + (amrex::Real(1.0) - two3rds*sigmam)*s6);
1246 } else if (k == domlo && bc.lo(2) == amrex::BCType::ext_dir) {
1247 Im = S(i,j,k-1,n);
1248 } else {
1249 Im = S(i,j,k,n);
1250 }
1251}
1252
1253template <>
1255void PredictStateOnZFace<PPM::upwind> ( const int i, const int j, const int k, const int n,
1256 const amrex::Real /*unused*/, const amrex::Real /*unused*/,
1257 amrex::Real& Im, amrex::Real& Ip,
1259 const amrex::Array4<const amrex::Real> & /*unused*/,
1260 const amrex::BCRec /*unused*/,
1261 const int /*unused*/, const int /*unused*/,
1262 const PPM::upwind& /*limiter*/,
1263 int /*unused*/)
1264{
1265 Im = S(i,j,k,n);
1266 Ip = S(i,j,k,n);
1267}
1268
1269template <>
1271void PredictStateOnZFace<PPM::minmod> ( const int i, const int j, const int k, const int n,
1272 const amrex::Real dt, const amrex::Real dx,
1273 amrex::Real& Im, amrex::Real& Ip,
1275 const amrex::Array4<const amrex::Real> &vel_edge,
1276 const amrex::BCRec bc,
1277 const int domlo, const int domhi,
1278 const PPM::minmod& /*limiter*/,
1279 int /*unused*/)
1280{
1281 const amrex::Real s0 = S(i,j,k ,n);
1282 const amrex::Real sm1 = Godunov_minmod_ghost_lo(k, S(i,j,k-1,n), s0, vel_edge(i,j,k ), bc.lo(2), domlo);
1283 const amrex::Real sp1 = Godunov_minmod_ghost_hi(k, s0, S(i,j,k+1,n), vel_edge(i,j,k+1), bc.hi(2), domhi);
1284
1285 constexpr auto half{amrex::Real(0.5)};
1286 constexpr auto one{amrex::Real(1.0)};
1287
1288 const amrex::Real sigmap = amrex::Math::abs(vel_edge(i,j,k+1))*dt/dx;
1289 const amrex::Real sigmam = amrex::Math::abs(vel_edge(i,j,k ))*dt/dx;
1290
1291 auto dsp = amrex::Real(0.0);
1292 auto dsm = amrex::Real(0.0);
1293 minmod_fn(sm1, s0, sp1, dsm, dsp);
1294 Godunov_minmod_bc_lo(k, sm1, s0, vel_edge(i,j,k ), dsm, bc.lo(2), domlo);
1295 Godunov_minmod_bc_hi(k, s0, sp1, vel_edge(i,j,k+1), dsp, bc.hi(2), domhi);
1296
1297 if (vel_edge(i, j, k + 1) > small_vel) {
1298 Ip = s0 + half * (one - sigmap) * dsp;
1299 } else if (k == domhi && bc.hi(2) == amrex::BCType::ext_dir) {
1300 // Unless the flow leaves through it, the state on a boundary with a Dirichlet value
1301 // is that value, which the ghost cell holds (see PredictStateOnXFace)
1302 Ip = S(i,j,k+1,n);
1303 } else {
1304 Ip = S(i,j,k,n);
1305 }
1306
1307 if (vel_edge(i, j, k) < -small_vel) {
1308 Im = s0 - half * (one - sigmam) * dsm;
1309 } else if (k == domlo && bc.lo(2) == amrex::BCType::ext_dir) {
1310 Im = S(i,j,k-1,n);
1311 } else {
1312 Im = S(i,j,k,n);
1313 }
1314}
1315#endif
1316
1317template <typename Limiter>
1320 amrex::Array4<amrex::Real> const& Imy,
1321 amrex::Array4<amrex::Real> const& Imz),
1323 amrex::Array4<amrex::Real> const& Ipy,
1324 amrex::Array4<amrex::Real> const& Ipz),
1327 amrex::Geometry geom,
1328 amrex::Real dt,
1329 amrex::BCRec const* pbc,
1330 const Limiter& limiter,
1331 amrex::Array4<int const> const& bc_arr = {})
1332{
1333 const amrex::Box& domain = geom.Domain();
1334 const amrex::Dim3 dlo = amrex::lbound(domain);
1335 const amrex::Dim3 dhi = amrex::ubound(domain);
1336
1337 const auto dx = geom.CellSizeArray();
1338 AMREX_D_TERM( const amrex::Real l_dtdx = dt / dx[0];,
1339 const amrex::Real l_dtdy = dt / dx[1];,
1340 const amrex::Real l_dtdz = dt / dx[2];);
1341
1342 amrex::ParallelFor(bx, AMREX_SPACEDIM,
1343 [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
1344 {
1345 // The boundary stencils in SetXBCs/SetYBCs/SetZBCs cover the first two cell
1346 // layers, so for direction_dependent they must be gated on the velocity at the
1347 // domain boundary rather than on the velocity of the cell being filled. Here
1348 // that is the normal velocity of the boundary cell itself. The reads are
1349 // guarded so we never touch the boundary cell from a box that is nowhere near
1350 // it; vel carries 3 ghost cells, so it is in reach wherever the gate is used.
1351 const amrex::Real xlo_v = (i <= dlo.x+1) ? vel(dlo.x,j,k,0) : amrex::Real(0.0);
1352 const amrex::Real xhi_v = (i >= dhi.x-1) ? vel(dhi.x,j,k,0) : amrex::Real(0.0);
1353 const amrex::Real ylo_v = (j <= dlo.y+1) ? vel(i,dlo.y,k,1) : amrex::Real(0.0);
1354 const amrex::Real yhi_v = (j >= dhi.y-1) ? vel(i,dhi.y,k,1) : amrex::Real(0.0);
1355 // Use the position-dependent boundary condition where one was given, as the
1356 // PLM path does; getBC falls back to pbc[n] when bc_arr is null.
1357 const amrex::BCRec bc = HydroBC::getBC(i, j, k, n, domain, pbc, bc_arr);
1358 PredictVelOnXFace(i,j,k,n,l_dtdx,vel(i,j,k,0),xlo_v,xhi_v,q,Imx,Ipx,bc,dlo.x,dhi.x,limiter);
1359 PredictVelOnYFace(i,j,k,n,l_dtdy,vel(i,j,k,1),ylo_v,yhi_v,q,Imy,Ipy,bc,dlo.y,dhi.y,limiter);
1360#if (AMREX_SPACEDIM==3)
1361 const amrex::Real zlo_v = (k <= dlo.z+1) ? vel(i,j,dlo.z,2) : amrex::Real(0.0);
1362 const amrex::Real zhi_v = (k >= dhi.z-1) ? vel(i,j,dhi.z,2) : amrex::Real(0.0);
1363 PredictVelOnZFace(i,j,k,n,l_dtdz,vel(i,j,k,2),zlo_v,zhi_v,q,Imz,Ipz,bc,dlo.z,dhi.z,limiter);
1364#endif
1365 });
1366}
1367
1368template <typename Limiter>
1371 amrex::Array4<amrex::Real> const& Imy,
1372 amrex::Array4<amrex::Real> const& Imz),
1374 amrex::Array4<amrex::Real> const& Ipy,
1375 amrex::Array4<amrex::Real> const& Ipz),
1380 amrex::Geometry geom,
1381 amrex::Real l_dt,
1382 amrex::BCRec const* pbc,
1383 const int ncomp,
1384 const Limiter& limiter,
1385 int limiter_type,
1386 amrex::Array4<int const> const& bc_arr = {})
1387{
1388 const amrex::Box& domain = geom.Domain();
1389 const amrex::Dim3 dlo = amrex::lbound(domain);
1390 const amrex::Dim3 dhi = amrex::ubound(domain);
1391
1392 AMREX_D_TERM (const auto dx = geom.CellSize(0);,
1393 const auto dy = geom.CellSize(1);,
1394 const auto dz = geom.CellSize(2););
1395
1396 amrex::ParallelFor(bx, ncomp,
1397 [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
1398 {
1399 // Use the position-dependent boundary condition where one was given, as the
1400 // PLM path does; getBC falls back to pbc[n] when bc_arr is null.
1401 const amrex::BCRec bc = HydroBC::getBC(i, j, k, n, domain, pbc, bc_arr);
1402 PPM::PredictStateOnXFace(i, j, k, n, l_dt, dx, Imx(i,j,k,n), Ipx(i,j,k,n),
1403 q, umac, bc, dlo.x, dhi.x, limiter, limiter_type);
1404 PPM::PredictStateOnYFace(i, j, k, n, l_dt, dy, Imy(i,j,k,n), Ipy(i,j,k,n),
1405 q, vmac, bc, dlo.y, dhi.y, limiter, limiter_type);
1406#if (AMREX_SPACEDIM==3)
1407 PPM::PredictStateOnZFace(i, j, k, n, l_dt, dz, Imz(i,j,k,n), Ipz(i,j,k,n),
1408 q, wmac, bc, dlo.z, dhi.z, limiter, limiter_type);
1409#endif
1410 });
1411}
1412} // namespace
1413
1414#endif
1415/** @} */
#define AMREX_FORCE_INLINE
#define AMREX_GPU_DEVICE
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_TERM(a, b, c)
#define AMREX_D_DECL(a, b, c)
__host__ __device__ const int * hi() const &noexcept
__host__ __device__ const int * lo() const &noexcept
const Real * CellSize() const noexcept
GpuArray< Real, 3 > CellSizeArray() const noexcept
const Box & Domain() const noexcept
constexpr amrex::Real eps
Definition hydro_bds_edge_state_2D.cpp:17
static constexpr amrex::Real small_vel
Definition hydro_constants.H:37
amrex_real Real
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
ArrayND< T, 4, true > Array4
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_minmod_bc_lo(const int n, const amrex::Real sm1, const amrex::Real s0, const amrex::Real vel_edge, amrex::Real &dsm, const int bclo, const int domlo)
Definition hydro_godunov_ppm.H:45
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void minmod_fn(const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, amrex::Real &dsm, amrex::Real &dsp)
Definition hydro_godunov_ppm.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Godunov_minmod_ghost_hi(const int n, const amrex::Real s0, const amrex::Real sp1, const amrex::Real vel_edge, const int bchi, const int domhi)
Definition hydro_godunov_ppm.H:108
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Godunov_minmod_bc_hi(const int n, const amrex::Real s0, const amrex::Real sp1, const amrex::Real vel_edge, amrex::Real &dsp, const int bchi, const int domhi)
Definition hydro_godunov_ppm.H:65
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Godunov_minmod_ghost_lo(const int n, const amrex::Real sm1, const amrex::Real s0, const amrex::Real vel_edge, const int bclo, const int domlo)
Definition hydro_godunov_ppm.H:89
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::BCRec getBC(const int i, const int j, const int k, const int n, const amrex::Box &m_domain, const amrex::BCRec *bcr, amrex::Array4< int const > const &bca)
Definition hydro_bcs_K.H:34
Definition hydro_godunov_ppm.H:125
void PredictVelOnFaces(amrex::Box const &bx, AMREX_D_DECL(amrex::Array4< amrex::Real > const &Imx, amrex::Array4< amrex::Real > const &Imy, amrex::Array4< amrex::Real > const &Imz), AMREX_D_DECL(amrex::Array4< amrex::Real > const &Ipx, amrex::Array4< amrex::Real > const &Ipy, amrex::Array4< amrex::Real > const &Ipz), amrex::Array4< amrex::Real const > const &q, amrex::Array4< amrex::Real const > const &vel, amrex::Geometry geom, amrex::Real dt, amrex::BCRec const *pbc, const Limiter &limiter, amrex::Array4< int const > const &bc_arr={})
Definition hydro_godunov_ppm.H:1318
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetXBCs(const int i, const int j, const int k, const int n, amrex::Real &sm, amrex::Real &sp, amrex::Real &sedge1, amrex::Real &sedge2, const amrex::Array4< const amrex::Real > &s, const amrex::Real vel_dlo, const amrex::Real vel_dhi, const int bclo, const int bchi, const int domlo, const int domhi)
Definition hydro_godunov_ppm.H:461
AMREX_GPU_HOST_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::Array4< const amrex::Real > &vel_edge, const amrex::BCRec bc, const int domlo, const int domhi, const Limiter &, int)
Definition hydro_godunov_ppm.H:920
static constexpr int default_limiter
Definition hydro_godunov_ppm.H:129
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictVelOnYFace(const int i, const int j, const int k, const int n, const amrex::Real dtdy, const amrex::Real v_ad, const amrex::Real vel_dlo, const amrex::Real vel_dhi, const amrex::Array4< const amrex::Real > &S, const amrex::Array4< amrex::Real > &Im, const amrex::Array4< amrex::Real > &Ip, const amrex::BCRec bc, const int domlo, const int domhi, const Limiter &)
Definition hydro_godunov_ppm.H:816
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictStateOnXFace< PPM::minmod >(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::Array4< const amrex::Real > &vel_edge, const amrex::BCRec bc, const int domlo, const int domhi, const PPM::minmod &, int)
Definition hydro_godunov_ppm.H:1013
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictStateOnXFace< PPM::upwind >(const int i, const int j, const int k, const int n, const amrex::Real, const amrex::Real, amrex::Real &Im, amrex::Real &Ip, const amrex::Array4< const amrex::Real > &S, const amrex::Array4< const amrex::Real > &, const amrex::BCRec, const int, const int, const PPM::upwind &, int)
Definition hydro_godunov_ppm.H:996
void PredictStateOnFaces(amrex::Box const &bx, AMREX_D_DECL(amrex::Array4< amrex::Real > const &Imx, amrex::Array4< amrex::Real > const &Imy, amrex::Array4< amrex::Real > const &Imz), AMREX_D_DECL(amrex::Array4< amrex::Real > const &Ipx, amrex::Array4< amrex::Real > const &Ipy, amrex::Array4< amrex::Real > const &Ipz), AMREX_D_DECL(amrex::Array4< amrex::Real const > const &umac, amrex::Array4< amrex::Real const > const &vmac, amrex::Array4< amrex::Real const > const &wmac), amrex::Array4< amrex::Real const > const &q, amrex::Geometry geom, amrex::Real l_dt, amrex::BCRec const *pbc, const int ncomp, const Limiter &limiter, int limiter_type, amrex::Array4< int const > const &bc_arr={})
Definition hydro_godunov_ppm.H:1369
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetYBCs(const int i, const int j, const int k, const int n, amrex::Real &sm, amrex::Real &sp, amrex::Real &sedge1, amrex::Real &sedge2, const amrex::Array4< const amrex::Real > &s, const amrex::Real vel_dlo, const amrex::Real vel_dhi, const int bclo, const int bchi, const int domlo, const int domhi)
Definition hydro_godunov_ppm.H:561
AMREX_GPU_HOST_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 dx, amrex::Real &Im, amrex::Real &Ip, const amrex::Array4< const amrex::Real > &S, const amrex::Array4< const amrex::Real > &vel_edge, const amrex::BCRec bc, const int domlo, const int domhi, const Limiter &, int)
Definition hydro_godunov_ppm.H:1060
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictStateOnYFace< PPM::minmod >(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::Array4< const amrex::Real > &vel_edge, const amrex::BCRec bc, const int domlo, const int domhi, const PPM::minmod &, int)
Definition hydro_godunov_ppm.H:1143
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictStateOnYFace< PPM::upwind >(const int i, const int j, const int k, const int n, const amrex::Real, const amrex::Real, amrex::Real &Im, amrex::Real &Ip, const amrex::Array4< const amrex::Real > &S, const amrex::Array4< const amrex::Real > &, const amrex::BCRec, const int, const int, const PPM::upwind &, int)
Definition hydro_godunov_ppm.H:1126
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void PredictVelOnXFace(const int i, const int j, const int k, const int n, const amrex::Real dtdx, const amrex::Real v_ad, const amrex::Real vel_dlo, const amrex::Real vel_dhi, const amrex::Array4< const amrex::Real > &S, const amrex::Array4< amrex::Real > &Im, const amrex::Array4< amrex::Real > &Ip, const amrex::BCRec bc, const int domlo, const int domhi, const Limiter &)
Definition hydro_godunov_ppm.H:767
limiters
Definition hydro_godunov_ppm.H:127
@ MINMOD
Definition hydro_godunov_ppm.H:127
@ VanLeer
Definition hydro_godunov_ppm.H:127
@ WENOZ
Definition hydro_godunov_ppm.H:127
@ WENO_JS
Definition hydro_godunov_ppm.H:127
@ NoLimiter
Definition hydro_godunov_ppm.H:127
@ UPWIND
Definition hydro_godunov_ppm.H:127
__host__ __device__ constexpr GpuTuple< detail::tuple_decay_t< Ts >... > makeTuple(Ts &&... args)
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
BoxND< 3 > Box
Definition hydro_godunov_ppm.H:423
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:451
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)
Definition hydro_godunov_ppm.H:429
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)
Definition hydro_godunov_ppm.H:440
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:425
Definition hydro_godunov_ppm.H:131
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:168
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:153
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real)
Definition hydro_godunov_ppm.H:137
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:133
Definition hydro_godunov_ppm.H:387
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)
Definition hydro_godunov_ppm.H:393
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:389
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:415
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)
Definition hydro_godunov_ppm.H:404
Definition hydro_godunov_ppm.H:176
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real s0, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:230
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:178
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:212
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real vanLeer(const amrex::Real a, const amrex::Real b, const amrex::Real c)
Definition hydro_godunov_ppm.H:181
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real)
Definition hydro_godunov_ppm.H:195
Definition hydro_godunov_ppm.H:324
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:326
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:368
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:379
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:330
Definition hydro_godunov_ppm.H:265
static constexpr bool do_limiting
Definition hydro_godunov_ppm.H:267
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge2(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:271
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::GpuTuple< amrex::Real, amrex::Real > sm_sp(const amrex::Real, const amrex::Real sedge1, const amrex::Real sedge2)
Definition hydro_godunov_ppm.H:316
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real sedge1(const amrex::Real sm2, const amrex::Real sm1, const amrex::Real s0, const amrex::Real sp1, const amrex::Real sp2)
Definition hydro_godunov_ppm.H:305