Block-Structured AMR Software Framework
AMReX_MLMG_1D_K.H
Go to the documentation of this file.
1 #ifndef AMREX_MLMG_1D_K_H_
2 #define AMREX_MLMG_1D_K_H_
3 #include <AMReX_Config.H>
4 
5 namespace amrex {
6 
7 template <typename T>
9 void mlmg_lin_cc_interp_r2 (Box const& bx, Array4<T> const& ff,
10  Array4<T const> const& cc, int nc) noexcept
11 {
12  const auto lo = amrex::lbound(bx);
13  const auto hi = amrex::ubound(bx);
14 
15  for (int n = 0; n < nc; ++n) {
17  for (int i = lo.x; i <= hi.x; ++i) {
18  const int ic = i/2;
19  const int ioff = 2*(i-ic*2)-1;
20  ff(i,0,0,n) = T(0.75)*cc(ic,0,0,n) + T(0.25)*cc(ic+ioff,0,0,n);
21  }
22  }
23 }
24 
25 template <typename T>
27 void mlmg_lin_cc_interp_r4 (Box const& bx, Array4<T> const& ff,
28  Array4<T const> const& cc, int nc) noexcept
29 {
30  const auto lo = amrex::lbound(bx);
31  const auto hi = amrex::ubound(bx);
32 
33  for (int n = 0; n < nc; ++n) {
35  for (int i = lo.x; i <= hi.x; ++i) {
36  const int ic = i/4;
37  ff(i,0,0,n) = cc(ic,0,0,n);
38  }
39  }
40 }
41 
42 template <typename T>
44 void mlmg_lin_nd_interp_r2 (int i, int, int, int n, Array4<T> const& fine,
45  Array4<T const> const& crse) noexcept
46 {
47  int ic = amrex::coarsen(i,2);
48  bool i_is_odd = (ic*2 != i);
49  if (i_is_odd) {
50  // Fine node along a horizontal cell edge
51  fine(i,0,0,n) = T(0.5)*(crse(ic,0,0,n) + crse(ic+1,0,0,n));
52  } else {
53  // Fine node coincident with coarse node
54  fine(i,0,0,n) = crse(ic,0,0,n);
55  }
56 }
57 
58 template <typename T>
60 void mlmg_lin_nd_interp_r4 (int i, int, int, int n, Array4<T> const& fine,
61  Array4<T const> const& crse) noexcept
62 {
63  int ic = amrex::coarsen(i,4);
64  bool i_injection = (ic*4 == i);
65  if (i_injection) {
66  fine(i,0,0,n) = crse(ic,0,0,n);
67  } else {
68  fine(i,0,0,n) = T(0.25)*(crse(ic ,0,0,n)*T(4*(ic+1)-i)
69  + crse(ic+1,0,0,n)*T(i-4*ic));
70  }
71 }
72 
73 }
74 
75 #endif
#define AMREX_PRAGMA_SIMD
Definition: AMReX_Extension.H:80
#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 const > crse
Definition: AMReX_InterpFaceRegister.cpp:92
static int ff(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:59
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlmg_lin_cc_interp_r2(Box const &bx, Array4< T > const &ff, Array4< T const > const &cc, int nc) noexcept
Definition: AMReX_MLMG_1D_K.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlmg_lin_cc_interp_r4(Box const &bx, Array4< T > const &ff, Array4< T const > const &cc, int nc) noexcept
Definition: AMReX_MLMG_1D_K.H:27
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlmg_lin_nd_interp_r2(int i, int, int, int n, Array4< T > const &fine, Array4< T const > const &crse) noexcept
Definition: AMReX_MLMG_1D_K.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlmg_lin_nd_interp_r4(int i, int, int, int n, Array4< T > const &fine, Array4< T const > const &crse) noexcept
Definition: AMReX_MLMG_1D_K.H:60
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