1 #ifndef AMREX_MF_INTERP_3D_C_H_
2 #define AMREX_MF_INTERP_3D_C_H_
8 Array4<Real const>
const& u,
int scomp,
int ncomp,
9 Box const& domain,
IntVect const& ratio, BCRec
const* bc) noexcept
23 for (
int ns = 0; ns < ncomp; ++ns) {
29 Real df = Real(2.0) * (u(i+1,j,k,nu) - u(i ,j,k,nu));
30 Real db = Real(2.0) * (u(i ,j,k,nu) - u(i-1,j,k,nu));
33 slope(i,j,k,ns ) = dcx;
35 slope(i,j,k,ns ) = Real(0.0);
41 Real df = Real(2.0) * (u(i,j+1,k,nu) - u(i,j ,k,nu));
42 Real db = Real(2.0) * (u(i,j ,k,nu) - u(i,j-1,k,nu));
45 slope(i,j,k,ns+ ncomp) = dcy;
47 slope(i,j,k,ns+ ncomp) = Real(0.0);
53 Real df = Real(2.0) * (u(i,j,k+1,nu) - u(i,j,k ,nu));
54 Real db = Real(2.0) * (u(i,j,k ,nu) - u(i,j,k-1,nu));
57 slope(i,j,k,ns+2*ncomp) = dcz;
59 slope(i,j,k,ns+2*ncomp) = Real(0.0);
64 if (sx != Real(0.0) || sy != Real(0.0) || sz != Real(0.0)) {
65 Real dumax =
std::abs(sx) * Real(ratio[0]-1)/Real(2*ratio[0])
66 +
std::abs(sy) * Real(ratio[1]-1)/Real(2*ratio[1])
67 +
std::abs(sz) * Real(ratio[2]-1)/Real(2*ratio[2]);
68 Real umax = u(i,j,k,nu);
69 Real umin = u(i,j,k,nu);
70 int ilim = ratio[0] > 1 ? 1 : 0;
71 int jlim = ratio[1] > 1 ? 1 : 0;
72 int klim = ratio[2] > 1 ? 1 : 0;
73 for (
int koff = -klim; koff <= klim; ++koff) {
74 for (
int joff = -jlim; joff <= jlim; ++joff) {
75 for (
int ioff = -ilim; ioff <= ilim; ++ioff) {
76 umin =
amrex::min(umin, u(i+ioff,j+joff,k+koff,nu));
77 umax =
amrex::max(umax, u(i+ioff,j+joff,k+koff,nu));
79 if (dumax * alpha > (umax - u(i,j,k,nu))) {
80 alpha = (umax - u(i,j,k,nu)) / dumax;
82 if (dumax * alpha > (u(i,j,k,nu) - umin)) {
83 alpha = (u(i,j,k,nu) - umin) / dumax;
91 if (dcx != Real(0.0)) {
94 if (dcy != Real(0.0)) {
97 if (dcz != Real(0.0)) {
103 for (
int ns = 0; ns < ncomp; ++ns) {
104 slope(i,j,k,ns ) *= sfx;
105 slope(i,j,k,ns+ ncomp) *= sfy;
106 slope(i,j,k,ns+2*ncomp) *= sfz;
112 Array4<Real const>
const& u,
int scomp,
int ncomp,
113 Box const& domain,
IntVect const& ratio, BCRec
const* bc) noexcept
115 Real sfx = Real(1.0);
116 Real sfy = Real(1.0);
117 Real sfz = Real(1.0);
119 for (
int ns = 0; ns < ncomp; ++ns) {
125 Real df = Real(2.0) * (u(i+1,j,k,nu) - u(i ,j,k,nu));
126 Real db = Real(2.0) * (u(i ,j,k,nu) - u(i-1,j,k,nu));
129 if (dc != Real(0.0)) {
132 slope(i,j,k,ns ) = dc;
134 slope(i,j,k,ns ) = Real(0.0);
140 Real df = Real(2.0) * (u(i,j+1,k,nu) - u(i,j ,k,nu));
141 Real db = Real(2.0) * (u(i,j ,k,nu) - u(i,j-1,k,nu));
144 if (dc != Real(0.0)) {
147 slope(i,j,k,ns+ ncomp) = dc;
149 slope(i,j,k,ns+ ncomp) = Real(0.0);
156 Real df = Real(2.0) * (u(i,j,k+1,nu) - u(i,j,k ,nu));
157 Real db = Real(2.0) * (u(i,j,k ,nu) - u(i,j,k-1,nu));
160 if (dc != Real(0.0)) {
163 slope(i,j,k,ns+2*ncomp) = dc;
165 slope(i,j,k,ns+2*ncomp) = Real(0.0);
170 for (
int ns = 0; ns < ncomp; ++ns) {
171 slope(i,j,k,ns ) *= sfx;
172 slope(i,j,k,ns+ ncomp) *= sfy;
173 slope(i,j,k,ns+2*ncomp) *= sfz;
179 Array4<Real const>
const& u,
int scomp,
int ncomp,
181 BCRec
const* bc) noexcept
192 Real df = Real(2.0) * (u(i+1,j,k,nu) - u(i ,j,k,nu));
193 Real db = Real(2.0) * (u(i ,j,k,nu) - u(i-1,j,k,nu));
201 Real df = Real(2.0) * (u(i,j+1,k,nu) - u(i,j ,k,nu));
202 Real db = Real(2.0) * (u(i,j ,k,nu) - u(i,j-1,k,nu));
210 Real df = Real(2.0) * (u(i,j,k+1,nu) - u(i,j,k ,nu));
211 Real db = Real(2.0) * (u(i,j,k ,nu) - u(i,j,k-1,nu));
217 if (sx != Real(0.0) || sy != Real(0.0) || sz != Real(0.0)) {
218 Real dumax =
std::abs(sx) * Real(ratio[0]-1)/Real(2*ratio[0])
219 +
std::abs(sy) * Real(ratio[1]-1)/Real(2*ratio[1])
220 +
std::abs(sz) * Real(ratio[2]-1)/Real(2*ratio[2]);
221 Real umax = u(i,j,k,nu);
222 Real umin = u(i,j,k,nu);
223 int ilim = ratio[0] > 1 ? 1 : 0;
224 int jlim = ratio[1] > 1 ? 1 : 0;
225 int klim = ratio[2] > 1 ? 1 : 0;
226 for (
int koff = -klim; koff <= klim; ++koff) {
227 for (
int joff = -jlim; joff <= jlim; ++joff) {
228 for (
int ioff = -ilim; ioff <= ilim; ++ioff) {
229 umin =
amrex::min(umin, u(i+ioff,j+joff,k+koff,nu));
230 umax =
amrex::max(umax, u(i+ioff,j+joff,k+koff,nu));
232 if (dumax * alpha > (umax - u(i,j,k,nu))) {
233 alpha = (umax - u(i,j,k,nu)) / dumax;
235 if (dumax * alpha > (u(i,j,k,nu) - umin)) {
236 alpha = (u(i,j,k,nu) - umin) / dumax;
240 slope(i,j,k,ns ) = sx * alpha;
241 slope(i,j,k,ns+ ncomp) = sy * alpha;
242 slope(i,j,k,ns+2*ncomp) = sz * alpha;
247 Array4<Real const>
const&
slope, Array4<Real const>
const&
crse,
248 int ccomp,
int ncomp,
IntVect const& ratio) noexcept
253 const Real xoff = (
static_cast<Real
>(i - ic*ratio[0]) + Real(0.5)) / Real(ratio[0]) - Real(0.5);
254 const Real yoff = (
static_cast<Real
>(j - jc*ratio[1]) + Real(0.5)) / Real(ratio[1]) - Real(0.5);
255 const Real zoff = (
static_cast<Real
>(k - kc*ratio[2]) + Real(0.5)) / Real(ratio[2]) - Real(0.5);
256 fine(i,j,k,fcomp+ns) =
crse(ic,jc,kc,ccomp+ns)
257 + xoff *
slope(ic,jc,kc,ns)
258 + yoff *
slope(ic,jc,kc,ns+ncomp)
259 + zoff *
slope(ic,jc,kc,ns+ncomp*2);
265 Array4<T const>
const&
crse,
int ccomp,
IntVect const& ratio) noexcept
270 int ioff = i - ic*ratio[0];
271 int joff = j - jc*ratio[1];
272 int koff = k - kc*ratio[2];
275 if (ioff*2 < ratio[0]) {
277 wx = Real(ratio[0]+1+2*ioff) / Real(2*ratio[0]);
280 wx = Real(3*ratio[0]-1-2*ioff) / Real(2*ratio[0]);
282 if (joff*2 < ratio[1]) {
284 wy = Real(ratio[1]+1+2*joff) / Real(2*ratio[1]);
287 wy = Real(3*ratio[1]-1-2*joff) / Real(2*ratio[1]);
289 if (koff*2 < ratio[2]) {
291 wz = Real(ratio[2]+1+2*koff) / Real(2*ratio[2]);
294 wz = Real(3*ratio[2]-1-2*koff) / Real(2*ratio[2]);
296 fine(i,j,k,n+fcomp) =
297 crse(ic ,jc ,kc ,n+ccomp)* wx * wy * wz +
298 crse(ic+sx,jc ,kc ,n+ccomp)*(Real(1.0)-wx)* wy * wz +
299 crse(ic ,jc+sy,kc ,n+ccomp)* wx *(Real(1.0)-wy)* wz +
300 crse(ic+sx,jc+sy,kc ,n+ccomp)*(Real(1.0)-wx)*(Real(1.0)-wy)* wz +
301 crse(ic ,jc ,kc+sz,n+ccomp)* wx * wy *(Real(1.0)-wz) +
302 crse(ic+sx,jc ,kc+sz,n+ccomp)*(Real(1.0)-wx)* wy *(Real(1.0)-wz) +
303 crse(ic ,jc+sy,kc+sz,n+ccomp)* wx *(Real(1.0)-wy)*(Real(1.0)-wz) +
304 crse(ic+sx,jc+sy,kc+sz,n+ccomp)*(Real(1.0)-wx)*(Real(1.0)-wy)*(Real(1.0)-wz);
309 Array4<Real const>
const&
crse,
int ccomp,
IntVect const& ratio) noexcept
314 int ioff = i - ic*ratio[0];
315 int joff = j - jc*ratio[1];
316 int koff = k - kc*ratio[2];
317 Real rxinv = Real(1.0) / Real(ratio[0]);
318 Real ryinv = Real(1.0) / Real(ratio[1]);
319 Real rzinv = Real(1.0) / Real(ratio[2]);
320 if (ioff != 0 && joff != 0 && koff != 0) {
322 fine(i,j,k,n+fcomp) = rxinv * ryinv * rzinv *
323 (
crse(ic ,jc ,kc ,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * (ratio[1]-joff) * (ratio[2]-koff)) +
324 crse(ic+1,jc ,kc ,n+ccomp) *
static_cast<Real
>(( ioff) * (ratio[1]-joff) * (ratio[2]-koff)) +
325 crse(ic ,jc+1,kc ,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * ( joff) * (ratio[2]-koff)) +
326 crse(ic+1,jc+1,kc ,n+ccomp) *
static_cast<Real
>(( ioff) * ( joff) * (ratio[2]-koff)) +
327 crse(ic ,jc ,kc+1,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * (ratio[1]-joff) * ( koff)) +
328 crse(ic+1,jc ,kc+1,n+ccomp) *
static_cast<Real
>(( ioff) * (ratio[1]-joff) * ( koff)) +
329 crse(ic ,jc+1,kc+1,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * ( joff) * ( koff)) +
330 crse(ic+1,jc+1,kc+1,n+ccomp) *
static_cast<Real
>(( ioff) * ( joff) * ( koff)));
331 }
else if (joff != 0 && koff != 0) {
333 fine(i,j,k,n+fcomp) = ryinv * rzinv *
334 (
crse(ic,jc ,kc ,n+ccomp) *
static_cast<Real
>((ratio[1]-joff) * (ratio[2]-koff)) +
335 crse(ic,jc+1,kc ,n+ccomp) *
static_cast<Real
>(( joff) * (ratio[2]-koff)) +
336 crse(ic,jc ,kc+1,n+ccomp) *
static_cast<Real
>((ratio[1]-joff) * ( koff)) +
337 crse(ic,jc+1,kc+1,n+ccomp) *
static_cast<Real
>(( joff) * ( koff)));
338 }
else if (ioff != 0 && koff != 0) {
340 fine(i,j,k,n+fcomp) = rxinv * rzinv *
341 (
crse(ic ,jc,kc ,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * (ratio[2]-koff)) +
342 crse(ic+1,jc,kc ,n+ccomp) *
static_cast<Real
>(( ioff) * (ratio[2]-koff)) +
343 crse(ic ,jc,kc+1,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * ( koff)) +
344 crse(ic+1,jc,kc+1,n+ccomp) *
static_cast<Real
>(( ioff) * ( koff)));
345 }
else if (ioff != 0 && joff != 0) {
347 fine(i,j,k,n+fcomp) = rxinv * ryinv *
348 (
crse(ic ,jc ,kc,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * (ratio[1]-joff)) +
349 crse(ic+1,jc ,kc,n+ccomp) *
static_cast<Real
>(( ioff) * (ratio[1]-joff)) +
350 crse(ic ,jc+1,kc,n+ccomp) *
static_cast<Real
>((ratio[0]-ioff) * ( joff)) +
351 crse(ic+1,jc+1,kc,n+ccomp) *
static_cast<Real
>(( ioff) * ( joff)));
352 }
else if (ioff != 0) {
354 fine(i,j,k,n+fcomp) = rxinv*(
static_cast<Real
>(ratio[0]-ioff)*
crse(ic ,jc,kc,n+ccomp) +
355 static_cast<Real
>( ioff)*
crse(ic+1,jc,kc,n+ccomp));
356 }
else if (joff != 0) {
358 fine(i,j,k,n+fcomp) = ryinv*(
static_cast<Real
>(ratio[1]-joff)*
crse(ic,jc ,kc,n+ccomp) +
359 static_cast<Real
>( joff)*
crse(ic,jc+1,kc,n+ccomp));
360 }
else if (koff != 0) {
362 fine(i,j,k,n+fcomp) = rzinv*(
static_cast<Real
>(ratio[2]-koff)*
crse(ic,jc,kc ,n+ccomp) +
363 static_cast<Real
>( koff)*
crse(ic,jc,kc+1,n+ccomp));
366 fine(i,j,k,n+fcomp) =
crse(ic,jc,kc,n+ccomp);
372 Array4<Real const>
const&
crse,
int ccomp,
373 Array4<Real>
const&
slope,
375 BCRec
const* bc) noexcept
388 slope(i,j,k,9*n ) = sx;
389 slope(i,j,k,9*n+1) = sy;
390 slope(i,j,k,9*n+2) = sz;
391 slope(i,j,k,9*n+3) = sxx;
392 slope(i,j,k,9*n+4) = syy;
393 slope(i,j,k,9*n+5) = szz;
394 slope(i,j,k,9*n+6) = sxy;
395 slope(i,j,k,9*n+7) = sxz;
396 slope(i,j,k,9*n+8) = syz;
401 Array4<Real>
const&
fine,
int fcomp,
402 Array4<Real const>
const&
crse,
int ccomp,
403 Array4<Real const>
const&
slope,
409 int irx = i - ic*ratio[0];
410 int jry = j - jc*ratio[1];
411 int krz = k - kc*ratio[2];
414 Real xoff = ( Real(irx) + 0.5_rt ) / Real(ratio[0]) - 0.5_rt;
415 Real yoff = ( Real(jry) + 0.5_rt ) / Real(ratio[1]) - 0.5_rt;
416 Real zoff = ( Real(krz) + 0.5_rt ) / Real(ratio[2]) - 0.5_rt;
418 fine(i,j,k,fcomp+n) =
crse(ic,jc,kc,ccomp+n)
419 + xoff *
slope(ic,jc,kc,9*n )
420 + yoff *
slope(ic,jc,kc,9*n+1)
421 + zoff *
slope(ic,jc,kc,9*n+2)
422 + 0.5_rt * xoff * xoff *
slope(ic,jc,kc,9*n+3)
423 + 0.5_rt * yoff * yoff *
slope(ic,jc,kc,9*n+4)
424 + 0.5_rt * zoff * zoff *
slope(ic,jc,kc,9*n+5)
425 + xoff * yoff *
slope(ic,jc,kc,9*n+6)
426 + xoff * zoff *
slope(ic,jc,kc,9*n+7)
427 + yoff * zoff *
slope(ic,jc,kc,9*n+8);
#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< Real > slope
Definition: AMReX_InterpFaceRegister.cpp:91
Array4< Real const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_compute_slopes_y(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:37
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_bilin_interp(int i, int, int, int n, Array4< T > const &fine, int fcomp, Array4< T const > const &crse, int ccomp, IntVect const &ratio) noexcept
Definition: AMReX_MFInterp_1D_C.H:186
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_quadratic_calcslope(int i, int j, int, int n, Array4< Real const > const &crse, int ccomp, Array4< Real > const &slope, Box const &domain, BCRec const *bc) noexcept
Definition: AMReX_MFInterp_2D_C.H:363
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_cons_lin_interp_llslope(int i, int, int, Array4< Real > const &slope, Array4< Real const > const &u, int scomp, int ncomp, Box const &domain, IntVect const &, BCRec const *bc) noexcept
Definition: AMReX_MFInterp_1D_C.H:39
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
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 void mf_cell_cons_lin_interp_limit_minmax_llslope(int i, int, int, Array4< Real > const &slope, Array4< Real const > const &u, int scomp, int ncomp, Box const &domain, IntVect const &ratio, BCRec const *bc) noexcept
Definition: AMReX_MFInterp_1D_C.H:7
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 Real mf_cell_quadratic_compute_slopes_yy(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:110
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_cell_quadratic_compute_slopes_xy(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:152
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_cons_lin_interp_mcslope(int i, int, int, int ns, Array4< Real > const &slope, Array4< Real const > const &u, int scomp, int, Box const &domain, IntVect const &ratio, BCRec const *bc) noexcept
Definition: AMReX_MFInterp_1D_C.H:66
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_cell_quadratic_compute_slopes_yz(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:220
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_cell_quadratic_compute_slopes_zz(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:131
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_cell_quadratic_compute_slopes_xx(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:89
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_cons_lin_interp(int i, int, int, int ns, Array4< Real > const &fine, int fcomp, Array4< Real const > const &slope, Array4< Real const > const &crse, int ccomp, int, IntVect const &ratio) noexcept
Definition: AMReX_MFInterp_1D_C.H:102
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_cell_quadratic_compute_slopes_xz(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:186
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_nodebilin_interp(int i, int, int, int n, Array4< Real > const &fine, int fcomp, Array4< Real const > const &crse, int ccomp, IntVect const &ratio) noexcept
Definition: AMReX_MFInterp_1D_C.H:206
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_compute_slopes_x(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mf_cell_quadratic_interp(int i, int j, int, int n, Array4< Real > const &fine, int fcomp, Array4< Real const > const &crse, int ccomp, Array4< Real const > const &slope, IntVect const &ratio) noexcept
Definition: AMReX_MFInterp_2D_C.H:384
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mf_compute_slopes_z(int i, int j, int k, Array4< Real const > const &u, int nu, Box const &domain, BCRec const &bc)
Definition: AMReX_MFInterp_C.H:63