Block-Structured AMR Software Framework
AMReX_FluxReg_2D_C.H
Go to the documentation of this file.
1 #ifndef AMREX_FLUXREG_2D_C_H_
2 #define AMREX_FLUXREG_2D_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 jc = lo.y; jc <= hi.y; ++jc) {
41  for (int joff = 0; joff < ratio.y; ++joff) {
42  const int j = ratio.y*jc + joff;
43  reg(ic,jc,0,n+rcomp) += mult*flx(i,j,0,n+fcomp);
44  }
45  }
46  }
47  break;
48  }
49  default:
50  {
51  const int jc = lo.y;
52  const int j = jc*ratio.y;
53  for (int n = 0; n < ncomp; ++n) {
54  for (int ic = lo.x; ic <= hi.x; ++ic) {
55  for (int ioff = 0; ioff < ratio.x; ++ioff) {
56  const int i = ratio.x*ic + ioff;
57  reg(ic,jc,0,n+rcomp) += mult*flx(i,j,0,n+fcomp);
58  }
59  }
60  }
61  }
62  }
63 }
64 
65 
83 AMREX_GPU_HOST_DEVICE inline void
84 fluxreg_fineareaadd (Box const& bx, Array4<Real> const& reg, const int rcomp,
85  Array4<Real const> const& area,
86  Array4<Real const> const& flx, const int fcomp, const int ncomp,
87  const int dir, Dim3 const& ratio, const Real mult) noexcept
88 {
89  const auto lo = amrex::lbound(bx);
90  const auto hi = amrex::ubound(bx);
91 
92  switch (dir) {
93  case 0:
94  {
95  const int ic = lo.x;
96  const int i = ic*ratio.x;
97  for (int n = 0; n < ncomp; ++n) {
98  for (int jc = lo.y; jc <= hi.y; ++jc) {
99  for (int joff = 0; joff < ratio.y; ++joff) {
100  const int j = ratio.y*jc + joff;
101  reg(ic,jc,0,n+rcomp) += mult*area(i,j,0)
102  * flx(i,j,0,n+fcomp);
103  }
104  }
105  }
106  break;
107  }
108  default:
109  {
110  const int jc = lo.y;
111  const int j = jc*ratio.y;
112  for (int n = 0; n < ncomp; ++n) {
113  for (int ic = lo.x; ic <= hi.x; ++ic) {
114  for (int ioff = 0; ioff < ratio.x; ++ioff) {
115  const int i = ratio.x*ic + ioff;
116  reg(ic,jc,0,n+rcomp) += mult*area(i,j,0)
117  * flx(i,j,0,n+fcomp);
118  }
119  }
120  }
121  break;
122  }
123  }
124 }
125 
126 AMREX_GPU_HOST_DEVICE inline void
127 fluxreg_reflux (Box const& bx, Array4<Real> const& s, const int scomp,
128  Array4<Real const> const& f, Array4<Real const> const& v,
129  const int ncomp, const Real mult, const Orientation face) noexcept
130 {
131  const auto lo = amrex::lbound(bx);
132  const auto hi = amrex::ubound(bx);
133 
134  if (face.isLow()) {
135  const int dir = face.coordDir();
136  switch (dir) {
137  case 0:
138  {
139  for (int n = 0; n < ncomp; ++n) {
140  for (int j = lo.y; j <= hi.y; ++j) {
141  for (int i = lo.x; i <= hi.x; ++i) {
142  s(i,j,0,n+scomp) += -mult*(f(i+1,j,0,n)/v(i,j,0));
143  }
144  }
145  }
146  break;
147  }
148  default:
149  {
150  for (int n = 0; n < ncomp; ++n) {
151  for (int j = lo.y; j <= hi.y; ++j) {
152  for (int i = lo.x; i <= hi.x; ++i) {
153  s(i,j,0,n+scomp) += -mult*(f(i,j+1,0,n)/v(i,j,0));
154  }
155  }
156  }
157  break;
158  }
159  }
160  } else {
161  for (int n = 0; n < ncomp; ++n) {
162  for (int j = lo.y; j <= hi.y; ++j) {
163  for (int i = lo.x; i <= hi.x; ++i) {
164  s(i,j,0,n+scomp) += mult*(f(i,j,0,n)/v(i,j,0));
165  }
166  }
167  }
168  }
169 }
170 
171 }
172 
173 #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