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_ux, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vy, Array4< Real > &tau13i, Array4< Real > &tau23i, Array4< Real > &tau33i)
 
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_ux, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vy, Array4< Real > &tau13i, Array4< Real > &tau23i, Array4< Real > &tau33i)
 

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_ux,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vy,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i,
Array4< Real > &  tau33i 
)

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_uxx map factor at x-faces
[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]mf_vyy map factor at y-faces
[in,out]tau13icontribution to stress from du/dz
[in,out]tau23icontribution to stress from dv/dz
[in,out]tau33icontribution to stress from dw/dz
52 {
53  // NOTE: mu_eff includes factor of 2
54 
55  // Handle constant alpha case, in which the provided mu_eff is actually
56  // "alpha" and the viscosity needs to be scaled by rho. This can be further
57  // optimized with if statements below instead of creating a new FAB,
58  // but this is implementation is cleaner.
59  FArrayBox temp;
60  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
61  gbx.grow(IntVect(0,0,1));
62  temp.resize(gbx,1, The_Async_Arena());
63  Array4<Real> rhoAlpha = temp.array();
64 
65  if (cell_data)
66  // constant alpha (stored in mu_eff)
67  {
68  ParallelFor(gbx,
69  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
70  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
71  });
72  }
73  else
74  // constant mu_eff
75  {
76  ParallelFor(gbx,
77  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
78  rhoAlpha(i,j,k) = mu_eff;
79  });
80  }
81 
82  // First block: cell centered stresses
83  //***********************************************************************************
84  Real OneThird = (one/three);
85  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
86  {
87  Real mfx = mf_mx(i,j,0);
88  Real mfy = mf_my(i,j,0);
89 
90  Real mu_tot = rhoAlpha(i,j,k);
91 
92  if (tau33i) tau33i(i,j,k) = -mu_tot * tau33(i,j,k);
93 
94  tau11(i,j,k) = -mu_tot / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
95  tau22(i,j,k) = -mu_tot / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
96  tau33(i,j,k) = -mu_tot * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
97  });
98 
99  // Second block: off diagonal stresses
100  //***********************************************************************************
101  ParallelFor(tbxxy,tbxxz,tbxyz,
102  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
103  {
104  Real mfx = myhalf * (mf_ux(i,j,0) + mf_ux(i,j-1,0));
105  Real mfy = myhalf * (mf_vy(i,j,0) + mf_vy(i-1,j,0));
106 
107  Real mu_tot = fourth*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
108  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
109 
110  tau12(i,j,k) *= -mu_tot / mfx;
111  tau21(i,j,k) *= -mu_tot / mfy;
112  },
113  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
114  {
115  Real mfy = mf_uy(i,j,0);
116 
117  Real mu_tot = fourth * ( rhoAlpha(i-1, j , k ) + rhoAlpha(i , j , k )
118  + rhoAlpha(i-1, j , k-1) + rhoAlpha(i , j , k-1) );
119 
120  tau13(i,j,k) *= -mu_tot;
121  tau31(i,j,k) *= -mu_tot / mfy;
122 
123  if (tau13i) tau13i(i,j,k) *= -mu_tot;
124  },
125  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
126  {
127  Real mfx = mf_vx(i,j,0);
128 
129  Real mu_tot = fourth * ( rhoAlpha(i , j-1, k ) + rhoAlpha(i , j , k )
130  + rhoAlpha(i , j-1, k-1) + rhoAlpha(i , j , k-1) );
131 
132  tau23(i,j,k) *= -mu_tot;
133  tau32(i,j,k) *= -mu_tot / mfx;
134 
135  if (tau23i) tau23i(i,j,k) *= -mu_tot;
136  });
137 }
constexpr amrex::Real three
Definition: ERF_Constants.H:11
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real fourth
Definition: ERF_Constants.H:14
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
@ tau12
Definition: ERF_DataStruct.H:38
@ tau23
Definition: ERF_DataStruct.H:38
@ tau33
Definition: ERF_DataStruct.H:38
@ tau22
Definition: ERF_DataStruct.H:38
@ tau11
Definition: ERF_DataStruct.H:38
@ tau32
Definition: ERF_DataStruct.H:38
@ tau31
Definition: ERF_DataStruct.H:38
@ tau21
Definition: ERF_DataStruct.H:38
@ tau13
Definition: ERF_DataStruct.H:38
#define Rho_comp
Definition: ERF_IndexDefines.H:36
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);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19

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_ux,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vy,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i,
Array4< Real > &  tau33i 
)

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_uxx map factor at x-faces
[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]mf_vyy map factor at y-faces
[in,out]tau13icontribution to stress from du/dz
[in,out]tau23icontribution to stress from dv/dz
[in,out]tau33icontribution to stress from dw/dz
187 {
188  // NOTE: mu_eff includes factor of 2
189 
190  // Handle constant alpha case, in which the provided mu_eff is actually
191  // "alpha" and the viscosity needs to be scaled by rho. This can be further
192  // optimized with if statements below instead of creating a new FAB,
193  // but this is implementation is cleaner.
194  FArrayBox temp;
195  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
196  gbx.grow(IntVect(0,0,1));
197  temp.resize(gbx,1, The_Async_Arena());
198  Array4<Real> rhoAlpha = temp.array();
199 
200  if (cell_data)
201  // constant alpha (stored in mu_eff)
202  {
203  ParallelFor(gbx,
204  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
205  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
206  });
207  }
208  else
209  // constant mu_eff
210  {
211  ParallelFor(gbx,
212  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
213  rhoAlpha(i,j,k) = mu_eff;
214  });
215  }
216 
217  // First block: cell centered stresses
218  //***********************************************************************************
219  Real OneThird = (one/three);
220  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
221  {
222  Real mfx = mf_mx(i,j,0);
223  Real mfy = mf_my(i,j,0);
224 
225  Real mu_11 = rhoAlpha(i,j,k) + two * mu_turb(i, j, k, EddyDiff::Mom_h);
226  Real mu_22 = mu_11;
227  Real mu_33 = rhoAlpha(i,j,k) + two * mu_turb(i, j, k, EddyDiff::Mom_v);
228 
229  if (tau33i) tau33i(i,j,k) = -mu_33 * tau33(i,j,k);
230 
231  tau11(i,j,k) = -mu_11 / mfy * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
232  tau22(i,j,k) = -mu_22 / mfx * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
233  tau33(i,j,k) = -mu_33 * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
234  });
235 
236  // Second block: off diagonal stresses
237  //***********************************************************************************
238  ParallelFor(tbxxy,tbxxz,tbxyz,
239  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
240  {
241  Real mfx = myhalf * (mf_ux(i,j,0) + mf_ux(i,j-1,0));
242  Real mfy = myhalf * (mf_vy(i,j,0) + mf_vy(i-1,j,0));
243 
244  Real mu_bar = fourth*( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
245  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
246  Real rhoAlpha_bar = fourth*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
247  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
248  Real mu_tot = rhoAlpha_bar + two*mu_bar;
249 
250  tau12(i,j,k) *= -mu_tot / mfx;
251  tau21(i,j,k) *= -mu_tot / mfy;
252  },
253  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
254  {
255  Real mfy = mf_uy(i,j,0);
256 
257  Real mu_bar = fourth*( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
258  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
259  Real rhoAlpha_bar = fourth*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
260  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
261  Real mu_tot = rhoAlpha_bar + two*mu_bar;
262 
263  tau13(i,j,k) *= -mu_tot;
264  tau31(i,j,k) *= -mu_tot / mfy;
265 
266  if (tau13i) tau13i(i,j,k) *= -mu_tot;
267  },
268  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
269  {
270  Real mfx = mf_vx(i,j,0);
271 
272  Real mu_bar = fourth*( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
273  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
274  Real rhoAlpha_bar = fourth*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
275  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
276  Real mu_tot = rhoAlpha_bar + two*mu_bar;
277 
278  tau23(i,j,k) *= -mu_tot;
279  tau32(i,j,k) *= -mu_tot / mfx;
280 
281  if (tau23i) tau23i(i,j,k) *= -mu_tot;
282  });
283 }
constexpr amrex::Real two
Definition: ERF_Constants.H:10
@ Mom_h
Definition: ERF_IndexDefines.H:206
@ Mom_v
Definition: ERF_IndexDefines.H:211

Referenced by erf_make_tau_terms().

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