Block-Structured AMR Software Framework
AMReX_InterpBndryData_3D_K.H
Go to the documentation of this file.
1 #ifndef AMREX_INTERP_BNDRYDATA_3D_K_H_
2 #define AMREX_INTERP_BNDRYDATA_3D_K_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array4.H>
6 
7 namespace amrex {
8 
9 template<typename T>
11 void interpbndrydata_o1 (int i, int j, int k, int n,
12  Array4<T> const& bdry, int nb,
13  Array4<T const> const& crse, int nc, Dim3 const& r) noexcept
14 {
15  int ic = amrex::coarsen(i,r.x);
16  int jc = amrex::coarsen(j,r.y);
17  int kc = amrex::coarsen(k,r.z);
18  bdry(i,j,k,n+nb) = crse(ic,jc,kc,n+nc);
19 }
20 
21 template<typename T>
23 void interpbndrydata_x_o3 (int i, int j, int k, int n,
24  Array4<T> const& bdry, int nb,
25  Array4<T const> const& crse, int nc, Dim3 const& r,
26  Array4<int const> const& mask, int not_covered, int /*max_width*/) noexcept
27 {
28  int ic = amrex::coarsen(i,r.x);
29  int jc = amrex::coarsen(j,r.y);
30  int kc = amrex::coarsen(k,r.z);
31 
32  int lo = (mask(i,j-r.y,k) == not_covered) ? jc-1 : jc;
33  int hi = (mask(i,j+r.y,k) == not_covered) ? jc+1 : jc;
34  T fac = (hi == lo+1) ? T(1.0) : T(0.5);
35  T dy = fac*(crse(ic,hi,kc,n+nc)-crse(ic,lo,kc,n+nc));
36  T dy2 = (hi==lo+2) ? T(0.5)*(crse(ic,jc+1,kc,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic,jc-1,kc,n+nc)) : T(0.);
37 
38  lo = (mask(i,j,k-r.z) == not_covered) ? kc-1 : kc;
39  hi = (mask(i,j,k+r.z) == not_covered) ? kc+1 : kc;
40  fac = (hi == lo+1) ? T(1.0) : T(0.5);
41  T dz = fac*(crse(ic,jc,hi,n+nc)-crse(ic,jc,lo,n+nc));
42  T dz2 = (hi==lo+2) ? T(0.5)*(crse(ic,jc,kc+1,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic,jc,kc-1,n+nc)) : T(0.);
43 
44  T dyz = (mask(i,j-r.y,k-r.z) == not_covered && mask(i,j+r.y,k-r.z) == not_covered &&
45  mask(i,j-r.y,k+r.z) == not_covered && mask(i,j+r.y,k+r.z) == not_covered)
46  ? T(0.25)*(crse(ic,jc+1,kc+1,n+nc)-crse(ic,jc-1,kc+1,n+nc)+crse(ic,jc-1,kc-1,n+nc)-crse(ic,jc+1,kc-1,n+nc))
47  : T(0.0);
48 
49  T y = -T(0.5) + (j-jc*r.y+T(0.5))/r.y;
50  T z = -T(0.5) + (k-kc*r.z+T(0.5))/r.z;
51  bdry(i,j,k,n+nb) = crse(ic,jc,kc,n+nc) + y*dy + (y*y)*dy2 + z*dz + (z*z)*dz2 + y*z*dyz;
52 }
53 
54 template<typename T>
56 void interpbndrydata_y_o3 (int i, int j, int k, int n,
57  Array4<T> const& bdry, int nb,
58  Array4<T const> const& crse, int nc, Dim3 const& r,
59  Array4<int const> const& mask, int not_covered, int /*max_width*/) noexcept
60 {
61  int ic = amrex::coarsen(i,r.x);
62  int jc = amrex::coarsen(j,r.y);
63  int kc = amrex::coarsen(k,r.z);
64 
65  int lo = (mask(i-r.x,j,k) == not_covered) ? ic-1 : ic;
66  int hi = (mask(i+r.x,j,k) == not_covered) ? ic+1 : ic;
67  T fac = (hi == lo+1) ? T(1.0) : T(0.5);
68  T dx = fac*(crse(hi,jc,kc,n+nc)-crse(lo,jc,kc,n+nc));
69  T dx2 = (hi==lo+2) ? T(0.5)*(crse(ic+1,jc,kc,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic-1,jc,kc,n+nc)) : T(0.);
70 
71  lo = (mask(i,j,k-r.z) == not_covered) ? kc-1 : kc;
72  hi = (mask(i,j,k+r.z) == not_covered) ? kc+1 : kc;
73  fac = (hi == lo+1) ? T(1.0) : T(0.5);
74  T dz = fac*(crse(ic,jc,hi,n+nc)-crse(ic,jc,lo,n+nc));
75  T dz2 = (hi==lo+2) ? T(0.5)*(crse(ic,jc,kc+1,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic,jc,kc-1,n+nc)) : T(0.);
76 
77  T dxz = (mask(i-r.x,j,k-r.z) == not_covered && mask(i+r.x,j,k-r.z) == not_covered &&
78  mask(i-r.x,j,k+r.z) == not_covered && mask(i+r.x,j,k+r.z) == not_covered)
79  ? T(0.25)*(crse(ic+1,jc,kc+1,n+nc)-crse(ic-1,jc,kc+1,n+nc)+crse(ic-1,jc,kc-1,n+nc)-crse(ic+1,jc,kc-1,n+nc))
80  : T(0.0);
81 
82 
83  T x = -T(0.5) + (i-ic*r.x+T(0.5))/r.x;
84  T z = -T(0.5) + (k-kc*r.z+T(0.5))/r.z;
85  bdry(i,j,k,n+nb) = crse(ic,jc,kc,n+nc) + x*dx + (x*x)*dx2 + z*dz + (z*z)*dz2 + x*z*dxz;
86 }
87 
88 template<typename T>
90 void interpbndrydata_z_o3 (int i, int j, int k, int n,
91  Array4<T> const& bdry, int nb,
92  Array4<T const> const& crse, int nc, Dim3 const& r,
93  Array4<int const> const& mask, int not_covered, int /*max_width*/) noexcept
94 {
95  int ic = amrex::coarsen(i,r.x);
96  int jc = amrex::coarsen(j,r.y);
97  int kc = amrex::coarsen(k,r.z);
98 
99  int lo = (mask(i-r.x,j,k) == not_covered) ? ic-1 : ic;
100  int hi = (mask(i+r.x,j,k) == not_covered) ? ic+1 : ic;
101  T fac = (hi == lo+1) ? T(1.0) : T(0.5);
102  T dx = fac*(crse(hi,jc,kc,n+nc)-crse(lo,jc,kc,n+nc));
103  T dx2 = (hi==lo+2) ? T(0.5)*(crse(ic+1,jc,kc,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic-1,jc,kc,n+nc)) : T(0.);
104 
105  lo = (mask(i,j-r.y,k) == not_covered) ? jc-1 : jc;
106  hi = (mask(i,j+r.y,k) == not_covered) ? jc+1 : jc;
107  fac = (hi == lo+1) ? T(1.0) : T(0.5);
108  T dy = fac*(crse(ic,hi,kc,n+nc)-crse(ic,lo,kc,n+nc));
109  T dy2 = (hi==lo+2) ? T(0.5)*(crse(ic,jc+1,kc,n+nc) - T(2.)*crse(ic,jc,kc,n+nc) + crse(ic,jc-1,kc,n+nc)) : T(0.);
110 
111  T dxy = (mask(i-r.x,j-r.y,k) == not_covered && mask(i+r.x,j-r.y,k) == not_covered &&
112  mask(i-r.x,j+r.y,k) == not_covered && mask(i+r.x,j+r.y,k) == not_covered)
113  ? T(0.25)*(crse(ic+1,jc+1,kc,n+nc)-crse(ic-1,jc+1,kc,n+nc)+crse(ic-1,jc-1,kc,n+nc)-crse(ic+1,jc-1,kc,n+nc))
114  : T(0.0);
115 
116  T x = -T(0.5) + (i-ic*r.x+T(0.5))/r.x;
117  T y = -T(0.5) + (j-jc*r.y+T(0.5))/r.y;
118  bdry(i,j,k,n+nb) = crse(ic,jc,kc,n+nc) + x*dx + (x*x)*dx2 + y*dy + (y*y)*dy2 + x*y*dxy;
119 }
120 
121 }
122 #endif
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Array4< int const > mask
Definition: AMReX_InterpFaceRegister.cpp:93
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void interpbndrydata_y_o3(int i, int j, int, int n, Array4< T > const &bdry, int nb, Array4< T const > const &crse, int nc, Dim3 const &r, Array4< int const > const &mask, int not_covered, int max_width) noexcept
Definition: AMReX_InterpBndryData_2D_K.H:75
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void interpbndrydata_x_o3(int i, int, int, int n, Array4< T > const &bdry, int nb, Array4< T const > const &crse, int nc, Dim3 const &r, Array4< int const > const &, int, int) noexcept
Definition: AMReX_InterpBndryData_1D_K.H:22
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void interpbndrydata_z_o3(int i, int j, int k, int n, Array4< T > const &bdry, int nb, Array4< T const > const &crse, int nc, Dim3 const &r, Array4< int const > const &mask, int not_covered, int) noexcept
Definition: AMReX_InterpBndryData_3D_K.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void interpbndrydata_o1(int i, int, int, int n, Array4< T > const &bdry, int nb, Array4< T const > const &crse, int nc, Dim3 const &r) noexcept
Definition: AMReX_InterpBndryData_1D_K.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
Definition: AMReX_Array4.H:61
Definition: AMReX_Dim3.H:12