Block-Structured AMR Software Framework
AMReX_YAFluxRegister_3D_K.H
Go to the documentation of this file.
1 #ifndef AMREX_YAFLUXREGISTER_3D_K_H_
2 #define AMREX_YAFLUXREGISTER_3D_K_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_BaseFab.H>
6 
7 namespace amrex {
8 
9 template <typename T>
11 void yafluxreg_crseadd (Box const& bx, Array4<T> const& d, Array4<int const> const& flag,
12  Array4<T const> const& fx,
13  Array4<T const> const& fy,
14  Array4<T const> const& fz,
15  T dtdx, T dtdy, T dtdz, int nc) noexcept
16 {
17  auto const lo = amrex::lbound(bx);
18  auto const hi = amrex::ubound(bx);
19 
20  for (int k = lo.z; k <= hi.z; ++k) {
21  for (int j = lo.y; j <= hi.y; ++j) {
22  for (int i = lo.x; i <= hi.x; ++i) {
23  if (flag(i,j,k) == amrex_yafluxreg_crse_fine_boundary_cell)
24  {
25  if (flag(i-1,j,k) == amrex_yafluxreg_fine_cell) {
26  for (int n = 0; n < nc; ++n) {
27  d(i,j,k,n) -= dtdx*fx(i,j,k,n);
28  }
29  }
30  if (flag(i+1,j,k) == amrex_yafluxreg_fine_cell) {
31  for (int n = 0; n < nc; ++n) {
32  d(i,j,k,n) += dtdx*fx(i+1,j,k,n);
33  }
34  }
35 
36  if (flag(i,j-1,k) == amrex_yafluxreg_fine_cell) {
37  for (int n = 0; n < nc; ++n) {
38  d(i,j,k,n) -= dtdy*fy(i,j,k,n);
39  }
40  }
41  if (flag(i,j+1,k) == amrex_yafluxreg_fine_cell) {
42  for (int n = 0; n < nc; ++n) {
43  d(i,j,k,n) += dtdy*fy(i,j+1,k,n);
44  }
45  }
46 
47  if (flag(i,j,k-1) == amrex_yafluxreg_fine_cell) {
48  for (int n = 0; n < nc; ++n) {
49  d(i,j,k,n) -= dtdz*fz(i,j,k,n);
50  }
51  }
52  if (flag(i,j,k+1) == amrex_yafluxreg_fine_cell) {
53  for (int n = 0; n < nc; ++n) {
54  d(i,j,k,n) += dtdz*fz(i,j,k+1,n);
55  }
56  }
57  }
58  }}}
59 }
60 
61 template <typename T>
63 void yafluxreg_fineadd (Box const& bx, Array4<T> const& d, Array4<T const> const& f,
64  T dtdx, int nc, int dirside, Dim3 const& rr) noexcept
65 {
66  const auto lo = amrex::lbound(bx);
67  const auto hi = amrex::ubound(bx);
68 
69  switch (dirside) {
70  case 0 :
71  {
72  for (int n = 0; n < nc; ++n) {
73  for (int k = lo.z; k <= hi.z; ++k) {
74  for (int j = lo.y; j <= hi.y; ++j) {
75  const int i = lo.x;
76  const int ii = (i+1)*rr.x;
77  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
78  for ( int koff = 0; koff < rr.z; ++koff) {
79  const int kk = k*rr.z + koff;
80  for (int joff = 0; joff < rr.y; ++joff) {
81  const int jj = j*rr.y + joff;
82  T tmp = -dtdx*f(ii,jj,kk,n);
84  }
85  }
86  }
87  }
88  }
89  break;
90  }
91  case 1 :
92  {
93  for (int n = 0; n < nc; ++n) {
94  for (int k = lo.z; k <= hi.z; ++k) {
95  for (int j = lo.y; j <= hi.y; ++j) {
96  const int i = lo.x;
97  const int ii = i*rr.x;
98  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
99  for (int koff = 0; koff < rr.z; ++koff) {
100  const int kk = k*rr.z + koff;
101  for (int joff = 0; joff < rr.y; ++joff) {
102  const int jj = j*rr.y + joff;
103  T tmp = dtdx*f(ii,jj,kk,n);
105  }
106  }
107  }
108  }
109  }
110  break;
111  }
112  case 2 :
113  {
114  for (int n = 0; n < nc; ++n) {
115  for (int k = lo.z; k <= hi.z; ++k) {
116  for (int i = lo.x; i <= hi.x; ++i) {
117  const int j = lo.y;
118  const int jj = (j+1)*rr.y;
119  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
120  for ( int koff = 0; koff < rr.z; ++koff) {
121  const int kk = k*rr.z + koff;
122  for (int ioff = 0; ioff < rr.x; ++ioff) {
123  const int ii = i*rr.x + ioff;
124  T tmp = -dtdx*f(ii,jj,kk,n);
126  }
127  }
128  }
129  }
130  }
131  break;
132  }
133  case 3 :
134  {
135  for (int n = 0; n < nc; ++n) {
136  for (int k = lo.z; k <= hi.z; ++k) {
137  for (int i = lo.x; i <= hi.x; ++i) {
138  const int j = lo.y;
139  const int jj = j*rr.y;
140  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
141  for ( int koff = 0; koff < rr.z; ++koff) {
142  const int kk = k*rr.z + koff;
143  for (int ioff = 0; ioff < rr.x; ++ioff) {
144  const int ii = i*rr.x + ioff;
145  T tmp = dtdx*f(ii,jj,kk,n);
147  }
148  }
149  }
150  }
151  }
152  break;
153  }
154  case 4 :
155  {
156  for (int n = 0; n < nc; ++n) {
157  for (int j = lo.y; j <= hi.y; ++j) {
158  for (int i = lo.x; i <= hi.x; ++i) {
159  const int k = lo.z;
160  const int kk = (k+1)*rr.z;
161  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
162  for ( int joff = 0; joff < rr.y; ++joff) {
163  const int jj = j*rr.y + joff;
164  for (int ioff = 0; ioff < rr.x; ++ioff) {
165  const int ii = i*rr.x + ioff;
166  T tmp = -dtdx*f(ii,jj,kk,n);
168  }
169  }
170  }
171  }
172  }
173  break;
174  }
175  default:
176  {
177  for (int n = 0; n < nc; ++n) {
178  for (int j = lo.y; j <= hi.y; ++j) {
179  for (int i = lo.x; i <= hi.x; ++i) {
180  const int k = lo.z;
181  const int kk = k*rr.z;
182  T* AMREX_RESTRICT dp = &(d(i,j,k,n));
183  for ( int joff = 0; joff < rr.y; ++joff) {
184  const int jj = j*rr.y + joff;
185  for (int ioff = 0; ioff < rr.x; ++ioff) {
186  const int ii = i*rr.x + ioff;
187  T tmp = dtdx*f(ii,jj,kk,n);
189  }
190  }
191  }
192  }
193  }
194  }
195  }
196 }
197 
198 }
199 #endif
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_RESTRICT
Definition: AMReX_Extension.H:37
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
constexpr int amrex_yafluxreg_fine_cell
Definition: AMReX_YAFluxRegister_K.H:8
constexpr int amrex_yafluxreg_crse_fine_boundary_cell
Definition: AMReX_YAFluxRegister_K.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Add(T *const sum, T const value) noexcept
Definition: AMReX_GpuAtomic.H:619
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.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 yafluxreg_fineadd(Box const &bx, Array4< T > const &d, Array4< T const > const &f, T dtdx, int nc, int dirside, Dim3 const &rr) noexcept
Definition: AMReX_YAFluxRegister_1D_K.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void yafluxreg_crseadd(Box const &bx, Array4< T > const &d, Array4< int const > const &flag, Array4< T const > const &fx, T dtdx, int nc) noexcept
Definition: AMReX_YAFluxRegister_1D_K.H:11
integer, parameter dp
Definition: AMReX_SDCquadrature.F90:8
Definition: AMReX_Array4.H:61