ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ComputeStress_S.cpp File Reference
#include <ERF_Diffusion.H>
#include <ERF_TerrainMetrics.H>
Include dependency graph for ERF_ComputeStress_S.cpp:

Functions

void ComputeStressConsVisc_S (Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Real mu_eff, const Array4< const Real > &cell_data, Array4< Real > &tau11, Array4< Real > &tau22, Array4< Real > &tau33, Array4< Real > &tau12, Array4< Real > &tau21, Array4< Real > &tau13, Array4< Real > &tau31, Array4< Real > &tau23, Array4< Real > &tau32, const Array4< const Real > &er_arr, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, Array4< Real > &tau13i, Array4< Real > &tau23i)
 
void ComputeStressVarVisc_S (Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Real mu_eff, const Array4< const Real > &mu_turb, const Array4< const Real > &cell_data, Array4< Real > &tau11, Array4< Real > &tau22, Array4< Real > &tau33, Array4< Real > &tau12, Array4< Real > &tau21, Array4< Real > &tau13, Array4< Real > &tau31, Array4< Real > &tau23, Array4< Real > &tau32, const Array4< const Real > &er_arr, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, Array4< Real > &tau13i, Array4< Real > &tau23i)
 

Function Documentation

◆ ComputeStressConsVisc_S()

void ComputeStressConsVisc_S ( Box  bxcc,
Box  tbxxy,
Box  tbxxz,
Box  tbxyz,
Real  mu_eff,
const Array4< const Real > &  cell_data,
Array4< Real > &  tau11,
Array4< Real > &  tau22,
Array4< Real > &  tau33,
Array4< Real > &  tau12,
Array4< Real > &  tau21,
Array4< Real > &  tau13,
Array4< Real > &  tau31,
Array4< Real > &  tau23,
Array4< Real > &  tau32,
const Array4< const Real > &  er_arr,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i 
)

Function for computing the stress with constant viscosity on a stretched grid.

Parameters
[in]bxcccell center box for tau_ii
[in]tbxxynodal xy box for tau_12
[in]tbxxznodal xz box for tau_13
[in]tbxyznodal yz box for tau_23
[in]mu_effconstant molecular viscosity
[in]cell_datato access rho if ConstantAlpha
[in,out]tau1111 strain -> stress
[in,out]tau2222 strain -> stress
[in,out]tau3333 strain -> stress
[in,out]tau1212 strain -> stress
[in,out]tau1313 strain -> stress
[in,out]tau2121 strain -> stress
[in,out]tau2323 strain -> stress
[in,out]tau3131 strain -> stress
[in,out]tau3232 strain -> stress
[in]er_arrexpansion rate
[in]mf_mxx map factor at cell centers
[in]mf_vxx map factor at y-faces
[in]mf_myy map factor at cell centers
[in]mf_uyy map factor at x-faces
[in,out]tau13icontribution to stress from du/dz
[in,out]tau23icontribution to stress from dv/dz
46 {
47  // NOTE: mu_eff includes factor of 2
48 
49  // Handle constant alpha case, in which the provided mu_eff is actually
50  // "alpha" and the viscosity needs to be scaled by rho. This can be further
51  // optimized with if statements below instead of creating a new FAB,
52  // but this is implementation is cleaner.
53  FArrayBox temp;
54  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
55  gbx.grow(IntVect(0,0,1));
56  temp.resize(gbx,1, The_Async_Arena());
57  Array4<Real> rhoAlpha = temp.array();
58 
59  if (cell_data)
60  // constant alpha (stored in mu_eff)
61  {
62  ParallelFor(gbx,
63  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
64  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
65  });
66  }
67  else
68  // constant mu_eff
69  {
70  ParallelFor(gbx,
71  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
72  rhoAlpha(i,j,k) = mu_eff;
73  });
74  }
75 
76  // First block: cell centered stresses
77  //***********************************************************************************
78  Real OneThird = (one/three);
79  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
80  {
81  Real mfx = mf_mx(i,j,0);
82  Real mfy = mf_my(i,j,0);
83 
84  Real mu_tot = rhoAlpha(i,j,k);
85 
86 
87  tau11(i,j,k) = -mu_tot / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
88  tau22(i,j,k) = -mu_tot / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
89  tau33(i,j,k) = -mu_tot * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
90  });
91 
92  // Second block: off diagonal stresses
93  //***********************************************************************************
94  ParallelFor(tbxxy,tbxxz,tbxyz,
95  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
96  {
97  // Edge map factors as in the strain kernels: m_x from the v-points and m_y from the
98  // u-points on either side of the edge
99  Real mfy = myhalf * (mf_uy(i,j,0) + mf_uy(i ,j-1,0));
100  Real mfx = myhalf * (mf_vx(i,j,0) + mf_vx(i-1,j ,0));
101 
102  Real mu_tot = fourth*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
103  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
104 
105  tau12(i,j,k) *= -mu_tot / mfx;
106  tau21(i,j,k) *= -mu_tot / mfy;
107  },
108  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
109  {
110  Real mfy = mf_uy(i,j,0);
111 
112  Real mu_tot = fourth * ( rhoAlpha(i-1, j , k ) + rhoAlpha(i , j , k )
113  + rhoAlpha(i-1, j , k-1) + rhoAlpha(i , j , k-1) );
114 
115  tau13(i,j,k) *= -mu_tot;
116  tau31(i,j,k) *= -mu_tot / mfy;
117 
118  if (tau13i) tau13i(i,j,k) *= -mu_tot;
119  },
120  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
121  {
122  Real mfx = mf_vx(i,j,0);
123 
124  Real mu_tot = fourth * ( rhoAlpha(i , j-1, k ) + rhoAlpha(i , j , k )
125  + rhoAlpha(i , j-1, k-1) + rhoAlpha(i , j , k-1) );
126 
127  tau23(i,j,k) *= -mu_tot;
128  tau32(i,j,k) *= -mu_tot / mfx;
129 
130  if (tau23i) tau23i(i,j,k) *= -mu_tot;
131  });
132 }
@ tau12
Definition: ERF_DataStruct.H:51
@ tau23
Definition: ERF_DataStruct.H:51
@ tau33
Definition: ERF_DataStruct.H:51
@ tau22
Definition: ERF_DataStruct.H:51
@ tau11
Definition: ERF_DataStruct.H:51
@ tau32
Definition: ERF_DataStruct.H:51
@ tau31
Definition: ERF_DataStruct.H:51
@ tau21
Definition: ERF_DataStruct.H:51
@ tau13
Definition: ERF_DataStruct.H:51
#define Rho_comp
Definition: ERF_IndexDefines.H:61
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 three
Definition: ERF_NumericalConstants.H:39
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41

Referenced by erf_make_tau_terms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeStressVarVisc_S()

void ComputeStressVarVisc_S ( Box  bxcc,
Box  tbxxy,
Box  tbxxz,
Box  tbxyz,
Real  mu_eff,
const Array4< const Real > &  mu_turb,
const Array4< const Real > &  cell_data,
Array4< Real > &  tau11,
Array4< Real > &  tau22,
Array4< Real > &  tau33,
Array4< Real > &  tau12,
Array4< Real > &  tau21,
Array4< Real > &  tau13,
Array4< Real > &  tau31,
Array4< Real > &  tau23,
Array4< Real > &  tau32,
const Array4< const Real > &  er_arr,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i 
)

Function for computing the stress with variable viscosity on a stretched grid.

Parameters
[in]bxcccell center box for tau_ii
[in]tbxxynodal xy box for tau_12
[in]tbxxznodal xz box for tau_13
[in]tbxyznodal yz box for tau_23
[in]mu_effconstant molecular viscosity
[in]mu_turbvariable turbulent viscosity
[in]cell_datato access rho if ConstantAlpha
[in,out]tau1111 strain -> stress
[in,out]tau2222 strain -> stress
[in,out]tau3333 strain -> stress
[in,out]tau1212 strain -> stress
[in,out]tau1313 strain -> stress
[in,out]tau2121 strain -> stress
[in,out]tau2323 strain -> stress
[in,out]tau3131 strain -> stress
[in,out]tau3232 strain -> stress
[in]er_arrexpansion rate
[in]mf_mxx map factor at cell centers
[in]mf_vxx map factor at y-faces
[in]mf_myy map factor at cell centers
[in]mf_uyy map factor at x-faces
[in,out]tau13icontribution to stress from du/dz
[in,out]tau23icontribution to stress from dv/dz
176 {
177  // NOTE: mu_eff includes factor of 2
178 
179  // Handle constant alpha case, in which the provided mu_eff is actually
180  // "alpha" and the viscosity needs to be scaled by rho. This can be further
181  // optimized with if statements below instead of creating a new FAB,
182  // but this is implementation is cleaner.
183  FArrayBox temp;
184  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
185  gbx.grow(IntVect(0,0,1));
186  temp.resize(gbx,1, The_Async_Arena());
187  Array4<Real> rhoAlpha = temp.array();
188 
189  if (cell_data)
190  // constant alpha (stored in mu_eff)
191  {
192  ParallelFor(gbx,
193  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
194  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
195  });
196  }
197  else
198  // constant mu_eff
199  {
200  ParallelFor(gbx,
201  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
202  rhoAlpha(i,j,k) = mu_eff;
203  });
204  }
205 
206  // First block: cell centered stresses
207  //***********************************************************************************
208  Real OneThird = (one/three);
209  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
210  {
211  Real mfx = mf_mx(i,j,0);
212  Real mfy = mf_my(i,j,0);
213 
214  Real mu_11 = rhoAlpha(i,j,k) + two * mu_turb(i, j, k, EddyDiff::Mom_h);
215  Real mu_22 = mu_11;
216  Real mu_33 = rhoAlpha(i,j,k) + two * mu_turb(i, j, k, EddyDiff::Mom_v);
217 
218 
219  tau11(i,j,k) = -mu_11 / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
220  tau22(i,j,k) = -mu_22 / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
221  tau33(i,j,k) = -mu_33 * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
222  });
223 
224  // Second block: off diagonal stresses
225  //***********************************************************************************
226  ParallelFor(tbxxy,tbxxz,tbxyz,
227  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
228  {
229  // Edge map factors as in the strain kernels: m_x from the v-points and m_y from the
230  // u-points on either side of the edge
231  Real mfy = myhalf * (mf_uy(i,j,0) + mf_uy(i ,j-1,0));
232  Real mfx = myhalf * (mf_vx(i,j,0) + mf_vx(i-1,j ,0));
233 
234  Real mu_bar = fourth*( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
235  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
236  Real rhoAlpha_bar = fourth*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
237  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
238  Real mu_tot = rhoAlpha_bar + two*mu_bar;
239 
240  tau12(i,j,k) *= -mu_tot / mfx;
241  tau21(i,j,k) *= -mu_tot / mfy;
242  },
243  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
244  {
245  Real mfy = mf_uy(i,j,0);
246 
247  Real mu_bar = fourth*( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
248  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
249  Real rhoAlpha_bar = fourth*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
250  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
251  Real mu_tot = rhoAlpha_bar + two*mu_bar;
252 
253  tau13(i,j,k) *= -mu_tot;
254  tau31(i,j,k) *= -mu_tot / mfy;
255 
256  if (tau13i) tau13i(i,j,k) *= -mu_tot;
257  },
258  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
259  {
260  Real mfx = mf_vx(i,j,0);
261 
262  Real mu_bar = fourth*( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
263  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
264  Real rhoAlpha_bar = fourth*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
265  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
266  Real mu_tot = rhoAlpha_bar + two*mu_bar;
267 
268  tau23(i,j,k) *= -mu_tot;
269  tau32(i,j,k) *= -mu_tot / mfx;
270 
271  if (tau23i) tau23i(i,j,k) *= -mu_tot;
272  });
273 }
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
@ Mom_h
Definition: ERF_IndexDefines.H:261
@ Mom_v
Definition: ERF_IndexDefines.H:266

Referenced by erf_make_tau_terms().

Here is the call graph for this function:
Here is the caller graph for this function: