ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_MakeTauTerms.cpp File Reference
#include "AMReX_ArrayLim.H"
#include "AMReX_BCRec.H"
#include "AMReX_GpuContainers.H"
#include "ERF_TI_slow_headers.H"
#include "ERF_EOS.H"
#include "ERF_Utils.H"
Include dependency graph for ERF_MakeTauTerms.cpp:

Functions

void erf_make_tau_terms (int level, int nrk, const Vector< BCRec > &domain_bcs_type_h, const MultiFab &z_phys_nd, Vector< MultiFab > &S_data, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &zvel, Vector< std::unique_ptr< MultiFab >> &Tau_lev, MultiFab *SmnSmn, MultiFab *eddyDiffs, const Geometry geom, const SolverChoice &solverChoice, std::unique_ptr< SurfaceLayer > &, Gpu::DeviceVector< Real > &stretched_dz_d, const MultiFab &detJ, Vector< std::unique_ptr< MultiFab >> &mapfac)
 

Function Documentation

◆ erf_make_tau_terms()

void erf_make_tau_terms ( int  level,
int  nrk,
const Vector< BCRec > &  domain_bcs_type_h,
const MultiFab &  z_phys_nd,
Vector< MultiFab > &  S_data,
const MultiFab &  xvel,
const MultiFab &  yvel,
const MultiFab &  zvel,
Vector< std::unique_ptr< MultiFab >> &  Tau_lev,
MultiFab *  SmnSmn,
MultiFab *  eddyDiffs,
const Geometry  geom,
const SolverChoice solverChoice,
std::unique_ptr< SurfaceLayer > &  ,
Gpu::DeviceVector< Real > &  stretched_dz_d,
const MultiFab &  detJ,
Vector< std::unique_ptr< MultiFab >> &  mapfac 
)
28 {
29  BL_PROFILE_REGION("erf_make_tau_terms()");
30 
31  const BCRec* bc_ptr_h = domain_bcs_type_h.data();
32 
33  DiffChoice dc = solverChoice.diffChoice;
34  TurbChoice tc = solverChoice.turbChoice[level];
35 
36  const bool l_use_terrain_fitted_coords = (solverChoice.mesh_type != MeshType::ConstantDz);
37  const bool l_moving_terrain = (solverChoice.terrain_type == TerrainType::MovingFittedMesh);
38  if (l_moving_terrain) AMREX_ALWAYS_ASSERT (l_use_terrain_fitted_coords);
39 
40 
41  const bool l_use_diff = ( (dc.molec_diff_type != MolecDiffType::None) || tc.use_kturb );
42  const bool l_use_constAlpha = ( dc.molec_diff_type == MolecDiffType::ConstantAlpha );
43  const bool l_use_turb = ( tc.les_type == LESType::Smagorinsky ||
44  tc.les_type == LESType::Deardorff ||
45  tc.rans_type == RANSType::kEqn ||
46  tc.pbl_type == PBLType::MYNN25 ||
47  tc.pbl_type == PBLType::MYNNEDMF ||
48  tc.pbl_type == PBLType::YSU ||
49  tc.pbl_type == PBLType::MRF);
50 
51  const bool need_SmnSmn = (tc.les_type == LESType::Deardorff ||
52  tc.rans_type == RANSType::kEqn);
53 
54  const Box& domain = geom.Domain();
55  const int domlo_z = domain.smallEnd(2);
56  const int domhi_z = domain.bigEnd(2);
57 
58  const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
59 
60  // *****************************************************************************
61  // Pre-computed quantities
62  // *****************************************************************************
63  const BoxArray& ba = S_data[IntVars::cons].boxArray();
64  const DistributionMapping& dm = S_data[IntVars::cons].DistributionMap();
65 
66  std::unique_ptr<MultiFab> expr;
67 
68  if (l_use_diff) {
69  expr = std::make_unique<MultiFab>(ba, dm, 1, IntVect(1,1,1));
70 
71  // if using constant alpha (mu = rho * alpha), then first divide by the
72  // reference density -- mu_eff will be scaled by the instantaneous
73  // local density later when ComputeStress*Visc_*() is called
74  Real mu_eff = (l_use_constAlpha) ? 2.0 * dc.dynamic_viscosity / dc.rho0_trans
75  : 2.0 * dc.dynamic_viscosity;
76 
77  auto dz_ptr = stretched_dz_d.data();
78 
79 #ifdef _OPENMP
80 #pragma omp parallel if (Gpu::notInLaunchRegion())
81 #endif
82  for ( MFIter mfi(S_data[IntVars::cons],TileNoZ()); mfi.isValid(); ++mfi)
83  {
84  const Box& bx = mfi.tilebox();
85  const Box& valid_bx = mfi.validbox();
86 
87  // Velocities
88  const Array4<const Real> & u = xvel.array(mfi);
89  const Array4<const Real> & v = yvel.array(mfi);
90  const Array4<const Real> & w = zvel.array(mfi);
91 
92  // Map factors
93  const Array4<const Real>& mf_mx = mapfac[MapFacType::m_x]->const_array(mfi);
94  const Array4<const Real>& mf_ux = mapfac[MapFacType::u_x]->const_array(mfi);
95  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
96  const Array4<const Real>& mf_my = mapfac[MapFacType::m_y]->const_array(mfi);
97  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
98  const Array4<const Real>& mf_vy = mapfac[MapFacType::v_y]->const_array(mfi);
99 
100  // Eddy viscosity
101  const Array4<Real const>& mu_turb = l_use_turb ? eddyDiffs->const_array(mfi) :
102  Array4<const Real>{};
103  const Array4<Real const>& cell_data = l_use_constAlpha ? S_data[IntVars::cons].const_array(mfi) :
104  Array4<const Real>{};
105 
106  // Terrain metrics
107  const Array4<const Real>& z_nd = z_phys_nd.const_array(mfi);
108  const Array4<const Real>& detJ_arr = detJ.const_array(mfi);
109 
110  //-------------------------------------------------------------------------------
111  // NOTE: Tile boxes with terrain are not intuitive. The linear combination of
112  // stress terms requires care. Create a tile box that intersects the
113  // valid box, then grow the box in x/y. Compute the strain on the local
114  // FAB over this grown tile box. Compute the stress over the tile box,
115  // except tau_ii which still needs the halo cells. Finally, write from
116  // the local FAB to the Tau MF but only on the tile box.
117  //-------------------------------------------------------------------------------
118 
119  //-------------------------------------------------------------------------------
120  // TODO: Avoid recomputing strain on the first RK stage. One could populate
121  // the FABs with tau_ij, compute stress, and then write to tau_ij. The
122  // problem with this approach is you will over-write the needed halo layer
123  // needed by subsequent tile boxes (particularly S_ii becomes Tau_ii).
124  //-------------------------------------------------------------------------------
125 
126  // Strain/Stress tile boxes
127  Box bxcc = mfi.tilebox();
128  Box tbxxy = mfi.tilebox(IntVect(1,1,0));
129  Box tbxxz = mfi.tilebox(IntVect(1,0,1));
130  Box tbxyz = mfi.tilebox(IntVect(0,1,1));
131 
132  // We need a halo cell for terrain
133  bxcc.grow(IntVect(1,1,0));
134  tbxxy.grow(IntVect(1,1,0));
135  tbxxz.grow(IntVect(1,1,0));
136  tbxyz.grow(IntVect(1,1,0));
137 
138  if (bxcc.smallEnd(2) != domain.smallEnd(2)) {
139  bxcc.growLo(2,1);
140  tbxxy.growLo(2,1);
141  tbxxz.growLo(2,1);
142  tbxyz.growLo(2,1);
143  }
144 
145  if (bxcc.bigEnd(2) != domain.bigEnd(2)) {
146  bxcc.growHi(2,1);
147  tbxxy.growHi(2,1);
148  tbxxz.growHi(2,1);
149  tbxyz.growHi(2,1);
150  }
151 
152  // Expansion rate
153  Array4<Real> er_arr = expr->array(mfi);
154 
155  // Temporary storage for tiling/OMP
156  FArrayBox S11,S22,S33;
157  FArrayBox S12,S13,S23;
158  S11.resize( bxcc,1,The_Async_Arena()); S22.resize(bxcc,1,The_Async_Arena()); S33.resize(bxcc,1,The_Async_Arena());
159  S12.resize(tbxxy,1,The_Async_Arena()); S13.resize(tbxxz,1,The_Async_Arena()); S23.resize(tbxyz,1,The_Async_Arena());
160  Array4<Real> s11 = S11.array(); Array4<Real> s22 = S22.array(); Array4<Real> s33 = S33.array();
161  Array4<Real> s12 = S12.array(); Array4<Real> s13 = S13.array(); Array4<Real> s23 = S23.array();
162 
163  // Symmetric strain/stresses
164  Array4<Real> tau11 = Tau_lev[TauType::tau11]->array(mfi); Array4<Real> tau22 = Tau_lev[TauType::tau22]->array(mfi);
165  Array4<Real> tau33 = Tau_lev[TauType::tau33]->array(mfi); Array4<Real> tau12 = Tau_lev[TauType::tau12]->array(mfi);
166  Array4<Real> tau13 = Tau_lev[TauType::tau13]->array(mfi); Array4<Real> tau23 = Tau_lev[TauType::tau23]->array(mfi);
167 
168  // Strain magnitude
169  Array4<Real> SmnSmn_a;
170 
171  if (solverChoice.mesh_type == MeshType::StretchedDz) {
172  // Terrain non-symmetric terms
173  FArrayBox S21,S31,S32;
174  S21.resize(tbxxy,1,The_Async_Arena()); S31.resize(tbxxz,1,The_Async_Arena()); S32.resize(tbxyz,1,The_Async_Arena());
175  Array4<Real> s21 = S21.array(); Array4<Real> s31 = S31.array(); Array4<Real> s32 = S32.array();
176  Array4<Real> tau21 = Tau_lev[TauType::tau21]->array(mfi);
177  Array4<Real> tau31 = Tau_lev[TauType::tau31]->array(mfi);
178  Array4<Real> tau32 = Tau_lev[TauType::tau32]->array(mfi);
179 
180 
181  // *****************************************************************************
182  // Expansion rate compute terrain
183  // *****************************************************************************
184  {
185  BL_PROFILE("slow_rhs_making_er_S");
186  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
187  {
188  Real mfsq = mf_mx(i,j,0)*mf_my(i,j,0);
189  er_arr(i,j,k) = (u(i+1, j , k )/mf_uy(i+1,j,0) - u(i, j, k)/mf_uy(i,j,0))*dxInv[0]*mfsq +
190  (v(i , j+1, k )/mf_vx(i,j+1,0) - v(i, j, k)/mf_vx(i,j,0))*dxInv[1]*mfsq +
191  (w(i , j , k+1) - w(i, j, k))/dz_ptr[k];
192  });
193  } // end profile
194 
195  // *****************************************************************************
196  // Strain tensor compute terrain
197  // *****************************************************************************
198  {
199  BL_PROFILE("slow_rhs_making_strain_S");
200  ComputeStrain_S(bxcc, tbxxy, tbxxz, tbxyz, domain,
201  u, v, w,
202  s11, s22, s33,
203  s12, s21,
204  s13, s31,
205  s23, s32,
206  stretched_dz_d, dxInv,
207  mf_mx, mf_ux, mf_vx,
208  mf_my, mf_uy, mf_vy, bc_ptr_h);
209  } // profile
210 
211  // Populate SmnSmn if using Deardorff or k-eqn RANS (used as diff src in post)
212  // and in the first RK stage (TKE tendencies constant for nrk>0, following WRF)
213  if ((nrk==0) && (need_SmnSmn)) {
214  SmnSmn_a = SmnSmn->array(mfi);
215  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
216  {
217  SmnSmn_a(i,j,k) = ComputeSmnSmn(i,j,k,s11,s22,s33,s12,s13,s23);
218  });
219  }
220 
221  // *****************************************************************************
222  // Stress tensor compute terrain
223  // *****************************************************************************
224  {
225  BL_PROFILE("slow_rhs_making_stress_T");
226 
227  // Remove Halo cells just for tau_ij comps
228  tbxxy.grow(IntVect(-1,-1,0));
229  tbxxz.grow(IntVect(-1,-1,0));
230  tbxyz.grow(IntVect(-1,-1,0));
231 
232  if (!l_use_turb) {
233  ComputeStressConsVisc_S(bxcc, tbxxy, tbxxz, tbxyz, mu_eff,
234  cell_data,
235  s11, s22, s33,
236  s12, s21,
237  s13, s31,
238  s23, s32,
239  er_arr, stretched_dz_d, dxInv,
240  mf_mx, mf_ux, mf_vx,
241  mf_my, mf_uy, mf_vy);
242  } else {
243  ComputeStressVarVisc_S(bxcc, tbxxy, tbxxz, tbxyz, mu_eff, mu_turb,
244  cell_data,
245  s11, s22, s33,
246  s12, s21,
247  s13, s31,
248  s23, s32,
249  er_arr, stretched_dz_d, dxInv,
250  mf_mx, mf_ux, mf_vx,
251  mf_my, mf_uy, mf_vy);
252  }
253 
254  // Remove halo cells from tau_ii but extend across valid_box bdry
255  bxcc.grow(IntVect(-1,-1,0));
256  if (bxcc.smallEnd(0) == valid_bx.smallEnd(0)) bxcc.growLo(0, 1);
257  if (bxcc.bigEnd(0) == valid_bx.bigEnd(0)) bxcc.growHi(0, 1);
258  if (bxcc.smallEnd(1) == valid_bx.smallEnd(1)) bxcc.growLo(1, 1);
259  if (bxcc.bigEnd(1) == valid_bx.bigEnd(1)) bxcc.growHi(1, 1);
260 
261  // Copy from temp FABs back to tau
262  ParallelFor(bxcc,
263  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
264  tau11(i,j,k) = s11(i,j,k);
265  tau22(i,j,k) = s22(i,j,k);
266  tau33(i,j,k) = s33(i,j,k);
267  });
268 
269  ParallelFor(tbxxy, tbxxz, tbxyz,
270  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
271  tau12(i,j,k) = s12(i,j,k);
272  tau21(i,j,k) = s21(i,j,k);
273  },
274  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
275  tau13(i,j,k) = s13(i,j,k);
276  tau31(i,j,k) = s31(i,j,k);
277  },
278  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
279  tau23(i,j,k) = s23(i,j,k);
280  tau32(i,j,k) = s32(i,j,k);
281  });
282  } // end profile
283 
284  } else if (l_use_terrain_fitted_coords) {
285 
286  // Terrain non-symmetric terms
287  FArrayBox S21,S31,S32;
288  S21.resize(tbxxy,1,The_Async_Arena()); S31.resize(tbxxz,1,The_Async_Arena()); S32.resize(tbxyz,1,The_Async_Arena());
289  Array4<Real> s21 = S21.array(); Array4<Real> s31 = S31.array(); Array4<Real> s32 = S32.array();
290  Array4<Real> tau21 = Tau_lev[TauType::tau21]->array(mfi);
291  Array4<Real> tau31 = Tau_lev[TauType::tau31]->array(mfi);
292  Array4<Real> tau32 = Tau_lev[TauType::tau32]->array(mfi);
293 
294 
295  // *****************************************************************************
296  // Expansion rate compute terrain
297  // *****************************************************************************
298  {
299  BL_PROFILE("slow_rhs_making_er_T");
300  Box gbxo = surroundingNodes(bxcc,2);
301 
302  // We make a temporary container for contravariant velocity Omega here
303  // -- it is only used to compute er_arr below
304  FArrayBox Omega;
305  Omega.resize(gbxo,1,The_Async_Arena());
306 
307  // First create Omega using velocity (not momentum)
308  Array4<Real> omega_arr = Omega.array();
309  ParallelFor(gbxo, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
310  {
311  omega_arr(i,j,k) = (k == 0) ? 0. : OmegaFromW(i,j,k,w(i,j,k),u,v,
312  mf_ux,mf_vy,z_nd,dxInv);
313  });
314 
315  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
316  {
317 
318  Real met_u_h_zeta_hi = Compute_h_zeta_AtIface(i+1, j , k, dxInv, z_nd);
319  Real met_u_h_zeta_lo = Compute_h_zeta_AtIface(i , j , k, dxInv, z_nd);
320 
321  Real met_v_h_zeta_hi = Compute_h_zeta_AtJface(i , j+1, k, dxInv, z_nd);
322  Real met_v_h_zeta_lo = Compute_h_zeta_AtJface(i , j , k, dxInv, z_nd);
323 
324  Real Omega_hi = omega_arr(i,j,k+1);
325  Real Omega_lo = omega_arr(i,j,k );
326 
327  Real mfsq = mf_mx(i,j,0)*mf_my(i,j,0);
328 
329  Real expansionRate = (u(i+1,j ,k)/mf_uy(i+1,j,0)*met_u_h_zeta_hi - u(i,j,k)/mf_uy(i,j,0)*met_u_h_zeta_lo)*dxInv[0]*mfsq +
330  (v(i ,j+1,k)/mf_vx(i,j+1,0)*met_v_h_zeta_hi - v(i,j,k)/mf_vx(i,j,0)*met_v_h_zeta_lo)*dxInv[1]*mfsq +
331  (Omega_hi - Omega_lo)*dxInv[2];
332 
333  er_arr(i,j,k) = expansionRate / detJ_arr(i,j,k);
334  });
335  } // end profile
336 
337  // *****************************************************************************
338  // Strain tensor compute terrain
339  // *****************************************************************************
340  {
341  BL_PROFILE("slow_rhs_making_strain_T");
342  ComputeStrain_T(bxcc, tbxxy, tbxxz, tbxyz, domain,
343  u, v, w,
344  s11, s22, s33,
345  s12, s21,
346  s13, s31,
347  s23, s32,
348  z_nd, detJ_arr, dxInv,
349  mf_mx, mf_ux, mf_vx,
350  mf_my, mf_uy, mf_vy, bc_ptr_h);
351  } // profile
352 
353  // Populate SmnSmn if using Deardorff or k-eqn RANS (used as diff src in post)
354  // and in the first RK stage (TKE tendencies constant for nrk>0, following WRF)
355  if ((nrk==0) && (need_SmnSmn)) {
356  SmnSmn_a = SmnSmn->array(mfi);
357  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
358  {
359  SmnSmn_a(i,j,k) = ComputeSmnSmn(i,j,k,
360  s11,s22,s33,
361  s12,s13,s23);
362  });
363  }
364 
365  // *****************************************************************************
366  // Stress tensor compute terrain
367  // *****************************************************************************
368  {
369  BL_PROFILE("slow_rhs_making_stress_T");
370 
371  // Remove Halo cells just for tau_ij comps
372  tbxxy.grow(IntVect(-1,-1,0));
373  tbxxz.grow(IntVect(-1,-1,0));
374  tbxyz.grow(IntVect(-1,-1,0));
375 
376  if (!l_use_turb) {
377  ComputeStressConsVisc_T(bxcc, tbxxy, tbxxz, tbxyz, mu_eff,
378  cell_data,
379  s11, s22, s33,
380  s12, s21,
381  s13, s31,
382  s23, s32,
383  er_arr, z_nd, detJ_arr, dxInv,
384  mf_mx, mf_ux, mf_vx,
385  mf_my, mf_uy, mf_vy);
386  } else {
387  ComputeStressVarVisc_T(bxcc, tbxxy, tbxxz, tbxyz, mu_eff, mu_turb,
388  cell_data,
389  s11, s22, s33,
390  s12, s21,
391  s13, s31,
392  s23, s32,
393  er_arr, z_nd, detJ_arr, dxInv,
394  mf_mx, mf_ux, mf_vx,
395  mf_my, mf_uy, mf_vy);
396  }
397 
398  // Remove halo cells from tau_ii but extend across valid_box bdry
399  bxcc.grow(IntVect(-1,-1,0));
400  if (bxcc.smallEnd(0) == valid_bx.smallEnd(0)) bxcc.growLo(0, 1);
401  if (bxcc.bigEnd(0) == valid_bx.bigEnd(0)) bxcc.growHi(0, 1);
402  if (bxcc.smallEnd(1) == valid_bx.smallEnd(1)) bxcc.growLo(1, 1);
403  if (bxcc.bigEnd(1) == valid_bx.bigEnd(1)) bxcc.growHi(1, 1);
404 
405  // Copy from temp FABs back to tau
406  ParallelFor(bxcc,
407  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
408  tau11(i,j,k) = s11(i,j,k);
409  tau22(i,j,k) = s22(i,j,k);
410  tau33(i,j,k) = s33(i,j,k);
411  });
412 
413  ParallelFor(tbxxy, tbxxz, tbxyz,
414  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
415  tau12(i,j,k) = s12(i,j,k);
416  tau21(i,j,k) = s21(i,j,k);
417  },
418  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
419  tau13(i,j,k) = s13(i,j,k);
420  tau31(i,j,k) = s31(i,j,k);
421  },
422  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
423  tau23(i,j,k) = s23(i,j,k);
424  tau32(i,j,k) = s32(i,j,k);
425  });
426  } // end profile
427 
428  } else {
429 
430  // *****************************************************************************
431  // Expansion rate compute no terrain
432  // *****************************************************************************
433  {
434  BL_PROFILE("slow_rhs_making_er_N");
435  ParallelFor(bxcc, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
436  Real mfsq = mf_mx(i,j,0)*mf_my(i,j,0);
437  er_arr(i,j,k) = (u(i+1, j , k )/mf_uy(i+1,j,0) - u(i, j, k)/mf_uy(i,j,0))*dxInv[0]*mfsq +
438  (v(i , j+1, k )/mf_vx(i,j+1,0) - v(i, j, k)/mf_vx(i,j,0))*dxInv[1]*mfsq +
439  (w(i , j , k+1) - w(i, j, k))*dxInv[2];
440  });
441  } // end profile
442 
443 
444  // *****************************************************************************
445  // Strain tensor compute no terrain
446  // *****************************************************************************
447  {
448  BL_PROFILE("slow_rhs_making_strain_N");
449  ComputeStrain_N(bxcc, tbxxy, tbxxz, tbxyz, domain,
450  u, v, w,
451  s11, s22, s33,
452  s12, s13, s23,
453  dxInv,
454  mf_mx, mf_ux, mf_vx,
455  mf_my, mf_uy, mf_vy, bc_ptr_h);
456  } // end profile
457 
458  // Populate SmnSmn if using Deardorff or k-eqn RANS (used as diff src in post)
459  // and in the first RK stage (TKE tendencies constant for nrk>0, following WRF)
460  if ((nrk==0) && (need_SmnSmn)) {
461  SmnSmn_a = SmnSmn->array(mfi);
462  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
463  {
464  SmnSmn_a(i,j,k) = ComputeSmnSmn(i,j,k,
465  s11,s22,s33,
466  s12,s13,s23);
467  });
468  }
469 
470  // *****************************************************************************
471  // Stress tensor compute no terrain
472  // *****************************************************************************
473  {
474  BL_PROFILE("slow_rhs_making_stress_N");
475 
476  // Remove Halo cells just for tau_ij comps
477  tbxxy.grow(IntVect(-1,-1,0));
478  tbxxz.grow(IntVect(-1,-1,0));
479  tbxyz.grow(IntVect(-1,-1,0));
480  if (tbxxy.smallEnd(2) > domlo_z) {
481  tbxxy.growLo(2,-1);
482  tbxxz.growLo(2,-1);
483  tbxyz.growLo(2,-1);
484  }
485  if (tbxxy.bigEnd(2) < domhi_z) {
486  tbxxy.growHi(2,-1);
487  tbxxz.growHi(2,-1);
488  tbxyz.growHi(2,-1);
489  }
490 
491  if (!l_use_turb) {
492  ComputeStressConsVisc_N(bxcc, tbxxy, tbxxz, tbxyz, mu_eff,
493  cell_data,
494  s11, s22, s33,
495  s12, s13, s23,
496  er_arr);
497  } else {
498  ComputeStressVarVisc_N(bxcc, tbxxy, tbxxz, tbxyz, mu_eff, mu_turb,
499  cell_data,
500  s11, s22, s33,
501  s12, s13, s23,
502  er_arr);
503  }
504 
505  // Remove halo cells from tau_ii but extend across valid_box bdry
506  bxcc.grow(IntVect(-1,-1,0));
507  if (bxcc.smallEnd(0) == valid_bx.smallEnd(0)) bxcc.growLo(0, 1);
508  if (bxcc.bigEnd(0) == valid_bx.bigEnd(0)) bxcc.growHi(0, 1);
509  if (bxcc.smallEnd(1) == valid_bx.smallEnd(1)) bxcc.growLo(1, 1);
510  if (bxcc.bigEnd(1) == valid_bx.bigEnd(1)) bxcc.growHi(1, 1);
511 
512  // Copy from temp FABs back to tau
513  ParallelFor(bxcc,
514  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
515  tau11(i,j,k) = s11(i,j,k);
516  tau22(i,j,k) = s22(i,j,k);
517  tau33(i,j,k) = s33(i,j,k);
518  });
519  ParallelFor(tbxxy, tbxxz, tbxyz,
520  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
521  tau12(i,j,k) = s12(i,j,k);
522  },
523  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
524  tau13(i,j,k) = s13(i,j,k);
525  },
526  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
527  tau23(i,j,k) = s23(i,j,k);
528  });
529  } // end profile
530  } // l_use_terrain_fitted_coords
531  } // MFIter
532  } // l_use_diff
533 }
void ComputeStrain_N(Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Box domain, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, Array4< Real > &tau11, Array4< Real > &tau22, Array4< Real > &tau33, Array4< Real > &tau12, Array4< Real > &tau13, Array4< Real > &tau23, 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, const BCRec *bc_ptr)
Definition: ERF_ComputeStrain_N.cpp:28
void ComputeStrain_S(Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Box domain, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, 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 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, const BCRec *bc_ptr)
Definition: ERF_ComputeStrain_S.cpp:36
void ComputeStrain_T(Box bxcc, Box tbxxy, Box tbxxz, Box tbxyz, Box domain, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, 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 > &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, const BCRec *bc_ptr)
Definition: ERF_ComputeStrain_T.cpp:36
void ComputeStressVarVisc_N(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 > &tau13, Array4< Real > &tau23, const Array4< const Real > &er_arr)
Definition: ERF_ComputeStress_N.cpp:105
void ComputeStressConsVisc_N(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 > &tau13, Array4< Real > &tau23, const Array4< const Real > &er_arr)
Definition: ERF_ComputeStress_N.cpp:23
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)
Definition: ERF_ComputeStress_S.cpp:150
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)
Definition: ERF_ComputeStress_S.cpp:29
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)
Definition: ERF_ComputeStress_T.cpp:29
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)
Definition: ERF_ComputeStress_T.cpp:336
@ 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
@ v_x
Definition: ERF_DataStruct.H:22
@ u_y
Definition: ERF_DataStruct.H:23
@ v_y
Definition: ERF_DataStruct.H:23
@ m_y
Definition: ERF_DataStruct.H:23
@ u_x
Definition: ERF_DataStruct.H:22
@ m_x
Definition: ERF_DataStruct.H:22
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real ComputeSmnSmn(int &i, int &j, int &k, const amrex::Array4< amrex::Real const > &tau11, const amrex::Array4< amrex::Real const > &tau22, const amrex::Array4< amrex::Real const > &tau33, const amrex::Array4< amrex::Real const > &tau12, const amrex::Array4< amrex::Real const > &tau13, const amrex::Array4< amrex::Real const > &tau23)
Definition: ERF_EddyViscosity.H:37
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real OmegaFromW(int &i, int &j, int &k, amrex::Real w, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:415
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(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:96
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(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:139
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ cons
Definition: ERF_IndexDefines.H:158
@ xvel
Definition: ERF_IndexDefines.H:141
@ zvel
Definition: ERF_IndexDefines.H:143
@ yvel
Definition: ERF_IndexDefines.H:142
Definition: ERF_DiffStruct.H:19
amrex::Real rho0_trans
Definition: ERF_DiffStruct.H:88
MolecDiffType molec_diff_type
Definition: ERF_DiffStruct.H:81
amrex::Real dynamic_viscosity
Definition: ERF_DiffStruct.H:93
static MeshType mesh_type
Definition: ERF_DataStruct.H:708
DiffChoice diffChoice
Definition: ERF_DataStruct.H:717
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:719
static TerrainType terrain_type
Definition: ERF_DataStruct.H:702
Definition: ERF_TurbStruct.H:39
PBLType pbl_type
Definition: ERF_TurbStruct.H:356
RANSType rans_type
Definition: ERF_TurbStruct.H:353
LESType les_type
Definition: ERF_TurbStruct.H:316
bool use_kturb
Definition: ERF_TurbStruct.H:362

Referenced by erf_slow_rhs_pre().

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