1 #ifndef AMREX_MLPOISSON_3D_K_H_
2 #define AMREX_MLPOISSON_3D_K_H_
3 #include <AMReX_Config.H>
11 T dhx, T dhy, T dhz) noexcept
13 y(i,j,k) = dhx * (
x(i-1,j,k) - T(2.0)*
x(i,j,k) +
x(i+1,j,k))
14 + dhy * (
x(i,j-1,k) - T(2.0)*
x(i,j,k) +
x(i,j+1,k))
15 + dhz * (
x(i,j,k-1) - T(2.0)*
x(i,j,k) +
x(i,j,k+1));
23 T dhx, T dhy, T dhz) noexcept
25 if (osm(i,j,k) == 0) {
28 y(i,j,k) = dhx * (
x(i-1,j,k) - T(2.0)*
x(i,j,k) +
x(i+1,j,k))
29 + dhy * (
x(i,j-1,k) - T(2.0)*
x(i,j,k) +
x(i,j+1,k))
30 + dhz * (
x(i,j,k-1) - T(2.0)*
x(i,j,k) +
x(i,j,k+1));
37 Array4<T const>
const& sol, T dxinv) noexcept
42 for (
int k = lo.z; k <= hi.z; ++k) {
43 for (
int j = lo.y; j <= hi.y; ++j) {
45 for (
int i = lo.x; i <= hi.x; ++i) {
46 fx(i,j,k) = dxinv*(sol(i,j,k)-sol(i-1,j,k));
55 Array4<T const>
const& sol, T dxinv,
int xlen) noexcept
60 for (
int k = lo.z; k <= hi.z; ++k) {
61 for (
int j = lo.y; j <= hi.y; ++j) {
63 fx(i,j,k) = dxinv*(sol(i,j,k)-sol(i-1,j,k));
65 fx(i,j,k) = dxinv*(sol(i,j,k)-sol(i-1,j,k));
78 for (
int k = lo.z; k <= hi.z; ++k) {
79 for (
int j = lo.y; j <= hi.y; ++j) {
81 for (
int i = lo.x; i <= hi.x; ++i) {
82 fy(i,j,k) = dyinv*(sol(i,j,k)-sol(i,j-1,k));
96 for (
int k = lo.z; k <= hi.z; ++k) {
99 for (
int i = lo.x; i <= hi.x; ++i) {
100 fy(i,j,k) = dyinv*(sol(i,j,k)-sol(i,j-1,k));
104 for (
int i = lo.x; i <= hi.x; ++i) {
105 fy(i,j,k) = dyinv*(sol(i,j,k)-sol(i,j-1,k));
110 template <
typename T>
118 for (
int k = lo.z; k <= hi.z; ++k) {
119 for (
int j = lo.y; j <= hi.y; ++j) {
121 for (
int i = lo.x; i <= hi.x; ++i) {
122 fz(i,j,k) = dzinv*(sol(i,j,k)-sol(i,j,k-1));
128 template <
typename T>
137 for (
int j = lo.y; j <= hi.y; ++j) {
139 for (
int i = lo.x; i <= hi.x; ++i) {
140 fz(i,j,k) = dzinv*(sol(i,j,k)-sol(i,j,k-1));
145 for (
int j = lo.y; j <= hi.y; ++j) {
147 for (
int i = lo.x; i <= hi.x; ++i) {
148 fz(i,j,k) = dzinv*(sol(i,j,k)-sol(i,j,k-1));
153 template <
typename T>
164 Box const& vbox,
int redblack) noexcept
169 constexpr T omega = T(1.15);
171 const T gamma = T(-2.)*(dhx+dhy+dhz);
173 if ((i+j+k+redblack)%2 == 0) {
174 T cf0 = (i == vlo.x && m0(vlo.x-1,j,k) > 0)
175 ? f0(vlo.x,j,k) : T(0.0);
176 T cf1 = (j == vlo.y && m1(i,vlo.y-1,k) > 0)
177 ? f1(i,vlo.y,k) : T(0.0);
178 T cf2 = (k == vlo.z && m2(i,j,vlo.z-1) > 0)
179 ? f2(i,j,vlo.z) : T(0.0);
180 T cf3 = (i == vhi.x && m3(vhi.x+1,j,k) > 0)
181 ? f3(vhi.x,j,k) : T(0.0);
182 T cf4 = (j == vhi.y && m4(i,vhi.y+1,k) > 0)
183 ? f4(i,vhi.y,k) : T(0.0);
184 T cf5 = (k == vhi.z && m5(i,j,vhi.z+1) > 0)
185 ? f5(i,j,vhi.z) : T(0.0);
187 T g_m_d = gamma + dhx*(cf0+cf3) + dhy*(cf1+cf4) + dhz*(cf2+cf5);
189 T res = rhs(i,j,k) - gamma*phi(i,j,k)
190 - dhx*(phi(i-1,j,k) + phi(i+1,j,k))
191 - dhy*(phi(i,j-1,k) + phi(i,j+1,k))
192 - dhz*(phi(i,j,k-1) + phi(i,j,k+1));
194 phi(i,j,k) = phi(i,j,k) + omega/g_m_d * res;
198 template <
typename T>
210 Box const& vbox,
int redblack) noexcept
215 constexpr T omega = T(1.15);
217 const T gamma = T(-2.)*(dhx+dhy+dhz);
219 if ((i+j+k+redblack)%2 == 0) {
220 if (osm(i,j,k) == 0) {
223 T cf0 = (i == vlo.x && m0(vlo.x-1,j,k) > 0)
224 ? f0(vlo.x,j,k) : T(0.0);
225 T cf1 = (j == vlo.y && m1(i,vlo.y-1,k) > 0)
226 ? f1(i,vlo.y,k) : T(0.0);
227 T cf2 = (k == vlo.z && m2(i,j,vlo.z-1) > 0)
228 ? f2(i,j,vlo.z) : T(0.0);
229 T cf3 = (i == vhi.x && m3(vhi.x+1,j,k) > 0)
230 ? f3(vhi.x,j,k) : T(0.0);
231 T cf4 = (j == vhi.y && m4(i,vhi.y+1,k) > 0)
232 ? f4(i,vhi.y,k) : T(0.0);
233 T cf5 = (k == vhi.z && m5(i,j,vhi.z+1) > 0)
234 ? f5(i,j,vhi.z) : T(0.0);
236 T g_m_d = gamma + dhx*(cf0+cf3) + dhy*(cf1+cf4) + dhz*(cf2+cf5);
238 T res = rhs(i,j,k) - gamma*phi(i,j,k)
239 - dhx*(phi(i-1,j,k) + phi(i+1,j,k))
240 - dhy*(phi(i,j-1,k) + phi(i,j+1,k))
241 - dhz*(phi(i,j,k-1) + phi(i,j,k+1));
243 phi(i,j,k) = phi(i,j,k) + omega/g_m_d * res;
248 template <
typename T>
259 Box const& vbox) noexcept
264 const T gamma = T(-2.)*(dhx+dhy+dhz);
266 T cf0 = (i == vlo.x && m0(vlo.x-1,j,k) > 0)
267 ? f0(vlo.x,j,k) : T(0.0);
268 T cf1 = (j == vlo.y && m1(i,vlo.y-1,k) > 0)
269 ? f1(i,vlo.y,k) : T(0.0);
270 T cf2 = (k == vlo.z && m2(i,j,vlo.z-1) > 0)
271 ? f2(i,j,vlo.z) : T(0.0);
272 T cf3 = (i == vhi.x && m3(vhi.x+1,j,k) > 0)
273 ? f3(vhi.x,j,k) : T(0.0);
274 T cf4 = (j == vhi.y && m4(i,vhi.y+1,k) > 0)
275 ? f4(i,vhi.y,k) : T(0.0);
276 T cf5 = (k == vhi.z && m5(i,j,vhi.z+1) > 0)
277 ? f5(i,j,vhi.z) : T(0.0);
279 T g_m_d = gamma + dhx*(cf0+cf3) + dhy*(cf1+cf4) + dhz*(cf2+cf5);
281 phi(i,j,k) += T(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k)) / g_m_d;
284 template <
typename T>
297 Box const& vbox) noexcept
302 const T gamma = T(-2.)*(dhx+dhy+dhz);
304 if (osm(i,j,k) == 0) {
307 T cf0 = (i == vlo.x && m0(vlo.x-1,j,k) > 0)
308 ? f0(vlo.x,j,k) : T(0.0);
309 T cf1 = (j == vlo.y && m1(i,vlo.y-1,k) > 0)
310 ? f1(i,vlo.y,k) : T(0.0);
311 T cf2 = (k == vlo.z && m2(i,j,vlo.z-1) > 0)
312 ? f2(i,j,vlo.z) : T(0.0);
313 T cf3 = (i == vhi.x && m3(vhi.x+1,j,k) > 0)
314 ? f3(vhi.x,j,k) : T(0.0);
315 T cf4 = (j == vhi.y && m4(i,vhi.y+1,k) > 0)
316 ? f4(i,vhi.y,k) : T(0.0);
317 T cf5 = (k == vhi.z && m5(i,j,vhi.z+1) > 0)
318 ? f5(i,j,vhi.z) : T(0.0);
320 T g_m_d = gamma + dhx*(cf0+cf3) + dhy*(cf1+cf4) + dhz*(cf2+cf5);
322 phi(i,j,k) += T(2.0/3.0) * (rhs(i,j,k) - Ax(i,j,k)) / g_m_d;
#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_Amr.cpp:49
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_3D_K.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_jacobi(int i, int, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< T const > const &Ax, T dhx, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Box const &vbox) noexcept
Definition: AMReX_MLPoisson_1D_K.H:193
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
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_1D_K.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx(int i, Array4< T > const &y, Array4< T const > const &x, T dhx) noexcept
Definition: AMReX_MLPoisson_1D_K.H:9
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_3D_K.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_jacobi_os(int i, int, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< T const > const &Ax, Array4< int const > const &osm, T dhx, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Box const &vbox) noexcept
Definition: AMReX_MLPoisson_1D_K.H:216
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_gsrb(int i, int, int, Array4< T > const &phi, Array4< T const > const &rhs, T dhx, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Box const &vbox, int redblack) noexcept
Definition: AMReX_MLPoisson_1D_K.H:102
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 mlpoisson_flux_xface(Box const &box, Array4< T > const &fx, Array4< T const > const &sol, T dxinv, int xlen) noexcept
Definition: AMReX_MLPoisson_1D_K.H:73
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_gsrb_os(int i, int, int, Array4< T > const &phi, Array4< T const > const &rhs, Array4< int const > const &osm, T dhx, Array4< T const > const &f0, Array4< int const > const &m0, Array4< T const > const &f1, Array4< int const > const &m1, Box const &vbox, int redblack) noexcept
Definition: AMReX_MLPoisson_1D_K.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_zface(Box const &box, Array4< T > const &fz, Array4< T const > const &sol, T dzinv, int zlen) noexcept
Definition: AMReX_MLPoisson_3D_K.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx_os(int i, Array4< T > const &y, Array4< T const > const &x, Array4< int const > const &osm, T dhx) noexcept
Definition: AMReX_MLPoisson_1D_K.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_flux_z(Box const &box, Array4< T > const &fz, Array4< T const > const &sol, T dzinv) noexcept
Definition: AMReX_MLPoisson_3D_K.H:112
Definition: AMReX_Array4.H:61