ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_AdvectionSrcForMom.cpp File Reference
#include "AMReX_BCRec.H"
#include <ERF_Advection.H>
#include <ERF_AdvectionSrcForMom_N.H>
#include <ERF_AdvectionSrcForMom_T.H>
Include dependency graph for ERF_AdvectionSrcForMom.cpp:

Functions

void AdvectionSrcForMom (const Box &bx, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &cell_data, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &omega, const Array4< const Real > &z_nd, const Array4< const Real > &ax, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, Gpu::DeviceVector< Real > &stretched_dz_d, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_m, const Array4< const Real > &mf_u, const Array4< const Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, MeshType &mesh_type, TerrainType &terrain_type, const int lo_z_face, const int hi_z_face, const Box &domain, const BCRec *bc_ptr_h)
 

Function Documentation

◆ AdvectionSrcForMom()

void AdvectionSrcForMom ( const Box &  bx,
const Box &  bxx,
const Box &  bxy,
const Box &  bxz,
const Array4< Real > &  rho_u_rhs,
const Array4< Real > &  rho_v_rhs,
const Array4< Real > &  rho_w_rhs,
const Array4< const Real > &  cell_data,
const Array4< const Real > &  u,
const Array4< const Real > &  v,
const Array4< const Real > &  w,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  omega,
const Array4< const Real > &  z_nd,
const Array4< const Real > &  ax,
const Array4< const Real > &  ay,
const Array4< const Real > &  az,
const Array4< const Real > &  detJ,
Gpu::DeviceVector< Real > &  stretched_dz_d,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const Array4< const Real > &  mf_m,
const Array4< const Real > &  mf_u,
const Array4< const Real > &  mf_v,
const AdvType  horiz_adv_type,
const AdvType  vert_adv_type,
const Real  horiz_upw_frac,
const Real  vert_upw_frac,
MeshType &  mesh_type,
TerrainType &  terrain_type,
const int  lo_z_face,
const int  hi_z_face,
const Box &  domain,
const BCRec *  bc_ptr_h 
)

Function for computing the advective tendency for the momentum equations This routine has explicit expressions for all cases (terrain or not) when the horizontal and vertical spatial orders are <= 2, and calls more specialized functions when either (or both) spatial order(s) is greater than 2.

Parameters
[in]bxxbox over which the x-momentum is updated
[in]bxybox over which the y-momentum is updated
[in]bxzbox over which the z-momentum is updated
[out]rho_u_rhstendency for the x-momentum equation
[out]rho_v_rhstendency for the y-momentum equation
[out]rho_w_rhstendency for the z-momentum equation
[in]ux-component of the velocity
[in]vy-component of the velocity
[in]wz-component of the velocity
[in]rho_ux-component of the momentum
[in]rho_vy-component of the momentum
[in]Omegacomponent of the momentum normal to the z-coordinate surface
[in]z_ndheight coordinate at nodes
[in]axArea fraction of x-faces
[in]ayArea fraction of y-faces
[in]azArea fraction of z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain_fitted_coords is false)
[in]cellSizeInvinverse of the mesh spacing
[in]mf_mmap factor at cell centers
[in]mf_umap factor at x-faces
[in]mf_vmap factor at y-faces
[in]horiz_adv_typesets the spatial order to be used for lateral derivatives
[in]vert_adv_typesets the spatial order to be used for vertical derivatives
71 {
72  BL_PROFILE_VAR("AdvectionSrcForMom", AdvectionSrcForMom);
73 
74  AMREX_ALWAYS_ASSERT(bxz.smallEnd(2) > 0);
75 
76  // compute mapfactor inverses
77  Box box2d_u(bxx); box2d_u.setRange(2,0); box2d_u.grow({3,3,0});
78  Box box2d_v(bxy); box2d_v.setRange(2,0); box2d_v.grow({3,3,0});
79  FArrayBox mf_u_invFAB(box2d_u,1,The_Async_Arena());
80  FArrayBox mf_v_invFAB(box2d_v,1,The_Async_Arena());
81  const Array4<Real>& mf_u_inv = mf_u_invFAB.array();
82  const Array4<Real>& mf_v_inv = mf_v_invFAB.array();
83 
84  const bool use_terrain_fitted_coords = ( terrain_type == TerrainType::StaticFittedMesh ||
85  terrain_type == TerrainType::MovingFittedMesh);
86 
87  ParallelFor(box2d_u, box2d_v,
88  [=] AMREX_GPU_DEVICE (int i, int j, int) noexcept
89  {
90  mf_u_inv(i,j,0) = 1. / mf_u(i,j,0);
91  },
92  [=] AMREX_GPU_DEVICE (int i, int j, int) noexcept
93  {
94  mf_v_inv(i,j,0) = 1. / mf_v(i,j,0);
95  });
96 
97  if (mesh_type == MeshType::ConstantDz && terrain_type != TerrainType::EB)
98  {
99  // amrex::Print() << "ADV:CONSTANT DZ " << std::endl;
100  AdvectionSrcForMom_ConstantDz(bxx, bxy, bxz,
101  rho_u_rhs, rho_v_rhs, rho_w_rhs, u, v, w,
102  rho_u, rho_v, omega,
103  cellSizeInv, stretched_dz_d,
104  mf_m, mf_u, mf_v,
105  horiz_adv_type, vert_adv_type,
106  horiz_upw_frac, vert_upw_frac,
107  terrain_type, lo_z_face, hi_z_face);
108  }
109  else if (mesh_type == MeshType::StretchedDz && terrain_type != TerrainType::EB)
110  {
111  // amrex::Print() << "ADV:STRETCHED DZ " << std::endl;
112  AdvectionSrcForMom_StretchedDz(bxx, bxy, bxz,
113  rho_u_rhs, rho_v_rhs, rho_w_rhs,
114  u, v, w, rho_u, rho_v, omega,
115  cellSizeInv, stretched_dz_d,
116  mf_m, mf_u, mf_v,
117  horiz_adv_type, vert_adv_type,
118  horiz_upw_frac, vert_upw_frac,
119  lo_z_face, hi_z_face);
120  }
121  else if ( terrain_type == TerrainType::EB)
122  {
123  // amrex::Print() << "ADV:EB " << std::endl;
124  AdvectionSrcForMom_EB(bxx, bxy, bxz,
125  rho_u_rhs, rho_v_rhs, rho_w_rhs,
126  u, v, w,
127  rho_u, rho_v, omega,
128  ax, ay, az, detJ,
129  cellSizeInv, mf_m, mf_u, mf_v,
130  horiz_adv_type, vert_adv_type,
131  horiz_upw_frac, vert_upw_frac,
132  lo_z_face, hi_z_face, domain);
133  }
134  else
135  {
136  AMREX_ALWAYS_ASSERT(use_terrain_fitted_coords);
137  // amrex::Print() << "ADV:TF " << std::endl;
138  AdvectionSrcForMom_TF(bxx, bxy, bxz,
139  rho_u_rhs, rho_v_rhs, rho_w_rhs,
140  u, v, w,
141  rho_u, rho_v, omega,
142  z_nd, ax, ay, az, detJ,
143  cellSizeInv, mf_m, mf_u, mf_v,
144  horiz_adv_type, vert_adv_type,
145  horiz_upw_frac, vert_upw_frac,
146  lo_z_face, hi_z_face);
147 
148  }
149 
150  // Open bc will be imposed upon all vars (we only access cons here for simplicity)
151  const bool xlo_open = (bc_ptr_h[BCVars::cons_bc].lo(0) == ERFBCType::open);
152  const bool xhi_open = (bc_ptr_h[BCVars::cons_bc].hi(0) == ERFBCType::open);
153  const bool ylo_open = (bc_ptr_h[BCVars::cons_bc].lo(1) == ERFBCType::open);
154  const bool yhi_open = (bc_ptr_h[BCVars::cons_bc].hi(1) == ERFBCType::open);
155 
156  // We recreate tbx, tbz, tbz here rather than using bxx, bxy, bxz because those
157  // have already been shrunk by one in the case of open BCs.
158  Box tbx(surroundingNodes(bx,0));
159  Box tby(surroundingNodes(bx,1));
160  Box tbz(surroundingNodes(bx,2)); tbz.growLo(2,-1); tbz.growHi(2,-1);
161 
162  const int domhi_z = domain.bigEnd(2);
163 
164  // Special advection operator for open BC (bndry normal/tangent operations)
165  if (xlo_open)
166  {
167  Box tbx_xlo, tby_xlo, tbz_xlo;
168  if (tbx.smallEnd(0) == domain.smallEnd(0)) { tbx_xlo = makeSlab(tbx,0,domain.smallEnd(0));}
169  if (tby.smallEnd(0) == domain.smallEnd(0)) { tby_xlo = makeSlab(tby,0,domain.smallEnd(0));}
170  if (tbz.smallEnd(0) == domain.smallEnd(0)) { tbz_xlo = makeSlab(tbz,0,domain.smallEnd(0));}
171 
172  bool do_lo = true;
173 
174  AdvectionSrcForOpenBC_Normal(tbx_xlo, 0, rho_u_rhs, u, cell_data, cellSizeInv, do_lo);
175  AdvectionSrcForOpenBC_Tangent_Ymom(tby_xlo, 0, rho_v_rhs, v,
176  rho_u, rho_v, omega,
177  ay, az, detJ, cellSizeInv,
178  do_lo);
179  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_xlo, 0, rho_w_rhs, w,
180  rho_u, rho_v, omega,
181  ax, ay, az, detJ, cellSizeInv,
182  domhi_z, do_lo);
183  }
184  if (xhi_open)
185  {
186  Box tbx_xhi, tby_xhi, tbz_xhi;
187  if (tbx.bigEnd(0) == domain.bigEnd(0)+1) { tbx_xhi = makeSlab(tbx,0,domain.bigEnd(0)+1);}
188  if (tby.bigEnd(0) == domain.bigEnd(0)) { tby_xhi = makeSlab(tby,0,domain.bigEnd(0) );}
189  if (tbz.bigEnd(0) == domain.bigEnd(0)) { tbz_xhi = makeSlab(tbz,0,domain.bigEnd(0) );}
190 
191  AdvectionSrcForOpenBC_Normal(tbx_xhi, 0, rho_u_rhs, u, cell_data, cellSizeInv);
192  AdvectionSrcForOpenBC_Tangent_Ymom(tby_xhi, 0, rho_v_rhs, v,
193  rho_u, rho_v, omega,
194  ay, az, detJ, cellSizeInv);
195  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_xhi, 0, rho_w_rhs, w,
196  rho_u, rho_v, omega,
197  ax, ay, az, detJ, cellSizeInv,
198  domhi_z);
199  }
200  if (ylo_open)
201  {
202  Box tbx_ylo, tby_ylo, tbz_ylo;
203  if (tbx.smallEnd(1) == domain.smallEnd(1)) { tbx_ylo = makeSlab(tbx,1,domain.smallEnd(1));}
204  if (tby.smallEnd(1) == domain.smallEnd(1)) { tby_ylo = makeSlab(tby,1,domain.smallEnd(1));}
205  if (tbz.smallEnd(1) == domain.smallEnd(1)) { tbz_ylo = makeSlab(tbz,1,domain.smallEnd(1));}
206 
207  bool do_lo = true;
208  AdvectionSrcForOpenBC_Tangent_Xmom(tbx_ylo, 1, rho_u_rhs, u,
209  rho_u, rho_v, omega,
210  ax, az, detJ, cellSizeInv,
211  do_lo);
212  AdvectionSrcForOpenBC_Normal(tby_ylo, 1, rho_v_rhs, v, cell_data, cellSizeInv, do_lo);
213  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_ylo, 1, rho_w_rhs, w,
214  rho_u, rho_v, omega,
215  ax, ay, az, detJ, cellSizeInv,
216  domhi_z, do_lo);
217  }
218  if (yhi_open)
219  {
220  Box tbx_yhi, tby_yhi, tbz_yhi;
221  if (tbx.bigEnd(1) == domain.bigEnd(1)) { tbx_yhi = makeSlab(tbx,1,domain.bigEnd(1) );}
222  if (tby.bigEnd(1) == domain.bigEnd(1)+1) { tby_yhi = makeSlab(tby,1,domain.bigEnd(1)+1);}
223  if (tbz.bigEnd(1) == domain.bigEnd(1)) { tbz_yhi = makeSlab(tbz,1,domain.bigEnd(1) );}
224 
225  AdvectionSrcForOpenBC_Tangent_Xmom(tbx_yhi, 1, rho_u_rhs, u,
226  rho_u, rho_v, omega,
227  ax, az, detJ, cellSizeInv);
228  AdvectionSrcForOpenBC_Normal(tby_yhi, 1, rho_v_rhs, v, cell_data, cellSizeInv);
229  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_yhi, 1, rho_w_rhs, w,
230  rho_u, rho_v, omega,
231  ax, ay, az, detJ, cellSizeInv,
232  domhi_z);
233  }
234 }
void AdvectionSrcForMom(const Box &bx, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &cell_data, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &omega, const Array4< const Real > &z_nd, const Array4< const Real > &ax, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, Gpu::DeviceVector< Real > &stretched_dz_d, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_m, const Array4< const Real > &mf_u, const Array4< const Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, MeshType &mesh_type, TerrainType &terrain_type, const int lo_z_face, const int hi_z_face, const Box &domain, const BCRec *bc_ptr_h)
Definition: ERF_AdvectionSrcForMom.cpp:40
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 AdvectionSrcForMom_StretchedDz(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 > &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::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, 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 int lo_z_face, const int hi_z_face)
void AdvectionSrcForMom_TF(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 > &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 int lo_z_face, const int hi_z_face)
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)
void AdvectionSrcForMom_EB(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 > &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 > &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 int lo_z_face, const int hi_z_face, const amrex::Box &domain)
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 AdvectionSrcForMom_ConstantDz(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 > &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::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, 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, TerrainType &terrain_type, const int lo_z_face, const int hi_z_face)
@ cons_bc
Definition: ERF_IndexDefines.H:76
@ open
Definition: ERF_IndexDefines.H:197
@ omega
Definition: ERF_Morrison.H:45
Here is the call graph for this function: