ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_AdvectionSrcForState.cpp File Reference
Include dependency graph for ERF_AdvectionSrcForState.cpp:

Functions

void AdvectionSrcForRho (const Box &bx, const Array4< Real > &advectionSrc, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< Real > &avg_xmom, const Array4< Real > &avg_ymom, const Array4< Real > &avg_zmom, const Array4< const Real > &ax_arr, const Array4< const Real > &ay_arr, const Array4< const Real > &az_arr, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vx, const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &flx_arr, const bool fixed_rho)
 
void AdvectionSrcForScalars (const Box &bx, const int icomp, const int ncomp, const Array4< const Real > &avg_xmom, const Array4< const Real > &avg_ymom, const Array4< const Real > &avg_zmom, const Array4< const Real > &cell_prim, const Array4< Real > &advectionSrc, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &flx_arr, const Box &domain, const BCRec *bc_ptr_h)
 

Function Documentation

◆ AdvectionSrcForRho()

void AdvectionSrcForRho ( const Box &  bx,
const Array4< Real > &  advectionSrc,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  Omega,
const Array4< Real > &  avg_xmom,
const Array4< Real > &  avg_ymom,
const Array4< Real > &  avg_zmom,
const Array4< const Real > &  ax_arr,
const Array4< const Real > &  ay_arr,
const Array4< const Real > &  az_arr,
const Array4< const Real > &  detJ,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vx,
const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &  flx_arr,
const bool  fixed_rho 
)

Function for computing the advective tendency for the density update equation This routine also constructs the time-averaged momentum fluxes used by scalar advection.

Parameters
[in]bxbox over which the scalars are updated
[out]advectionSrctendency for the scalar update equation
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of momentum normal to the z-coordinate surface
[out]avg_xmomx-component of time-averaged momentum defined in this routine
[out]avg_ymomy-component of time-averaged momentum defined in this routine
[out]avg_zmomz-component of time-averaged momentum defined in this routine
[in]ax_arrarea fraction of x-faces
[in]ay_arrarea fraction of y-faces
[in]az_arrarea fraction of z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the grid spacing
[in]mf_mxx map factor at cell centers
[in]mf_myy map factor at cell centers
[in]mf_uyy map factor at x-faces
[in]mf_vxx map factor at y-faces
[out]flx_arrdensity flux arrays
[in]fixed_rhoflag to zero the density tendency
54 {
55  BL_PROFILE_VAR("AdvectionSrcForRho", AdvectionSrcForRho);
56  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
57 
58  const Box xbx = surroundingNodes(bx,0);
59  const Box ybx = surroundingNodes(bx,1);
60  const Box zbx = surroundingNodes(bx,2);
61 
62  ParallelFor(xbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
63  {
64  (flx_arr[0])(i,j,k,0) = ax_arr(i,j,k) * rho_u(i,j,k) / mf_uy(i,j,0);
65  avg_xmom(i,j,k) = (flx_arr[0])(i,j,k,0);
66  });
67  ParallelFor(ybx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
68  {
69  (flx_arr[1])(i,j,k,0) = ay_arr(i,j,k) * rho_v(i,j,k) / mf_vx(i,j,0);
70  avg_ymom(i,j,k) = (flx_arr[1])(i,j,k,0);
71  });
72  ParallelFor(zbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
73  {
74  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
75  (flx_arr[2])(i,j,k,0) = az_arr(i,j,k) * Omega(i,j,k) / mfsq;
76  avg_zmom(i,j,k) = (flx_arr[2])(i,j,k,0);
77  });
78 
79  if (fixed_rho) {
80  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
81  {
82  advectionSrc(i,j,k,0) = zero;
83  });
84  } else
85  {
86  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
87  {
88  if (detJ(i,j,k) > zero) {
89  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
90  advectionSrc(i,j,k,0) = - mfsq / detJ(i,j,k) * (
91  ( (flx_arr[0])(i+1,j,k,0) - (flx_arr[0])(i ,j,k,0) ) * dxInv +
92  ( (flx_arr[1])(i,j+1,k,0) - (flx_arr[1])(i,j ,k,0) ) * dyInv +
93  ( (flx_arr[2])(i,j,k+1,0) - (flx_arr[2])(i,j,k ,0) ) * dzInv );
94  } else {
95  advectionSrc(i,j,k,0) = zero;
96  }
97  });
98  }
99 }
void AdvectionSrcForRho(const Box &bx, const Array4< Real > &advectionSrc, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< Real > &avg_xmom, const Array4< Real > &avg_ymom, const Array4< Real > &avg_zmom, const Array4< const Real > &ax_arr, const Array4< const Real > &ay_arr, const Array4< const Real > &az_arr, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vx, const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &flx_arr, const bool fixed_rho)
Definition: ERF_AdvectionSrcForState.cpp:35
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Here is the call graph for this function:

◆ AdvectionSrcForScalars()

void AdvectionSrcForScalars ( const Box &  bx,
const int  icomp,
const int  ncomp,
const Array4< const Real > &  avg_xmom,
const Array4< const Real > &  avg_ymom,
const Array4< const Real > &  avg_zmom,
const Array4< const Real > &  cell_prim,
const Array4< Real > &  advectionSrc,
const Array4< const Real > &  detJ,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_my,
const AdvType  horiz_adv_type,
const AdvType  vert_adv_type,
const Real  horiz_upw_frac,
const Real  vert_upw_frac,
const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &  flx_arr,
const Box &  domain,
const BCRec *  bc_ptr_h 
)

