ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ComputeStress_T.cpp File Reference
Include dependency graph for ERF_ComputeStress_T.cpp:

Functions

void ComputeStressConsVisc_T (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 > &z_nd, const Array4< const Real > &detJ, 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, Array4< Real > &tau13i, Array4< Real > &tau23i, const bool implicit_metric)
 
void ComputeStressVarVisc_T (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 > &z_nd, const Array4< const Real > &detJ, 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, Array4< Real > &tau13i, Array4< Real > &tau23i, const bool implicit_metric)
 

Function Documentation

◆ ComputeStressConsVisc_T()

void ComputeStressConsVisc_T ( 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 > &  z_nd,
const Array4< const Real > &  detJ,
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,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i,
const bool  implicit_metric 
)

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]detJJacobian determinant
[in]dxInvinverse cell size array
[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]implicit_metricerf.implicit_terrain_metric: tau13i/tau23i also hold the compact terrain-metric term on the interior faces (see ERF_TerrainImplicitMetric.H)
60 {
61  // NOTE: mu_eff includes factor of 2
62 
63  // Handle constant alpha case, in which the provided mu_eff is actually
64  // "alpha" and the viscosity needs to be scaled by rho. This can be further
65  // optimized with if statements below instead of creating a new FAB,
66  // but this is implementation is cleaner.
67  FArrayBox temp;
68  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
69  gbx.grow(IntVect(0,0,1));
70  temp.resize(gbx,1, The_Async_Arena());
71  Array4<Real> rhoAlpha = temp.array();
72 
73  if (cell_data)
74  // constant alpha (stored in mu_eff)
75  {
76  ParallelFor(gbx,
77  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
78  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
79  });
80  }
81  else
82  // constant mu_eff
83  {
84  ParallelFor(gbx,
85  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
86  rhoAlpha(i,j,k) = mu_eff;
87  });
88  }
89 
90  //***********************************************************************************
91  // NOTE: The first block computes (S-D).
92  // The second block computes JT*2mu*(S-D)
93  // Boxes are copied here for extrapolations in the second block operations
94  //***********************************************************************************
95  Box bxcc2 = bxcc;
96  bxcc2.grow(IntVect(-1,-1,0));
97 
98  // First block: compute S-D
99  //***********************************************************************************
100  Real OneThird = (one/three);
101  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
102 
103  tau11(i,j,k) -= OneThird*er_arr(i,j,k);
104  tau22(i,j,k) -= OneThird*er_arr(i,j,k);
105  tau33(i,j,k) -= OneThird*er_arr(i,j,k);
106  });
107 
108  // Second block: compute JT*2mu*(S-D)
109  //***********************************************************************************
110  // Fill tau33 first (no linear combination extrapolation)
111  //-----------------------------------------------------------------------------------
112  ParallelFor(bxcc2,
113  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
114  {
115  Real mfx = mf_mx(i,j,0);
116  Real mfy = mf_my(i,j,0);
117 
118  Real met_h_xi,met_h_eta;
119  met_h_xi = Compute_h_xi_AtCellCenter (i,j,k,dxInv,z_nd);
120  met_h_eta = Compute_h_eta_AtCellCenter (i,j,k,dxInv,z_nd);
121 
122  Real tau31bar = fourth * ( tau31(i , j , k ) + tau31(i+1, j , k )
123  + tau31(i , j , k+1) + tau31(i+1, j , k+1) );
124  Real tau32bar = fourth * ( tau32(i , j , k ) + tau32(i , j+1, k )
125  + tau32(i , j , k+1) + tau32(i , j+1, k+1) );
126  Real mu_tot = rhoAlpha(i,j,k);
127 
128  tau33(i,j,k) -= met_h_xi*mfx*tau31bar + met_h_eta*mfy*tau32bar;
129  tau33(i,j,k) *= -mu_tot;
130 
131  });
132 
133  // Second block: compute JT*2mu*(S-D)
134  //***********************************************************************************
135  // Fill tau13, tau23 next (linear combination extrapolation)
136  //-----------------------------------------------------------------------------------
137  // Extrapolate tau13 & tau23 to bottom
138  {
139  Box planexz = tbxxz; planexz.setBig(2, planexz.smallEnd(2) );
140  tbxxz.growLo(2,-1);
141  Box planeyz = tbxyz; planeyz.setBig(2, planeyz.smallEnd(2) );
142  tbxyz.growLo(2,-1);
143  ParallelFor(planexz,planeyz,
144  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
145  {
146  Real mfx = mf_ux(i,j,0);
147  Real mfy = mf_uy(i,j,0);
148 
149  Real met_h_xi,met_h_eta,met_h_zeta;
150  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
151  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
152  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
153 
154  Real tau11lo = myhalf * ( tau11(i , j , k ) + tau11(i-1, j , k ) );
155  Real tau11hi = myhalf * ( tau11(i , j , k+1) + tau11(i-1, j , k+1) );
156  Real tau11bar = Real(1.5)*tau11lo - myhalf*tau11hi;
157 
158  Real tau12lo = myhalf * ( tau12(i , j , k ) + tau12(i , j+1, k ) );
159  Real tau12hi = myhalf * ( tau12(i , j , k+1) + tau12(i , j+1, k+1) );
160  Real tau12bar = Real(1.5)*tau12lo - myhalf*tau12hi;
161 
162  Real mu_tot = fourth*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
163  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
164 
165  tau13(i,j,k) -= met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
166  tau13(i,j,k) *= -mu_tot;
167  if (tau13i) { tau13i(i,j,k) *= -mu_tot; }
168 
169  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
170  },
171  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
172  {
173  Real mfx = mf_vx(i,j,0);
174  Real mfy = mf_vy(i,j,0);
175 
176  Real met_h_xi,met_h_eta,met_h_zeta;
177  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
178  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
179  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
180 
181  Real tau21lo = myhalf * ( tau21(i , j , k ) + tau21(i+1, j , k ) );
182  Real tau21hi = myhalf * ( tau21(i , j , k+1) + tau21(i+1, j , k+1) );
183  Real tau21bar = Real(1.5)*tau21lo - myhalf*tau21hi;
184 
185  Real tau22lo = myhalf * ( tau22(i , j , k ) + tau22(i , j-1, k ) );
186  Real tau22hi = myhalf * ( tau22(i , j , k+1) + tau22(i , j-1, k+1) );
187  Real tau22bar = Real(1.5)*tau22lo - myhalf*tau22hi;
188 
189  Real mu_tot = fourth*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
190  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
191 
192  tau23(i,j,k) -= met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
193  tau23(i,j,k) *= -mu_tot;
194  if (tau23i) { tau23i(i,j,k) *= -mu_tot; }
195 
196  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
197  });
198  }
199  // Extrapolate tau13 & tau23 to top
200  {
201  Box planexz = tbxxz; planexz.setSmall(2, planexz.bigEnd(2) );
202  tbxxz.growHi(2,-1);
203  Box planeyz = tbxyz; planeyz.setSmall(2, planeyz.bigEnd(2) );
204  tbxyz.growHi(2,-1);
205  ParallelFor(planexz,planeyz,
206  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
207  {
208  Real mfx = mf_ux(i,j,0);
209  Real mfy = mf_uy(i,j,0);
210 
211  Real met_h_xi,met_h_eta,met_h_zeta;
212  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
213  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
214  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
215 
216  Real tau11lo = myhalf * ( tau11(i , j , k-2) + tau11(i-1, j , k-2) );
217  Real tau11hi = myhalf * ( tau11(i , j , k-1) + tau11(i-1, j , k-1) );
218  Real tau11bar = Real(1.5)*tau11hi - myhalf*tau11lo;
219 
220  Real tau12lo = myhalf * ( tau12(i , j , k-2) + tau12(i , j+1, k-2) );
221  Real tau12hi = myhalf * ( tau12(i , j , k-1) + tau12(i , j+1, k-1) );
222  Real tau12bar = Real(1.5)*tau12hi - myhalf*tau12lo;
223 
224  Real mu_tot = fourth*( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
225  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
226 
227  tau13(i,j,k) -= met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
228  tau13(i,j,k) *= -mu_tot;
229  if (tau13i) { tau13i(i,j,k) *= -mu_tot; }
230 
231  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
232  },
233  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
234  {
235  Real mfx = mf_vx(i,j,0);
236  Real mfy = mf_vy(i,j,0);
237 
238  Real met_h_xi,met_h_eta,met_h_zeta;
239  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
240  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
241  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
242 
243  Real tau21lo = myhalf * ( tau21(i , j , k-2) + tau21(i+1, j , k-2) );
244  Real tau21hi = myhalf * ( tau21(i , j , k-1) + tau21(i+1, j , k-1) );
245  Real tau21bar = Real(1.5)*tau21hi - myhalf*tau21lo;
246 
247  Real tau22lo = myhalf * ( tau22(i , j , k-2) + tau22(i , j-1, k-2) );
248  Real tau22hi = myhalf * ( tau22(i , j , k-1) + tau22(i , j-1, k-1) );
249  Real tau22bar = Real(1.5)*tau22hi - myhalf*tau22lo;
250 
251  Real mu_tot = fourth*( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
252  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
253 
254  tau23(i,j,k) -= met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
255  tau23(i,j,k) *= -mu_tot;
256  if (tau23i) { tau23i(i,j,k) *= -mu_tot; }
257 
258  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
259  });
260  }
261 
262  // Second block: compute JT*2mu*(S-D)
263  //***********************************************************************************
264  // Fill tau13, tau23 next (valid averaging region)
265  //-----------------------------------------------------------------------------------
266  ParallelFor(tbxxz,tbxyz,
267  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
268  {
269  Real mfx = mf_ux(i,j,0);
270  Real mfy = mf_uy(i,j,0);
271 
272  Real met_h_xi,met_h_eta,met_h_zeta;
273  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
274  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
275  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
276 
277  Real tau11bar = fourth * ( tau11(i , j , k ) + tau11(i-1, j , k )
278  + tau11(i , j , k-1) + tau11(i-1, j , k-1) );
279  Real tau12bar = fourth * ( tau12(i , j , k ) + tau12(i , j+1, k )
280  + tau12(i , j , k-1) + tau12(i , j+1, k-1) );
281  Real mu_tot = fourth * ( rhoAlpha(i-1, j , k ) + rhoAlpha(i , j , k )
282  + rhoAlpha(i-1, j , k-1) + rhoAlpha(i , j , k-1) );
283 
284  tau13(i,j,k) -= met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
285  tau13(i,j,k) *= -mu_tot;
286  if (tau13i) {
287  // erf.implicit_terrain_metric: the implicit solve also takes the compact
288  // K_h*M*d/dz metric term on these interior faces, so tau13i holds it too
289  const Real metric = (implicit_metric) ?
290  TerrainMetricMomFactor(0, met_h_xi, met_h_eta, mfx, mfy) : zero;
291  tau13i(i,j,k) *= -(mu_tot + mu_tot*metric);
292  }
293 
294  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
295  },
296  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
297  {
298  Real mfx = mf_vx(i,j,0);
299  Real mfy = mf_vy(i,j,0);
300 
301  Real met_h_xi,met_h_eta,met_h_zeta;
302  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
303  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
304  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
305 
306  Real tau21bar = fourth * ( tau21(i , j , k ) + tau21(i+1, j , k )
307  + tau21(i , j , k-1) + tau21(i+1, j , k-1) );
308  Real tau22bar = fourth * ( tau22(i , j , k ) + tau22(i , j-1, k )
309  + tau22(i , j , k-1) + tau22(i , j-1, k-1) );
310  Real mu_tot = fourth * ( rhoAlpha(i , j-1, k ) + rhoAlpha(i , j , k )
311  + rhoAlpha(i , j-1, k-1) + rhoAlpha(i , j , k-1) );
312 
313  tau23(i,j,k) -= met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
314  tau23(i,j,k) *= -mu_tot;
315  if (tau23i) {
316  // erf.implicit_terrain_metric: the implicit solve also takes the compact
317  // K_h*M*d/dz metric term on these interior faces, so tau23i holds it too
318  const Real metric = (implicit_metric) ?
319  TerrainMetricMomFactor(1, met_h_xi, met_h_eta, mfx, mfy) : zero;
320  tau23i(i,j,k) *= -(mu_tot + mu_tot*metric);
321  }
322 
323  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
324  });
325 
326  // Fill the remaining components: tau11, tau22, tau12/21
327  //-----------------------------------------------------------------------------------
328  ParallelFor(bxcc,tbxxy,
329  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
330  {
331  Real mfx = mf_mx(i,j,0);
332  Real mfy = mf_my(i,j,0);
333 
334  Real met_h_zeta = detJ(i,j,k);
335  Real mu_tot = rhoAlpha(i,j,k);
336 
337  tau11(i,j,k) *= -mu_tot*met_h_zeta/mfy;
338  tau22(i,j,k) *= -mu_tot*met_h_zeta/mfx;
339  },
340  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
341  {
342  // Edge map factors as in the strain kernels: m_x from the v-points and m_y from the
343  // u-points on either side of the edge
344  Real mfy = myhalf * (mf_uy(i,j,0) + mf_uy(i ,j-1,0));
345  Real mfx = myhalf * (mf_vx(i,j,0) + mf_vx(i-1,j ,0));
346 
347  Real met_h_zeta = Compute_h_zeta_AtEdgeCenterK(i,j,k,dxInv,z_nd);
348 
349  Real mu_tot = fourth*( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
350  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
351 
352  tau12(i,j,k) *= -mu_tot*met_h_zeta/mfx;
353  tau21(i,j,k) *= -mu_tot*met_h_zeta/mfy;
354  });
355 }
@ 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
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
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 zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real TerrainMetricMomFactor(const int stagdir, const amrex::Real h_xi, const amrex::Real h_eta, const amrex::Real mx, const amrex::Real my) noexcept
Definition: ERF_TerrainImplicitMetric.H:39
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:621
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:596
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:572
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterK(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:497
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:646
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:227
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:252
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:670
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:693

Referenced by erf_make_tau_terms().

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

◆ ComputeStressVarVisc_T()

void ComputeStressVarVisc_T ( 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 > &  z_nd,
const Array4< const Real > &  detJ,
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,
Array4< Real > &  tau13i,
Array4< Real > &  tau23i,
const bool  implicit_metric 
)

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]detJJacobian determinant
[in]dxInvinverse cell size array
[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]implicit_metricerf.implicit_terrain_metric: tau13i/tau23i also hold the compact terrain-metric term on the interior faces (see ERF_TerrainImplicitMetric.H)

NOTE: The zeta-face stresses tau13/tau23 are the terrain-normal combination tau_i3 - h_xi*tau_i1 - h_eta*tau_i2. tau_i3 is a vertical stress and takes K_v (EddyDiff::Mom_v); tau_i1 and tau_i2 are horizontal stresses and take K_h (EddyDiff::Mom_h), as the h*Fx terms of the scalar fluxes do. Applying K_v to the projected terms makes the operator non-symmetric and, when K_h*h^2 > 2*K_v, anti-diffusive. The projected stresses K_h*S are formed at the cells and xy edges and averaged to the zeta edges. On a uniform slope with uniform dz this is the transpose of the metric term in S11/S22, so the strain part of the operator dissipates energy for any K_h and K_v (an edge-averaged K_h times averaged strains does not, where K_h varies from cell to cell). tau13i/tau23i (the part the implicit solve takes) are pure K_v terms.

424 {
425  // NOTE: mu_eff includes factor of 2
426 
427  // Handle constant alpha case, in which the provided mu_eff is actually
428  // "alpha" and the viscosity needs to be scaled by rho. This can be further
429  // optimized with if statements below instead of creating a new FAB,
430  // but this is implementation is cleaner.
431  FArrayBox temp;
432  Box gbx = bxcc; // Note: bxcc have been grown in x/y only.
433  gbx.grow(IntVect(0,0,1));
434  temp.resize(gbx,1, The_Async_Arena());
435  Array4<Real> rhoAlpha = temp.array();
436 
437  if (cell_data)
438  // constant alpha (stored in mu_eff)
439  {
440  ParallelFor(gbx,
441  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
442  rhoAlpha(i,j,k) = cell_data(i, j, k, Rho_comp) * mu_eff;
443  });
444  }
445  else
446  // constant mu_eff
447  {
448  ParallelFor(gbx,
449  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
450  rhoAlpha(i,j,k) = mu_eff;
451  });
452  }
453 
454  //***********************************************************************************
455  // NOTE: The first block computes (S-D).
456  // The second block computes JT*2K*(S-D)
457  // Boxes are copied here for extrapolations in the second block operations
458  //***********************************************************************************
459  Box bxcc2 = bxcc;
460  bxcc2.grow(IntVect(-1,-1,0));
461 
462  // First block: compute S-D
463  //***********************************************************************************
464  Real OneThird = (one/three);
465  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
466 
467  tau11(i,j,k) -= OneThird*er_arr(i,j,k);
468  tau22(i,j,k) -= OneThird*er_arr(i,j,k);
469  tau33(i,j,k) -= OneThird*er_arr(i,j,k);
470  });
471 
472  // Second block: compute JT*2K*(S-D)
473  //***********************************************************************************
474  // Fill tau33 first (no linear combination extrapolation)
475  //-----------------------------------------------------------------------------------
476  ParallelFor(bxcc2,
477  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
478  {
479  Real mfx = mf_mx(i,j,0);
480  Real mfy = mf_my(i,j,0);
481 
482  Real met_h_xi,met_h_eta;
483  met_h_xi = Compute_h_xi_AtCellCenter (i,j,k,dxInv,z_nd);
484  met_h_eta = Compute_h_eta_AtCellCenter (i,j,k,dxInv,z_nd);
485 
486  Real tau31bar = fourth * ( tau31(i , j , k ) + tau31(i+1, j , k )
487  + tau31(i , j , k+1) + tau31(i+1, j , k+1) );
488  Real tau32bar = fourth * ( tau32(i , j , k ) + tau32(i , j+1, k )
489  + tau32(i , j , k+1) + tau32(i , j+1, k+1) );
490 
491  Real mu_tot = rhoAlpha(i,j,k) + two*mu_turb(i, j, k, EddyDiff::Mom_v);
492 
493  tau33(i,j,k) -= met_h_xi*mfx*tau31bar + met_h_eta*mfy*tau32bar;
494  tau33(i,j,k) *= -mu_tot;
495 
496  });
497 
498  // The zeta-face stresses project the horizontal stresses K_h*S11, K_h*S12, K_h*S21 and
499  // K_h*S22 (see the NOTE above). Form them where they live -- at the cells and the xy
500  // edges, with the coefficients the tau11/tau22/tau12 kernels below apply -- and average
501  // the stresses to the zeta edges, as the scalar fluxes average K_h*grad. On a uniform
502  // slope with uniform dz that is the transpose of the metric term in S11/S22, which keeps
503  // the strain part of the operator dissipative for any K_h and K_v (see the NOTE above).
504  //-----------------------------------------------------------------------------------
505  // kh12 is read at (i,j+1) over tbxxz and kh21 at (i+1,j) over tbxyz. On a tile that is not
506  // the last in x or y the nodal tile box tbxxy stops one node short of those reads, so form
507  // them on the nodes the reads need; the strains are valid there (they are computed on the
508  // halo-grown boxes).
509  Box khxy = tbxxy;
510  khxy.setSmall(0, amrex::min(tbxxz.smallEnd(0), tbxyz.smallEnd(0)));
511  khxy.setSmall(1, amrex::min(tbxxz.smallEnd(1), tbxyz.smallEnd(1)));
512  khxy.setBig (0, amrex::max(tbxxz.bigEnd(0) , tbxyz.bigEnd(0)+1));
513  khxy.setBig (1, amrex::max(tbxxz.bigEnd(1)+1, tbxyz.bigEnd(1) ));
514  FArrayBox kh11_fab(bxcc,1,The_Async_Arena()), kh22_fab(bxcc,1,The_Async_Arena());
515  FArrayBox kh12_fab(khxy,1,The_Async_Arena()), kh21_fab(khxy,1,The_Async_Arena());
516  const Array4<Real> kh11 = kh11_fab.array();
517  const Array4<Real> kh22 = kh22_fab.array();
518  const Array4<Real> kh12 = kh12_fab.array();
519  const Array4<Real> kh21 = kh21_fab.array();
520  ParallelFor(bxcc, khxy,
521  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
522  {
523  Real mu_h_tot = rhoAlpha(i,j,k) + two*mu_turb(i, j, k, EddyDiff::Mom_h);
524  kh11(i,j,k) = mu_h_tot*tau11(i,j,k);
525  kh22(i,j,k) = mu_h_tot*tau22(i,j,k);
526  },
527  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
528  {
529  Real mu_bar = fourth * ( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
530  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
531  Real rhoAlpha_bar = fourth * ( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
532  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
533  Real mu_h_tot = rhoAlpha_bar + two*mu_bar;
534  kh12(i,j,k) = mu_h_tot*tau12(i,j,k);
535  kh21(i,j,k) = mu_h_tot*tau21(i,j,k);
536  });
537 
538  // Second block: compute JT*2K*(S-D)
539  //***********************************************************************************
540  // Fill tau13, tau23 next (linear combination extrapolation)
541  //-----------------------------------------------------------------------------------
542  // Extrapolate tau13 & tau23 to bottom
543  {
544  Box planexz = tbxxz; planexz.setBig(2, planexz.smallEnd(2) );
545  tbxxz.growLo(2,-1);
546  Box planeyz = tbxyz; planeyz.setBig(2, planeyz.smallEnd(2) );
547  tbxyz.growLo(2,-1);
548  ParallelFor(planexz,planeyz,
549  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
550  {
551  Real mfx = mf_ux(i,j,0);
552  Real mfy = mf_uy(i,j,0);
553 
554  Real met_h_xi,met_h_eta,met_h_zeta;
555  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
556  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
557  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
558 
559  Real tau11lo = myhalf * ( kh11(i , j , k ) + kh11(i-1, j , k ) );
560  Real tau11hi = myhalf * ( kh11(i , j , k+1) + kh11(i-1, j , k+1) );
561  Real tau11bar = Real(1.5)*tau11lo - myhalf*tau11hi;
562 
563  Real tau12lo = myhalf * ( kh12(i , j , k ) + kh12(i , j+1, k ) );
564  Real tau12hi = myhalf * ( kh12(i , j , k+1) + kh12(i , j+1, k+1) );
565  Real tau12bar = Real(1.5)*tau12lo - myhalf*tau12hi;
566 
567  Real mu_bar = fourth * ( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
568  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
569  Real rhoAlpha_bar = fourth * ( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
570  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
571  Real mu_tot = rhoAlpha_bar + two*mu_bar;
572 
573  // K_v on S13; the projected horizontal stresses carry K_h (see the NOTE above)
574  tau13(i,j,k) *= -mu_tot;
575  tau13(i,j,k) += met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
576  if (tau13i) { tau13i(i,j,k) *= -mu_tot; }
577 
578  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
579  },
580  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
581  {
582  Real mfx = mf_vx(i,j,0);
583  Real mfy = mf_vy(i,j,0);
584 
585  Real met_h_xi,met_h_eta,met_h_zeta;
586  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
587  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
588  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
589 
590  Real tau21lo = myhalf * ( kh21(i , j , k ) + kh21(i+1, j , k ) );
591  Real tau21hi = myhalf * ( kh21(i , j , k+1) + kh21(i+1, j , k+1) );
592  Real tau21bar = Real(1.5)*tau21lo - myhalf*tau21hi;
593 
594  Real tau22lo = myhalf * ( kh22(i , j , k ) + kh22(i , j-1, k ) );
595  Real tau22hi = myhalf * ( kh22(i , j , k+1) + kh22(i , j-1, k+1) );
596  Real tau22bar = Real(1.5)*tau22lo - myhalf*tau22hi;
597 
598  Real mu_bar = fourth * ( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
599  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
600  Real rhoAlpha_bar = fourth * ( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
601  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
602  Real mu_tot = rhoAlpha_bar + two*mu_bar;
603 
604  // K_v on S23; the projected horizontal stresses carry K_h (see the NOTE above)
605  tau23(i,j,k) *= -mu_tot;
606  tau23(i,j,k) += met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
607  if (tau23i) { tau23i(i,j,k) *= -mu_tot; }
608 
609  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
610  });
611  }
612  // Extrapolate tau13 & tau23 to top
613  {
614  Box planexz = tbxxz; planexz.setSmall(2, planexz.bigEnd(2) );
615  tbxxz.growHi(2,-1);
616  Box planeyz = tbxyz; planeyz.setSmall(2, planeyz.bigEnd(2) );
617  tbxyz.growHi(2,-1);
618  ParallelFor(planexz,planeyz,
619  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
620  {
621  Real mfx = mf_ux(i,j,0);
622  Real mfy = mf_uy(i,j,0);
623 
624  Real met_h_xi,met_h_eta,met_h_zeta;
625  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
626  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
627  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
628 
629  Real tau11lo = myhalf * ( kh11(i , j , k-2) + kh11(i-1, j , k-2) );
630  Real tau11hi = myhalf * ( kh11(i , j , k-1) + kh11(i-1, j , k-1) );
631  Real tau11bar = Real(1.5)*tau11hi - myhalf*tau11lo;
632 
633  Real tau12lo = myhalf * ( kh12(i , j , k-2) + kh12(i , j+1, k-2) );
634  Real tau12hi = myhalf * ( kh12(i , j , k-1) + kh12(i , j+1, k-1) );
635  Real tau12bar = Real(1.5)*tau12hi - myhalf*tau12lo;
636 
637  Real mu_bar = fourth * ( mu_turb(i-1, j, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
638  + mu_turb(i-1, j, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
639  Real rhoAlpha_bar = fourth * ( rhoAlpha(i-1, j, k ) + rhoAlpha(i, j, k )
640  + rhoAlpha(i-1, j, k-1) + rhoAlpha(i, j, k-1) );
641  Real mu_tot = rhoAlpha_bar + two*mu_bar;
642 
643  // K_v on S13; the projected horizontal stresses carry K_h (see the NOTE above)
644  tau13(i,j,k) *= -mu_tot;
645  tau13(i,j,k) += met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
646  if (tau13i) { tau13i(i,j,k) *= -mu_tot; }
647 
648  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
649  },
650  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
651  {
652  Real mfx = mf_vx(i,j,0);
653  Real mfy = mf_vy(i,j,0);
654 
655  Real met_h_xi,met_h_eta,met_h_zeta;
656  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
657  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
658  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
659 
660  Real tau21lo = myhalf * ( kh21(i , j , k-2) + kh21(i+1, j , k-2) );
661  Real tau21hi = myhalf * ( kh21(i , j , k-1) + kh21(i+1, j , k-1) );
662  Real tau21bar = Real(1.5)*tau21hi - myhalf*tau21lo;
663 
664  Real tau22lo = myhalf * ( kh22(i , j , k-2) + kh22(i , j-1, k-2) );
665  Real tau22hi = myhalf * ( kh22(i , j , k-1) + kh22(i , j-1, k-1) );
666  Real tau22bar = Real(1.5)*tau22hi - myhalf*tau22lo;
667 
668  Real mu_bar = fourth * ( mu_turb(i, j-1, k , EddyDiff::Mom_v) + mu_turb(i, j, k , EddyDiff::Mom_v)
669  + mu_turb(i, j-1, k-1, EddyDiff::Mom_v) + mu_turb(i, j, k-1, EddyDiff::Mom_v) );
670  Real rhoAlpha_bar = fourth * ( rhoAlpha(i, j-1, k ) + rhoAlpha(i, j, k )
671  + rhoAlpha(i, j-1, k-1) + rhoAlpha(i, j, k-1) );
672  Real mu_tot = rhoAlpha_bar + two*mu_bar;
673 
674  // K_v on S23; the projected horizontal stresses carry K_h (see the NOTE above)
675  tau23(i,j,k) *= -mu_tot;
676  tau23(i,j,k) += met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
677  if (tau23i) { tau23i(i,j,k) *= -mu_tot; }
678 
679  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
680  });
681  }
682 
683  // Second block: compute JT*2K*(S-D)
684  //***********************************************************************************
685  // Fill tau13, tau23 next (valid averaging region)
686  //-----------------------------------------------------------------------------------
687  ParallelFor(tbxxz,tbxyz,
688  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
689  {
690  Real mfx = mf_ux(i,j,0);
691  Real mfy = mf_uy(i,j,0);
692 
693  Real met_h_xi,met_h_eta,met_h_zeta;
694  met_h_xi = Compute_h_xi_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
695  met_h_eta = Compute_h_eta_AtEdgeCenterJ (i,j,k,dxInv,z_nd);
696  met_h_zeta = Compute_h_zeta_AtEdgeCenterJ(i,j,k,dxInv,z_nd);
697 
698  Real tau11bar = fourth * ( kh11(i , j , k ) + kh11(i-1, j , k )
699  + kh11(i , j , k-1) + kh11(i-1, j , k-1) );
700  Real tau12bar = fourth * ( kh12(i , j , k ) + kh12(i , j+1, k )
701  + kh12(i , j , k-1) + kh12(i , j+1, k-1) );
702 
703  Real mu_bar = fourth * ( mu_turb(i-1, j , k , EddyDiff::Mom_v) + mu_turb(i , j , k , EddyDiff::Mom_v)
704  + mu_turb(i-1, j , k-1, EddyDiff::Mom_v) + mu_turb(i , j , k-1, EddyDiff::Mom_v) );
705  Real rhoAlpha_bar = fourth * ( rhoAlpha(i-1, j , k ) + rhoAlpha(i , j , k )
706  + rhoAlpha(i-1, j , k-1) + rhoAlpha(i , j , k-1) );
707  Real mu_tot = rhoAlpha_bar + two*mu_bar;
708 
709  // K_v on S13; the projected horizontal stresses carry K_h (see the NOTE above)
710  tau13(i,j,k) *= -mu_tot;
711  tau13(i,j,k) += met_h_xi*mfx*tau11bar + met_h_eta*mfy*tau12bar;
712  if (tau13i) {
713  // erf.implicit_terrain_metric: the implicit solve also takes the compact
714  // K_h*M*d/dz metric term on these interior faces, with K_h averaged to the edge
715  // as getRhoAlphaForFaces averages it there, so tau13i holds it too
716  Real metric_coef = zero;
717  if (implicit_metric) {
718  Real mu_h_bar = fourth * ( mu_turb(i-1, j , k , EddyDiff::Mom_h) + mu_turb(i , j , k , EddyDiff::Mom_h)
719  + mu_turb(i-1, j , k-1, EddyDiff::Mom_h) + mu_turb(i , j , k-1, EddyDiff::Mom_h) );
720  metric_coef = (rhoAlpha_bar + two*mu_h_bar)
721  * TerrainMetricMomFactor(0, met_h_xi, met_h_eta, mfx, mfy);
722  }
723  tau13i(i,j,k) *= -(mu_tot + metric_coef);
724  }
725 
726  tau31(i,j,k) *= -mu_tot*met_h_zeta/mfy;
727  },
728  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
729  {
730  Real mfx = mf_vx(i,j,0);
731  Real mfy = mf_vy(i,j,0);
732 
733  Real met_h_xi,met_h_eta,met_h_zeta;
734  met_h_xi = Compute_h_xi_AtEdgeCenterI (i,j,k,dxInv,z_nd);
735  met_h_eta = Compute_h_eta_AtEdgeCenterI (i,j,k,dxInv,z_nd);
736  met_h_zeta = Compute_h_zeta_AtEdgeCenterI(i,j,k,dxInv,z_nd);
737 
738  Real tau21bar = fourth * ( kh21(i , j , k ) + kh21(i+1, j , k )
739  + kh21(i , j , k-1) + kh21(i+1, j , k-1) );
740  Real tau22bar = fourth * ( kh22(i , j , k ) + kh22(i , j-1, k )
741  + kh22(i , j , k-1) + kh22(i , j-1, k-1) );
742 
743  Real mu_bar = fourth * ( mu_turb(i , j-1, k , EddyDiff::Mom_v) + mu_turb(i , j , k , EddyDiff::Mom_v)
744  + mu_turb(i , j-1, k-1, EddyDiff::Mom_v) + mu_turb(i , j , k-1, EddyDiff::Mom_v) );
745  Real rhoAlpha_bar = fourth * ( rhoAlpha(i , j-1, k ) + rhoAlpha(i , j , k )
746  + rhoAlpha(i , j-1, k-1) + rhoAlpha(i , j , k-1) );
747  Real mu_tot = rhoAlpha_bar + two*mu_bar;
748 
749  // K_v on S23; the projected horizontal stresses carry K_h (see the NOTE above)
750  tau23(i,j,k) *= -mu_tot;
751  tau23(i,j,k) += met_h_xi*mfx*tau21bar + met_h_eta*mfy*tau22bar;
752  if (tau23i) {
753  // erf.implicit_terrain_metric: the implicit solve also takes the compact
754  // K_h*M*d/dz metric term on these interior faces, with K_h averaged to the edge
755  // as getRhoAlphaForFaces averages it there, so tau23i holds it too
756  Real metric_coef = zero;
757  if (implicit_metric) {
758  Real mu_h_bar = fourth * ( mu_turb(i , j-1, k , EddyDiff::Mom_h) + mu_turb(i , j , k , EddyDiff::Mom_h)
759  + mu_turb(i , j-1, k-1, EddyDiff::Mom_h) + mu_turb(i , j , k-1, EddyDiff::Mom_h) );
760  metric_coef = (rhoAlpha_bar + two*mu_h_bar)
761  * TerrainMetricMomFactor(1, met_h_xi, met_h_eta, mfx, mfy);
762  }
763  tau23i(i,j,k) *= -(mu_tot + metric_coef);
764  }
765 
766  tau32(i,j,k) *= -mu_tot*met_h_zeta/mfx;
767  });
768 
769  // Fill the remaining components: tau11, tau22, tau12/21
770  //-----------------------------------------------------------------------------------
771  ParallelFor(bxcc,tbxxy,
772  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
773  {
774  Real mfx = mf_mx(i,j,0);
775  Real mfy = mf_my(i,j,0);
776 
777  Real met_h_zeta = detJ(i,j,k);
778 
779  Real mu_tot = rhoAlpha(i,j,k) + two*mu_turb(i, j, k, EddyDiff::Mom_h);
780 
781  tau11(i,j,k) *= -mu_tot*met_h_zeta/mfy;
782  tau22(i,j,k) *= -mu_tot*met_h_zeta/mfx;
783  },
784  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
785  {
786  // Edge map factors as in the strain kernels: m_x from the v-points and m_y from the
787  // u-points on either side of the edge
788  Real mfy = myhalf * (mf_uy(i,j,0) + mf_uy(i ,j-1,0));
789  Real mfx = myhalf * (mf_vx(i,j,0) + mf_vx(i-1,j ,0));
790 
791  Real met_h_zeta = Compute_h_zeta_AtEdgeCenterK(i,j,k,dxInv,z_nd);
792 
793  Real mu_bar = fourth * ( mu_turb(i-1, j , k, EddyDiff::Mom_h) + mu_turb(i, j , k, EddyDiff::Mom_h)
794  + mu_turb(i-1, j-1, k, EddyDiff::Mom_h) + mu_turb(i, j-1, k, EddyDiff::Mom_h) );
795  Real rhoAlpha_bar = fourth * ( rhoAlpha(i-1, j , k) + rhoAlpha(i, j , k)
796  + rhoAlpha(i-1, j-1, k) + rhoAlpha(i, j-1, k) );
797  Real mu_tot = rhoAlpha_bar + two*mu_bar;
798 
799  tau12(i,j,k) *= -mu_tot*met_h_zeta/mfx;
800  tau21(i,j,k) *= -mu_tot*met_h_zeta/mfy;
801  });
802 }
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: