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)
 
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)
 

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 
)

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

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

Referenced by erf_make_tau_terms().

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