Function for computing the advective tendency for scalar update equations other than density 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 two

Parameters
[in]bxbox over which the scalars are updated if no external boundary conditions
[in]icompcomponent of first scalar to be updated
[in]ncompnumber of components to be updated
[in]avg_xmomx-component of time-averaged momentum defined in this routine
[in]avg_ymomy-component of time-averaged momentum defined in this routine
[in]avg_zmomz-component of time-averaged momentum defined in this routine
[in]cell_primprimitive form of scalar variables, here only potential temperature theta
[out]advectionSrctendency for the scalar update equation
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the grid spacing
[in]mf_mxx map factor at cell centers
[in]mf_myy map factor at cell centers
[in]horiz_adv_typeadvection scheme to be used in horiz. directions for dry scalars
[in]vert_adv_typeadvection scheme to be used in vert. directions for dry scalars
[in]horiz_upw_fracupwinding fraction to be used in horiz. directions for dry scalars (for Blended schemes only)
[in]vert_upw_fracupwinding fraction to be used in vert. directions for dry scalars (for Blended schemes only)
[out]flx_arrscalar flux arrays
[in]domaincomputational domain
[in]bc_ptr_hboundary condition records on host
148 {
149  BL_PROFILE_VAR("AdvectionSrcForScalars", AdvectionSrcForScalars);
150 
151  // Open bc will be imposed upon all vars (we only access cons here for simplicity)
152  const bool xlo_open = (bc_ptr_h[BCVars::cons_bc].lo(0) == ERFBCType::open);
153  const bool xhi_open = (bc_ptr_h[BCVars::cons_bc].hi(0) == ERFBCType::open);
154  const bool ylo_open = (bc_ptr_h[BCVars::cons_bc].lo(1) == ERFBCType::open);
155  const bool yhi_open = (bc_ptr_h[BCVars::cons_bc].hi(1) == ERFBCType::open);
156 
157  for (int n(0); n<ncomp; ++n) {
158  const int cons_comp = icomp + n;
159  // Native ERF stores primitive scalar components one slot below their
160  // conserved counterparts. Keep that mapping at this adapter boundary.
161  const int scalar_comp = cons_comp - 1;
162  // The face fluxes are stored in the component matching the conserved
163  // variable they carry, because the flux registers index them that way:
164  // CrseAdd/FineAdd are called with srccomp == destcomp == the state
165  // component being refluxed. (The EB path already does this.)
166  const int flux_comp = cons_comp;
167 
168  BuildScalarAdvectionFluxes(bx, cell_prim, scalar_comp, flx_arr, flux_comp,
169  avg_xmom, avg_ymom, avg_zmom,
170  horiz_adv_type, vert_adv_type,
171  horiz_upw_frac, vert_upw_frac);
172 
173  ApplyScalarAdvectionFluxDivergence(bx, flx_arr, flux_comp,
174  advectionSrc, cons_comp, detJ,
175  cellSizeInv, mf_mx, mf_my);
176 
177  } // n
178 
179  // Special advection operator for open BC (bndry tangent operations)
180  //
181  // The state is tangent to every lateral boundary, so where two perpendicular open
182  // boundaries meet there is no boundary-normal operator to own the corner cell.
183  // These kernels assign rather than accumulate, so the corner must appear in
184  // exactly one patch: OpenBCTangentPatches gives the four edges trimmed clear of
185  // the corners, plus the corners tagged with both open sides so that the kernel
186  // differences across neither open boundary there.
187  for (const OpenBCPatch& patch : OpenBCTangentPatches(bx, domain,
188  xlo_open, xhi_open, ylo_open, yhi_open))
189  {
190  AdvectionSrcForOpenBC_Tangent_Cons(patch.box, patch.x_side, patch.y_side,
191  icomp, ncomp, advectionSrc, cell_prim,
192  avg_xmom, avg_ymom, avg_zmom,
193  detJ, cellSizeInv);
194  }
195 }
void BuildScalarAdvectionFluxes(const amrex::Box &bx, const amrex::Array4< const amrex::Real > &scalar, const int scalar_comp, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const int flux_comp, 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 AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac)
Definition: ERF_AdvectionSrcForScalars.H:204
void ApplyScalarAdvectionFluxDivergence(const amrex::Box &bx, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const int flux_comp, const amrex::Array4< amrex::Real > &rhs, const int rhs_comp, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my)
Definition: ERF_AdvectionSrcForScalars.H:313
void AdvectionSrcForScalars(const Box &bx, const int icomp, const int ncomp, const Array4< const Real > &avg_xmom, const Array4< const Real > &avg_ymom, const Array4< const Real > &avg_zmom, const Array4< const Real > &cell_prim, const Array4< Real > &advectionSrc, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, const GpuArray< const Array4< Real >, AMREX_SPACEDIM > &flx_arr, const Box &domain, const BCRec *bc_ptr_h)
Definition: ERF_AdvectionSrcForState.cpp:129
amrex::Vector< OpenBCPatch > OpenBCTangentPatches(const amrex::Box &b, const amrex::Box &domain, const bool xlo_open, const bool xhi_open, const bool ylo_open, const bool yhi_open)
Definition: ERF_Advection.H:291
void AdvectionSrcForOpenBC_Tangent_Cons(const amrex::Box &bx, const OpenSide x_side, const OpenSide y_side, 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)
@ cons_bc
Definition: ERF_IndexDefines.H:89
@ open
Definition: ERF_IndexDefines.H:304
Definition: ERF_Advection.H:217
Here is the call graph for this function: