Block-Structured AMR Software Framework
AMReX_InterpFaceReg_2D_C.H
Go to the documentation of this file.
1 #ifndef AMREX_INTERP_FACE_REG_2D_C_H_
2 #define AMREX_INTERP_FACE_REG_2D_C_H_
3 
4 namespace amrex {
5 
7 void interp_face_reg (int i, int j, IntVect const& rr, Array4<Real> const& fine, int scomp,
8  Array4<Real const> const& crse, Array4<Real> const& slope, int ncomp,
9  Box const& domface, int idim)
10 {
11  int ic = amrex::coarsen(i,rr[0]);
12  int jc = amrex::coarsen(j,rr[1]);
13  if (idim == 0) {
14  if (jc == domface.smallEnd(1) || jc == domface.bigEnd(1)) {
15  for (int n = 0; n < ncomp; ++n) {
16  fine(i,j,0,n+scomp) = crse(ic,jc,0,n);
17  }
18  } else {
19  Real sfy = Real(1.0);
20  for (int n = 0; n < ncomp; ++n) {
21  Real dc = Real(0.5) * (crse(ic,jc+1,0,n) - crse(ic,jc-1,0,n));
22  Real df = Real(2.0) * (crse(ic,jc+1,0,n) - crse(ic,jc ,0,n));
23  Real db = Real(2.0) * (crse(ic,jc ,0,n) - crse(ic,jc-1,0,n));
24  Real sy = (df*db >= Real(0.0)) ?
25  amrex::min(std::abs(df),std::abs(db)) : Real(0.);
26  sy = std::copysign(Real(1.),dc)*amrex::min(sy,std::abs(dc));
27  if (dc != Real(0.0)) {
28  sfy = amrex::min(sfy, sy / dc);
29  }
30  slope(i,j,0,n) = dc;
31  }
32  Real yoff = (static_cast<Real>(j - jc*rr[1]) + Real(0.5)) / Real(rr[1]) - Real(0.5);
33  for (int n = 0; n < ncomp; ++n) {
34  fine(i,j,0,n+scomp) = crse(ic,jc,0,n) + yoff * slope(i,j,0,n) * sfy;
35  }
36  }
37  } else {
38  if (ic == domface.smallEnd(0) || ic == domface.bigEnd(0)) {
39  for (int n = 0; n < ncomp; ++n) {
40  fine(i,j,0,n+scomp) = crse(ic,jc,0,n);
41  }
42  } else {
43  Real sfx = Real(1.0);
44  for (int n = 0; n < ncomp; ++n) {
45  Real dc = Real(0.5) * (crse(ic+1,jc,0,n) - crse(ic-1,jc,0,n));
46  Real df = Real(2.0) * (crse(ic+1,jc,0,n) - crse(ic ,jc,0,n));
47  Real db = Real(2.0) * (crse(ic ,jc,0,n) - crse(ic-1,jc,0,n));
48  Real sx = (df*db >= Real(0.0)) ?
49  amrex::min(std::abs(df),std::abs(db)) : Real(0.);
50  sx = std::copysign(Real(1.),dc)*amrex::min(sx,std::abs(dc));
51  if (dc != Real(0.0)) {
52  sfx = amrex::min(sfx, sx / dc);
53  }
54  slope(i,j,0,n) = dc;
55  }
56  Real xoff = (static_cast<Real>(i - ic*rr[0]) + Real(0.5)) / Real(rr[0]) - Real(0.5);
57  for (int n = 0; n < ncomp; ++n) {
58  fine(i,j,0,n+scomp) = crse(ic,jc,0,n) + xoff * slope(i,j,0,n) * sfx;
59  }
60  }
61  }
62 }
63 
64 }
65 
66 #endif
#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
Box domface
Definition: AMReX_InterpFaceRegister.cpp:94
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition: AMReX_Box.H:105
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & bigEnd() const &noexcept
Get the bigend.
Definition: AMReX_Box.H:116
Definition: AMReX_Amr.cpp:49
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 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 interp_face_reg(int i, int j, IntVect const &rr, Array4< Real > const &fine, int scomp, Array4< Real const > const &crse, Array4< Real > const &slope, int ncomp, Box const &domface, int idim)
Definition: AMReX_InterpFaceReg_2D_C.H:7
Definition: AMReX_Array4.H:61