1 #ifndef ERF_INTERPOLATE_WENO_H_
2 #define ERF_INTERPOLATE_WENO_H_
11 WENO3 (
const amrex::Array4<const amrex::Real>& phi,
23 amrex::Real upw_lo)
const
26 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
29 amrex::Real sp1 =
m_phi(i+1, j , k , qty_index);
30 amrex::Real s =
m_phi(i , j , k , qty_index);
31 amrex::Real sm1 =
m_phi(i-1, j , k , qty_index);
32 amrex::Real sm2 =
m_phi(i-2, j , k , qty_index);
35 amrex::Real Fhi =
Evaluate(sm2,sm1,s );
36 amrex::Real Flo =
Evaluate(sp1,s ,sm1);
39 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
50 amrex::Real upw_lo)
const
53 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
56 amrex::Real sp1 =
m_phi(i , j+1, k , qty_index);
57 amrex::Real s =
m_phi(i , j , k , qty_index);
58 amrex::Real sm1 =
m_phi(i , j-1, k , qty_index);
59 amrex::Real sm2 =
m_phi(i , j-2, k , qty_index);
62 amrex::Real Fhi =
Evaluate(sm2,sm1,s );
63 amrex::Real Flo =
Evaluate(sp1,s ,sm1);
66 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
77 amrex::Real upw_lo)
const
80 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
83 amrex::Real sp1 =
m_phi(i , j , k+1, qty_index);
84 amrex::Real s =
m_phi(i , j , k , qty_index);
85 amrex::Real sm1 =
m_phi(i , j , k-1, qty_index);
86 amrex::Real sm2 =
m_phi(i , j , k-2, qty_index);
89 amrex::Real Fhi =
Evaluate(sm2,sm1,s );
90 amrex::Real Flo =
Evaluate(sp1,s ,sm1);
93 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
100 const amrex::Real& s ,
101 const amrex::Real& sp1)
const
104 amrex::Real b1 = (s - sm1) * (s - sm1);
105 amrex::Real b2 = (sp1 - s) * (sp1 - s);
108 amrex::Real w1 =
g1 / ( (
eps + b1) * (
eps + b1) );
109 amrex::Real w2 =
g2 / ( (
eps + b2) * (
eps + b2) );
112 amrex::Real wsum = w1 + w2;
115 amrex::Real v1 = -sm1 + 3.0 * s;
116 amrex::Real v2 = s + sp1;
119 return ( (w1 * v1 + w2 * v2) / (2.0 * wsum) );
123 amrex::Array4<const amrex::Real>
m_phi;
124 const amrex::Real
eps=1.0e-40;
125 static constexpr amrex::Real
g1=(1.0/3.0);
126 static constexpr amrex::Real
g2=(2.0/3.0);
134 WENO5 (
const amrex::Array4<const amrex::Real>& phi,
144 const int& qty_index,
146 amrex::Real upw_lo)
const
149 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
152 amrex::Real sp2 =
m_phi(i+2, j , k , qty_index);
153 amrex::Real sp1 =
m_phi(i+1, j , k , qty_index);
154 amrex::Real s =
m_phi(i , j , k , qty_index);
155 amrex::Real sm1 =
m_phi(i-1, j , k , qty_index);
156 amrex::Real sm2 =
m_phi(i-2, j , k , qty_index);
157 amrex::Real sm3 =
m_phi(i-3, j , k , qty_index);
160 amrex::Real Fhi =
Evaluate(sm3,sm2,sm1,s ,sp1);
161 amrex::Real Flo =
Evaluate(sp2,sp1,s ,sm1,sm2);
164 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
173 const int& qty_index,
175 amrex::Real upw_lo)
const
178 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
181 amrex::Real sp2 =
m_phi(i , j+2, k , qty_index);
182 amrex::Real sp1 =
m_phi(i , j+1, k , qty_index);
183 amrex::Real s =
m_phi(i , j , k , qty_index);
184 amrex::Real sm1 =
m_phi(i , j-1, k , qty_index);
185 amrex::Real sm2 =
m_phi(i , j-2, k , qty_index);
186 amrex::Real sm3 =
m_phi(i , j-3, k , qty_index);
189 amrex::Real Fhi =
Evaluate(sm3,sm2,sm1,s ,sp1);
190 amrex::Real Flo =
Evaluate(sp2,sp1,s ,sm1,sm2);
193 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
202 const int& qty_index,
204 amrex::Real upw_lo)
const
207 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
210 amrex::Real sp2 =
m_phi(i , j , k+2, qty_index);
211 amrex::Real sp1 =
m_phi(i , j , k+1, qty_index);
212 amrex::Real s =
m_phi(i , j , k , qty_index);
213 amrex::Real sm1 =
m_phi(i , j , k-1, qty_index);
214 amrex::Real sm2 =
m_phi(i , j , k-2, qty_index);
215 amrex::Real sm3 =
m_phi(i , j , k-3, qty_index);
218 amrex::Real Fhi =
Evaluate(sm3,sm2,sm1,s ,sp1);
219 amrex::Real Flo =
Evaluate(sp2,sp1,s ,sm1,sm2);
222 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
229 const amrex::Real& sm1,
230 const amrex::Real& s ,
231 const amrex::Real& sp1,
232 const amrex::Real& sp2)
const
235 amrex::Real b1 =
c1 * (sm2 - 2.0 * sm1 + s) * (sm2 - 2.0 * sm1 + s) +
236 0.25 * (sm2 - 4.0 * sm1 + 3.0 * s) * (sm2 - 4.0 * sm1 + 3.0 * s);
237 amrex::Real b2 =
c1 * (sm1 - 2.0 * s + sp1) * (sm1 - 2.0 * s + sp1) +
238 0.25 * (sm1 - sp1) * (sm1 - sp1);
239 amrex::Real b3 =
c1 * (s - 2.0 * sp1 + sp2) * (s - 2.0 * sp1 + sp2) +
240 0.25 * (3.0 * s - 4.0 * sp1 + sp2) * (3.0 * s - 4.0 * sp1 + sp2);
243 amrex::Real w1 =
g1 / ( (
eps + b1) * (
eps + b1) );
244 amrex::Real w2 =
g2 / ( (
eps + b2) * (
eps + b2) );
245 amrex::Real w3 =
g3 / ( (
eps + b3) * (
eps + b3) );
248 amrex::Real wsum = w1 + w2 + w3;
251 amrex::Real v1 = 2.0 * sm2 - 7.0 * sm1 + 11.0 * s;
252 amrex::Real v2 = -sm1 + 5.0 * s + 2.0 * sp1;
253 amrex::Real v3 = 2.0 * s + 5.0 * sp1 - sp2;
256 return ( (w1 * v1 + w2 * v2 + w3 * v3) / (6.0 * wsum) );
260 amrex::Array4<const amrex::Real>
m_phi;
261 const amrex::Real
eps=1.0e-40;
262 static constexpr amrex::Real
c1=(13.0/12.0);
263 static constexpr amrex::Real
g1=(1.0/10.0);
264 static constexpr amrex::Real
g2=(3.0/5.0);
265 static constexpr amrex::Real
g3=(3.0/10.0);
273 WENO7 (
const amrex::Array4<const amrex::Real>& phi,
283 const int& qty_index,
285 amrex::Real upw_lo)
const
288 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
291 amrex::Real sp3 =
m_phi(i+3, j , k , qty_index);
292 amrex::Real sp2 =
m_phi(i+2, j , k , qty_index);
293 amrex::Real sp1 =
m_phi(i+1, j , k , qty_index);
294 amrex::Real s =
m_phi(i , j , k , qty_index);
295 amrex::Real sm1 =
m_phi(i-1, j , k , qty_index);
296 amrex::Real sm2 =
m_phi(i-2, j , k , qty_index);
297 amrex::Real sm3 =
m_phi(i-3, j , k , qty_index);
298 amrex::Real sm4 =
m_phi(i-4, j , k , qty_index);
301 amrex::Real Fhi =
Evaluate(sm4,sm3,sm2,sm1,s ,sp1,sp2);
302 amrex::Real Flo =
Evaluate(sp3,sp2,sp1,s ,sm1,sm2,sm3);
305 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
314 const int& qty_index,
316 amrex::Real upw_lo)
const
319 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
322 amrex::Real sp3 =
m_phi(i , j+3, k , qty_index);
323 amrex::Real sp2 =
m_phi(i , j+2, k , qty_index);
324 amrex::Real sp1 =
m_phi(i , j+1, k , qty_index);
325 amrex::Real s =
m_phi(i , j , k , qty_index);
326 amrex::Real sm1 =
m_phi(i , j-1, k , qty_index);
327 amrex::Real sm2 =
m_phi(i , j-2, k , qty_index);
328 amrex::Real sm3 =
m_phi(i , j-3, k , qty_index);
329 amrex::Real sm4 =
m_phi(i , j-4, k , qty_index);
332 amrex::Real Fhi =
Evaluate(sm4,sm3,sm2,sm1,s ,sp1,sp2);
333 amrex::Real Flo =
Evaluate(sp3,sp2,sp1,s ,sm1,sm2,sm3);
336 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
345 const int& qty_index,
347 amrex::Real upw_lo)
const
350 if (upw_lo != 0.) upw_lo = (upw_lo > 0) ? 1. : -1.;
353 amrex::Real sp3 =
m_phi(i , j , k+2, qty_index);
354 amrex::Real sp2 =
m_phi(i , j , k+2, qty_index);
355 amrex::Real sp1 =
m_phi(i , j , k+1, qty_index);
356 amrex::Real s =
m_phi(i , j , k , qty_index);
357 amrex::Real sm1 =
m_phi(i , j , k-1, qty_index);
358 amrex::Real sm2 =
m_phi(i , j , k-2, qty_index);
359 amrex::Real sm3 =
m_phi(i , j , k-3, qty_index);
360 amrex::Real sm4 =
m_phi(i , j , k-3, qty_index);
363 amrex::Real Fhi =
Evaluate(sm4,sm3,sm2,sm1,s ,sp1,sp2);
364 amrex::Real Flo =
Evaluate(sp3,sp2,sp1,s ,sm1,sm2,sm3);
367 val_lo = (1.0 + upw_lo)/2.0 * Fhi + (1.0 - upw_lo)/2.0 * Flo;
374 const amrex::Real& sm2,
375 const amrex::Real& sm1,
376 const amrex::Real& s ,
377 const amrex::Real& sp1,
378 const amrex::Real& sp2,
379 const amrex::Real& sp3)
const
382 amrex::Real b1 = ( sm3 * sm3 * 6649./2880.0
383 - sm3 * sm2 * 2623./160.0
384 + sm3 * sm1 * 9449./480.0
385 - sm3 * s * 11389./1440.0
386 + sm2 * sm2 * 28547./960.0
387 - sm2 * sm1 * 35047./480.0
388 + sm2 * s * 14369./480.0
389 + sm1 * sm1 * 44747./960.0
390 - sm1 * s * 6383./160.0
391 + s * s * 25729./2880.0 );
392 amrex::Real b2 = ( sm2 * sm2 * 3169/2880.0
393 - sm2 * sm1 * 3229/480.0
394 + sm2 * s * 3169/480.0
395 - sm2 * sp1 * 2989/1440.0
396 + sm1 * sm1 * 11147/960.0
397 - sm1 * s * 11767/480.0
398 + sm1 * sp1 * 1283/160.0
399 + s * s * 13667/960.0
400 - s * sp1 * 5069/480.0
401 + sp1 * sp1 * 6649/2880.0 );
402 amrex::Real b3 = ( sm1 * sm1 * 6649./2880.0
403 - sm1 * s * 5069./480.0
404 + sm1 * sp1 * 1283./160.0
405 - sm1 * sp2 * 2989./1440.0
406 + s * s * 13667./960.0
407 - s * sp1 * 11767./480.0
408 + s * sp2 * 3169./480.0
409 + sp1 * sp1 * 11147./960.0
410 - sp1 * sp2 * 3229./480.0
411 + sp2 * sp2 * 3169./2880.0 );
412 amrex::Real b4 = ( s * s * 25729./2880.
413 - s * sp1 * 6383./160.
414 + s * sp2 * 14369./480.
415 - s * sp3 * 11389./1440.
416 + sp1 * sp1 * 44747./960.
417 - sp1 * sp2 * 35047./480.
418 + sp1 * sp3 * 9449./480.
419 + sp2 * sp2 * 28547./960.
420 - sp2 * sp3 * 2623./160.
421 + sp3 * sp3 * 6649./2880. );
424 amrex::Real w1 =
g1 / ( (
eps + b1) * (
eps + b1) );
425 amrex::Real w2 =
g2 / ( (
eps + b2) * (
eps + b2) );
426 amrex::Real w3 =
g3 / ( (
eps + b3) * (
eps + b3) );
427 amrex::Real w4 =
g4 / ( (
eps + b4) * (
eps + b4) );
430 amrex::Real wsum = w1 + w2 + w3 + w4;
433 amrex::Real v1 = (-0.3125)*sm3 + ( 1.3125)*sm2 + (-2.1875)*sm1 + ( 2.1875)*s;
434 amrex::Real v2 = ( 0.0625)*sm2 + (-0.3125)*sm1 + ( 0.9375)*s + ( 0.3125)*sp1;
435 amrex::Real v3 = (-0.0625)*sm1 + ( 0.5625)*s + ( 0.5625)*sp1 + (-0.0625)*sp2;
436 amrex::Real v4 = ( 0.3125)*s + ( 0.9375)*sp1 + (-0.3125)*sp2 + ( 0.0625)*sp3;
439 return ( (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4) / (wsum) );
443 amrex::Array4<const amrex::Real>
m_phi;
444 const amrex::Real
eps=1.0e-40;
445 static constexpr amrex::Real
g1=( 1.0/64.0);
446 static constexpr amrex::Real
g2=(21.0/64.0);
447 static constexpr amrex::Real
g3=(35.0/64.0);
448 static constexpr amrex::Real
g4=( 7.0/64.0);
Definition: ERF_Interpolation_WENO.H:10
static constexpr amrex::Real g1
Definition: ERF_Interpolation_WENO.H:125
amrex::Array4< const amrex::Real > m_phi
Definition: ERF_Interpolation_WENO.H:123
const amrex::Real eps
Definition: ERF_Interpolation_WENO.H:124
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInZ(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:72
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Evaluate(const amrex::Real &sm1, const amrex::Real &s, const amrex::Real &sp1) const
Definition: ERF_Interpolation_WENO.H:99
static constexpr amrex::Real g2
Definition: ERF_Interpolation_WENO.H:126
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInX(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:18
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInY(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:45
WENO3(const amrex::Array4< const amrex::Real > &phi, const amrex::Real)
Definition: ERF_Interpolation_WENO.H:11
Definition: ERF_Interpolation_WENO.H:133
const amrex::Real eps
Definition: ERF_Interpolation_WENO.H:261
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInX(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:141
amrex::Array4< const amrex::Real > m_phi
Definition: ERF_Interpolation_WENO.H:260
static constexpr amrex::Real c1
Definition: ERF_Interpolation_WENO.H:262
static constexpr amrex::Real g2
Definition: ERF_Interpolation_WENO.H:264
WENO5(const amrex::Array4< const amrex::Real > &phi, const amrex::Real)
Definition: ERF_Interpolation_WENO.H:134
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInY(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:170
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInZ(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:199
static constexpr amrex::Real g3
Definition: ERF_Interpolation_WENO.H:265
static constexpr amrex::Real g1
Definition: ERF_Interpolation_WENO.H:263
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Evaluate(const amrex::Real &sm2, const amrex::Real &sm1, const amrex::Real &s, const amrex::Real &sp1, const amrex::Real &sp2) const
Definition: ERF_Interpolation_WENO.H:228
Definition: ERF_Interpolation_WENO.H:272
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Evaluate(const amrex::Real &sm3, const amrex::Real &sm2, const amrex::Real &sm1, const amrex::Real &s, const amrex::Real &sp1, const amrex::Real &sp2, const amrex::Real &sp3) const
Definition: ERF_Interpolation_WENO.H:373
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInZ(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:342
const amrex::Real eps
Definition: ERF_Interpolation_WENO.H:444
static constexpr amrex::Real g4
Definition: ERF_Interpolation_WENO.H:448
static constexpr amrex::Real g3
Definition: ERF_Interpolation_WENO.H:447
static constexpr amrex::Real g2
Definition: ERF_Interpolation_WENO.H:446
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInX(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:280
static constexpr amrex::Real g1
Definition: ERF_Interpolation_WENO.H:445
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInY(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo) const
Definition: ERF_Interpolation_WENO.H:311
amrex::Array4< const amrex::Real > m_phi
Definition: ERF_Interpolation_WENO.H:443
WENO7(const amrex::Array4< const amrex::Real > &phi, const amrex::Real)
Definition: ERF_Interpolation_WENO.H:273