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