Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_YAFluxRegister_2D_K.H
Go to the documentation of this file.
1#ifndef AMREX_YAFLUXREGISTER_2D_K_H_
2#define AMREX_YAFLUXREGISTER_2D_K_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_BaseFab.H>
6
7namespace amrex {
8
9template <typename T>
11void yafluxreg_crseadd (Box const& bx, Array4<T> const& d, Array4<int const> const& flag,
12 Array4<T const> const& fx, Array4<T const> const& fy,
13 T dtdx, T dtdy, int nc) noexcept
14{
15 auto const lo = amrex::lbound(bx);
16 auto const hi = amrex::ubound(bx);
17
18 for (int j = lo.y; j <= hi.y; ++j) {
19 for (int i = lo.x; i <= hi.x; ++i) {
21 {
22 if (flag(i-1,j,0) == amrex_yafluxreg_fine_cell) {
23 for (int n = 0; n < nc; ++n) {
24 d(i,j,0,n) -= dtdx*fx(i,j,0,n);
25 }
26 }
27 if (flag(i+1,j,0) == amrex_yafluxreg_fine_cell) {
28 for (int n = 0; n < nc; ++n) {
29 d(i,j,0,n) += dtdx*fx(i+1,j,0,n);
30 }
31 }
32
33 if (flag(i,j-1,0) == amrex_yafluxreg_fine_cell) {
34 for (int n = 0; n < nc; ++n) {
35 d(i,j,0,n) -= dtdy*fy(i,j,0,n);
36 }
37 }
38 if (flag(i,j+1,0) == amrex_yafluxreg_fine_cell) {
39 for (int n = 0; n < nc; ++n) {
40 d(i,j,0,n) += dtdy*fy(i,j+1,0,n);
41 }
42 }
43 }
44 }}
45}
46
47template <typename T>
49void yafluxreg_fineadd (Box const& bx, Array4<T> const& d, Array4<T const> const& f,
50 T dtdx, int nc, int dirside, Dim3 const& rr) noexcept
51{
52 const auto lo = amrex::lbound(bx);
53 const auto hi = amrex::ubound(bx);
54
55 switch (dirside) {
56 case 0 :
57 {
58 for (int n = 0; n < nc; ++n) {
59 for (int j = lo.y; j <= hi.y; ++j) {
60 const int i = lo.x;
61 const int ii = (i+1)*rr.x;
62 T* AMREX_RESTRICT dp = &(d(i,j,0,n));
63 for (int joff = 0; joff < rr.y; ++joff) {
64 const int jj = j*rr.y + joff;
65 T tmp = -dtdx*f(ii,jj,0,n);
67 }
68 }
69 }
70 break;
71 }
72 case 1 :
73 {
74 for (int n = 0; n < nc; ++n) {
75 for (int j = lo.y; j <= hi.y; ++j) {
76 const int i = lo.x;
77 const int ii = i*rr.x;
78 T* AMREX_RESTRICT dp = &(d(i,j,0,n));
79 for (int joff = 0; joff < rr.y; ++joff) {
80 const int jj = j*rr.y + joff;
81 T tmp = dtdx*f(ii,jj,0,n);
83 }
84 }
85 }
86 break;
87 }
88 case 2 :
89 {
90 for (int n = 0; n < nc; ++n) {
91 for (int i = lo.x; i <= hi.x; ++i) {
92 const int j = lo.y;
93 const int jj = (j+1)*rr.y;
94 T* AMREX_RESTRICT dp = &(d(i,j,0,n));
95 for (int ioff = 0; ioff < rr.x; ++ioff) {
96 const int ii = i*rr.x + ioff;
97 T tmp = -dtdx*f(ii,jj,0,n);
99 }
100 }
101 }
102 break;
103 }
104 default:
105 {
106 for (int n = 0; n < nc; ++n) {
107 for (int i = lo.x; i <= hi.x; ++i) {
108 const int j = lo.y;
109 const int jj = j*rr.y;
110 T* AMREX_RESTRICT dp = &(d(i,j,0,n));
111 for (int ioff = 0; ioff < rr.x; ++ioff) {
112 const int ii = i*rr.x + ioff;
113 T tmp = dtdx*f(ii,jj,0,n);
115 }
116 }
117 }
118 }
119 }
120}
121
122}
123#endif
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_RESTRICT
Definition AMReX_Extension.H:37
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
constexpr int amrex_yafluxreg_fine_cell
Definition AMReX_YAFluxRegister_K.H:8
constexpr int amrex_yafluxreg_crse_fine_boundary_cell
Definition AMReX_YAFluxRegister_K.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Add(T *const sum, T const value) noexcept
Definition AMReX_GpuAtomic.H:619
Definition AMReX_Amr.cpp:49
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 AMREX_FORCE_INLINE void yafluxreg_fineadd(Box const &bx, Array4< T > const &d, Array4< T const > const &f, T dtdx, int nc, int dirside, Dim3 const &rr) noexcept
Definition AMReX_YAFluxRegister_1D_K.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void yafluxreg_crseadd(Box const &bx, Array4< T > const &d, Array4< int const > const &flag, Array4< T const > const &fx, T dtdx, int nc) noexcept
Definition AMReX_YAFluxRegister_1D_K.H:11
integer, parameter dp
Definition AMReX_SDCquadrature.F90:8
Definition AMReX_Array4.H:61