ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 Gpu::DeviceVector< Real > &stretched_dz_d, const GpuArray< Real, AMREX_SPACEDIM > &dxInv, 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)
 
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 Gpu::DeviceVector< Real > &stretched_dz_d, const GpuArray< Real, AMREX_SPACEDIM > &dxInv, 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)
 

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 Gpu::DeviceVector< Real > &  stretched_dz_d,
const GpuArray< Real, AMREX_SPACEDIM > &  dxInv,
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 
)

Function for computing the stress with constant viscosity and with terrain.

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

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 Gpu::DeviceVector< Real > &  stretched_dz_d,
const GpuArray< Real, AMREX_SPACEDIM > &  dxInv,
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 
)

Function for computing the stress with constant viscosity and with terrain.

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
166 {
167  // Handle constant alpha case, in which the provided mu_eff is actually
168  // "alpha" and the viscosity needs to be scaled by rho. This can be further
169  // optimized with if statements below instead of creating a new FAB,
170  // but this is implementation is cleaner.
171  FArrayBox temp;
172  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
173  gbx.grow(IntVect(0,0,1));
174  temp.resize(gbx,1, The_Async_Arena());
175  Array4<Real> rhoAlpha = temp.array();
176  if (cell_data) {
177  ParallelFor(gbx,
178  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
179  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
180  });
181  } else {
182  ParallelFor(gbx,
183  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
184  rhoAlpha(i,j,k) = mu_eff;
185  });
186  }
187 
188  auto dz_ptr = stretched_dz_d.data();
189 
190  // First block: cell centered stresses
191  //***********************************************************************************
192  Real OneThird = (1./3.);
193  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
194  {
195  Real mfx = mf_mx(i,j,0);
196  Real mfy = mf_my(i,j,0);
197 
198  Real mu_tot = rhoAlpha(i,j,k) + 2.0*mu_turb(i, j, k, EddyDiff::Mom_h);
199  Real met_h_zeta = dz_ptr[k]*dxInv[2];
200 
201  tau11(i,j,k) = -mu_tot * (met_h_zeta/mfy) * ( tau11(i,j,k) - OneThird*er_arr(i,j,k) );
202  tau22(i,j,k) = -mu_tot * (met_h_zeta/mfx) * ( tau22(i,j,k) - OneThird*er_arr(i,j,k) );
203  tau33(i,j,k) = -mu_tot * ( tau33(i,j,k) - OneThird*er_arr(i,j,k) );
204  });
205 
206  // Second block: off diagonal stresses
207  //***********************************************************************************
208  ParallelFor(tbxxy,tbxxz,tbxyz,
209  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
210  {
211  Real mfx = 0.5 * (mf_ux(i,j,0) + mf_ux(i,j-1,0));
212  Real mfy = 0.5 * (mf_vy(i,j,0) + mf_vy(i-1,j,0));
213 
214  Real met_h_zeta = dz_ptr[k]*dxInv[2];
215 
216  Real mu_bar = 0.25*( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
217  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
218  Real rhoAlpha_bar = 0.25*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
219  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
220  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
221 
222  tau12(i,j,k) *= -mu_tot*met_h_zeta/mfx;
223  tau21(i,j,k) *= -mu_tot*met_h_zeta/mfy;
224  },
225  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
226  {
227  Real mfy = mf_uy(i,j,0);
228 
229  Real met_h_zeta = 0.5 * (dz_ptr[k] + dz_ptr[k-1]) * dxInv[2];
230 
231  Real mu_bar = 0.25*( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
232  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
233  Real rhoAlpha_bar = 0.25*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
234  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
235  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
236 
237  tau13(i,j,k) *= -mu_tot;
238  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
239  },
240  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
241  {
242  Real mfx = mf_vx(i,j,0);
243 
244  Real met_h_zeta = 0.5 * (dz_ptr[k] + dz_ptr[k-1]) * dxInv[2];
245 
246  Real mu_bar = 0.25*( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
247  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
248  Real rhoAlpha_bar = 0.25*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
249  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
250  Real mu_tot = rhoAlpha_bar + 2.0*mu_bar;
251 
252  tau23(i,j,k) *= -mu_tot;
253  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
254  });
255 }
@ 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: