ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Advection.H
Go to the documentation of this file.
1 #ifndef ERF_ADVECTION_H_
2 #define ERF_ADVECTION_H_
3 
4 #include <AMReX.H>
5 #include <AMReX_MultiFab.H>
6 #include <AMReX_BCRec.H>
7 #include <AMReX_YAFluxRegister.H>
8 #include <ERF_DataStruct.H>
9 #include <ERF_IndexDefines.H>
10 #include <ERF_ABLMost.H>
11 
12 
13 /** Compute advection tendency for density and potential temperature */
14 void AdvectionSrcForRho (const amrex::Box& bx,
15  const amrex::Array4<amrex::Real>& src,
16  const amrex::Array4<const amrex::Real>& rho_u, // These are being used
17  const amrex::Array4<const amrex::Real>& rho_v, // to define the fluxes
18  const amrex::Array4<const amrex::Real>& omega,
19  const amrex::Array4< amrex::Real>& avg_xmom, // These are being defined
20  const amrex::Array4< amrex::Real>& avg_ymom, // from the rho fluxes
21  const amrex::Array4< amrex::Real>& avg_zmom,
22  const amrex::Array4<const amrex::Real>& ax_arr,
23  const amrex::Array4<const amrex::Real>& ay_arr,
24  const amrex::Array4<const amrex::Real>& az_arr,
25  const amrex::Array4<const amrex::Real>& detJ,
26  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
27  const amrex::Array4<const amrex::Real>& mf_m,
28  const amrex::Array4<const amrex::Real>& mf_u,
29  const amrex::Array4<const amrex::Real>& mf_v,
30  const amrex::GpuArray<const amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_arr,
31  const bool const_rho);
32 
33 /** Compute advection tendency for all scalars other than density and potential temperature */
34 void AdvectionSrcForScalars (const amrex::Real& dt,
35  const amrex::Box& bx,
36  const int icomp, const int ncomp,
37  const amrex::Array4<const amrex::Real>& avg_xmom,
38  const amrex::Array4<const amrex::Real>& avg_ymom,
39  const amrex::Array4<const amrex::Real>& avg_zmom,
40  const amrex::Array4<const amrex::Real>& cur_cons,
41  const amrex::Array4<const amrex::Real>& cell_prim,
42  const amrex::Array4<amrex::Real>& src,
43  const bool& use_mono_adv,
44  amrex::Real* max_s_ptr,
45  amrex::Real* min_s_ptr,
46  const amrex::Array4<const amrex::Real>& vf_arr,
47  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
48  const amrex::Array4<const amrex::Real>& mf_m,
49  const AdvType horiz_adv_type, const AdvType vert_adv_type,
50  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
51  const amrex::GpuArray<const amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_arr,
52  const amrex::GpuArray< amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_tmp_arr,
53  const amrex::Box& domain,
54  const amrex::BCRec* bc_ptr_h);
55 
56 /** Compute advection tendencies for all components of momentum */
57 void AdvectionSrcForMom (const amrex::Box& bx,
58  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
59  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
60  const amrex::Array4< amrex::Real>& rho_w_rhs,
61  const amrex::Array4<const amrex::Real>& rho,
62  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
63  const amrex::Array4<const amrex::Real>& w ,
64  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
65  const amrex::Array4<const amrex::Real>& Omega ,
66  const amrex::Array4<const amrex::Real>& z_nd,
67  const amrex::Array4<const amrex::Real>& ax,
68  const amrex::Array4<const amrex::Real>& ay,
69  const amrex::Array4<const amrex::Real>& az,
70  const amrex::Array4<const amrex::Real>& detJ,
71  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
72  const amrex::Array4<const amrex::Real>& mf_m,
73  const amrex::Array4<const amrex::Real>& mf_u,
74  const amrex::Array4<const amrex::Real>& mf_v,
75  const AdvType horiz_adv_type, const AdvType vert_adv_type,
76  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
77  const bool use_terrain, const int lo_z_face, const int hi_z_face,
78  const amrex::Box& domain,
79  const amrex::BCRec* bc_ptr_h);
80 
81 /** Compute advection tendencies for all normal components of momentum */
82 void
83 AdvectionSrcForOpenBC_Normal (const amrex::Box& bx,
84  const int& dir,
85  const amrex::Array4< amrex::Real>& rhs_arr,
86  const amrex::Array4<const amrex::Real>& vel_norm_arr,
87  const amrex::Array4<const amrex::Real>& cell_data_arr,
88  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
89  const bool do_lo=false);
90 
91 /** Compute advection tendencies for u momentum tangent to open bc*/
92 void
93 AdvectionSrcForOpenBC_Tangent_Xmom (const amrex::Box& bxx,
94  const int& dir,
95  const amrex::Array4< amrex::Real>& rho_u_rhs,
96  const amrex::Array4<const amrex::Real>& u,
97  const amrex::Array4<const amrex::Real>& rho_u,
98  const amrex::Array4<const amrex::Real>& rho_v,
99  const amrex::Array4<const amrex::Real>& Omega,
100  const amrex::Array4<const amrex::Real>& ax,
101  const amrex::Array4<const amrex::Real>& az,
102  const amrex::Array4<const amrex::Real>& detJ,
103  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
104  const bool do_lo=false);
105 
106 /** Compute advection tendencies for v momentum tangent to open bc*/
107 void
108 AdvectionSrcForOpenBC_Tangent_Ymom (const amrex::Box& bxy,
109  const int& dir,
110  const amrex::Array4< amrex::Real>& rho_v_rhs,
111  const amrex::Array4<const amrex::Real>& v,
112  const amrex::Array4<const amrex::Real>& rho_u,
113  const amrex::Array4<const amrex::Real>& rho_v,
114  const amrex::Array4<const amrex::Real>& Omega,
115  const amrex::Array4<const amrex::Real>& ay,
116  const amrex::Array4<const amrex::Real>& az,
117  const amrex::Array4<const amrex::Real>& detJ,
118  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
119  const bool do_lo=false);
120 
121 /** Compute advection tendencies for w momentum tangent to open bc*/
122 void
123 AdvectionSrcForOpenBC_Tangent_Zmom (const amrex::Box& bxz,
124  const int& dir,
125  const amrex::Array4< amrex::Real>& rho_w_rhs,
126  const amrex::Array4<const amrex::Real>& w,
127  const amrex::Array4<const amrex::Real>& rho_u,
128  const amrex::Array4<const amrex::Real>& rho_v,
129  const amrex::Array4<const amrex::Real>& Omega,
130  const amrex::Array4<const amrex::Real>& ax,
131  const amrex::Array4<const amrex::Real>& ay,
132  const amrex::Array4<const amrex::Real>& az,
133  const amrex::Array4<const amrex::Real>& detJ,
134  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
135  const int domhi_z,
136  const bool do_lo=false);
137 
138 /** Compute advection tendencies for cons tangential to BC (2nd order)*/
139 void
141  const int& dir,
142  const int& icomp,
143  const int& ncomp,
144  const amrex::Array4< amrex::Real>& cell_rhs,
145  const amrex::Array4<const amrex::Real>& cell_prim,
146  const amrex::Array4<const amrex::Real>& avg_xmom,
147  const amrex::Array4<const amrex::Real>& avg_ymom,
148  const amrex::Array4<const amrex::Real>& avg_zmom,
149  const amrex::Array4<const amrex::Real>& detJ,
150  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
151  const bool do_lo=false);
152 
153 /** Compute advection tendencies in normal dir for vars tangent to open bc */
154 AMREX_GPU_HOST_DEVICE
155 AMREX_FORCE_INLINE
156 amrex::Real
158  const int& j,
159  const int& k,
160  const int& nprim,
161  const int& dir,
162  const amrex::Array4<const amrex::Real>& prim_tang_arr,
163  const amrex::Array4<const amrex::Real>& mom_norm_arr,
164  const amrex::Real& dxInv,
165  const bool do_lo=false);
166 
167 AMREX_GPU_HOST_DEVICE
168 AMREX_FORCE_INLINE
169 AdvType
170 EfficientAdvType (int nrk, AdvType adv_type)
171 {
172  AdvType eff_adv_type;
173 
174  if (nrk == 0) {
175 
176  eff_adv_type = AdvType::Centered_2nd;
177 
178  } else if (nrk == 1) {
179 
180  if ( (adv_type == AdvType::Centered_2nd) ||
181  (adv_type == AdvType::Upwind_3rd) ||
182  (adv_type == AdvType::Centered_4th) ||
183  (adv_type == AdvType::Weno_3) ||
184  (adv_type == AdvType::Weno_3Z) ||
185  (adv_type == AdvType::Weno_3MZQ) )
186  {
187  eff_adv_type = AdvType::Centered_2nd;
188 
189  } else if ( (adv_type == AdvType::Upwind_5th) ||
190  (adv_type == AdvType::Weno_5) ||
191  (adv_type == AdvType::Weno_5Z) )
192  {
193  eff_adv_type = AdvType::Upwind_3rd;
194 
195  } else { // (adv_type == AdvType::Centered_6th)
196 
197  eff_adv_type = AdvType::Centered_4th;
198  }
199 
200  } else {
201 
202  eff_adv_type = adv_type;
203  }
204 
205  return(eff_adv_type);
206 }
207 #endif
void AdvectionSrcForRho(const amrex::Box &bx, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &omega, const amrex::Array4< amrex::Real > &avg_xmom, const amrex::Array4< amrex::Real > &avg_ymom, const amrex::Array4< amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const bool const_rho)
void AdvectionSrcForOpenBC_Tangent_Ymom(const amrex::Box &bxy, const int &dir, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Tangent_Xmom(const amrex::Box &bxx, const int &dir, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Normal(const amrex::Box &bx, const int &dir, const amrex::Array4< amrex::Real > &rhs_arr, const amrex::Array4< const amrex::Real > &vel_norm_arr, const amrex::Array4< const amrex::Real > &cell_data_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const bool do_lo=false)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForOpenBC_Tangent(const int &i, const int &j, const int &k, const int &nprim, const int &dir, const amrex::Array4< const amrex::Real > &prim_tang_arr, const amrex::Array4< const amrex::Real > &mom_norm_arr, const amrex::Real &dxInv, const bool do_lo=false)
void AdvectionSrcForMom(const amrex::Box &bx, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const bool use_terrain, const int lo_z_face, const int hi_z_face, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
void AdvectionSrcForOpenBC_Tangent_Cons(const amrex::Box &bx, const int &dir, const int &icomp, const int &ncomp, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Tangent_Zmom(const amrex::Box &bxz, const int &dir, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const int domhi_z, const bool do_lo=false)
void AdvectionSrcForScalars(const amrex::Real &dt, const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cur_cons, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const bool &use_mono_adv, amrex::Real *max_s_ptr, amrex::Real *min_s_ptr, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_tmp_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE AdvType EfficientAdvType(int nrk, AdvType adv_type)
Definition: ERF_Advection.H:170
AdvType
Definition: ERF_IndexDefines.H:191
@ Centered_4th
@ Centered_2nd
@ rho
Definition: ERF_Kessler.H:30
@ omega
Definition: ERF_SAM.H:49