1 #ifndef AMREX_MLTENSOR_2D_K_H_
2 #define AMREX_MLTENSOR_2D_K_H_
3 #include <AMReX_Config.H>
22 0,AMREX_SPACEDIM>
const& bct,
25 0,AMREX_SPACEDIM>
const& bcl,
26 int inhomog,
int maxorder,
28 Dim3 const& dlo,
Dim3 const& dhi) noexcept
36 int const i = vlo.x-1;
37 int const j = vlo.y-1;
43 if ((x_interior && y_interior) || (x_exterior && y_exterior)) {
44 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
48 bcvalxlo, maxorder, dxinv[0], inhomog, icomp);
49 Real tmp = vel(i,j,k,icomp);
53 bcvalylo, maxorder, dxinv[1], inhomog, icomp);
54 vel(i,j,k,icomp) = 0.5_rt*(tmp+vel(i,j,k,icomp));
56 }
else if (x_interior || dlo.x == vlo.x) {
57 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
61 bcvalxlo, maxorder, dxinv[0], inhomog, icomp);
63 }
else if (y_interior || dlo.y == vlo.y) {
64 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
68 bcvalylo, maxorder, dxinv[1], inhomog, icomp);
72 }
else if (icorner == 1) {
73 int const i = vhi.x+1;
74 int const j = vlo.y-1;
80 if ((x_interior && y_interior) || (x_exterior && y_exterior)) {
81 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
85 bcvalxhi, maxorder, dxinv[0], inhomog, icomp);
86 Real tmp = vel(i,j,k,icomp);
90 bcvalylo, maxorder, dxinv[1], inhomog, icomp);
91 vel(i,j,k,icomp) = 0.5_rt*(tmp+vel(i,j,k,icomp));
93 }
else if (x_interior || dhi.x == vhi.x) {
94 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
98 bcvalxhi, maxorder, dxinv[0], inhomog, icomp);
100 }
else if (y_interior || dlo.y == vlo.y) {
101 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
105 bcvalylo, maxorder, dxinv[1], inhomog, icomp);
109 }
else if (icorner == 2) {
110 int const i = vlo.x-1;
111 int const j = vhi.y+1;
117 if ((x_interior && y_interior) || (x_exterior && y_exterior)) {
118 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
122 bcvalxlo, maxorder, dxinv[0], inhomog, icomp);
123 Real tmp = vel(i,j,k,icomp);
127 bcvalyhi, maxorder, dxinv[1], inhomog, icomp);
128 vel(i,j,k,icomp) = 0.5_rt*(tmp+vel(i,j,k,icomp));
130 }
else if (x_interior || dlo.x == vlo.x) {
131 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
135 bcvalxlo, maxorder, dxinv[0], inhomog, icomp);
137 }
else if (y_interior || dhi.y == vhi.y) {
138 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
142 bcvalyhi, maxorder, dxinv[1], inhomog, icomp);
146 }
else if (icorner == 3) {
147 int const i = vhi.x+1;
148 int const j = vhi.y+1;
154 if ((x_interior && y_interior) || (x_exterior && y_exterior)) {
155 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
159 bcvalxhi, maxorder, dxinv[0], inhomog, icomp);
160 Real tmp = vel(i,j,k,icomp);
164 bcvalyhi, maxorder, dxinv[1], inhomog, icomp);
165 vel(i,j,k,icomp) = 0.5_rt*(tmp+vel(i,j,k,icomp));
167 }
else if (x_interior || dhi.x == vhi.x) {
168 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
172 bcvalxhi, maxorder, dxinv[0], inhomog, icomp);
174 }
else if (y_interior || dhi.y == vhi.y) {
175 for (
int icomp = 0; icomp < AMREX_SPACEDIM; ++icomp) {
179 bcvalyhi, maxorder, dxinv[1], inhomog, icomp);
193 const Real dyi = dxinv[1];
196 constexpr Real twoThirds = Real(2./3.);
199 for (
int j = lo.y; j <= hi.y; ++j) {
201 for (
int i = lo.x; i <= hi.x; ++i) {
205 Real xif = kapx(i,j,0);
206 Real mun = Real(0.75)*(etax(i,j,0,0)-xif);
207 Real mut = etax(i,j,0,1);
208 fx(i,j,0,0) = -mun*(-twoThirds*divu) - xif*divu;
209 fx(i,j,0,1) = -mut*dudy;
221 const Real dxi = dxinv[0];
224 constexpr Real twoThirds = Real(2./3.);
227 for (
int j = lo.y; j <= hi.y; ++j) {
229 for (
int i = lo.x; i <= hi.x; ++i) {
233 Real xif = kapy(i,j,0);
234 Real mun = Real(0.75)*(etay(i,j,0,1)-xif);
235 Real mut = etay(i,j,0,0);
236 fy(i,j,0,0) = -mut*dvdx;
237 fy(i,j,0,1) = -mun*(-twoThirds*divu) - xif*divu;
252 0,AMREX_SPACEDIM>
const& bct,
253 Dim3 const& dlo,
Dim3 const& dhi) noexcept
255 const Real dyi = dxinv[1];
258 constexpr Real twoThirds = Real(2./3.);
263 for (
int j = lo.y; j <= hi.y; ++j) {
264 for (
int i = lo.x; i <= hi.x; ++i) {
265 Real dudy =
mltensor_dy_on_xface(i,j,k,0,vel,dyi,bvxlo,bvxhi,bct,dlo,dhi);
266 Real dvdy =
mltensor_dy_on_xface(i,j,k,1,vel,dyi,bvxlo,bvxhi,bct,dlo,dhi);
268 Real xif = kapx(i,j,0);
269 Real mun = Real(0.75)*(etax(i,j,0,0)-xif);
270 Real mut = etax(i,j,0,1);
271 fx(i,j,0,0) = -mun*(-twoThirds*divu) - xif*divu;
272 fx(i,j,0,1) = -mut*dudy;
287 0,AMREX_SPACEDIM>
const& bct,
288 Dim3 const& dlo,
Dim3 const& dhi) noexcept
290 const Real dxi = dxinv[0];
293 constexpr Real twoThirds = Real(2./3.);
296 for (
int j = lo.y; j <= hi.y; ++j) {
297 for (
int i = lo.x; i <= hi.x; ++i) {
298 Real dudx =
mltensor_dx_on_yface(i,j,k,0,vel,dxi,bvylo,bvyhi,bct,dlo,dhi);
299 Real dvdx =
mltensor_dx_on_yface(i,j,k,1,vel,dxi,bvylo,bvyhi,bct,dlo,dhi);
301 Real xif = kapy(i,j,0);
302 Real mun = Real(0.75)*(etay(i,j,0,1)-xif);
303 Real mut = etay(i,j,0,0);
304 fy(i,j,0,0) = -mut*dvdx;
305 fy(i,j,0,1) = -mun*(-twoThirds*divu) - xif*divu;
315 Real bscalar) noexcept
317 const Real dxi = bscalar * dxinv[0];
318 const Real dyi = bscalar * dxinv[1];
322 for (
int j = lo.y; j <= hi.y; ++j) {
324 for (
int i = lo.x; i <= hi.x; ++i) {
325 Ax(i,j,0,0) += dxi*(fx(i+1,j ,0,0) - fx(i,j,0,0))
326 + dyi*(fy(i ,j+1,0,0) - fy(i,j,0,0));
327 Ax(i,j,0,1) += dxi*(fx(i+1,j ,0,1) - fx(i,j,0,1))
328 + dyi*(fy(i ,j+1,0,1) - fy(i,j,0,1));
339 Real bscalar) noexcept
341 const Real dxi = bscalar * dxinv[0];
342 const Real dyi = bscalar * dxinv[1];
346 for (
int j = lo.y; j <= hi.y; ++j) {
348 for (
int i = lo.x; i <= hi.x; ++i) {
349 if (osm(i,j,0) == 0) {
353 Ax(i,j,0,0) += dxi*(fx(i+1,j ,0,0) - fx(i,j,0,0))
354 + dyi*(fy(i ,j+1,0,0) - fy(i,j,0,0));
355 Ax(i,j,0,1) += dxi*(fx(i+1,j ,0,1) - fx(i,j,0,1))
356 + dyi*(fy(i ,j+1,0,1) - fy(i,j,0,1));
367 const Real dxi = dxinv[0];
368 const Real dyi = dxinv[1];
373 for (
int j = lo.y; j <= hi.y; ++j) {
375 for (
int i = lo.x; i <= hi.x; ++i) {
376 Real dudx = (vel(i,j,0,0) - vel(i-1,j,0,0))*dxi;
377 Real dvdx = (vel(i,j,0,1) - vel(i-1,j,0,1))*dxi;
393 const Real dxi = dxinv[0];
394 const Real dyi = dxinv[1];
399 for (
int j = lo.y; j <= hi.y; ++j) {
401 for (
int i = lo.x; i <= hi.x; ++i) {
404 Real dudy = (vel(i,j,0,0) - vel(i,j-1,0,0))*dyi;
405 Real dvdy = (vel(i,j,0,1) - vel(i,j-1,0,1))*dyi;
422 0,AMREX_SPACEDIM>
const& bct,
423 Dim3 const& dlo,
Dim3 const& dhi) noexcept
425 const Real dxi = dxinv[0];
426 const Real dyi = dxinv[1];
431 for (
int j = lo.y; j <= hi.y; ++j) {
432 for (
int i = lo.x; i <= hi.x; ++i) {
433 Real dudx = (vel(i,j,0,0) - vel(i-1,j,0,0))*dxi;
434 Real dvdx = (vel(i,j,0,1) - vel(i-1,j,0,1))*dxi;
435 Real dudy =
mltensor_dy_on_xface(i,j,k,0,vel,dyi,bvxlo,bvxhi,bct,dlo,dhi);
436 Real dvdy =
mltensor_dy_on_xface(i,j,k,1,vel,dyi,bvxlo,bvxhi,bct,dlo,dhi);
453 0,AMREX_SPACEDIM>
const& bct,
454 Dim3 const& dlo,
Dim3 const& dhi) noexcept
456 const Real dxi = dxinv[0];
457 const Real dyi = dxinv[1];
462 for (
int j = lo.y; j <= hi.y; ++j) {
463 for (
int i = lo.x; i <= hi.x; ++i) {
464 Real dudx =
mltensor_dx_on_yface(i,j,k,0,vel,dxi,bvylo,bvyhi,bct,dlo,dhi);
465 Real dvdx =
mltensor_dx_on_yface(i,j,k,1,vel,dxi,bvylo,bvyhi,bct,dlo,dhi);
466 Real dudy = (vel(i,j,0,0) - vel(i,j-1,0,0))*dyi;
467 Real dvdy = (vel(i,j,0,1) - vel(i,j-1,0,1))*dyi;
#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
@ not_covered
Definition: AMReX_BndryData.H:44
@ covered
Definition: AMReX_BndryData.H:44
Maintain an identifier for boundary condition types.
Definition: AMReX_BoundCond.H:20
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int yhi() noexcept
Int value of the y-hi-face.
Definition: AMReX_Orientation.H:110
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int ylo() noexcept
Int value of the y-lo-face.
Definition: AMReX_Orientation.H:106
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xlo() noexcept
Int value of the x-lo-face.
Definition: AMReX_Orientation.H:98
@ low
Definition: AMReX_Orientation.H:34
@ high
Definition: AMReX_Orientation.H:34
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xhi() noexcept
Int value of the x-hi-face.
Definition: AMReX_Orientation.H:102
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mltensor_dx_on_yface(int i, int j, int k, int n, Array4< Real const > const &vel, Real dxi) noexcept
Definition: AMReX_MLTensor_K.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mltensor_vel_grads_fy(Box const &box, Array4< Real > const &fy, Array4< Real const > const &vel, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLTensor_2D_K.H:389
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mltensor_cross_terms_os(Box const &box, Array4< Real > const &Ax, Array4< Real const > const &fx, Array4< Real const > const &fy, Array4< int const > const &osm, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, Real bscalar) noexcept
Definition: AMReX_MLTensor_2D_K.H:334
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 void mltensor_cross_terms_fx(Box const &box, Array4< Real > const &fx, Array4< Real const > const &vel, Array4< Real const > const &etax, Array4< Real const > const &kapx, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLTensor_2D_K.H:187
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 mltensor_vel_grads_fx(Box const &box, Array4< Real > const &fx, Array4< Real const > const &vel, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLTensor_2D_K.H:363
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mltensor_cross_terms(Box const &box, Array4< Real > const &Ax, Array4< Real const > const &fx, Array4< Real const > const &fy, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, Real bscalar) noexcept
Definition: AMReX_MLTensor_2D_K.H:311
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 length(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:322
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mllinop_apply_bc_x(int side, Box const &box, int blen, Array4< T > const &phi, Array4< int const > const &mask, BoundCond bct, T bcl, Array4< T const > const &bcval, int maxorder, T dxinv, int inhomog, int icomp) noexcept
Definition: AMReX_MLLinOp_K.H:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mltensor_fill_corners(int icorner, Box const &vbox, Array4< Real > const &vel, Array4< int const > const &mxlo, Array4< int const > const &mylo, Array4< int const > const &mxhi, Array4< int const > const &myhi, Array4< Real const > const &bcvalxlo, Array4< Real const > const &bcvalylo, Array4< Real const > const &bcvalxhi, Array4< Real const > const &bcvalyhi, Array2D< BoundCond, 0, 2 *AMREX_SPACEDIM, 0, AMREX_SPACEDIM > const &bct, Array2D< Real, 0, 2 *AMREX_SPACEDIM, 0, AMREX_SPACEDIM > const &bcl, int inhomog, int maxorder, GpuArray< Real, AMREX_SPACEDIM > const &dxinv, Dim3 const &dlo, Dim3 const &dhi) noexcept
Definition: AMReX_MLTensor_2D_K.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mltensor_dy_on_xface(int i, int j, int k, int n, Array4< Real const > const &vel, Real dyi) noexcept
Definition: AMReX_MLTensor_K.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mllinop_apply_bc_y(int side, Box const &box, int blen, Array4< T > const &phi, Array4< int const > const &mask, BoundCond bct, T bcl, Array4< T const > const &bcval, int maxorder, T dyinv, int inhomog, int icomp) noexcept
Definition: AMReX_MLLinOp_K.H:119
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mltensor_cross_terms_fy(Box const &box, Array4< Real > const &fy, Array4< Real const > const &vel, Array4< Real const > const &etay, Array4< Real const > const &kapy, GpuArray< Real, AMREX_SPACEDIM > const &dxinv) noexcept
Definition: AMReX_MLTensor_2D_K.H:215
Definition: AMReX_Array.H:282
Definition: AMReX_Array4.H:61
Definition: AMReX_Dim3.H:12