WarpX
Interpolate_K.H
Go to the documentation of this file.
1 #ifndef WARPX_INTERP_K_H_
2 #define WARPX_INTERP_K_H_
3 
4 #include <AMReX_FArrayBox.H>
5 
6 namespace Interpolate {
7 
8 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
9 void interp (int j, int k, int l,
10  amrex::Array4<amrex::Real > const& fine,
11  amrex::Array4<amrex::Real const> const& crse,
12  int r_ratio, IntVect const& type) noexcept
13 {
14  using amrex::Real;
15  Real const rr = 1.0_rt/static_cast<Real>(r_ratio);
16 
17  int const jg = amrex::coarsen(j,r_ratio);
18  Real const wx = static_cast<Real>(type[0]) * static_cast<amrex::Real>(j-jg*r_ratio) * rr;
19  Real const owx = 1.0_rt-wx;
20 
21  int const kg = amrex::coarsen(k,r_ratio);
22  Real const wy = static_cast<Real>(type[1]) * static_cast<amrex::Real>(k-kg*r_ratio) * rr;
23  Real const owy = 1.0_rt-wy;
24 
25 #if (AMREX_SPACEDIM == 2)
26  fine(j,k,l) = owx * owy * crse(jg ,kg ,0)
27  + owx * wy * crse(jg ,kg+1,0)
28  + wx * owy * crse(jg+1,kg ,0)
29  + wx * wy * crse(jg+1,kg+1,0);
30 #else
31  int const lg = amrex::coarsen(l,r_ratio);
32  Real const wz = static_cast<Real>(type[2]) * static_cast<amrex::Real>(l-lg*r_ratio) * rr;
33  Real const owz = 1.0_rt-wz;
34  fine(j,k,l) = owx * owy * owz * crse(jg ,kg ,lg )
35  + wx * owy * owz * crse(jg+1,kg ,lg )
36  + owx * wy * owz * crse(jg ,kg+1,lg )
37  + wx * wy * owz * crse(jg+1,kg+1,lg )
38  + owx * owy * wz * crse(jg ,kg ,lg+1)
39  + wx * owy * wz * crse(jg+1,kg ,lg+1)
40  + owx * wy * wz * crse(jg ,kg+1,lg+1)
41  + wx * wy * wz * crse(jg+1,kg+1,lg+1);
42 #endif
43 }
44 
45 }
46 
47 #endif
Definition: Interpolate.cpp:4
type
Definition: run_alltests_1node.py:67
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void interp(int j, int k, int l, amrex::Array4< amrex::Real > const &fine, amrex::Array4< amrex::Real const > const &crse, int r_ratio, IntVect const &type) noexcept
Definition: Interpolate_K.H:9