AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
hydro_godunov_corner_couple.H
Go to the documentation of this file.
1 /**
2  * \file hydro_godunov_corner_couple.H
3  *
4  * \addtogroup Godunov
5  * @{
6  */
7 
8 #ifndef HYDRO_GODUNOV_CORNER_COUPLE_H
9 #define HYDRO_GODUNOV_CORNER_COUPLE_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 
19 
21 void AddCornerCoupleTermYX ( amrex::Real& lo1, amrex::Real& hi1,
22  int i, int j, int k, int n, amrex::Real dt, amrex::Real dx,
23  bool iconserv, amrex::Real lo, amrex::Real hi,
25  amrex::Array4<amrex::Real const> const& divu_cc,
28 {
29  // Modify state on y-faces with x-derivatives to be used for computing state on z-faces
30 
31  lo1 = lo;
32  hi1 = hi;
33 
34  // Here we add - dt/3 ( (q u)_x - q u_x ) = -dt/3 (u q_x)
35  lo1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j-1,k,n)*mac(i+1,j-1,k)
36  -state(i ,j-1,k,n)*mac(i ,j-1,k) )
37  + dt/(amrex::Real(3.0)*dx)*s(i,j-1,k,n)*(mac(i+1,j-1,k)-mac(i,j-1,k));
38  hi1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j ,k,n)*mac(i+1,j ,k)
39  -state(i ,j ,k,n)*mac(i ,j ,k) )
40  + dt/(amrex::Real(3.0)*dx)*s(i,j ,k,n)*(mac(i+1,j ,k) - mac(i,j ,k));
41 
42  // Here we add - dt/3 ( q divu ) if conservative
43  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j-1,k,n)*divu_cc(i,j-1,k) : amrex::Real(0.0);
44  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j ,k,n)*divu_cc(i,j ,k) : amrex::Real(0.0);
45 }
46 
48 void AddCornerCoupleTermZX ( amrex::Real& lo1, amrex::Real& hi1,
49  int i, int j, int k, int n, amrex::Real dt, amrex::Real dx,
50  bool iconserv, amrex::Real lo, amrex::Real hi,
52  amrex::Array4<amrex::Real const> const& divu_cc,
55 {
56  // Modify state on z-faces with x-derivatives to be used for computing state on y-faces
57 
58  lo1 = lo;
59  hi1 = hi;
60 
61  // Here we add - dt/3 ( (q u)_x - q u_x ) = -dt/3 (u q_x)
62  lo1 += - dt/(amrex::Real(3.0)*dx)*(state(i+1,j,k-1,n)*mac(i+1,j,k-1)
63  - state(i ,j,k-1,n)*mac(i ,j,k-1))
64  + dt/(amrex::Real(3.0)*dx)*s(i,j,k-1,n)*(mac(i+1,j,k-1)-mac(i,j,k-1));
65 
66  hi1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j,k ,n)*mac(i+1,j,k )
67  -state(i ,j,k ,n)*mac(i ,j,k ) )
68  + dt/(amrex::Real(3.0)*dx)*s(i,j,k ,n)*(mac(i+1,j,k ) - mac(i,j,k ));
69 
70  // Here we add - dt/3 ( q divu ) if conservative
71  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k-1,n)*divu_cc(i,j,k-1) : amrex::Real(0.0);
72  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k ,n)*divu_cc(i,j,k ) : amrex::Real(0.0);
73 }
74 
76 void AddCornerCoupleTermXY ( amrex::Real& lo1, amrex::Real& hi1,
77  int i, int j, int k, int n, amrex::Real dt, amrex::Real dy,
78  bool iconserv, amrex::Real lo, amrex::Real hi,
80  amrex::Array4<amrex::Real const> const& divu_cc,
83 {
84  // Modify state on x-faces with y-derivatives to be used for computing state on z-faces
85 
86  lo1 = lo;
87  hi1 = hi;
88 
89  // Here we add - dt/3 ( (q v)_y - q v_y ) = -dt/3 (v q_y)
90  lo1 += - dt/(amrex::Real(3.0)*dy)*( state(i-1,j+1,k,n)*mac(i-1,j+1,k)
91  -state(i-1,j ,k,n)*mac(i-1,j ,k) )
92  + dt/(amrex::Real(3.0)*dy)*s(i-1,j,k,n)*(mac(i-1,j+1,k)-mac(i-1,j,k));
93  hi1 += - dt/(amrex::Real(3.0)*dy)*( state(i ,j+1,k,n)*mac(i ,j+1,k)
94  -state(i ,j ,k,n)*mac(i ,j ,k) )
95  + dt/(amrex::Real(3.0)*dy)*s(i,j,k,n)*(mac(i,j+1,k)-mac(i,j,k));
96 
97  // Here we add - dt/3 ( q divu ) if conservative
98  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i-1,j,k,n)*divu_cc(i-1,j,k) : amrex::Real(0.0);
99  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i ,j,k,n)*divu_cc(i ,j,k) : amrex::Real(0.0);
100 }
101 
103 void AddCornerCoupleTermZY ( amrex::Real& lo1, amrex::Real& hi1,
104  int i, int j, int k, int n, amrex::Real dt, amrex::Real dy,
105  bool iconserv, amrex::Real lo, amrex::Real hi,
107  amrex::Array4<amrex::Real const> const& divu_cc,
109  amrex::Array4<amrex::Real const> const& state )
110 {
111  // Modify state on z-faces with y-derivatives to be used for computing state on x-faces
112 
113  lo1 = lo;
114  hi1 = hi;
115 
116  // Here we add - dt/3 ( (q v)_y - q v_y ) = -dt/3 (v q_y)
117  lo1 += - dt/(amrex::Real(3.0)*dy)*( state(i,j+1,k-1,n)*mac(i,j+1,k-1)
118  -state(i,j ,k-1,n)*mac(i,j ,k-1) )
119  + dt/(amrex::Real(3.0)*dy)*s(i,j,k-1,n)*(mac(i,j+1,k-1)-mac(i,j,k-1));
120  hi1 += - dt/(amrex::Real(3.0)*dy)*( state(i,j+1,k ,n)*mac(i,j+1,k )
121  -state(i,j ,k ,n)*mac(i,j ,k ) )
122  + dt/(amrex::Real(3.0)*dy)*s(i,j,k,n)*(mac(i,j+1,k) - mac(i,j,k));
123 
124  // Here we add - dt/3 ( q divu ) if conservative
125  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k-1,n)*divu_cc(i,j,k-1) : amrex::Real(0.0);
126  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k ,n)*divu_cc(i,j,k ) : amrex::Real(0.0);
127 }
128 
130 void AddCornerCoupleTermXZ ( amrex::Real& lo1, amrex::Real& hi1,
131  int i, int j, int k, int n, amrex::Real dt, amrex::Real dz,
132  bool iconserv, amrex::Real lo, amrex::Real hi,
134  amrex::Array4<amrex::Real const> const& divu_cc,
137 {
138  // Modify state on x-faces with z-derivatives to be used for computing state on y-faces
139 
140  lo1 = lo;
141  hi1 = hi;
142 
143  // Here we add - dt/3 ( (q w)_z - q w_z ) = -dt/3 (w q_z)
144  lo1 += - dt/(amrex::Real(3.0)*dz)*( state(i-1,j,k+1,n)*mac(i-1,j,k+1)
145  -state(i-1,j,k ,n)*mac(i-1,j,k) )
146  + dt/(amrex::Real(3.0)*dz)*s(i-1,j,k,n)*(mac(i-1,j,k+1) - mac(i-1,j,k));
147  hi1 += - dt/(amrex::Real(3.0)*dz)*( state(i ,j,k+1,n)*mac(i ,j,k+1)
148  -state(i ,j,k ,n)*mac(i ,j,k) )
149  + dt/(amrex::Real(3.0)*dz)*s(i,j,k,n)*(mac(i,j,k+1) - mac(i,j,k));
150 
151  // Here we add - dt/3 ( q divu ) if conservative
152  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i-1,j,k,n)*divu_cc(i-1,j,k) : amrex::Real(0.0);
153  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i ,j,k,n)*divu_cc(i ,j,k) : amrex::Real(0.0);
154 }
155 
157 void AddCornerCoupleTermYZ ( amrex::Real& lo1, amrex::Real& hi1,
158  int i, int j, int k, int n, amrex::Real dt, amrex::Real dz,
159  bool iconserv, amrex::Real lo, amrex::Real hi,
161  amrex::Array4<amrex::Real const> const& divu_cc,
164 {
165  // Modify state on y-faces with z-derivatives to be used for computing state on x-faces
166 
167  lo1 = lo;
168  hi1 = hi;
169 
170  // Here we add - dt/3 ( (q w)_z - q w_z ) = -dt/3 (w q_z)
171  lo1 += - dt/(amrex::Real(3.0)*dz)*( state(i,j-1,k+1,n)*mac(i,j-1,k+1)
172  -state(i,j-1,k ,n)*mac(i,j-1,k ) )
173  + dt/(amrex::Real(3.0)*dz)*s(i,j-1,k,n)*(mac(i,j-1,k+1)-mac(i,j-1,k));
174  hi1 += - dt/(amrex::Real(3.0)*dz)*( state(i,j ,k+1,n)*mac(i,j ,k+1)
175  -state(i,j ,k ,n)*mac(i,j ,k ) )
176  + dt/(amrex::Real(3.0)*dz)*s(i,j,k,n)*(mac(i,j,k+1) - mac(i,j,k));
177 
178  // Here we add - dt/3 ( q divu ) if conservative
179  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j-1,k,n)*divu_cc(i,j-1,k) : amrex::Real(0.0);
180  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j ,k,n)*divu_cc(i,j ,k) : amrex::Real(0.0);
181 }
182 }
183 #endif
184 /** @} */
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
Definition: hydro_godunov_corner_couple.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermZY(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dy, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:103
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermXY(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dy, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:76
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermXZ(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dz, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermYX(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dx, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermYZ(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dz, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:157
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddCornerCoupleTermZX(amrex::Real &lo1, amrex::Real &hi1, int i, int j, int k, int n, amrex::Real dt, amrex::Real dx, bool iconserv, amrex::Real lo, amrex::Real hi, amrex::Array4< amrex::Real const > const &s, amrex::Array4< amrex::Real const > const &divu_cc, amrex::Array4< amrex::Real const > const &mac, amrex::Array4< amrex::Real const > const &state)
Definition: hydro_godunov_corner_couple.H:48