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 > &upw_x, const Array4< const Real > &upw_y, const Array4< const Real > &upw_z, 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:16
const bool fixed_rho
Definition: ERF_InitCustomPert_SDMCongestus3D.H:42
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:36
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 > &  upw_x,
const Array4< const Real > &  upw_y,
const Array4< const Real > &  upw_z,
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]upw_xx-face field whose sign picks the upwind side: avg_xmom, or on a pseudo-incompressible level the direction set by the projection
[in]upw_yy-face field whose sign picks the upwind side
[in]upw_zz-face field whose sign picks the upwind side
[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
155 {
156  BL_PROFILE_VAR("AdvectionSrcForScalars", AdvectionSrcForScalars);
157 
158  // Open bc will be imposed upon all vars (we only access cons here for simplicity)
159  const bool xlo_open = (bc_ptr_h[BCVars::cons_bc].lo(0) == ERFBCType::open);
160  const bool xhi_open = (bc_ptr_h[BCVars::cons_bc].hi(0) == ERFBCType::open);
161  const bool ylo_open = (bc_ptr_h[BCVars::cons_bc].lo(1) == ERFBCType::open);
162  const bool yhi_open = (bc_ptr_h[BCVars::cons_bc].hi(1) == ERFBCType::open);
163 
164  for (int n(0); n<ncomp; ++n) {
165  const int cons_comp = icomp + n;
166  // Native ERF stores primitive scalar components one slot below their
167  // conserved counterparts. Keep that mapping at this adapter boundary.
168  const int scalar_comp = cons_comp - 1;
169  // The face fluxes are stored in the component matching the conserved
170  // variable they carry, because the flux registers index them that way:
171  // CrseAdd/FineAdd are called with srccomp == destcomp == the state
172  // component being refluxed. (The EB path already does this.)
173  const int flux_comp = cons_comp;
174 
175  BuildScalarAdvectionFluxes(bx, cell_prim, scalar_comp, flx_arr, flux_comp,
176  avg_xmom, avg_ymom, avg_zmom,
177  upw_x, upw_y, upw_z,
178  horiz_adv_type, vert_adv_type,
179  horiz_upw_frac, vert_upw_frac);
180 
181  ApplyScalarAdvectionFluxDivergence(bx, flx_arr, flux_comp,
182  advectionSrc, cons_comp, detJ,
183  cellSizeInv, mf_mx, mf_my);
184 
185  } // n
186 
187  // Special advection operator for open BC (bndry tangent operations)
188  //
189  // The state is tangent to every lateral boundary, so where two perpendicular open
190  // boundaries meet there is no boundary-normal operator to own the corner cell.
191  // These kernels assign rather than accumulate, so the corner must appear in
192  // exactly one patch: OpenBCTangentPatches gives the four edges trimmed clear of
193  // the corners, plus the corners tagged with both open sides so that the kernel
194  // differences across neither open boundary there.
195  for (const OpenBCPatch& patch : OpenBCTangentPatches(bx, domain,
196  xlo_open, xhi_open, ylo_open, yhi_open))
197  {
198  AdvectionSrcForOpenBC_Tangent_Cons(patch.box, patch.x_side, patch.y_side,
199  icomp, ncomp, advectionSrc, cell_prim,
200  avg_xmom, avg_ymom, avg_zmom,
201  detJ, mf_mx, mf_my, cellSizeInv);
202  }
203 }
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:342
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:467
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 > &upw_x, const Array4< const Real > &upw_y, const Array4< const Real > &upw_z, 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:133
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::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv)
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:294
@ cons_bc
Definition: ERF_IndexDefines.H:122
@ open
Definition: ERF_IndexDefines.H:324
Definition: ERF_Advection.H:220
Here is the call graph for this function: