Block-Structured AMR Software Framework
AMReX_MultiFabUtil_nd_C.H
Go to the documentation of this file.
1 #ifndef AMREX_MULTIFAB_UTIL_ND_C_H_
2 #define AMREX_MULTIFAB_UTIL_ND_C_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Gpu.H>
6 #include <AMReX_Geometry.H>
7 #include <AMReX_FArrayBox.H>
8 #include <AMReX_IArrayBox.H>
9 #include <cmath>
10 
11 namespace amrex {
12 
14 inline
15 void amrex_fill_slice_interp (Box const& bx, Array4<Real> slice,
16  Array4<Real const> const& full,
17  int scomp, int fcomp, int ncomp,
18  int dir, Real coord, GeometryData const& gd) noexcept
19 {
20  const auto lo = lbound(bx);
21  const auto hi = ubound(bx);
22 
23  int ilo = 0, jlo = 0, klo = 0;
24  int ihi = 0, jhi = 0, khi = 0;
25 
26  Real weight = (coord - gd.ProbLo(dir)) / gd.CellSize(dir);
27  auto dirhi = std::floor(weight + Real(0.5));
28  auto dirlo = dirhi-Real(1.);
29  weight -= dirlo+Real(0.5);
30 
31  if (weight < 0.5) {
32  switch (dir)
33  {
34  case 0:
35  ihi = 1;
36  break;
37  case 1:
38  jhi = 1;
39  break;
40  case 2:
41  khi = 1;
42  default: { break; }
43  }
44  } else {
45  switch (dir)
46  {
47  case 0:
48  ilo = -1;
49  break;
50  case 1:
51  jlo = -1;
52  break;
53  case 2:
54  klo = -1;
55  default: { break; }
56  }
57  }
58 
59  for (int n = 0; n < ncomp; ++n) {
60  const int ns = n + scomp;
61  const int nf = n + fcomp;
62  for (int k = lo.z; k <= hi.z; ++k) {
63  for (int j = lo.y; j <= hi.y; ++j) {
65  for (int i = lo.x; i <= hi.x; ++i) {
66  slice(i,j,k,ns) = (Real(1.0)-weight)*full(i+ilo,j+jlo,k+klo,nf)
67  + weight *full(i+ihi,j+jhi,k+khi,nf);
68  }
69  }
70  }
71  }
72 }
73 
74 }
75 
76 #endif
#define AMREX_PRAGMA_SIMD
Definition: AMReX_Extension.H:80
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE void amrex_fill_slice_interp(Box const &bx, Array4< Real > slice, Array4< Real const > const &full, int scomp, int fcomp, int ncomp, int dir, Real coord, GeometryData const &gd) noexcept
Definition: AMReX_MultiFabUtil_nd_C.H:15
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:308
Definition: AMReX_Array4.H:61
Definition: AMReX_Geometry.H:25