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_Array.H>
13 #include <iomanip>
14 #include <hydro_constants.H>
15 
17 
19 void AddCornerCoupleTermYX ( amrex::Real& lo1, amrex::Real& hi1,
20  int i, int j, int k, int n, amrex::Real dt, amrex::Real dx,
21  bool iconserv, amrex::Real lo, amrex::Real hi,
23  amrex::Array4<amrex::Real const> const& divu_cc,
26 {
27  // Modify state on y-faces with x-derivatives to be used for computing state on z-faces
28 
29  lo1 = lo;
30  hi1 = hi;
31 
32  // Here we add - dt/3 ( (q u)_x - q u_x ) = -dt/3 (u q_x)
33  lo1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j-1,k,n)*mac(i+1,j-1,k)
34  -state(i ,j-1,k,n)*mac(i ,j-1,k) )
35  + dt/(amrex::Real(3.0)*dx)*s(i,j-1,k,n)*(mac(i+1,j-1,k)-mac(i,j-1,k));
36  hi1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j ,k,n)*mac(i+1,j ,k)
37  -state(i ,j ,k,n)*mac(i ,j ,k) )
38  + dt/(amrex::Real(3.0)*dx)*s(i,j ,k,n)*(mac(i+1,j ,k) - mac(i,j ,k));
39 
40  // Here we add - dt/3 ( q divu ) if conservative
41  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j-1,k,n)*divu_cc(i,j-1,k) : amrex::Real(0.0);
42  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j ,k,n)*divu_cc(i,j ,k) : amrex::Real(0.0);
43 }
44 
46 void AddCornerCoupleTermZX ( amrex::Real& lo1, amrex::Real& hi1,
47  int i, int j, int k, int n, amrex::Real dt, amrex::Real dx,
48  bool iconserv, amrex::Real lo, amrex::Real hi,
50  amrex::Array4<amrex::Real const> const& divu_cc,
53 {
54  // Modify state on z-faces with x-derivatives to be used for computing state on y-faces
55 
56  lo1 = lo;
57  hi1 = hi;
58 
59  // Here we add - dt/3 ( (q u)_x - q u_x ) = -dt/3 (u q_x)
60  lo1 += - dt/(amrex::Real(3.0)*dx)*(state(i+1,j,k-1,n)*mac(i+1,j,k-1)
61  - state(i ,j,k-1,n)*mac(i ,j,k-1))
62  + dt/(amrex::Real(3.0)*dx)*s(i,j,k-1,n)*(mac(i+1,j,k-1)-mac(i,j,k-1));
63 
64  hi1 += - dt/(amrex::Real(3.0)*dx)*( state(i+1,j,k ,n)*mac(i+1,j,k )
65  -state(i ,j,k ,n)*mac(i ,j,k ) )
66  + dt/(amrex::Real(3.0)*dx)*s(i,j,k ,n)*(mac(i+1,j,k ) - mac(i,j,k ));
67 
68  // Here we add - dt/3 ( q divu ) if conservative
69  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k-1,n)*divu_cc(i,j,k-1) : amrex::Real(0.0);
70  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k ,n)*divu_cc(i,j,k ) : amrex::Real(0.0);
71 }
72 
74 void AddCornerCoupleTermXY ( amrex::Real& lo1, amrex::Real& hi1,
75  int i, int j, int k, int n, amrex::Real dt, amrex::Real dy,
76  bool iconserv, amrex::Real lo, amrex::Real hi,
78  amrex::Array4<amrex::Real const> const& divu_cc,
81 {
82  // Modify state on x-faces with y-derivatives to be used for computing state on z-faces
83 
84  lo1 = lo;
85  hi1 = hi;
86 
87  // Here we add - dt/3 ( (q v)_y - q v_y ) = -dt/3 (v q_y)
88  lo1 += - dt/(amrex::Real(3.0)*dy)*( state(i-1,j+1,k,n)*mac(i-1,j+1,k)
89  -state(i-1,j ,k,n)*mac(i-1,j ,k) )
90  + dt/(amrex::Real(3.0)*dy)*s(i-1,j,k,n)*(mac(i-1,j+1,k)-mac(i-1,j,k));
91  hi1 += - dt/(amrex::Real(3.0)*dy)*( state(i ,j+1,k,n)*mac(i ,j+1,k)
92  -state(i ,j ,k,n)*mac(i ,j ,k) )
93  + dt/(amrex::Real(3.0)*dy)*s(i,j,k,n)*(mac(i,j+1,k)-mac(i,j,k));
94 
95  // Here we add - dt/3 ( q divu ) if conservative
96  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i-1,j,k,n)*divu_cc(i-1,j,k) : amrex::Real(0.0);
97  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i ,j,k,n)*divu_cc(i ,j,k) : amrex::Real(0.0);
98 }
99 
101 void AddCornerCoupleTermZY ( amrex::Real& lo1, amrex::Real& hi1,
102  int i, int j, int k, int n, amrex::Real dt, amrex::Real dy,
103  bool iconserv, amrex::Real lo, amrex::Real hi,
105  amrex::Array4<amrex::Real const> const& divu_cc,
107  amrex::Array4<amrex::Real const> const& state )
108 {
109  // Modify state on z-faces with y-derivatives to be used for computing state on x-faces
110 
111  lo1 = lo;
112  hi1 = hi;
113 
114  // Here we add - dt/3 ( (q v)_y - q v_y ) = -dt/3 (v q_y)
115  lo1 += - dt/(amrex::Real(3.0)*dy)*( state(i,j+1,k-1,n)*mac(i,j+1,k-1)
116  -state(i,j ,k-1,n)*mac(i,j ,k-1) )
117  + dt/(amrex::Real(3.0)*dy)*s(i,j,k-1,n)*(mac(i,j+1,k-1)-mac(i,j,k-1));
118  hi1 += - dt/(amrex::Real(3.0)*dy)*( state(i,j+1,k ,n)*mac(i,j+1,k )
119  -state(i,j ,k ,n)*mac(i,j ,k ) )
120  + dt/(amrex::Real(3.0)*dy)*s(i,j,k,n)*(mac(i,j+1,k) - mac(i,j,k));
121 
122  // Here we add - dt/3 ( q divu ) if conservative
123  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k-1,n)*divu_cc(i,j,k-1) : amrex::Real(0.0);
124  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j,k ,n)*divu_cc(i,j,k ) : amrex::Real(0.0);
125 }
126 
128 void AddCornerCoupleTermXZ ( amrex::Real& lo1, amrex::Real& hi1,
129  int i, int j, int k, int n, amrex::Real dt, amrex::Real dz,
130  bool iconserv, amrex::Real lo, amrex::Real hi,
132  amrex::Array4<amrex::Real const> const& divu_cc,
135 {
136  // Modify state on x-faces with z-derivatives to be used for computing state on y-faces
137 
138  lo1 = lo;
139  hi1 = hi;
140 
141  // Here we add - dt/3 ( (q w)_z - q w_z ) = -dt/3 (w q_z)
142  lo1 += - dt/(amrex::Real(3.0)*dz)*( state(i-1,j,k+1,n)*mac(i-1,j,k+1)
143  -state(i-1,j,k ,n)*mac(i-1,j,k) )
144  + dt/(amrex::Real(3.0)*dz)*s(i-1,j,k,n)*(mac(i-1,j,k+1) - mac(i-1,j,k));
145  hi1 += - dt/(amrex::Real(3.0)*dz)*( state(i ,j,k+1,n)*mac(i ,j,k+1)
146  -state(i ,j,k ,n)*mac(i ,j,k) )
147  + dt/(amrex::Real(3.0)*dz)*s(i,j,k,n)*(mac(i,j,k+1) - mac(i,j,k));
148 
149  // Here we add - dt/3 ( q divu ) if conservative
150  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i-1,j,k,n)*divu_cc(i-1,j,k) : amrex::Real(0.0);
151  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i ,j,k,n)*divu_cc(i ,j,k) : amrex::Real(0.0);
152 }
153 
155 void AddCornerCoupleTermYZ ( amrex::Real& lo1, amrex::Real& hi1,
156  int i, int j, int k, int n, amrex::Real dt, amrex::Real dz,
157  bool iconserv, amrex::Real lo, amrex::Real hi,
159  amrex::Array4<amrex::Real const> const& divu_cc,
162 {
163  // Modify state on y-faces with z-derivatives to be used for computing state on x-faces
164 
165  lo1 = lo;
166  hi1 = hi;
167 
168  // Here we add - dt/3 ( (q w)_z - q w_z ) = -dt/3 (w q_z)
169  lo1 += - dt/(amrex::Real(3.0)*dz)*( state(i,j-1,k+1,n)*mac(i,j-1,k+1)
170  -state(i,j-1,k ,n)*mac(i,j-1,k ) )
171  + dt/(amrex::Real(3.0)*dz)*s(i,j-1,k,n)*(mac(i,j-1,k+1)-mac(i,j-1,k));
172  hi1 += - dt/(amrex::Real(3.0)*dz)*( state(i,j ,k+1,n)*mac(i,j ,k+1)
173  -state(i,j ,k ,n)*mac(i,j ,k ) )
174  + dt/(amrex::Real(3.0)*dz)*s(i,j,k,n)*(mac(i,j,k+1) - mac(i,j,k));
175 
176  // Here we add - dt/3 ( q divu ) if conservative
177  lo1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j-1,k,n)*divu_cc(i,j-1,k) : amrex::Real(0.0);
178  hi1 += (iconserv) ? - dt/(amrex::Real(3.0)) * s(i,j ,k,n)*divu_cc(i,j ,k) : amrex::Real(0.0);
179 }
180 }
181 #endif
182 /** @} */
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
Definition: hydro_godunov_corner_couple.H:16
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:101
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:74
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:128
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:19
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:155
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:46