1 #ifndef AMREX_MLPOISSON_2D_K_H_
2 #define AMREX_MLPOISSON_2D_K_H_
3 #include <AMReX_Config.H>
5 #if (AMREX_SPACEDIM == 2)
15 T dhx, T dhy) noexcept
17 y(i,j,0) = dhx * (
x(i-1,j,0) - T(2.)*
x(i,j,0) +
x(i+1,j,0))
18 + dhy * (
x(i,j-1,0) - T(2.)*
x(i,j,0) +
x(i,j+1,0));
26 T dhx, T dhy) noexcept
28 if (osm(i,j,0) == 0) {
31 y(i,j,0) = dhx * (
x(i-1,j,0) - T(2.)*
x(i,j,0) +
x(i+1,j,0))
32 + dhy * (
x(i,j-1,0) - T(2.)*
x(i,j,0) +
x(i,j+1,0));
40 T dhx, T dhy, T dx, T probxlo) noexcept
42 T rel = probxlo + i*dx;
43 T rer = probxlo +(i+1)*dx;
44 T rc = probxlo + (i+T(0.5))*dx;
45 y(i,j,0) = dhx * (rel*
x(i-1,j,0) - (rel+rer)*
x(i,j,0) + rer*
x(i+1,j,0))
46 + dhy * rc *(
x(i,j-1,0) - T(2.)*
x(i,j,0) +
x(i,j+1,0));
57 for (
int j = lo.y; j <= hi.y; ++j) {
59 for (
int i = lo.x; i <= hi.x; ++i) {
60 fx(i,j,0) = dxinv*(sol(i,j,0)-sol(i-1,j,0));
69 T dx, T probxlo) noexcept
74 for (
int j = lo.y; j <= hi.y; ++j) {
76 for (
int i = lo.x; i <= hi.x; ++i) {
77 T re = probxlo + i*dx;
78 fx(i,j,0) = dxinv*re*(sol(i,j,0)-sol(i-1,j,0));
91 for (
int j = lo.y; j <= hi.y; ++j) {
93 fx(i,j,0) = dxinv*(sol(i,j,0)-sol(i-1,j,0));
95 fx(i,j,0) = dxinv*(sol(i,j,0)-sol(i-1,j,0));
103 T dx, T probxlo) noexcept
108 for (
int j = lo.y; j <= hi.y; ++j) {
110 T re = probxlo + i*dx;
111 fx(i,j,0) = dxinv*re*(sol(i,j,0)-sol(i-1,j,0));
114 fx(i,j,0) = dxinv*re*(sol(i,j,0)-sol(i-1,j,0));
118 template <
typename T>
126 for (
int j = lo.y; j <= hi.y; ++j) {
128 for (
int i = lo.x; i <= hi.x; ++i) {
129 fy(i,j,0) = dyinv*(sol(i,j,0)-sol(i,j-1,0));
134 template <
typename T>
138 T dx, T probxlo) noexcept
143 for (
int j = lo.y; j <= hi.y; ++j) {
145 for (
int i = lo.x; i <= hi.x; ++i) {
146 T rc = probxlo + (i+T(0.5))*dx;
147 fy(i,j,0) = dyinv*rc*(sol(i,j,0)-sol(i,j-1,0));
152 template <
typename T>
162 for (
int i = lo.x; i <= hi.x; ++i) {
163 fy(i,j,0) = dyinv*(sol(i,j,0)-sol(i,j-1,0));
167 for (
int i = lo.x; i <= hi.x; ++i) {
168 fy(i,j,0) = dyinv*(sol(i,j,0)-sol(i,j-1,0));
172 template <
typename T>
176 T dx, T probxlo) noexcept
183 for (
int i = lo.x; i <= hi.x; ++i) {
184 T rc = probxlo + (i+T(0.5))*dx;
185 fy(i,j,0) = dyinv*rc*(sol(i,j,0)-sol(i,j-1,0));
189 for (
int i = lo.x; i <= hi.x; ++i) {
190 T rc = probxlo + (i+T(0.5))*dx;
191 fy(i,j,0) = dyinv*rc*(sol(i,j,0)-sol(i,j-1,0));
195 template <
typename T>
203 Box const& vbox,
int redblack) noexcept
208 T gamma = T(-2.0)*(dhx+dhy);
210 if ((i+j+redblack)%2 == 0) {
211 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
212 ? f0(vlo.x,j,0) : T(0.0);
213 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
214 ? f1(i,vlo.y,0) : T(0.0);
215 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
216 ? f2(vhi.x,j,0) : T(0.0);
217 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
218 ? f3(i,vhi.y,0) : T(0.0);
220 T g_m_d = gamma + dhx*(cf0+cf2) + dhy*(cf1+cf3);
222 T res = rhs(i,j,0) - gamma*phi(i,j,0)
223 - dhx*(phi(i-1,j,0) + phi(i+1,j,0))
224 - dhy*(phi(i,j-1,0) + phi(i,j+1,0));
226 phi(i,j,0) = phi(i,j,0) + res /g_m_d;
230 template <
typename T>
238 Box const& vbox,
int redblack) noexcept
243 T gamma = T(-2.0)*(dhx+dhy);
245 if ((i+j+redblack)%2 == 0) {
246 if (osm(i,j,0) == 0) {
249 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
250 ? f0(vlo.x,j,0) : T(0.0);
251 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
252 ? f1(i,vlo.y,0) : T(0.0);
253 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
254 ? f2(vhi.x,j,0) : T(0.0);
255 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
256 ? f3(i,vhi.y,0) : T(0.0);
258 T g_m_d = gamma + dhx*(cf0+cf2) + dhy*(cf1+cf3);
260 T res = rhs(i,j,0) - gamma*phi(i,j,0)
261 - dhx*(phi(i-1,j,0) + phi(i+1,j,0))
262 - dhy*(phi(i,j-1,0) + phi(i,j+1,0));
264 phi(i,j,0) = phi(i,j,0) + res /g_m_d;
269 template <
typename T>
277 Box const& vbox,
int redblack, T dx, T probxlo) noexcept
282 if ((i+j+redblack)%2 == 0) {
283 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
284 ? f0(vlo.x,j,0) : T(0.0);
285 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
286 ? f1(i,vlo.y,0) : T(0.0);
287 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
288 ? f2(vhi.x,j,0) : T(0.0);
289 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
290 ? f3(i,vhi.y,0) : T(0.0);
292 T rel = probxlo + i*dx;
293 T rer = probxlo +(i+1)*dx;
294 T rc = probxlo + (i+T(0.5))*dx;
296 T gamma = -dhx*(rel+rer) - T(2.0)*dhy*rc;
298 T g_m_d = gamma + dhx*(rel*cf0+rer*cf2) + dhy*rc*(cf1+cf3);
300 T res = rhs(i,j,0) - gamma*phi(i,j,0)
301 - dhx*(rel*phi(i-1,j,0) + rer*phi(i+1,j,0))
302 - dhy*rc *(phi(i,j-1,0) + phi(i,j+1,0));
304 phi(i,j,0) = phi(i,j,0) + res /g_m_d;
308 template <
typename T>
316 Box const& vbox) noexcept
321 T gamma = T(-2.0)*(dhx+dhy);
323 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
324 ? f0(vlo.x,j,0) : T(0.0);
325 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
326 ? f1(i,vlo.y,0) : T(0.0);
327 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
328 ? f2(vhi.x,j,0) : T(0.0);
329 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
330 ? f3(i,vhi.y,0) : T(0.0);
332 T g_m_d = gamma + dhx*(cf0+cf2) + dhy*(cf1+cf3);
334 phi(i,j,0) += T(2.0/3.0) * (rhs(i,j,0) - Ax(i,j,0)) / g_m_d;
337 template <
typename T>
346 Box const& vbox) noexcept
351 T gamma = T(-2.0)*(dhx+dhy);
353 if (osm(i,j,0) == 0) {
356 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
357 ? f0(vlo.x,j,0) : T(0.0);
358 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
359 ? f1(i,vlo.y,0) : T(0.0);
360 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
361 ? f2(vhi.x,j,0) : T(0.0);
362 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
363 ? f3(i,vhi.y,0) : T(0.0);
365 T g_m_d = gamma + dhx*(cf0+cf2) + dhy*(cf1+cf3);
367 phi(i,j,0) += T(2.0/3.0) * (rhs(i,j,0) - Ax(i,j,0)) / g_m_d;
371 template <
typename T>
379 Box const& vbox, T dx, T probxlo) noexcept
384 T cf0 = (i == vlo.x && m0(vlo.x-1,j,0) > 0)
385 ? f0(vlo.x,j,0) : T(0.0);
386 T cf1 = (j == vlo.y && m1(i,vlo.y-1,0) > 0)
387 ? f1(i,vlo.y,0) : T(0.0);
388 T cf2 = (i == vhi.x && m2(vhi.x+1,j,0) > 0)
389 ? f2(vhi.x,j,0) : T(0.0);
390 T cf3 = (j == vhi.y && m3(i,vhi.y+1,0) > 0)
391 ? f3(i,vhi.y,0) : T(0.0);
393 T rel = probxlo + i*dx;
394 T rer = probxlo +(i+1)*dx;
395 T rc = probxlo + (i+T(0.5))*dx;
397 T gamma = -dhx*(rel+rer) - T(2.0)*dhy*rc;
399 T g_m_d = gamma + dhx*(rel*cf0+rer*cf2) + dhy*rc*(cf1+cf3);
401 phi(i,j,0) += T(2.0/3.0) * (rhs(i,j,0) - Ax(i,j,0)) / g_m_d;
404 template <
typename T>
407 T dhx, T dhy, T dx, T probxlo) noexcept
409 T rel = probxlo + i*dx;
410 T rer = probxlo +(i+1)*dx;
411 T rc = probxlo + (i+T(0.5))*dx;
412 x(i,j,0) /= (-dhx*(rel+rer) - dhy*rc*T(2.0));
#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 mlpoisson_jacobi(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< T const > const &Ax, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox) noexcept
Definition: AMReX_MLPoisson_2D_K.H:310
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_xface_m(Box const &box, Array4< T > const &fx, Array4< T const > const &sol, T dxinv, int xlen, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:101
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_yface(Box const &box, Array4< T > const &fy, Array4< T const > const &sol, T dyinv, int ylen) noexcept
Definition: AMReX_MLPoisson_2D_K.H:154
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_jacobi_os(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< T const > const &Ax, Array4< int const > const &osm, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox) noexcept
Definition: AMReX_MLPoisson_2D_K.H:339
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx(int i, int j, Array4< T > const &y, Array4< T const > const &x, T dhx, T dhy) noexcept
Definition: AMReX_MLPoisson_2D_K.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_yface_m(Box const &box, Array4< T > const &fy, Array4< T const > const &sol, T dyinv, int ylen, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:174
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx_os(int i, int j, Array4< T > const &y, Array4< T const > const &x, Array4< int const > const &osm, T dhx, T dhy) noexcept
Definition: AMReX_MLPoisson_2D_K.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_y(Box const &box, Array4< T > const &fy, Array4< T const > const &sol, T dyinv) noexcept
Definition: AMReX_MLPoisson_2D_K.H:120
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_normalize(int i, int j, int, Array4< T > const &x, T dhx, T dhy, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:406
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_xface(Box const &box, Array4< T > const &fx, Array4< T const > const &sol, T dxinv, int xlen) noexcept
Definition: AMReX_MLPoisson_2D_K.H:85
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_y_m(Box const &box, Array4< T > const &fy, Array4< T const > const &sol, T dyinv, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:136
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_gsrb(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox, int redblack) noexcept
Definition: AMReX_MLPoisson_2D_K.H:197
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_x_m(Box const &box, Array4< T > const &fx, Array4< T const > const &sol, T dxinv, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:67
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_gsrb_os(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< int const > const &osm, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox, int redblack) noexcept
Definition: AMReX_MLPoisson_2D_K.H:232
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_gsrb_m(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox, int redblack, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:271
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_jacobi_m(int i, int j, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< T const > const &Ax, T dhx, T dhy, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Array4< T const > const &f2, Array4< int const > const &m2, Array4< T const > const &f3, Array4< int const > const &m3, Box const &vbox, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:373
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx_m(int i, int j, Array4< T > const &y, Array4< T const > const &x, T dhx, T dhy, T dx, T probxlo) noexcept
Definition: AMReX_MLPoisson_2D_K.H:38
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_x(Box const &box, Array4< T > const &fx, Array4< T const > const &sol, T dxinv) noexcept
Definition: AMReX_MLPoisson_2D_K.H:51
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