AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
hydro_bcs_K.H
Go to the documentation of this file.
1 /**
2  * \file hydro_bcs_K.H
3  *
4  * This header file contains the inlined __host__ __device__ functions required for
5  * the boundary condition routines for Godunov and MOL. It also contains function declarations
6  * for controlling host functions.
7  *
8  */
9 
10 /** \addtogroup Utilities
11  * @{
12  */
13 
14 
15 #ifndef HYDRO_BCS_K_H
16 #define HYDRO_BCS_K_H
17 
18 #include <AMReX_Gpu.H>
19 #include <AMReX_BCRec.H>
20 #include <AMReX_BC_TYPES.H>
21 #include <AMReX_Array.H>
22 #include <iomanip>
23 #include <hydro_constants.H>
24 
25 /**
26  * \namespace HydroBC
27  *
28  */
29 namespace HydroBC{
30 
31 /**
32  *
33  * <A ID="SetXEdgeBCs"></A>
34  *
35  * \brief Boundary condition effects
36  *
37  *
38  * For a detailed discussion see the AMReX-Hydro Guide
39  * <A HREF="https://amrex-codes.github.io/amrex/hydro_html/EBMOL.html#sec:slopes">
40  * section for EBMOL</A>.
41  *
42  */
43 
45 void SetXEdgeBCs( int i, int j, int k, int n,
47  amrex::Real &lo, amrex::Real &hi,
48  int bclo, int domlo,
49  int bchi, int domhi,
50  bool is_velocity )
51 {
52 
53  using namespace amrex;
54 
55  // This function is for setting BCs ON domain faces only.
56  AMREX_ASSERT( domlo <= i && i <= domhi+1 );
57 
58  if (i == domlo)
59  {
60  if (bclo == BCType::ext_dir)
61  {
62  lo = s(domlo-1, j, k, n);
63  // For turbulent inflow, there are times when the inflow face
64  // may have a predicted outflowing velocity. Here, we preserve
65  // the normal component of the Dirichlet BC, but allow the
66  // tangential components to transport values from the interior.
67  if ( n==XVEL && is_velocity ) hi=lo;
68  }
69  else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
70  bclo == BCType::reflect_even )
71  {
72  lo = hi;
73  }
74  else if (bclo == BCType::reflect_odd)
75  {
76  hi = 0.;
77  lo = hi;
78  }
79  }
80  else if (i == domhi+1)
81  {
82  if (bchi == BCType::ext_dir)
83  {
84  hi = s(domhi+1, j, k, n);
85  if ( n==XVEL && is_velocity ) lo = hi;
86  }
87  else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
88  bchi == BCType::reflect_even )
89  {
90  hi = lo;
91  }
92  else if (bchi == BCType::reflect_odd)
93  {
94  lo = 0.;
95  hi = lo;
96  }
97  }
98  else
99  return;
100 }
101 
102 /*
103  * \fn SetYEdgeBCs
104  */
105 /**
106  * \brief Boundary condition effects
107  *
108  * For a detailed discussion see the AMReX-Hydro Guide section EBMOL.
109  */
110 
112 void SetYEdgeBCs ( int i, int j, int k, int n,
114  amrex::Real &lo, amrex::Real &hi,
115  int bclo, int domlo,
116  int bchi, int domhi,
117  bool is_velocity )
118 {
119  using namespace amrex;
120 
121  // This function is for setting BCs ON domain faces only.
122  AMREX_ASSERT( domlo <= j && j <= domhi+1 );
123 
124  if (j == domlo)
125  {
126  if (bclo == BCType::ext_dir)
127  {
128  lo = s(i, domlo-1, k, n);
129  if ( n==YVEL && is_velocity ) hi=lo;
130  }
131  else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
132  bclo == BCType::reflect_even )
133  {
134  lo = hi;
135  }
136  else if (bclo == BCType::reflect_odd)
137  {
138  hi = 0.;
139  lo = hi;
140  }
141  }
142  else if (j == domhi+1)
143  {
144  if (bchi == BCType::ext_dir)
145  {
146  hi = s(i, domhi+1, k, n);
147  if ( n==YVEL && is_velocity ) lo=hi;
148  }
149  else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
150  bchi == BCType::reflect_even )
151  {
152  hi = lo;
153  }
154  else if(bchi == BCType::reflect_odd)
155  {
156  lo = 0.;
157  hi = lo;
158  }
159  }
160  else
161  return;
162 }
163 
164 
165 // //
166 // =============================== 3D ONLY =============================== //
167 // //
168 #if (AMREX_SPACEDIM==3)
169 
170 /**
171  *
172  * \brief Boundary condition effects
173  *
174  * For a detailed discussion see the AMReX-Hydro Guide.
175  * For 3D only.
176  */
177 
179 void SetZEdgeBCs ( int i, int j, int k, int n,
181  amrex::Real &lo, amrex::Real &hi,
182  int bclo, int domlo,
183  int bchi, int domhi,
184  bool is_velocity )
185 {
186  using namespace amrex;
187 
188  // This function is for setting BCs ON domain faces only.
189  AMREX_ASSERT( domlo <= k && k <= domhi+1 );
190 
191  if (k == domlo)
192  {
193  if (bclo == BCType::ext_dir)
194  {
195  lo = s(i, j, domlo-1, n);
196  if ( n==ZVEL && is_velocity ) hi=lo;
197  }
198  else if ( bclo == BCType::foextrap || bclo == BCType::hoextrap ||
199  bclo == BCType::reflect_even )
200  {
201  lo = hi;
202  }
203  else if(bclo == BCType::reflect_odd)
204  {
205  hi = 0.;
206  lo = hi;
207  }
208  }
209  else if (k == domhi+1)
210  {
211  if (bchi == BCType::ext_dir)
212  {
213  hi = s(i,j,domhi+1, n);
214  if ( n==ZVEL && is_velocity ) lo=hi;
215  }
216  else if ( bchi == BCType::foextrap || bchi == BCType::hoextrap ||
217  bchi == BCType::reflect_even )
218  {
219  hi = lo;
220  }
221  else if(bchi == BCType::reflect_odd)
222  {
223  lo = 0.;
224  hi = lo;
225  }
226  }
227  else
228  return;
229 }
230 #endif
231 } // namespace
232 #endif
233 /** @}*/
#define AMREX_ASSERT(EX)
#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_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetXEdgeBCs(int i, int j, int k, int n, const amrex::Array4< const amrex::Real > &s, amrex::Real &lo, amrex::Real &hi, int bclo, int domlo, int bchi, int domhi, bool is_velocity)
Boundary condition effects.
Definition: hydro_bcs_K.H:45
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void SetYEdgeBCs(int i, int j, int k, int n, const amrex::Array4< const amrex::Real > &s, amrex::Real &lo, amrex::Real &hi, int bclo, int domlo, int bchi, int domhi, bool is_velocity)
Boundary condition effects.
Definition: hydro_bcs_K.H:112