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

Referenced by erf_make_tau_terms().

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

Referenced by erf_make_tau_terms().

Here is the caller graph for this function: