ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_GetRhoAlphaForFaces.H
Go to the documentation of this file.
1 /**
2  * Average rhoAlpha from cell centers to lower and upper z-edges of staggered faces.
3  *
4  * @param[in] i face i-index
5  * @param[in] j face j-index
6  * @param[in] k face k-index
7  * @param[in] ioff x-direction staggering offset
8  * @param[in] joff y-direction staggering offset
9  * @param[out] rhoAlpha_lo rhoAlpha averaged to the lower z-edge
10  * @param[out] rhoAlpha_hi rhoAlpha averaged to the upper z-edge
11  * @param[in] cell_data conserved cell-centered state
12  * @param[in] mu_turb turbulent viscosity
13  * @param[in] mu_eff effective molecular viscosity. NOTE: unlike the mu_eff in
14  * ERF_MakeTauTerms.cpp and ComputeStress*, this does not include the
15  * factor of 2, because the u/v correction strains carry a factor of 1/2.
16  * @param[in] l_consA flag for conservative constant-alpha diffusion
17  * @param[in] l_turb flag for turbulent diffusion
18  * @param[in] eddy_comp eddy-viscosity component to average (EddyDiff::Mom_v, or
19  * EddyDiff::Mom_h for the terrain-metric coefficient)
20  */
21 AMREX_GPU_HOST_DEVICE
22 AMREX_FORCE_INLINE
23 void getRhoAlphaForFaces (int i, int j, int k, int ioff, int joff,
24  amrex::Real& rhoAlpha_lo, amrex::Real& rhoAlpha_hi,
25  const amrex::Array4<const amrex::Real>& cell_data,
26  const amrex::Array4<const amrex::Real>& mu_turb,
27  const amrex::Real mu_eff,
28  bool l_consA, bool l_turb,
29  const int eddy_comp = EddyDiff::Mom_v)
30 {
31  if (l_consA && l_turb) {
32  rhoAlpha_lo = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
33  + cell_data(i,j,k-1,Rho_comp ) + cell_data(i-ioff,j-joff,k-1,Rho_comp ) ) * mu_eff
34  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
35  + mu_turb(i,j,k-1,eddy_comp) + mu_turb(i-ioff,j-joff,k-1,eddy_comp) );
36  rhoAlpha_hi = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
37  + cell_data(i,j,k+1,Rho_comp ) + cell_data(i-ioff,j-joff,k+1,Rho_comp ) ) * mu_eff
38  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
39  + mu_turb(i,j,k+1,eddy_comp) + mu_turb(i-ioff,j-joff,k+1,eddy_comp) );
40  }
41  else if (l_turb) // with MolecDiffType::Constant or None
42  {
43  rhoAlpha_lo = mu_eff
44  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
45  + mu_turb(i,j,k-1,eddy_comp) + mu_turb(i-ioff,j-joff,k-1,eddy_comp) );
46  rhoAlpha_hi = mu_eff
47  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
48  + mu_turb(i,j,k+1,eddy_comp) + mu_turb(i-ioff,j-joff,k+1,eddy_comp) );
49  }
50  else if (l_consA) // without an LES/PBL model
51  {
52  rhoAlpha_lo = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
53  + cell_data(i,j,k-1,Rho_comp ) + cell_data(i-ioff,j-joff,k-1,Rho_comp ) ) * mu_eff;
54  rhoAlpha_hi = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
55  + cell_data(i,j,k+1,Rho_comp ) + cell_data(i-ioff,j-joff,k+1,Rho_comp ) ) * mu_eff;
56  }
57  else // with MolecDiffType::Constant or None - without an LES/PBL model
58  {
59  rhoAlpha_lo = mu_eff;
60  rhoAlpha_hi = mu_eff;
61  }
62 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getRhoAlphaForFaces(int i, int j, int k, int ioff, int joff, amrex::Real &rhoAlpha_lo, amrex::Real &rhoAlpha_hi, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &mu_turb, const amrex::Real mu_eff, bool l_consA, bool l_turb, const int eddy_comp=EddyDiff::Mom_v)
Definition: ERF_GetRhoAlphaForFaces.H:23
#define Rho_comp
Definition: ERF_IndexDefines.H:53
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Mom_v
Definition: ERF_IndexDefines.H:289