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 includes the factor
15  * of 2 only for the w (diagonal) correction stress, because the u/v
16  * (off-diagonal) correction strains already carry a factor of 1/2.
17  * @param[in] l_consA flag for conservative constant-alpha diffusion
18  * @param[in] l_turb flag for turbulent diffusion
19  * @param[in] eddy_comp eddy-viscosity component to average (EddyDiff::Mom_v, or
20  * EddyDiff::Mom_h for the terrain-metric coefficient)
21  */
22 AMREX_GPU_HOST_DEVICE
23 AMREX_FORCE_INLINE
24 void getRhoAlphaForFaces (int i, int j, int k, int ioff, int joff,
25  amrex::Real& rhoAlpha_lo, amrex::Real& rhoAlpha_hi,
26  const amrex::Array4<const amrex::Real>& cell_data,
27  const amrex::Array4<const amrex::Real>& mu_turb,
28  const amrex::Real mu_eff,
29  bool l_consA, bool l_turb,
30  const int eddy_comp = EddyDiff::Mom_v)
31 {
32  if (l_consA && l_turb) {
33  rhoAlpha_lo = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
34  + cell_data(i,j,k-1,Rho_comp ) + cell_data(i-ioff,j-joff,k-1,Rho_comp ) ) * mu_eff
35  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
36  + mu_turb(i,j,k-1,eddy_comp) + mu_turb(i-ioff,j-joff,k-1,eddy_comp) );
37  rhoAlpha_hi = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
38  + cell_data(i,j,k+1,Rho_comp ) + cell_data(i-ioff,j-joff,k+1,Rho_comp ) ) * mu_eff
39  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
40  + mu_turb(i,j,k+1,eddy_comp) + mu_turb(i-ioff,j-joff,k+1,eddy_comp) );
41  }
42  else if (l_turb) // with MolecDiffType::Constant or None
43  {
44  rhoAlpha_lo = mu_eff
45  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
46  + mu_turb(i,j,k-1,eddy_comp) + mu_turb(i-ioff,j-joff,k-1,eddy_comp) );
47  rhoAlpha_hi = mu_eff
48  + fourth * ( mu_turb(i,j,k ,eddy_comp) + mu_turb(i-ioff,j-joff,k ,eddy_comp)
49  + mu_turb(i,j,k+1,eddy_comp) + mu_turb(i-ioff,j-joff,k+1,eddy_comp) );
50  }
51  else if (l_consA) // without an LES/PBL model
52  {
53  rhoAlpha_lo = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
54  + cell_data(i,j,k-1,Rho_comp ) + cell_data(i-ioff,j-joff,k-1,Rho_comp ) ) * mu_eff;
55  rhoAlpha_hi = fourth * ( cell_data(i,j,k ,Rho_comp ) + cell_data(i-ioff,j-joff,k ,Rho_comp )
56  + cell_data(i,j,k+1,Rho_comp ) + cell_data(i-ioff,j-joff,k+1,Rho_comp ) ) * mu_eff;
57  }
58  else // with MolecDiffType::Constant or None - without an LES/PBL model
59  {
60  rhoAlpha_lo = mu_eff;
61  rhoAlpha_hi = mu_eff;
62  }
63 }
64 
65 /**
66  * Return rhoAlpha at cell centers below and above a z-staggered face.
67  *
68  * @param[in] i face i-index
69  * @param[in] j face j-index
70  * @param[in] k face k-index
71  * @param[out] rhoAlpha_lo rhoAlpha below the face
72  * @param[out] rhoAlpha_hi rhoAlpha above the face
73  * @param[in] cell_data conserved cell-centered state
74  * @param[in] mu_turb turbulent viscosity
75  * @param[in] mu_eff effective molecular viscosity. NOTE: unlike the mu_eff in
76  * ERF_MakeTauTerms.cpp and ComputeStress*, this includes the factor
77  * of 2 only for the w (diagonal) correction stress, because the u/v
78  * (off-diagonal) correction strains already carry a factor of 1/2.
79  * @param[in] l_consA flag for conservative constant-alpha diffusion
80  * @param[in] l_turb flag for turbulent diffusion
81  */
82 AMREX_GPU_HOST_DEVICE
83 AMREX_FORCE_INLINE
84 void getRhoAlphaForFaces (int i, int j, int k,
85  amrex::Real& rhoAlpha_lo, amrex::Real& rhoAlpha_hi,
86  const amrex::Array4<const amrex::Real>& cell_data,
87  const amrex::Array4<const amrex::Real>& mu_turb,
88  const amrex::Real mu_eff,
89  bool l_consA, bool l_turb)
90 {
91  if (l_consA && l_turb) {
92  rhoAlpha_lo = cell_data(i,j,k-1,Rho_comp) * mu_eff
93  + mu_turb(i,j,k-1,EddyDiff::Mom_v);
94  rhoAlpha_hi = cell_data(i,j,k ,Rho_comp) * mu_eff
95  + mu_turb(i,j,k ,EddyDiff::Mom_v);
96  }
97  else if (l_turb) // with MolecDiffType::Constant or None
98  {
99  rhoAlpha_lo = mu_eff + mu_turb(i,j,k-1,EddyDiff::Mom_v);
100  rhoAlpha_hi = mu_eff + mu_turb(i,j,k ,EddyDiff::Mom_v);
101  }
102  else if (l_consA) // without an LES/PBL model
103  {
104  rhoAlpha_lo = cell_data(i,j,k-1,Rho_comp) * mu_eff;
105  rhoAlpha_hi = cell_data(i,j,k ,Rho_comp) * mu_eff;
106  }
107  else // with MolecDiffType::Constant or None - without an LES/PBL model
108  {
109  rhoAlpha_lo = mu_eff;
110  rhoAlpha_hi = mu_eff;
111  }
112 }
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:24
#define Rho_comp
Definition: ERF_IndexDefines.H:42
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ Mom_v
Definition: ERF_IndexDefines.H:252