ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_DiffusionSrcForMom_EB.cpp File Reference
#include <AMReX.H>
#include <AMReX_EB_Slopes_K.H>
#include <ERF_EB.H>
#include <ERF_Diffusion.H>
#include <ERF_IndexDefines.H>
#include <ERF_EBSlopes.H>
#include <ERF_DiffStruct.H>
#include <ERF_EBStruct.H>
Include dependency graph for ERF_DiffusionSrcForMom_EB.cpp:

Namespaces

 erf_detail_DiffusionSrcForMom_EB
 

Functions

AMREX_GPU_DEVICE AMREX_FORCE_INLINE void compute_tangent_vectors (Real nx, Real ny, Real nz, Real &tbx_x, Real &tbx_y, Real &tbx_z, Real &tby_x, Real &tby_y, Real &tby_z)
 
template<int MomDir, EBBoundaryType WallModel>
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Real erf_detail_DiffusionSrcForMom_EB::eb_wall_correction (int i, int j, int k, const Array4< const Real > &u_arr, const Array4< const Real > &v_arr, const Array4< const Real > &w_arr, const Array4< const EBCellFlag > &u_cellflg, const Array4< const EBCellFlag > &v_cellflg, const Array4< const EBCellFlag > &w_cellflg, const Array4< const Real > &u_volcent, const Array4< const Real > &v_volcent, const Array4< const Real > &w_volcent, const Array4< const Real > &u_vfrac, const Array4< const Real > &v_vfrac, const Array4< const Real > &w_vfrac, const Array4< const Real > &mom_volfrac, const Array4< const Real > &mom_afrac_x, const Array4< const Real > &mom_afrac_y, const Array4< const Real > &mom_afrac_z, const Array4< const Real > &mom_bcent, const Array4< const Real > &mom_bnorm, const Array4< const Real > &mom_tau_eb13, const Array4< const Real > &mom_tau_eb23, Real dx, Real dy, Real dz, Real vol, Real mu_eff) noexcept
 
template<int MomDir, EBBoundaryType WallModel>
void erf_detail_DiffusionSrcForMom_EB::launch_eb_wall_correction (Box const &bx, [[maybe_unused]] eb_::CutCellList const &cut_cells, Array4< Real > const &mom_rhs, const Array4< const Real > &u_arr, const Array4< const Real > &v_arr, const Array4< const Real > &w_arr, const Array4< const EBCellFlag > &u_cellflg, const Array4< const EBCellFlag > &v_cellflg, const Array4< const EBCellFlag > &w_cellflg, const Array4< const Real > &u_volcent, const Array4< const Real > &v_volcent, const Array4< const Real > &w_volcent, const Array4< const Real > &u_vfrac, const Array4< const Real > &v_vfrac, const Array4< const Real > &w_vfrac, const Array4< const Real > &mom_volfrac, const Array4< const Real > &mom_afrac_x, const Array4< const Real > &mom_afrac_y, const Array4< const Real > &mom_afrac_z, const Array4< const Real > &mom_bcent, const Array4< const Real > &mom_bnorm, const Array4< const Real > &mom_tau_eb13, const Array4< const Real > &mom_tau_eb23, Real dx, Real dy, Real dz, Real vol, Real mu_eff) noexcept
 
void DiffusionSrcForMom_EB (const MFIter &mfi, [[maybe_unused]] const Box &domain, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &u_arr, const Array4< const Real > &v_arr, const Array4< const Real > &w_arr, const Array4< const Real > &tau11, const Array4< const Real > &tau22, const Array4< const Real > &tau33, const Array4< const Real > &tau12, const Array4< const Real > &tau13, const Array4< const Real > &tau23, const Array4< const Real > &u_tau_eb13, const Array4< const Real > &u_tau_eb23, const Array4< const Real > &v_tau_eb13, const Array4< const Real > &v_tau_eb23, const Array4< const Real > &w_tau_eb13, const Array4< const Real > &w_tau_eb23, const Real *dx_arr, 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 SolverChoice &solverChoice, const eb_ &ebfact, [[maybe_unused]] const BCRec *d_bcrec_ptr)
 

Function Documentation

◆ compute_tangent_vectors()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE void compute_tangent_vectors ( Real  nx,
Real  ny,
Real  nz,
Real &  tbx_x,
Real &  tbx_y,
Real &  tbx_z,
Real &  tby_x,
Real &  tby_y,
Real &  tby_z 
)

Compute the tangent directions at an EB boundary given the unit normal vector.

t_bx and t_by are the unit vectors along the projections of e_x and e_y onto the tangent plane. They are the directions in which the stored EB surface stresses tau_eb13 and tau_eb23 act, since those are built from the x- and y-components of the tangential velocity (see ERF_EBMOSTStress.H). For a horizontal surface they are exactly e_x and e_y. Note that they are individually unit but are not orthogonal to each other unless nx*ny is zero – t_bx . t_by = -nx*ny.

e_x has no projection onto the tangent plane when n is parallel to e_x, and likewise for e_y, so one of the two is undefined for an axis-aligned normal such as (1,0,0) (issue #3533). That limit is genuinely two-sided – approaching n = (1,0,0) from nz > 0 and from nz < 0 gives t_bx of -e_z and +e_z – so there is no continuous choice, and the degenerate vector is returned as zero. That keeps the momentum RHS finite, and it keeps the component that does have a limit continuous: the x-component of t_bx is sqrt(1-nx*nx), which tends to zero here as well. It also avoids driving w-momentum with tau_eb13, an x-associated stress, along an arbitrarily signed direction. Only nx and ny can be degenerate, and never both at once.

Parameters
[in]nxx-component of the normal vector
[in]nyy-component of the normal vector
[in]nzz-component of the normal vector
[out]tbx_xx-component of first tangent vector
[out]tbx_yy-component of first tangent vector
[out]tbx_zz-component of first tangent vector
[out]tby_xx-component of second tangent vector
[out]tby_yy-component of second tangent vector
[out]tby_zz-component of second tangent vector
46 {
47  // Below this the projection is all round-off and its direction is meaningless.
48  // The squared norms are formed as ny^2+nz^2 and nx^2+nz^2 rather than as the
49  // algebraically equal 1-nx^2 and 1-ny^2 to avoid cancellation for a near-axis normal
50  // The squared norm of a unit normal carries an absolute roundoff of order
51  // real_eps, so the floor is a (generous) multiple of it: 2.2e-12 in double,
52  // 1.2e-03 in single, i.e. a normal within ~2 degrees of the axis.
53  constexpr Real tol = Real(1.e4)*real_eps;
54 
55  // x-tangential vector: t_bx = (e_x - (e_x · n)n) / ||e_x - (e_x · n)n||
56  // e_x = (1,0,0), so e_x · n = nx
57  Real tbx_norm2 = ny*ny + nz*nz;
58  if (tbx_norm2 > tol) {
59  Real tbx_norm_inv = one / std::sqrt(tbx_norm2);
60  tbx_x = ( one - nx * nx) * tbx_norm_inv;
61  tbx_y = ( - nx * ny) * tbx_norm_inv;
62  tbx_z = ( - nx * nz) * tbx_norm_inv;
63  } else {
64  tbx_x = zero;
65  tbx_y = zero;
66  tbx_z = zero;
67  }
68 
69  // y-tangential vector: t_by = (e_y - (e_y · n)n) / ||e_y - (e_y · n)n||
70  // e_y = (0,1,0), so e_y · n = ny
71  Real tby_norm2 = nx*nx + nz*nz;
72  if (tby_norm2 > tol) {
73  Real tby_norm_inv = one / std::sqrt(tby_norm2);
74  tby_x = ( - ny * nx) * tby_norm_inv;
75  tby_y = ( one - ny * ny) * tby_norm_inv;
76  tby_z = ( - ny * nz) * tby_norm_inv;
77  } else {
78  tby_x = zero;
79  tby_y = zero;
80  tby_z = zero;
81  }
82 }
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
constexpr amrex::Real real_eps
Definition: ERF_NumericalConstants.H:34
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36

Referenced by erf_detail_DiffusionSrcForMom_EB::eb_wall_correction().

Here is the caller graph for this function:

◆ DiffusionSrcForMom_EB()

void DiffusionSrcForMom_EB ( const MFIter &  mfi,
[[maybe_unused] ] const Box &  domain,
const Box &  bxx,
const Box &  bxy,
const Box &  bxz,
const Array4< Real > &  rho_u_rhs,
const Array4< Real > &  rho_v_rhs,
const Array4< Real > &  rho_w_rhs,
const Array4< const Real > &  u_arr,
const Array4< const Real > &  v_arr,
const Array4< const Real > &  w_arr,
const Array4< const Real > &  tau11,
const Array4< const Real > &  tau22,
const Array4< const Real > &  tau33,
const Array4< const Real > &  tau12,
const Array4< const Real > &  tau13,
const Array4< const Real > &  tau23,
const Array4< const Real > &  u_tau_eb13,
const Array4< const Real > &  u_tau_eb23,
const Array4< const Real > &  v_tau_eb13,
const Array4< const Real > &  v_tau_eb23,
const Array4< const Real > &  w_tau_eb13,
const Array4< const Real > &  w_tau_eb23,
const Real *  dx_arr,
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 SolverChoice &  solverChoice,
const eb_ &  ebfact,
[[maybe_unused] ] const BCRec *  d_bcrec_ptr 
)

Function for computing the momentum RHS for diffusion operator without terrain.

Parameters
[in]mfiMultiFab Iterator
[in]domaincomputational domain
[in]bxxnodal x box for x-mom
[in]bxynodal y box for y-mom
[in]bxznodal z box for z-mom
[out]rho_u_rhsRHS for x-mom
[out]rho_v_rhsRHS for y-mom
[out]rho_w_rhsRHS for z-mom
[in]u_arrx-direction velocity
[in]v_arry-direction velocity
[in]w_arrz-direction velocity
[in]tau1111 stress
[in]tau2222 stress
[in]tau3333 stress
[in]tau1212 stress
[in]tau1313 stress
[in]tau2323 stress
[in]u_tau_eb13EB tangential stress for x-momentum on z-faces
[in]u_tau_eb23EB tangential stress for x-momentum on y-faces
[in]v_tau_eb13EB tangential stress for y-momentum on z-faces
[in]v_tau_eb23EB tangential stress for y-momentum on x-faces
[in]w_tau_eb13EB tangential stress for z-momentum on y-faces
[in]w_tau_eb23EB tangential stress for z-momentum on x-faces
[in]dx_arrcell size array
[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]solverChoicecontainer with diffusion parameters
[in]ebfactEB factories for cell- and face-centered variables
[in]d_bcrec_ptrboundary condition records on device
405 {
406  BL_PROFILE_VAR("DiffusionSrcForMom_EB()",DiffusionSrcForMom_EB);
407 
408  DiffChoice dc = solverChoice.diffChoice;
409  const bool l_use_constAlpha = ( dc.molec_diff_type == MolecDiffType::ConstantAlpha );
410  Real mu_eff = (l_use_constAlpha) ? two * dc.dynamic_viscosity / dc.rho0_trans
411  : two * dc.dynamic_viscosity;
412 
413  auto dxinv = dxInv[0], dyinv = dxInv[1], dzinv = dxInv[2];
414  Real dx = dx_arr[0], dy = dx_arr[1], dz = dx_arr[2];
415  Real vol = dx * dy * dz;
416 
417  EBChoice ebChoice = solverChoice.ebChoice;
418  const bool l_no_slip = (ebChoice.eb_boundary_type == EBBoundaryType::NoSlipWall);
419  const bool l_surface_layer = (ebChoice.eb_boundary_type == EBBoundaryType::SurfaceLayer);
420  const bool l_constraint_x = solverChoice.diffChoice.eb_diff_constraint_x;
421  const bool l_constraint_y = solverChoice.diffChoice.eb_diff_constraint_y;
422  const bool l_constraint_z = solverChoice.diffChoice.eb_diff_constraint_z;
423 
424  const auto* u_factory = ebfact.get_u_const_factory();
425  const auto* v_factory = ebfact.get_v_const_factory();
426  const auto* w_factory = ebfact.get_w_const_factory();
427 
428  auto const& u_cut_cells = ebfact.get_u_cut_cells(mfi.index());
429  auto const& v_cut_cells = ebfact.get_v_cut_cells(mfi.index());
430  auto const& w_cut_cells = ebfact.get_w_cut_cells(mfi.index());
431 
432  const auto& u_flagfab = u_factory->getMultiEBCellFlagFab()[mfi];
433  const auto& v_flagfab = v_factory->getMultiEBCellFlagFab()[mfi];
434  const auto& w_flagfab = w_factory->getMultiEBCellFlagFab()[mfi];
435 
436  FabType u_type = u_flagfab.getType();
437  FabType v_type = v_flagfab.getType();
438  FabType w_type = w_flagfab.getType();
439 
440  const bool l_wall_model = l_no_slip || l_surface_layer;
441  const bool l_u_correction = l_wall_model && !l_constraint_x &&
442  u_type == FabType::singlevalued;
443  const bool l_v_correction = l_wall_model && !l_constraint_y &&
444  v_type == FabType::singlevalued;
445  const bool l_w_correction = l_wall_model && !l_constraint_z &&
446  w_type == FabType::singlevalued;
447  const bool l_any_correction = l_u_correction || l_v_correction || l_w_correction;
448 
449  Array4<const Real> u_volfrac = u_factory->getVolFrac().const_array(mfi);
450  Array4<const Real> v_volfrac = v_factory->getVolFrac().const_array(mfi);
451  Array4<const Real> w_volfrac = w_factory->getVolFrac().const_array(mfi);
452 
453  Array4<const EBCellFlag> u_cellflg = u_flagfab.const_array();
454  Array4<const EBCellFlag> v_cellflg = v_flagfab.const_array();
455  Array4<const EBCellFlag> w_cellflg = w_flagfab.const_array();
456  Array4<const Real> u_volcent{};
457  Array4<const Real> v_volcent{};
458  Array4<const Real> w_volcent{};
459 
460  if (l_any_correction) {
461  if (u_type == FabType::singlevalued) {
462  u_volcent = u_factory->getCentroid().const_array(mfi);
463  }
464  if (v_type == FabType::singlevalued) {
465  v_volcent = v_factory->getCentroid().const_array(mfi);
466  }
467  if (w_type == FabType::singlevalued) {
468  w_volcent = w_factory->getCentroid().const_array(mfi);
469  }
470  }
471 
472  Array4<const Real> u_afrac_x{};
473  Array4<const Real> u_afrac_y{};
474  Array4<const Real> u_afrac_z{};
475  Array4<const Real> v_afrac_x{};
476  Array4<const Real> v_afrac_y{};
477  Array4<const Real> v_afrac_z{};
478  Array4<const Real> w_afrac_x{};
479  Array4<const Real> w_afrac_y{};
480  Array4<const Real> w_afrac_z{};
481 
482  if (u_type == FabType::singlevalued) {
483  u_afrac_x = u_factory->getAreaFrac()[0]->const_array(mfi);
484  u_afrac_y = u_factory->getAreaFrac()[1]->const_array(mfi);
485  u_afrac_z = u_factory->getAreaFrac()[2]->const_array(mfi);
486  }
487  if (v_type == FabType::singlevalued) {
488  v_afrac_x = v_factory->getAreaFrac()[0]->const_array(mfi);
489  v_afrac_y = v_factory->getAreaFrac()[1]->const_array(mfi);
490  v_afrac_z = v_factory->getAreaFrac()[2]->const_array(mfi);
491  }
492  if (w_type == FabType::singlevalued) {
493  w_afrac_x = w_factory->getAreaFrac()[0]->const_array(mfi);
494  w_afrac_y = w_factory->getAreaFrac()[1]->const_array(mfi);
495  w_afrac_z = w_factory->getAreaFrac()[2]->const_array(mfi);
496  }
497 
498  Array4<const Real> u_bcent{};
499  Array4<const Real> u_bnorm{};
500  Array4<const Real> v_bcent{};
501  Array4<const Real> v_bnorm{};
502  Array4<const Real> w_bcent{};
503  Array4<const Real> w_bnorm{};
504 
505  if (l_u_correction) {
506  u_bcent = u_factory->getBndryCent().const_array(mfi);
507  u_bnorm = u_factory->getBndryNormal().const_array(mfi);
508  }
509  if (l_v_correction) {
510  v_bcent = v_factory->getBndryCent().const_array(mfi);
511  v_bnorm = v_factory->getBndryNormal().const_array(mfi);
512  }
513  if (l_w_correction) {
514  w_bcent = w_factory->getBndryCent().const_array(mfi);
515  w_bnorm = w_factory->getBndryNormal().const_array(mfi);
516  }
517 
518  const Array4<const Real> unused_real{};
519 
520  // x-momentum
521  if (u_type == FabType::regular) {
522 
523  ParallelFor(bxx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
524 
525  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
526 
527  rho_u_rhs(i,j,k) -= ( (tau11(i , j , k ) - tau11(i-1, j , k ) ) * dxinv * mfsq
528  + (tau12(i , j+1, k ) - tau12(i , j , k ) ) * dyinv * mfsq
529  + (tau13(i , j , k+1) - tau13(i , j , k ) ) * dzinv );
530  });
531 
532  } else if (u_type == FabType::singlevalued) {
533 
534  ParallelFor(bxx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
535  EBCellFlag const cell_flag = u_cellflg(i,j,k);
536 
537  if (cell_flag.isRegular()) {
538  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
539 
540  rho_u_rhs(i,j,k) -= ( (tau11(i , j , k ) - tau11(i-1, j , k ) ) * dxinv * mfsq
541  + (tau12(i , j+1, k ) - tau12(i , j , k ) ) * dyinv * mfsq
542  + (tau13(i , j , k+1) - tau13(i , j , k ) ) * dzinv );
543  } else if (cell_flag.isSingleValued()) {
544  Real vfrac = u_volfrac(i,j,k);
545  if (vfrac <= zero) { return; }
546 
547  // Inv Jacobian
548  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
549 
550  Real diffContrib = ( (tau11(i , j , k ) * u_afrac_x(i+1,j ,k )
551  - tau11(i-1, j , k ) * u_afrac_x(i ,j ,k ) ) * dxinv * mfsq
552  + (tau12(i , j+1, k ) * u_afrac_y(i ,j+1,k )
553  - tau12(i , j , k ) * u_afrac_y(i ,j ,k ) ) * dyinv * mfsq
554  + (tau13(i , j , k+1) * u_afrac_z(i ,j ,k+1)
555  - tau13(i , j , k ) * u_afrac_z(i ,j ,k )) * dzinv );
556  diffContrib /= vfrac;
557 
558  rho_u_rhs(i,j,k) -= diffContrib;
559  }
560  });
561  } // u_type
562 
563  if (l_u_correction) {
564  if (l_no_slip) {
565  launch_eb_wall_correction<0,EBBoundaryType::NoSlipWall>(
566  bxx, u_cut_cells, rho_u_rhs, u_arr, v_arr, w_arr,
567  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
568  unused_real, unused_real, unused_real, u_volfrac,
569  u_afrac_x, u_afrac_y, u_afrac_z, u_bcent, u_bnorm,
570  unused_real, unused_real, dx, dy, dz, vol, mu_eff);
571  } else {
572  launch_eb_wall_correction<0,EBBoundaryType::SurfaceLayer>(
573  bxx, u_cut_cells, rho_u_rhs, u_arr, v_arr, w_arr,
574  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
575  u_volfrac, v_volfrac, w_volfrac, u_volfrac,
576  u_afrac_x, u_afrac_y, u_afrac_z, u_bcent, u_bnorm,
577  u_tau_eb13, u_tau_eb23, dx, dy, dz, vol, mu_eff);
578  }
579  }
580 
581  // y-momentum
582  if (v_type == FabType::regular) {
583 
584  ParallelFor(bxy, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
585 
586  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
587 
588  rho_v_rhs(i,j,k) -= ( (tau12(i+1, j , k ) - tau12(i , j , k ) ) * dxinv * mfsq
589  + (tau22(i , j , k ) - tau22(i , j-1, k ) ) * dyinv * mfsq
590  + (tau23(i , j , k+1) - tau23(i , j , k ) ) * dzinv );
591  });
592  } else if (v_type == FabType::singlevalued) {
593 
594  ParallelFor(bxy, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
595  EBCellFlag const cell_flag = v_cellflg(i,j,k);
596 
597  if (cell_flag.isRegular()) {
598  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
599 
600  rho_v_rhs(i,j,k) -= ( (tau12(i+1, j , k ) - tau12(i , j , k ) ) * dxinv * mfsq
601  + (tau22(i , j , k ) - tau22(i , j-1, k ) ) * dyinv * mfsq
602  + (tau23(i , j , k+1) - tau23(i , j , k ) ) * dzinv );
603  } else if (cell_flag.isSingleValued()) {
604  Real vfrac = v_volfrac(i,j,k);
605  if (vfrac <= zero) { return; }
606 
607  // Inv Jacobian
608  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
609 
610  Real diffContrib = ( (tau12(i+1, j , k ) * v_afrac_x(i+1,j ,k )
611  - tau12(i , j , k ) * v_afrac_x(i ,j ,k ) ) * dxinv * mfsq
612  + (tau22(i , j , k ) * v_afrac_y(i ,j+1,k )
613  - tau22(i , j-1, k ) * v_afrac_y(i ,j ,k ) ) * dyinv * mfsq
614  + (tau23(i , j , k+1) * v_afrac_z(i ,j ,k+1)
615  - tau23(i , j , k ) * v_afrac_z(i ,j ,k ) ) * dzinv );
616  diffContrib /= vfrac;
617 
618  rho_v_rhs(i,j,k) -= diffContrib;
619  }
620  });
621  } // v_type
622 
623  if (l_v_correction) {
624  if (l_no_slip) {
625  launch_eb_wall_correction<1,EBBoundaryType::NoSlipWall>(
626  bxy, v_cut_cells, rho_v_rhs, u_arr, v_arr, w_arr,
627  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
628  unused_real, unused_real, unused_real, v_volfrac,
629  v_afrac_x, v_afrac_y, v_afrac_z, v_bcent, v_bnorm,
630  unused_real, unused_real, dx, dy, dz, vol, mu_eff);
631  } else {
632  launch_eb_wall_correction<1,EBBoundaryType::SurfaceLayer>(
633  bxy, v_cut_cells, rho_v_rhs, u_arr, v_arr, w_arr,
634  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
635  u_volfrac, v_volfrac, w_volfrac, v_volfrac,
636  v_afrac_x, v_afrac_y, v_afrac_z, v_bcent, v_bnorm,
637  v_tau_eb13, v_tau_eb23, dx, dy, dz, vol, mu_eff);
638  }
639  }
640 
641  // z-momentum
642  if (w_type == FabType::regular) {
643 
644  ParallelFor(bxz, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
645 
646  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
647 
648  rho_w_rhs(i,j,k) -= ( (tau13(i+1, j , k ) - tau13(i , j , k ) ) * dxinv * mfsq
649  + (tau23(i , j+1, k ) - tau23(i , j , k ) ) * dyinv * mfsq
650  + (tau33(i , j , k ) - tau33(i , j , k-1) ) * dzinv );
651  });
652 
653  } else if (w_type == FabType::singlevalued) {
654 
655  ParallelFor(bxz, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
656  EBCellFlag const cell_flag = w_cellflg(i,j,k);
657 
658  if (cell_flag.isRegular()) {
659  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
660 
661  rho_w_rhs(i,j,k) -= ( (tau13(i+1, j , k ) - tau13(i , j , k ) ) * dxinv * mfsq
662  + (tau23(i , j+1, k ) - tau23(i , j , k ) ) * dyinv * mfsq
663  + (tau33(i , j , k ) - tau33(i , j , k-1) ) * dzinv );
664  } else if (cell_flag.isSingleValued()) {
665  Real vfrac = w_volfrac(i,j,k);
666  if (vfrac <= zero) { return; }
667 
668  // Inv Jacobian
669  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
670 
671  Real diffContrib = ( (tau13(i+1, j , k ) * w_afrac_x(i+1,j ,k )
672  - tau13(i , j , k ) * w_afrac_x(i ,j ,k ) ) * dxinv * mfsq
673  + (tau23(i , j+1, k ) * w_afrac_y(i ,j+1,k )
674  - tau23(i , j , k ) * w_afrac_y(i ,j ,k ) ) * dyinv * mfsq
675  + (tau33(i , j , k ) * w_afrac_z(i ,j ,k+1)
676  - tau33(i , j , k-1) * w_afrac_z(i ,j ,k ) ) * dzinv );
677  diffContrib /= vfrac;
678 
679  rho_w_rhs(i,j,k) -= diffContrib;
680  }
681  });
682  } // w_type
683 
684  if (l_w_correction) {
685  if (l_no_slip) {
686  launch_eb_wall_correction<2,EBBoundaryType::NoSlipWall>(
687  bxz, w_cut_cells, rho_w_rhs, u_arr, v_arr, w_arr,
688  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
689  unused_real, unused_real, unused_real, w_volfrac,
690  w_afrac_x, w_afrac_y, w_afrac_z, w_bcent, w_bnorm,
691  unused_real, unused_real, dx, dy, dz, vol, mu_eff);
692  } else {
693  launch_eb_wall_correction<2,EBBoundaryType::SurfaceLayer>(
694  bxz, w_cut_cells, rho_w_rhs, u_arr, v_arr, w_arr,
695  u_cellflg, v_cellflg, w_cellflg, u_volcent, v_volcent, w_volcent,
696  u_volfrac, v_volfrac, w_volfrac, w_volfrac,
697  w_afrac_x, w_afrac_y, w_afrac_z, w_bcent, w_bnorm,
698  w_tau_eb13, w_tau_eb23, dx, dy, dz, vol, mu_eff);
699  }
700  }
701 }
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
@ 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
@ tau13
Definition: ERF_DataStruct.H:51
void DiffusionSrcForMom_EB(const MFIter &mfi, [[maybe_unused]] const Box &domain, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &u_arr, const Array4< const Real > &v_arr, const Array4< const Real > &w_arr, const Array4< const Real > &tau11, const Array4< const Real > &tau22, const Array4< const Real > &tau33, const Array4< const Real > &tau12, const Array4< const Real > &tau13, const Array4< const Real > &tau23, const Array4< const Real > &u_tau_eb13, const Array4< const Real > &u_tau_eb23, const Array4< const Real > &v_tau_eb13, const Array4< const Real > &v_tau_eb23, const Array4< const Real > &w_tau_eb13, const Array4< const Real > &w_tau_eb23, const Real *dx_arr, 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 SolverChoice &solverChoice, const eb_ &ebfact, [[maybe_unused]] const BCRec *d_bcrec_ptr)
Definition: ERF_DiffusionSrcForMom_EB.cpp:373
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
const Real dy
Definition: ERF_InitCustomPert_ABL.H:101
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 two
Definition: ERF_NumericalConstants.H:38
CutCellList const & get_u_cut_cells(int grid_index) const noexcept
Return cut x-faces owned by a grid, cached when the EB factories are built.
Definition: ERF_EB.H:92
CutCellList const & get_v_cut_cells(int grid_index) const noexcept
Return cut y-faces owned by a grid, cached when the EB factories are built.
Definition: ERF_EB.H:98
CutCellList const & get_w_cut_cells(int grid_index) const noexcept
Return cut z-faces owned by a grid, cached when the EB factories are built.
Definition: ERF_EB.H:104
amrex::EBFArrayBoxFactory const * get_w_const_factory() const noexcept
Return the native AMReX z-face EB factory.
Definition: ERF_EB.H:136
amrex::EBFArrayBoxFactory const * get_u_const_factory() const noexcept
Return the native AMReX x-face EB factory.
Definition: ERF_EB.H:132
amrex::EBFArrayBoxFactory const * get_v_const_factory() const noexcept
Return the native AMReX y-face EB factory.
Definition: ERF_EB.H:134
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
Definition: ERF_DiffStruct.H:25
bool eb_diff_constraint_z
Whether to constrain EB diffusion in the z direction.
Definition: ERF_DiffStruct.H:112
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:97
bool eb_diff_constraint_y
Whether to constrain EB diffusion in the y direction.
Definition: ERF_DiffStruct.H:111
bool eb_diff_constraint_x
Whether to constrain EB diffusion in the x direction.
Definition: ERF_DiffStruct.H:110
amrex::Real dynamic_viscosity
Dynamic viscosity for momentum diffusion [kg/(m-s)].
Definition: ERF_DiffStruct.H:109
amrex::Real rho0_trans
Reference density used to compute dynamic diffusion coefficients [kg/m3].
Definition: ERF_DiffStruct.H:104
Definition: ERF_EBStruct.H:36
EBChoice ebChoice
Embedded-boundary options.
Definition: ERF_DataStruct.H:3021
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:3017
Here is the call graph for this function: