Block-Structured AMR Software Framework
AMReX_MLEBNodeFDLap_K.H
Go to the documentation of this file.
1 #ifndef AMREX_MLEBNODEFDLAP_K_H_
2 #define AMREX_MLEBNODEFDLAP_K_H_
3 #include <AMReX_Config.H>
4 
6 #include <AMReX_LO_BCTYPES.H>
7 
8 #if (AMREX_SPACEDIM == 1)
10 #elif (AMREX_SPACEDIM == 2)
12 #else
14 #endif
15 
16 namespace amrex {
17 
18 template <typename F>
20 void mlebndfdlap_grad_x_doit (int i, int j, int k, Array4<Real> const& px,
21  Array4<Real const> const& p, Array4<int const> const& dmsk,
22  Array4<Real const> const& ecx, F const& phieb, Real dxi)
23 {
24  if (dmsk(i,j,k) >= 0 && dmsk(i+1,j,k) >= 0) {
25  px(i,j,k) = dxi * (p(i+1,j,k) - p(i,j,k));
26  } else if (dmsk(i,j,k) < 0 && dmsk(i+1,j,k) < 0) {
27  px(i,j,k) = Real(0.0);
28  } else if (dmsk(i,j,k) < 0) {
29  px(i,j,k) = dxi * (p(i+1,j,k) - phieb(i,j,k)) / (Real(1.0) - Real(2.0) * ecx(i,j,k));
30  } else { //
31  px(i,j,k) = dxi * (phieb(i+1,j,k) - p(i,j,k)) / (Real(1.0) + Real(2.0) * ecx(i,j,k));
32  }
33 }
34 
35 template <typename F>
37 void mlebndfdlap_grad_y_doit (int i, int j, int k, Array4<Real> const& py,
38  Array4<Real const> const& p, Array4<int const> const& dmsk,
39  Array4<Real const> const& ecy, F const& phieb, Real dyi)
40 {
41  if (dmsk(i,j,k) >= 0 && dmsk(i,j+1,k) >= 0) {
42  py(i,j,k) = dyi * (p(i,j+1,k) - p(i,j,k));
43  } else if (dmsk(i,j,k) < 0 && dmsk(i,j+1,k) < 0) {
44  py(i,j,k) = Real(0.0);
45  } else if (dmsk(i,j,k) < 0) {
46  py(i,j,k) = dyi * (p(i,j+1,k) - phieb(i,j,k)) / (Real(1.0) - Real(2.0) * ecy(i,j,k));
47  } else { //
48  py(i,j,k) = dyi * (phieb(i,j+1,k) - p(i,j,k)) / (Real(1.0) + Real(2.0) * ecy(i,j,k));
49  }
50 }
51 
52 #if (AMREX_SPACEDIM > 2)
53 template <typename F>
55 void mlebndfdlap_grad_z_doit (int i, int j, int k, Array4<Real> const& pz,
56  Array4<Real const> const& p, Array4<int const> const& dmsk,
57  Array4<Real const> const& ecz, F const& phieb, Real dzi)
58 {
59  if (dmsk(i,j,k) >= 0 && dmsk(i,j,k+1) >= 0) {
60  pz(i,j,k) = dzi * (p(i,j,k+1) - p(i,j,k));
61  } else if (dmsk(i,j,k) < 0 && dmsk(i,j,k+1) < 0) {
62  pz(i,j,k) = Real(0.0);
63  } else if (dmsk(i,j,k) < 0) {
64  pz(i,j,k) = dzi * (p(i,j,k+1) - phieb(i,j,k)) / (Real(1.0) - Real(2.0) * ecz(i,j,k));
65  } else { //
66  pz(i,j,k) = dzi * (phieb(i,j,k+1) - p(i,j,k)) / (Real(1.0) + Real(2.0) * ecz(i,j,k));
67  }
68 }
69 #endif
70 
72 void mlebndfdlap_grad_x (Box const& b, Array4<Real> const& px, Array4<Real const> const& p,
73  Array4<int const> const& dmsk, Array4<Real const> const& ecx,
74  Real phieb, Real dxi)
75 {
76  AMREX_LOOP_3D(b, i, j, k,
77  {
78  mlebndfdlap_grad_x_doit(i,j,k, px, p, dmsk, ecx,
79  [=] (int, int, int) -> Real { return phieb; },
80  dxi);
81  });
82 }
83 
85 void mlebndfdlap_grad_x (Box const& b, Array4<Real> const& px, Array4<Real const> const& p,
86  Array4<int const> const& dmsk, Array4<Real const> const& ecx,
87  Array4<Real const> const& phieb, Real dxi)
88 {
89  AMREX_LOOP_3D(b, i, j, k,
90  {
91  mlebndfdlap_grad_x_doit(i,j,k, px, p, dmsk, ecx,
92  [=] (int i1, int i2, int i3) -> Real { return phieb(i1,i2,i3); },
93  dxi);
94  });
95 }
96 
98 void mlebndfdlap_grad_y (Box const& b, Array4<Real> const& py, Array4<Real const> const& p,
99  Array4<int const> const& dmsk, Array4<Real const> const& ecy,
100  Real phieb, Real dyi)
101 {
102  AMREX_LOOP_3D(b, i, j, k,
103  {
104  mlebndfdlap_grad_y_doit(i,j,k, py, p, dmsk, ecy,
105  [=] (int, int, int) -> Real { return phieb; },
106  dyi);
107  });
108 }
109 
111 void mlebndfdlap_grad_y (Box const& b, Array4<Real> const& py, Array4<Real const> const& p,
112  Array4<int const> const& dmsk, Array4<Real const> const& ecy,
113  Array4<Real const> const& phieb, Real dyi)
114 {
115  AMREX_LOOP_3D(b, i, j, k,
116  {
117  mlebndfdlap_grad_y_doit(i,j,k, py, p, dmsk, ecy,
118  [=] (int i1, int i2, int i3) -> Real { return phieb(i1,i2,i3); },
119  dyi);
120  });
121 }
122 
123 #if (AMREX_SPACEDIM > 2)
124 
126 void mlebndfdlap_grad_z (Box const& b, Array4<Real> const& pz, Array4<Real const> const& p,
127  Array4<int const> const& dmsk, Array4<Real const> const& ecz,
128  Real phieb, Real dzi)
129 {
130  AMREX_LOOP_3D(b, i, j, k,
131  {
132  mlebndfdlap_grad_z_doit(i,j,k, pz, p, dmsk, ecz,
133  [=] (int, int, int) -> Real { return phieb; },
134  dzi);
135  });
136 }
137 
139 void mlebndfdlap_grad_z (Box const& b, Array4<Real> const& pz, Array4<Real const> const& p,
140  Array4<int const> const& dmsk, Array4<Real const> const& ecz,
141  Array4<Real const> const& phieb, Real dzi)
142 {
143  AMREX_LOOP_3D(b, i, j, k,
144  {
145  mlebndfdlap_grad_z_doit(i,j,k, pz, p, dmsk, ecz,
146  [=] (int i1, int i2, int i3) -> Real { return phieb(i1,i2,i3); },
147  dzi);
148  });
149 }
150 
151 #endif
152 
154 void mlebndfdlap_grad_x (Box const& b, Array4<Real> const& px, Array4<Real const> const& p,
155  Real dxi)
156 {
157  AMREX_LOOP_3D(b, i, j, k,
158  {
159  px(i,j,k) = dxi * (p(i+1,j,k) - p(i,j,k));
160  });
161 }
162 
163 #if (AMREX_SPACEDIM > 1)
165 void mlebndfdlap_grad_y (Box const& b, Array4<Real> const& py, Array4<Real const> const& p,
166  Real dyi)
167 {
168  AMREX_LOOP_3D(b, i, j, k,
169  {
170  py(i,j,k) = dyi * (p(i,j+1,k) - p(i,j,k));
171  });
172 }
173 #endif
174 
175 #if (AMREX_SPACEDIM > 2)
177 void mlebndfdlap_grad_z (Box const& b, Array4<Real> const& pz, Array4<Real const> const& p,
178  Real dzi)
179 {
180  AMREX_LOOP_3D(b, i, j, k,
181  {
182  pz(i,j,k) = dzi * (p(i,j,k+1) - p(i,j,k));
183  });
184 }
185 #endif
186 
187 }
188 
189 #endif
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_LOOP_3D(bx, i, j, k, block)
Definition: AMReX_Loop.nolint.H:4
Definition: AMReX_Amr.cpp:49
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlebndfdlap_grad_x(Box const &b, Array4< Real > const &px, Array4< Real const > const &p, Array4< int const > const &dmsk, Array4< Real const > const &ecx, Real phieb, Real dxi)
Definition: AMReX_MLEBNodeFDLap_K.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlebndfdlap_grad_y_doit(int i, int j, int k, Array4< Real > const &py, Array4< Real const > const &p, Array4< int const > const &dmsk, Array4< Real const > const &ecy, F const &phieb, Real dyi)
Definition: AMReX_MLEBNodeFDLap_K.H:37
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlebndfdlap_grad_x_doit(int i, int j, int k, Array4< Real > const &px, Array4< Real const > const &p, Array4< int const > const &dmsk, Array4< Real const > const &ecx, F const &phieb, Real dxi)
Definition: AMReX_MLEBNodeFDLap_K.H:20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlebndfdlap_grad_y(Box const &b, Array4< Real > const &py, Array4< Real const > const &p, Array4< int const > const &dmsk, Array4< Real const > const &ecy, Real phieb, Real dyi)
Definition: AMReX_MLEBNodeFDLap_K.H:98
Definition: AMReX_Array4.H:61