1 #ifndef AMREX_MLALAP_2D_K_H_
2 #define AMREX_MLALAP_2D_K_H_
3 #include <AMReX_Config.H>
13 RT alpha, RT beta,
int ncomp) noexcept
15 const RT dhx = beta*dxinv[0]*dxinv[0];
16 const RT dhy = beta*dxinv[1]*dxinv[1];
21 for (
int n = 0; n < ncomp; ++n) {
22 for (
int j = lo.y; j <= hi.y; ++j) {
24 for (
int i = lo.x; i <= hi.x; ++i) {
25 y(i,j,0,n) = alpha*a(i,j,0,n)*
x(i,j,0,n)
26 - dhx * (
x(i-1,j,0,n) - RT(2.)*
x(i,j,0,n) +
x(i+1,j,0,n))
27 - dhy * (
x(i,j-1,0,n) - RT(2.)*
x(i,j,0,n) +
x(i,j+1,0,n));
33 template <
typename RT>
39 RT alpha, RT beta, RT dx, RT probxlo,
int ncomp) noexcept
41 const RT dhx = beta*dxinv[0]*dxinv[0];
42 const RT dhy = beta*dxinv[1]*dxinv[1];
47 for (
int n = 0; n < ncomp; ++n) {
48 for (
int j = lo.y; j <= hi.y; ++j) {
50 for (
int i = lo.x; i <= hi.x; ++i) {
51 RT rel = probxlo + i*dx;
52 RT rer = probxlo +(i+1)*dx;
53 RT rc = probxlo + (i+RT(0.5))*dx;
54 y(i,j,0,n) = alpha*a(i,j,0,n)*
x(i,j,0,n)*rc
55 - dhx * (rer*(
x(i+1,j,0,n) -
x(i ,j,0,n))
56 - rel*(
x(i ,j,0,n) -
x(i-1,j,0,n)))
57 - dhy * rc * (
x(i,j-1,0,n) - RT(2.)*
x(i,j,0,n) +
x(i,j+1,0,n));
63 template <
typename RT>
68 RT alpha, RT beta,
int ncomp) noexcept
70 const RT dhx = beta*dxinv[0]*dxinv[0];
71 const RT dhy = beta*dxinv[1]*dxinv[1];
76 for (
int n = 0; n < ncomp; ++n) {
77 for (
int j = lo.y; j <= hi.y; ++j) {
79 for (
int i = lo.x; i <= hi.x; ++i) {
80 x(i,j,0,n) /= alpha*a(i,j,0,n) + RT(2.0)*(dhx + dhy);
86 template <
typename RT>
92 RT dx, RT probxlo,
int ncomp) noexcept
94 const RT dhx = beta*dxinv[0]*dxinv[0];
95 const RT dhy = beta*dxinv[1]*dxinv[1];
100 for (
int n = 0; n < ncomp; ++n) {
101 for (
int j = lo.y; j <= hi.y; ++j) {
103 for (
int i = lo.x; i <= hi.x; ++i) {
104 RT rel = probxlo + i*dx;
105 RT rer = probxlo +(i+1)*dx;
106 RT rc = probxlo + (i+RT(0.5))*dx;
107 x(i,j,0,n) /= alpha*a(i,j,0,n)*rc
108 + dhx*(rel+rer) + dhy*(rc*RT(2.0));
114 template <
typename RT>
122 for (
int n = 0; n < ncomp; ++n) {
123 for (
int j = lo.y; j <= hi.y; ++j) {
125 for (
int i = lo.x; i <= hi.x; ++i) {
126 fx(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i-1,j,0,n));
132 template <
typename RT>
136 RT dx, RT probxlo,
int ncomp) noexcept
141 for (
int n = 0; n < ncomp; ++n) {
142 for (
int j = lo.y; j <= hi.y; ++j) {
144 for (
int i = lo.x; i <= hi.x; ++i) {
145 RT re = probxlo + i*dx;
146 fx(i,j,0,n) = -fac*re*(sol(i,j,0,n)-sol(i-1,j,0,n));
152 template <
typename RT>
160 for (
int n = 0; n < ncomp; ++n) {
161 for (
int j = lo.y; j <= hi.y; ++j) {
163 fx(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i-1,j,0,n));
165 fx(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i-1,j,0,n));
170 template <
typename RT>
174 RT dx, RT probxlo,
int ncomp) noexcept
179 for (
int n = 0; n < ncomp; ++n) {
180 for (
int j = lo.y; j <= hi.y; ++j) {
182 RT re = probxlo + i*dx;
183 fx(i,j,0,n) = -fac*re*(sol(i,j,0,n)-sol(i-1,j,0,n));
186 fx(i,j,0,n) = -fac*re*(sol(i,j,0,n)-sol(i-1,j,0,n));
191 template <
typename RT>
199 for (
int n = 0; n < ncomp; ++n) {
200 for (
int j = lo.y; j <= hi.y; ++j) {
202 for (
int i = lo.x; i <= hi.x; ++i) {
203 fy(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i,j-1,0,n));
209 template <
typename RT>
213 RT dx, RT probxlo,
int ncomp) noexcept
218 for (
int n = 0; n < ncomp; ++n) {
219 for (
int j = lo.y; j <= hi.y; ++j) {
221 for (
int i = lo.x; i <= hi.x; ++i) {
222 RT rc = probxlo + (i+RT(0.5))*dx;
223 fy(i,j,0,n) = -fac*rc*(sol(i,j,0,n)-sol(i,j-1,0,n));
229 template <
typename RT>
237 for (
int n = 0; n < ncomp; ++n) {
240 for (
int i = lo.x; i <= hi.x; ++i) {
241 fy(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i,j-1,0,n));
245 for (
int i = lo.x; i <= hi.x; ++i) {
246 fy(i,j,0,n) = -fac*(sol(i,j,0,n)-sol(i,j-1,0,n));
251 template <
typename RT>
255 RT dx, RT probxlo,
int ncomp) noexcept
260 for (
int n = 0; n < ncomp; ++n) {
263 for (
int i = lo.x; i <= hi.x; ++i) {
264 RT rc = probxlo + (i+RT(0.5))*dx;
265 fy(i,j,0,n) = -fac*rc*(sol(i,j,0,n)-sol(i,j-1,0,n));
269 for (
int i = lo.x; i <= hi.x; ++i) {
270 RT rc = probxlo + (i+RT(0.5))*dx;
271 fy(i,j,0,n) = -fac*rc*(sol(i,j,0,n)-sol(i,j-1,0,n));
276 template <
typename RT>
285 Box const& vbox,
int redblack,
int ncomp) noexcept
292 for (
int n = 0; n < ncomp; ++n) {
293 for (
int j = lo.y; j <= hi.y; ++j) {
295 for (
int i = lo.x; i <= hi.x; ++i) {
296 if ((i+j+redblack)%2 == 0) {
297 RT cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
298 ? f0(vlo.x,j,0,n) : RT(0.0);
299 RT cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
300 ? f1(i,vlo.y,0,n) : RT(0.0);
301 RT cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
302 ? f2(vhi.x,j,0,n) : RT(0.0);
303 RT cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
304 ? f3(i,vhi.y,0,n) : RT(0.0);
306 RT delta = dhx*(cf0 + cf2) + dhy*(cf1 + cf3);
308 RT gamma = alpha*a(i,j,0,n) + RT(2.0)*(dhx + dhy);
310 RT rho = dhx*(phi(i-1,j,0,n) + phi(i+1,j,0,n))
311 + dhy*(phi(i,j-1,0,n) + phi(i,j+1,0,n));
313 phi(i,j,0,n) = (rhs(i,j,0,n) + rho - phi(i,j,0,n)*delta)
321 template <
typename RT>
330 Box const& vbox,
int redblack,
331 RT dx, RT probxlo,
int ncomp) noexcept
338 for (
int n = 0; n < ncomp; ++n) {
339 for (
int j = lo.y; j <= hi.y; ++j) {
341 for (
int i = lo.x; i <= hi.x; ++i) {
342 if ((i+j+redblack)%2 == 0) {
343 RT cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
344 ? f0(vlo.x,j,0,n) : RT(0.0);
345 RT cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
346 ? f1(i,vlo.y,0,n) : RT(0.0);
347 RT cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
348 ? f2(vhi.x,j,0,n) : RT(0.0);
349 RT cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
350 ? f3(i,vhi.y,0,n) : RT(0.0);
352 RT rel = probxlo + i*dx;
353 RT rer = probxlo +(i+1)*dx;
354 RT rc = probxlo + (i+RT(0.5))*dx;
356 RT delta = dhx*(rel*cf0 + rer*cf2) + dhy*rc*(cf1 + cf3);
358 RT gamma = alpha*a(i,j,0,n)*rc + dhx*(rel+rer) + dhy*(RT(2.)*rc);
360 RT rho = dhx*(rel*phi(i-1,j,0,n) + rer*phi(i+1,j,0,n))
361 + dhy* rc*(phi(i,j-1,0,n) + phi(i,j+1,0,n));
363 phi(i,j,0,n) = (rhs(i,j,0,n) + rho - phi(i,j,0,n)*delta)
373 #if (AMREX_SPACEDIM == 2)
375 using namespace TwoD;
#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
Definition: AMReX_MLALap_2D_K.H:5
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_x(Box const &box, Array4< RT > const &fx, Array4< RT const > const &sol, RT fac, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:116
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_normalize_m(Box const &box, Array4< RT > const &x, Array4< RT const > const &a, GpuArray< RT, 2 > const &dxinv, RT alpha, RT beta, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:88
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_xface(Box const &box, Array4< RT > const &fx, Array4< RT const > const &sol, RT fac, int xlen, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:154
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_y(Box const &box, Array4< RT > const &fy, Array4< RT const > const &sol, RT fac, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:193
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_adotx(Box const &box, Array4< RT > const &y, Array4< RT const > const &x, Array4< RT const > const &a, GpuArray< RT, 2 > const &dxinv, RT alpha, RT beta, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:9
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_xface_m(Box const &box, Array4< RT > const &fx, Array4< RT const > const &sol, RT fac, int xlen, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:172
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_x_m(Box const &box, Array4< RT > const &fx, Array4< RT const > const &sol, RT fac, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:134
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_gsrb(Box const &box, Array4< RT > const &phi, Array4< RT const > const &rhs, RT alpha, RT dhx, RT dhy, Array4< RT const > const &a, Array4< RT const > const &f0, Array4< int const > const &m0, Array4< RT const > const &f1, Array4< int const > const &m1, Array4< RT const > const &f2, Array4< int const > const &m2, Array4< RT const > const &f3, Array4< int const > const &m3, Box const &vbox, int redblack, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:278
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_yface_m(Box const &box, Array4< RT > const &fy, Array4< RT const > const &sol, RT fac, int ylen, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:253
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_gsrb_m(Box const &box, Array4< RT > const &phi, Array4< RT const > const &rhs, RT alpha, RT dhx, RT dhy, Array4< RT const > const &a, Array4< RT const > const &f0, Array4< int const > const &m0, Array4< RT const > const &f1, Array4< int const > const &m1, Array4< RT const > const &f2, Array4< int const > const &m2, Array4< RT const > const &f3, Array4< int const > const &m3, Box const &vbox, int redblack, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:323
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_y_m(Box const &box, Array4< RT > const &fy, Array4< RT const > const &sol, RT fac, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:211
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_adotx_m(Box const &box, Array4< RT > const &y, Array4< RT const > const &x, Array4< RT const > const &a, GpuArray< RT, 2 > const &dxinv, RT alpha, RT beta, RT dx, RT probxlo, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:35
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_normalize(Box const &box, Array4< RT > const &x, Array4< RT const > const &a, GpuArray< RT, 2 > const &dxinv, RT alpha, RT beta, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:65
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlalap_flux_yface(Box const &box, Array4< RT > const &fy, Array4< RT const > const &sol, RT fac, int ylen, int ncomp) noexcept
Definition: AMReX_MLALap_2D_K.H:231
Definition: AMReX_Amr.cpp:49
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
Definition: AMReX_Array4.H:61
Definition: AMReX_Array.H:34