Block-Structured AMR Software Framework
AMReX_FluxReg_3D_C.H
Go to the documentation of this file.
1 #ifndef AMREX_FLUXREG_3D_C_H_
2 #define AMREX_FLUXREG_3D_C_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_FArrayBox.H>
6 
7 namespace amrex {
8 
9 
26 AMREX_GPU_HOST_DEVICE inline void
27 fluxreg_fineadd (Box const& bx, Array4<Real> const& reg, const int rcomp,
28  Array4<Real const> const& flx, const int fcomp, const int ncomp,
29  const int dir, Dim3 const& ratio, const Real mult) noexcept
30 {
31  const auto lo = amrex::lbound(bx);
32  const auto hi = amrex::ubound(bx);
33 
34  switch (dir) {
35  case 0:
36  {
37  const int ic = lo.x;
38  const int i = ic*ratio.x;
39  for (int n = 0; n < ncomp; ++n) {
40  for (int kc = lo.z; kc <= hi.z; ++kc) {
41  for (int koff = 0; koff < ratio.z; ++koff) {
42  const int k = ratio.z*kc + koff;
43  for (int jc = lo.y; jc <= hi.y; ++jc) {
44  for (int joff = 0; joff < ratio.y; ++joff) {
45  const int j = ratio.y*jc + joff;
46  reg(ic,jc,kc,n+rcomp) += mult*flx(i,j,k,n+fcomp);
47  }
48  }
49  }
50  }
51  }
52  break;
53  }
54  case 1:
55  {
56  const int jc = lo.y;
57  const int j = jc*ratio.y;
58  for (int n = 0; n < ncomp; ++n) {
59  for (int kc = lo.z; kc <= hi.z; ++kc) {
60  for (int koff = 0; koff < ratio.z; ++koff) {
61  const int k = ratio.z*kc + koff;
62  for (int ic = lo.x; ic <= hi.x; ++ic) {
63  for (int ioff = 0; ioff < ratio.x; ++ioff) {
64  const int i = ratio.x*ic + ioff;
65  reg(ic,jc,kc,n+rcomp) += mult*flx(i,j,k,n+fcomp);
66  }
67  }
68  }
69  }
70  }
71  break;
72  }
73  default:
74  {
75  const int kc = lo.z;
76  const int k = kc*ratio.z;
77  for (int n = 0; n < ncomp; ++n) {
78  for (int jc = lo.y; jc <= hi.y; ++jc) {
79  for (int joff = 0; joff < ratio.y; ++joff) {
80  const int j = ratio.y*jc + joff;
81  for (int ic = lo.x; ic <= hi.x; ++ic) {
82  for (int ioff = 0; ioff < ratio.x; ++ioff) {
83  const int i = ratio.x*ic + ioff;
84  reg(ic,jc,kc,n+rcomp) += mult*flx(i,j,k,n+fcomp);
85  }
86  }
87  }
88  }
89  }
90  }
91  }
92 }
93 
94 
112 AMREX_GPU_HOST_DEVICE inline void
113 fluxreg_fineareaadd (Box const& bx, Array4<Real> const& reg, const int rcomp,
114  Array4<Real const> const& area,
115  Array4<Real const> const& flx, const int fcomp, const int ncomp,
116  const int dir, Dim3 const& ratio, const Real mult) noexcept
117 {
118  const auto lo = amrex::lbound(bx);
119  const auto hi = amrex::ubound(bx);
120 
121  switch (dir) {
122  case 0:
123  {
124  const int ic = lo.x;
125  const int i = ic*ratio.x;
126  for (int n = 0; n < ncomp; ++n) {
127  for (int kc = lo.z; kc <= hi.z; ++kc) {
128  for (int koff = 0; koff < ratio.z; ++koff) {
129  const int k = ratio.z*kc + koff;
130  for (int jc = lo.y; jc <= hi.y; ++jc) {
131  for (int joff = 0; joff < ratio.y; ++joff) {
132  const int j = ratio.y*jc + joff;
133  reg(ic,jc,kc,n+rcomp) += mult*area(i,j,k)
134  * flx(i,j,k,n+fcomp);
135  }
136  }
137  }
138  }
139  }
140  break;
141  }
142  case 1:
143  {
144  const int jc = lo.y;
145  const int j = jc*ratio.y;
146  for (int n = 0; n < ncomp; ++n) {
147  for (int kc = lo.z; kc <= hi.z; ++kc) {
148  for (int koff = 0; koff < ratio.z; ++koff) {
149  const int k = ratio.z*kc + koff;
150  for (int ic = lo.x; ic <= hi.x; ++ic) {
151  for (int ioff = 0; ioff < ratio.x; ++ioff) {
152  const int i = ratio.x*ic + ioff;
153  reg(ic,jc,kc,n+rcomp) += mult*area(i,j,k)
154  * flx(i,j,k,n+fcomp);
155  }
156  }
157  }
158  }
159  }
160  break;
161  }
162  default:
163  {
164  const int kc = lo.z;
165  const int k = kc*ratio.z;
166  for (int n = 0; n < ncomp; ++n) {
167  for (int jc = lo.y; jc <= hi.y; ++jc) {
168  for (int joff = 0; joff < ratio.y; ++joff) {
169  const int j = ratio.y*jc + joff;
170  for (int ic = lo.x; ic <= hi.x; ++ic) {
171  for (int ioff = 0; ioff < ratio.x; ++ioff) {
172  const int i = ratio.x*ic + ioff;
173  reg(ic,jc,kc,n+rcomp) += mult*area(i,j,k)
174  * flx(i,j,k,n+fcomp);
175  }
176  }
177  }
178  }
179  }
180  }
181  }
182 }
183 
184 AMREX_GPU_HOST_DEVICE inline void
185 fluxreg_reflux (Box const& bx, Array4<Real> const& s, const int scomp,
186  Array4<Real const> const& f, Array4<Real const> const& v,
187  const int ncomp, const Real mult, const Orientation face) noexcept
188 {
189  const auto lo = amrex::lbound(bx);
190  const auto hi = amrex::ubound(bx);
191 
192  if (face.isLow()) {
193  const int dir = face.coordDir();
194  switch (dir) {
195  case 0:
196  {
197  for (int n = 0; n < ncomp; ++n) {
198  for (int k = lo.z; k <= hi.z; ++k) {
199  for (int j = lo.y; j <= hi.y; ++j) {
200  for (int i = lo.x; i <= hi.x; ++i) {
201  s(i,j,k,n+scomp) += -mult*f(i+1,j,k,n)/v(i,j,k);
202  }
203  }
204  }
205  }
206  break;
207  }
208  case 1:
209  {
210  for (int n = 0; n < ncomp; ++n) {
211  for (int k = lo.z; k <= hi.z; ++k) {
212  for (int j = lo.y; j <= hi.y; ++j) {
213  for (int i = lo.x; i <= hi.x; ++i) {
214  s(i,j,k,n+scomp) += -mult*f(i,j+1,k,n)/v(i,j,k);
215  }
216  }
217  }
218  }
219  break;
220  }
221  default:
222  {
223  for (int n = 0; n < ncomp; ++n) {
224  for (int k = lo.z; k <= hi.z; ++k) {
225  for (int j = lo.y; j <= hi.y; ++j) {
226  for (int i = lo.x; i <= hi.x; ++i) {
227  s(i,j,k,n+scomp) += -mult*f(i,j,k+1,n)/v(i,j,k);
228  }
229  }
230  }
231  }
232  }
233  }
234  } else {
235  for (int n = 0; n < ncomp; ++n) {
236  for (int k = lo.z; k <= hi.z; ++k) {
237  for (int j = lo.y; j <= hi.y; ++j) {
238  for (int i = lo.x; i <= hi.x; ++i) {
239  s(i,j,k,n+scomp) += mult*f(i,j,k,n)/v(i,j,k);
240  }
241  }
242  }
243  }
244  }
245 }
246 
247 }
248 
249 #endif
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
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
AMREX_GPU_HOST_DEVICE void fluxreg_fineadd(Box const &bx, Array4< Real > const &reg, const int rcomp, Array4< Real const > const &flx, const int fcomp, const int ncomp, const int, Dim3 const &ratio, const Real mult) noexcept
Add fine grid flux to flux register. Flux array is a fine grid edge based object, Register is a coars...
Definition: AMReX_FluxReg_1D_C.H:26
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 void fluxreg_fineareaadd(Box const &bx, Array4< Real > const &reg, const int rcomp, Array4< Real const > const &area, Array4< Real const > const &flx, const int fcomp, const int ncomp, const int, Dim3 const &ratio, const Real mult) noexcept
Add fine grid flux times area to flux register. Flux array is a fine grid edge based object,...
Definition: AMReX_FluxReg_1D_C.H:56
AMREX_GPU_HOST_DEVICE void fluxreg_reflux(Box const &bx, Array4< Real > const &s, const int scomp, Array4< Real const > const &f, Array4< Real const > const &v, const int ncomp, const Real mult, const Orientation face) noexcept
Definition: AMReX_FluxReg_1D_C.H:70