1 #ifndef AMREX_INTERP_C_H_
2 #define AMREX_INTERP_C_H_
3 #include <AMReX_Config.H>
5 #if (AMREX_SPACEDIM == 1)
7 #elif (AMREX_SPACEDIM == 2)
28 if (ci*ratio[0] ==
fi) {
29 #if (AMREX_SPACEDIM >= 2)
34 #if (AMREX_SPACEDIM == 3)
54 if (cj*ratio[1] == fj) {
56 #if (AMREX_SPACEDIM == 3)
76 if (ck*ratio[2] == fk) {
96 IntVect const& ratio,
Box const& per_grown_domain,
int dim) noexcept
100 #if (AMREX_SPACEDIM == 1)
107 #if (AMREX_SPACEDIM == 3)
113 if (dim == 0 && ci*ratio[0] == i) {
116 fine(i, j, k, n) =
crse(ci, cj, ck, n);
117 #if (AMREX_SPACEDIM >= 2)
118 if (cj > per_grown_domain.smallEnd(1) && cj < per_grown_domain.bigEnd(1) && ratio[1] > 1) {
119 Real sfy = Real(1.0);
120 Real dc = Real(0.5) * (
crse(ci,cj+1,ck,n) -
crse(ci,cj-1,ck,n));
121 Real df = Real(2.0) * (
crse(ci,cj+1,ck,n) -
crse(ci,cj ,ck,n));
122 Real db = Real(2.0) * (
crse(ci,cj ,ck,n) -
crse(ci,cj-1,ck,n));
123 Real sy = (df*db >= Real(0.0)) ?
126 if (dc != Real(0.0)) {
130 Real yoff = (
static_cast<Real
>(j - cj*ratio[1]) + Real(0.5)) / Real(ratio[1]) - Real(0.5);
133 #if (AMREX_SPACEDIM == 3)
134 if (ck > per_grown_domain.smallEnd(2) && ck < per_grown_domain.bigEnd(2) && ratio[2] > 1) {
135 Real sfz = Real(1.0);
136 Real dc = Real(0.5) * (
crse(ci,cj,ck+1,n) -
crse(ci,cj,ck-1,n));
137 Real df = Real(2.0) * (
crse(ci,cj,ck+1,n) -
crse(ci,cj,ck ,n));
138 Real db = Real(2.0) * (
crse(ci,cj,ck ,n) -
crse(ci,cj,ck-1,n));
139 Real sz = (df*db >= Real(0.0)) ?
142 if (dc != Real(0.0)) {
146 Real zoff = (
static_cast<Real
>(k - ck*ratio[2]) + Real(0.5)) / Real(ratio[2]) - Real(0.5);
154 #if (AMREX_SPACEDIM >= 2)
155 if (dim == 1 && cj*ratio[1] == j) {
158 fine(i, j, k, n) =
crse(ci, cj, ck, n);
159 if (ci > per_grown_domain.smallEnd(0) && ci < per_grown_domain.bigEnd(0) && ratio[0] > 1) {
160 Real sfx = Real(1.0);
161 Real dc = Real(0.5) * (
crse(ci+1,cj,ck,n) -
crse(ci-1,cj,ck,n));
162 Real df = Real(2.0) * (
crse(ci+1,cj,ck,n) -
crse(ci ,cj,ck,n));
163 Real db = Real(2.0) * (
crse(ci ,cj,ck,n) -
crse(ci-1,cj,ck,n));
164 Real sx = (df*db >= Real(0.0)) ?
167 if (dc != Real(0.0)) {
171 Real xoff = (
static_cast<Real
>(i - ci*ratio[0]) + Real(0.5)) / Real(ratio[0]) - Real(0.5);
174 #if (AMREX_SPACEDIM == 3)
175 if (ck > per_grown_domain.smallEnd(2) && ck < per_grown_domain.bigEnd(2) && ratio[2] > 1) {
176 Real sfz = Real(1.0);
177 Real dc = Real(0.5) * (
crse(ci,cj,ck+1,n) -
crse(ci,cj,ck-1,n));
178 Real df = Real(2.0) * (
crse(ci,cj,ck+1,n) -
crse(ci,cj,ck ,n));
179 Real db = Real(2.0) * (
crse(ci,cj,ck ,n) -
crse(ci,cj,ck-1,n));
180 Real sz = (df*db >= Real(0.0)) ?
183 if (dc != Real(0.0)) {
187 Real zoff = (
static_cast<Real
>(k - ck*ratio[2]) + Real(0.5)) / Real(ratio[2]) - Real(0.5);
195 #if (AMREX_SPACEDIM == 3)
196 if (dim == 2 && ck*ratio[2] == k) {
199 fine(i, j, k, n) =
crse(ci, cj, ck, n);
200 if (ci > per_grown_domain.smallEnd(0) && ci < per_grown_domain.bigEnd(0) && ratio[0] > 1) {
201 Real sfx = Real(1.0);
202 Real dc = Real(0.5) * (
crse(ci+1,cj,ck,n) -
crse(ci-1,cj,ck,n));
203 Real df = Real(2.0) * (
crse(ci+1,cj,ck,n) -
crse(ci ,cj,ck,n));
204 Real db = Real(2.0) * (
crse(ci ,cj,ck,n) -
crse(ci-1,cj,ck,n));
205 Real sx = (df*db >= Real(0.0)) ?
208 if (dc != Real(0.0)) {
212 Real xoff = (
static_cast<Real
>(i - ci*ratio[0]) + Real(0.5)) / Real(ratio[0]) - Real(0.5);
215 if (cj > per_grown_domain.smallEnd(1) && cj < per_grown_domain.bigEnd(1) && ratio[1] > 1) {
216 Real sfy = Real(1.0);
217 Real dc = Real(0.5) * (
crse(ci,cj+1,ck,n) -
crse(ci,cj-1,ck,n));
218 Real df = Real(2.0) * (
crse(ci,cj+1,ck,n) -
crse(ci,cj ,ck,n));
219 Real db = Real(2.0) * (
crse(ci,cj ,ck,n) -
crse(ci,cj-1,ck,n));
220 Real sy = (df*db >= Real(0.0)) ?
223 if (dc != Real(0.0)) {
227 Real yoff = (
static_cast<Real
>(j - cj*ratio[1]) + Real(0.5)) / Real(ratio[1]) - Real(0.5);
246 if (i-ci*ratio[0] != 0)
248 Real
const w =
static_cast<Real
>(i-ci*ratio[0]) * (Real(1.)/Real(ratio[0]));
249 int i1 = ci*ratio[0];
250 int i2 = (ci+1)*ratio[0];
251 fine(i,j,k,n) = (Real(1.)-w) *
fine(i1,j,k,n) + w *
fine(i2,j,k,n);
261 if (j-cj*ratio[1] != 0)
263 Real
const w =
static_cast<Real
>(j-cj*ratio[1]) * (Real(1.)/Real(ratio[1]));
264 int j1 = cj*ratio[1];
265 int j2 = (cj+1)*ratio[1];
266 fine(i,j,k,n) = (Real(1.)-w) *
fine(i,j1,k,n) + w *
fine(i,j2,k,n);
277 if (k-ck*ratio[2] != 0)
279 Real
const w =
static_cast<Real
>(k-ck*ratio[2]) * (Real(1.)/Real(ratio[2]));
280 int k1 = ck*ratio[2];
281 int k2 = (ck+1)*ratio[2];
282 fine(i,j,k,n) = (Real(1.)-w) *
fine(i,j,k1,n) + w *
fine(i,j,k2,n);
290 constexpr
Array1D<Real,-2,2> c = {Real(0.01708984), Real(-0.12304688),
291 Real(0.92285156), Real(0.20507812),
294 int s = 2*(i-ii*2) - 1;
295 fine(i,j,k,n) = c(-2*s)*
crse(ii-2,j,k,n)
296 + c( -s)*
crse(ii-1,j,k,n)
297 + c( 0)*
crse(ii ,j,k,n)
298 + c( s)*
crse(ii+1,j,k,n)
299 + c( 2*s)*
crse(ii+2,j,k,n);
306 constexpr
Array1D<Real,-2,2> c = {Real(0.01708984), Real(-0.12304688),
307 Real(0.92285156), Real(0.20507812),
310 int s = 2*(j-jj*2) - 1;
311 fine(i,j,k,n) = c(-2*s)*
crse(i,jj-2,k,n)
312 + c( -s)*
crse(i,jj-1,k,n)
313 + c( 0)*
crse(i,jj ,k,n)
314 + c( s)*
crse(i,jj+1,k,n)
315 + c( 2*s)*
crse(i,jj+2,k,n);
322 constexpr
Array1D<Real,-2,2> c = {Real(0.01708984), Real(-0.12304688),
323 Real(0.92285156), Real(0.20507812),
326 int s = 2*(k-kk*2) - 1;
327 fine(i,j,k,n) = c(-2*s)*
crse(i,j,kk-2,n)
328 + c( -s)*
crse(i,j,kk-1,n)
329 + c( 0)*
crse(i,j,kk ,n)
330 + c( s)*
crse(i,j,kk+1,n)
331 + c( 2*s)*
crse(i,j,kk+2,n);
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Array4< Real > fine
Definition: AMReX_InterpFaceRegister.cpp:90
Array4< int const > mask
Definition: AMReX_InterpFaceRegister.cpp:93
Array4< Real > slope
Definition: AMReX_InterpFaceRegister.cpp:91
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
static int fi(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:49
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void cell_quartic_interp_z(int i, int j, int k, int n, Array4< Real > const &fine, Array4< Real const > const &crse) noexcept
Definition: AMReX_Interp_C.H:319
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T abs(const GpuComplex< T > &a_z) noexcept
Return the absolute value of a complex number.
Definition: AMReX_GpuComplex.H:356
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_face_interp_x(int fi, int fj, int fk, int n, Array4< T > const &fine, Array4< T const > const &crse, Array4< int const > const &mask, IntVect const &ratio) noexcept
Definition: AMReX_Interp_C.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_face_interp_y(int fi, int fj, int fk, int n, Array4< T > const &fine, Array4< T const > const &crse, Array4< int const > const &mask, IntVect const &ratio) noexcept
Definition: AMReX_Interp_C.H:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_cons_linear_face_interp(int i, int j, int k, int n, Array4< T > const &fine, Array4< T const > const &crse, Array4< int const > const &mask, IntVect const &ratio, Box const &per_grown_domain, int dim) noexcept
Definition: AMReX_Interp_C.H:94
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void cell_quartic_interp_y(int i, int j, int k, int n, Array4< Real > const &fine, Array4< Real const > const &crse) noexcept
Definition: AMReX_Interp_C.H:303
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_interp_x(int i, int, int, int n, Array4< T > const &fine, Array4< T const > const &crse, IntVect const &ratio) noexcept
Definition: AMReX_Interp_1D_C.H:97
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_interp_y(int i, int j, int, int n, Array4< T > const &fine, Array4< T const > const &crse, IntVect const &ratio) noexcept
Definition: AMReX_Interp_2D_C.H:189
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void cell_quartic_interp_x(int i, int j, int k, int n, Array4< Real > const &fine, Array4< Real const > const &crse) noexcept
Definition: AMReX_Interp_C.H:287
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_face_interp_z(int fi, int fj, int fk, int n, Array4< T > const &fine, Array4< T const > const &crse, Array4< int const > const &mask, IntVect const &ratio) noexcept
Definition: AMReX_Interp_C.H:71
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void face_linear_interp_z(int i, int j, int k, int n, Array4< T > const &fine, Array4< T const > const &crse, IntVect const &ratio) noexcept
Definition: AMReX_Interp_3D_C.H:374
Definition: AMReX_Array.H:161
Definition: AMReX_Array4.H:61