Block-Structured AMR Software Framework
AMReX_InterpBndryData_2D_K.H
Go to the documentation of this file.
1 #ifndef AMREX_INTERP_BNDRYDATA_2D_K_H_
2 #define AMREX_INTERP_BNDRYDATA_2D_K_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array4.H>
6 #include <AMReX_LOUtil_K.H>
7 
8 namespace amrex {
9 
10 template<typename T>
12 void interpbndrydata_o1 (int i, int j, int /*k*/, int n,
13  Array4<T> const& bdry, int nb,
14  Array4<T const> const& crse, int nc, Dim3 const& r) noexcept
15 {
16  int ic = amrex::coarsen(i,r.x);
17  int jc = amrex::coarsen(j,r.y);
18  bdry(i,j,0,n+nb) = crse(ic,jc,0,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 
31  T x[3], y[3], c[3];
32  x[0] = T(0.0);
33  y[0] = crse(ic,jc,0,n+nc);
34  int NN = 1;
35 
36  if (mask(i,j-r.y,0) == not_covered) {
37  x[NN] = T(-1.0);
38  y[NN] = crse(ic,jc-1,0,n+nc);
39  ++NN;
40  } else if (max_width >= 2 &&
41  mask.contains(i,(jc+2)*r.y,0) &&
42  mask (i,(jc+2)*r.y,0) == not_covered && crse.contains(ic,jc+2,0)) {
43  x[NN] = T(2.0);
44  y[NN] = crse(ic,jc+2,0,n+nc);
45  ++NN;
46  }
47 
48  if (mask(i,j+r.y,0) == not_covered) {
49  x[NN] = T(1.0);
50  y[NN] = crse(ic,jc+1,0,n+nc);
51  ++NN;
52  } else if (max_width >= 2 &&
53  mask.contains(i,jc*r.y-r.y-1,0) &&
54  mask (i,jc*r.y-r.y-1,0) == not_covered && crse.contains(ic,jc-2,0)) {
55  x[NN] = T(-2.0);
56  y[NN] = crse(ic,jc-2,0,n+nc);
57  ++NN;
58  }
59 
60  if ( (mask(i,j-r.y,0) != not_covered) && (mask(i,j+r.y,0) != not_covered) ) {
61  NN = 1;
62  }
63 
64  T xInt = -T(0.5) + (j-jc*r.y+T(0.5))/r.y;
65  poly_interp_coeff(xInt, x, NN, c);
66  T b = T(0.0);
67  for (int m = 0; m < NN; ++m) {
68  b += c[m]*y[m];
69  }
70  bdry(i,j,0,n+nb) = b;
71 }
72 
73 template<typename T>
75 void interpbndrydata_y_o3 (int i, int j, int /*k*/, int n,
76  Array4<T> const& bdry, int nb,
77  Array4<T const> const& crse, int nc, Dim3 const& r,
78  Array4<int const> const& mask, int not_covered, int max_width) noexcept
79 {
80  int ic = amrex::coarsen(i,r.x);
81  int jc = amrex::coarsen(j,r.y);
82 
83  T x[3], y[3], c[3];
84  x[0] = T(0.0);
85  y[0] = crse(ic,jc,0,n+nc);
86  int NN = 1;
87 
88  if (mask(i-r.x,j,0) == not_covered) {
89  x[NN] = T(-1.0);
90  y[NN] = crse(ic-1,jc,0,n+nc);
91  ++NN;
92  } else if (max_width >= 2 &&
93  mask.contains((ic+2)*r.x,j,0) &&
94  mask ((ic+2)*r.x,j,0) == not_covered && crse.contains(ic+2,jc,0)) {
95  x[NN] = T(2.0);
96  y[NN] = crse(ic+2,jc,0,n+nc);
97  ++NN;
98  }
99 
100  if (mask(i+r.x,j,0) == not_covered) {
101  x[NN] = T(1.0);
102  y[NN] = crse(ic+1,jc,0,n+nc);
103  ++NN;
104  } else if (max_width >= 2 &&
105  mask.contains(ic*r.x-r.x-1,j,0) &&
106  mask (ic*r.x-r.x-1,j,0) == not_covered && crse.contains(ic-2,jc,0)) {
107  x[NN] = T(-2.0);
108  y[NN] = crse(ic-2,jc,0,n+nc);
109  ++NN;
110  }
111 
112  if ( (mask(i-r.x,j,0) != not_covered) && (mask(i+r.x,j,0) != not_covered) ) {
113  NN = 1;
114  }
115 
116  T xInt = -T(0.5) + (i-ic*r.x+T(0.5))/r.x;
117  poly_interp_coeff(xInt, x, NN, c);
118  T b = T(0.0);
119  for (int m = 0; m < NN; ++m) {
120  b += c[m]*y[m];
121  }
122  bdry(i,j,0,n+nb) = b;
123 }
124 
125 }
126 #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 poly_interp_coeff(T xInt, T const *AMREX_RESTRICT x, int N, T *AMREX_RESTRICT c) noexcept
Definition: AMReX_LOUtil_K.H:24
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_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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool contains(int i, int j, int k) const noexcept
Definition: AMReX_Array4.H:251
Definition: AMReX_Dim3.H:12