AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
 
Loading...
Searching...
No Matches
hydro_ebgodunov_bcs_K.H
Go to the documentation of this file.
1/**
2 * \file hydro_ebgodunov_K.H
3 *
4 * \addtogroup EBGodunov
5 * @{
6 */
7
8#ifndef HYDRO_EBGODUNOV_K_H
9#define HYDRO_EBGODUNOV_K_H
10
11#include <AMReX_Gpu.H>
12#include <AMReX_BCRec.H>
13#include <AMReX_BC_TYPES.H>
14#include <AMReX_Array.H>
15#include <iomanip>
16#include <hydro_constants.H>
17
18/* This header file contains the inlined __host__ __device__ functions required
19 for setting BCs for computing the advective velocity and transverse terms in
20 3D EBGodunov ExtrapVel.
21*/
22
23namespace EBGodunovBC {
24
26void SetXBCs (const int i, const int j, const int k, const int n,
28 amrex::Real &lo, amrex::Real &hi,
29 amrex::Real velm, amrex::Real velp,
30 const int bclo, const int bchi,
31 const int domlo, const int domhi,
32 const bool is_velocity )
33{
34 using namespace amrex;
35
36
37 // Low X
38 if (i <= domlo)
39 {
40 if ( (bclo == BCType::direction_dependent) && is_velocity &&
41 (n == XVEL) && (s(domlo-1,j,k,n) >= amrex::Real(0.0)) )
42 {
43 lo = s(domlo-1, j, k, n);
44 hi = s(domlo-1, j, k, n);
45 }
46 else if ( bclo == BCType::ext_dir ||
47 (bclo == BCType::direction_dependent && velp >= amrex::Real(0.0)) )
48 {
49 lo = s(domlo-1,j,k,n);
50 // For turbulent inflow, there are times when the inflow face
51 // may have a predicted outflowing velocity. Here, we preserve
52 // the normal component of the Dirichlet BC, but allow the
53 // tangential components to transport values from the interior.
54 if( n == XVEL && is_velocity ) hi=lo;
55 }
56 else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
57 (bclo == BCType::direction_dependent && velp < amrex::Real(0.0)) )
58 {
59 lo = hi;
60 } else if (bclo == BCType::reflect_even)
61 {
62 // Only act on the domain face itself. Beyond the face we leave the
63 // states unchanged, which is what the non-EB versions in
64 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
65 // out of the same arrays that hold the upwinded intermediate edge
66 // states: the code reuses the space holding Imx (which supplies hi),
67 // so with GPUs it would be undefined which values are seen here.
68 // Only 3D ever needs to set the BC beyond the domain face.
69 if ( i == domlo ) {
70 lo = hi;
71 }
72 }
73 else if (bclo == BCType::reflect_odd)
74 {
75 if ( i == domlo ) {
76 hi = Real(0.);
77 lo = Real(0.);
78 }
79 }
80 }
81 // High X
82 else if (i > domhi)
83 {
84 if ( (bchi == BCType::direction_dependent) && is_velocity &&
85 (n == XVEL) && (s(domhi+1,j,k,n) <= amrex::Real(0.0)) )
86 {
87 hi = s(domhi+1, j, k, n);
88 lo = s(domhi+1, j, k, n);
89 }
90 else if ( (bchi == BCType::ext_dir) ||
91 (bchi == BCType::direction_dependent && velm <= amrex::Real(0.0)) )
92 {
93 hi = s(domhi+1,j,k,n) ;
94 if( n ==XVEL && is_velocity ) lo=hi;
95 }
96 else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
97 (bchi== BCType::direction_dependent && velm > amrex::Real(0.0)) )
98 {
99 hi = lo;
100 }
101 else if (bchi == BCType::reflect_even)
102 {
103 // Only act on the domain face itself. Beyond the face we leave the
104 // states unchanged, which is what the non-EB versions in
105 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
106 // out of the same arrays that hold the upwinded intermediate edge
107 // states: the code reuses the space holding Imx (which supplies hi),
108 // so with GPUs it would be undefined which values are seen here.
109 if ( i == domhi+1 ) {
110 hi = lo;
111 }
112 }
113 else if (bchi == BCType::reflect_odd)
114 {
115 if ( i == domhi+1 ) {
116 hi = Real(0.);
117 lo = Real(0.);
118 }
119 }
120 }
121 else
122 return;
123}
124
126void SetYBCs (const int i, const int j, const int k, const int n,
128 amrex::Real &lo, amrex::Real &hi,
129 amrex::Real velm, amrex::Real velp,
130 const int bclo, const int bchi,
131 const int domlo, const int domhi,
132 const bool is_velocity )
133{
134 using namespace amrex;
135
136
137 // Low Y
138 if (j <= domlo)
139 {
140 if ( (bclo == BCType::direction_dependent) && is_velocity &&
141 (n == YVEL) && (s(i,domlo-1,k,n) >= amrex::Real(0.0)) )
142 {
143 lo = s(i, domlo-1, k, n);
144 hi = s(i, domlo-1, k, n);
145 }
146 else if ( bclo == BCType::ext_dir ||
147 (bclo == BCType::direction_dependent && velp >= amrex::Real(0.0)) )
148 {
149 lo = s(i,domlo-1,k,n);
150 if ( n == YVEL && is_velocity ) hi = lo;
151 }
152 else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
153 (bclo == BCType::direction_dependent && velp < amrex::Real(0.0)) )
154 {
155 lo = hi;
156 }
157 else if (bclo == BCType::reflect_even)
158 {
159 // Only act on the domain face itself. Beyond the face we leave the
160 // states unchanged, which is what the non-EB versions in
161 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
162 // out of the same arrays that hold the upwinded intermediate edge
163 // states: the code reuses the space holding Imx (which supplies hi),
164 // so with GPUs it would be undefined which values are seen here.
165 if ( j == domlo ) {
166 lo = hi;
167 }
168 }
169 else if(bclo == BCType::reflect_odd)
170 {
171 if ( j == domlo ) {
172 hi = Real(0.);
173 lo = Real(0.);
174 }
175 }
176 }
177 // High Y
178 else if (j > domhi)
179 {
180 if ( (bchi == BCType::direction_dependent) && is_velocity &&
181 (n == YVEL) && (s(i,domhi+1,k,n) <= amrex::Real(0.0)) )
182 {
183 hi = s(i, domhi+1, k, n);
184 lo = s(i, domhi+1, k, n);
185 }
186 else if ( (bchi == BCType::ext_dir) ||
187 (bchi == BCType::direction_dependent && velm <= amrex::Real(0.0)) )
188 {
189 hi = s(i,domhi+1,k,n);
190 if( n == YVEL && is_velocity ) lo = hi ;
191 }
192 else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
193 (bchi== BCType::direction_dependent && velm > amrex::Real(0.0)) )
194 {
195 hi = lo;
196 }
197 else if (bchi == BCType::reflect_even)
198 {
199 // Only act on the domain face itself. Beyond the face we leave the
200 // states unchanged, which is what the non-EB versions in
201 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
202 // out of the same arrays that hold the upwinded intermediate edge
203 // states: the code reuses the space holding Imx (which supplies hi),
204 // so with GPUs it would be undefined which values are seen here.
205 if ( j == domhi+1 ) {
206 hi = lo;
207 }
208 }
209 else if (bchi == BCType::reflect_odd)
210 {
211 if ( j == domhi+1 ) {
212 hi = Real(0.);
213 lo = Real(0.);
214 }
215 }
216 }
217 else
218 return;
219}
220
221#if (AMREX_SPACEDIM==3)
223void SetZBCs (const int i, const int j, const int k, const int n,
225 amrex::Real &lo, amrex::Real &hi,
226 amrex::Real velm, amrex::Real velp,
227 const int bclo, const int bchi,
228 const int domlo, const int domhi,
229 const bool is_velocity)
230{
231 using namespace amrex;
232
233
234 // Low Z
235 if (k <= domlo)
236 {
237 if ( (bclo == BCType::direction_dependent) && is_velocity &&
238 (n == ZVEL) && (s(i,j,domlo-1,n) >= amrex::Real(0.0)) )
239 {
240 lo = s(i, j, domlo-1, n);
241 hi = s(i, j, domlo-1, n);
242 }
243 else if ( bclo == BCType::ext_dir ||
244 (bclo == BCType::direction_dependent && velp >= amrex::Real(0.0)) )
245 {
246 lo =s(i,j,domlo-1,n);
247 if ( n == ZVEL && is_velocity ) hi = lo;
248 }
249 else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
250 (bclo == BCType::direction_dependent && velp < amrex::Real(0.0)) )
251 {
252 lo = hi;
253 }
254 else if (bclo == BCType::reflect_even)
255 {
256 // Only act on the domain face itself. Beyond the face we leave the
257 // states unchanged, which is what the non-EB versions in
258 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
259 // out of the same arrays that hold the upwinded intermediate edge
260 // states: the code reuses the space holding Imx (which supplies hi),
261 // so with GPUs it would be undefined which values are seen here.
262 if ( k == domlo ) {
263 lo = hi;
264 }
265 }
266 else if(bclo == BCType::reflect_odd)
267 {
268 if ( k == domlo ) {
269 hi = Real(0.);
270 lo = Real(0.);
271 }
272 }
273 }
274 // High Z
275 else if (k > domhi)
276 {
277 if ( (bchi == BCType::direction_dependent) && is_velocity &&
278 (n == ZVEL) && (s(i,j,domhi+1,n) <= amrex::Real(0.0)) )
279 {
280 hi = s(i, j, domhi+1, n);
281 lo = s(i, j, domhi+1, n);
282 }
283 else if ( (bchi == BCType::ext_dir) ||
284 (bchi == BCType::direction_dependent && velm <= amrex::Real(0.0)) )
285 {
286 hi = s(i,j,domhi+1,n);
287 if ( n == ZVEL && is_velocity ) lo = hi ;
288 }
289 else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
290 (bchi== BCType::direction_dependent && velm > amrex::Real(0.0)) )
291 {
292 hi = lo;
293 }
294 else if (bchi == BCType::reflect_even)
295 {
296 // Only act on the domain face itself. Beyond the face we leave the
297 // states unchanged, which is what the non-EB versions in
298 // Utils/hydro_bcs_K.H do. It also avoids reading the reflected states
299 // out of the same arrays that hold the upwinded intermediate edge
300 // states: the code reuses the space holding Imx (which supplies hi),
301 // so with GPUs it would be undefined which values are seen here.
302 if ( k == domhi+1 ) {
303 hi = lo;
304 }
305 }
306 else if (bchi == BCType::reflect_odd)
307 {
308 if ( k == domhi+1 ) {
309 hi = Real(0.);
310 lo = Real(0.);
311 }
312 }
313 }
314 else
315 return;
316}
317#endif
318}
319#endif
320/** @} */
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define YVEL
Definition hydro_constants.H:29
#define XVEL
Definition hydro_constants.H:28
#define ZVEL
Definition hydro_constants.H:30
amrex_real Real
Definition hydro_ebgodunov_bcs_K.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetYBCs(const int i, const int j, const int k, const int n, const amrex::Array4< const amrex::Real > &s, amrex::Real &lo, amrex::Real &hi, amrex::Real velm, amrex::Real velp, const int bclo, const int bchi, const int domlo, const int domhi, const bool is_velocity)
Definition hydro_ebgodunov_bcs_K.H:126
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetXBCs(const int i, const int j, const int k, const int n, const amrex::Array4< const amrex::Real > &s, amrex::Real &lo, amrex::Real &hi, amrex::Real velm, amrex::Real velp, const int bclo, const int bchi, const int domlo, const int domhi, const bool is_velocity)
Definition hydro_ebgodunov_bcs_K.H:26