ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_DiffusionSrcForMom.cpp File Reference
#include <AMReX.H>
#include <ERF_Diffusion.H>
#include <ERF_IndexDefines.H>
Include dependency graph for ERF_DiffusionSrcForMom.cpp:

Functions

void DiffusionSrcForMom (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 > &tau11, const Array4< const Real > &tau22, const Array4< const Real > &tau33, const Array4< const Real > &tau12, const Array4< const Real > &tau21, const Array4< const Real > &tau13, const Array4< const Real > &tau31, const Array4< const Real > &tau23, const Array4< const Real > &tau32, const Array4< const Real > &detJ, 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 bool l_stretched_dz, const bool l_variable_dz)
 

Function Documentation

◆ DiffusionSrcForMom()

void DiffusionSrcForMom ( 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 > &  tau11,
const Array4< const Real > &  tau22,
const Array4< const Real > &  tau33,
const Array4< const Real > &  tau12,
const Array4< const Real > &  tau21,
const Array4< const Real > &  tau13,
const Array4< const Real > &  tau31,
const Array4< const Real > &  tau23,
const Array4< const Real > &  tau32,
const Array4< const Real > &  detJ,
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 bool  l_stretched_dz,
const bool  l_variable_dz 
)

Function for computing the momentum RHS from diffusion

Parameters
[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]tau1111 stress
[in]tau2222 stress
[in]tau3333 stress
[in]tau1212 stress
[in]tau1313 stress
[in]tau2121 stress
[in]tau2323 stress
[in]tau3131 stress
[in]tau3232 stress
[in]detJJacobian determinant
[in]differChoicecontainer with diffusion parameters
[in]dxInvinverse cell size array
[in]mf_mmap factor at cell center
51 {
52  BL_PROFILE_VAR("DiffusionSrcForMom()",DiffusionSrcForMom);
53 
54  auto dxinv = dxInv[0], dyinv = dxInv[1], dzinv = dxInv[2];
55 
56  if (l_variable_dz) { // Variable dz (i.e. terrain-fitted coordinates)
57  ParallelFor(bxx, bxy, bxz,
58  [=] AMREX_GPU_DEVICE (int i, int j, int k)
59  {
60  // Inv Jacobian
61  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
62 
63  Real diffContrib = ( (tau11(i , j , k ) - tau11(i-1, j ,k )) * dxinv * mfsq // Contribution to x-mom eqn from diffusive flux in x-dir
64  + (tau12(i , j+1, k ) - tau12(i , j ,k )) * dyinv * mfsq // Contribution to x-mom eqn from diffusive flux in y-dir
65  + (tau13(i , j , k+1) - tau13(i , j ,k )) * dzinv ); // Contribution to x-mom eqn from diffusive flux in z-dir;
66  diffContrib /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
67  rho_u_rhs(i,j,k) -= diffContrib;
68  },
69  [=] AMREX_GPU_DEVICE (int i, int j, int k)
70  {
71  // Inv Jacobian
72  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
73 
74  Real diffContrib = ( (tau21(i+1, j , k ) - tau21(i , j , k )) * dxinv * mfsq // Contribution to y-mom eqn from diffusive flux in x-dir
75  + (tau22(i , j , k ) - tau22(i , j-1, k )) * dyinv * mfsq // Contribution to y-mom eqn from diffusive flux in y-dir
76  + (tau23(i , j , k+1) - tau23(i , j , k )) * dzinv ); // Contribution to y-mom eqn from diffusive flux in z-dir;
77  diffContrib /= 0.5*(detJ(i,j,k) + detJ(i,j-1,k));
78  rho_v_rhs(i,j,k) -= diffContrib;
79  },
80  [=] AMREX_GPU_DEVICE (int i, int j, int k)
81  {
82  // Inv Jacobian
83  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
84 
85  Real diffContrib = ( (tau31(i+1, j , k ) - tau31(i , j , k )) * dxinv * mfsq // Contribution to z-mom eqn from diffusive flux in x-dir
86  + (tau32(i , j+1, k ) - tau32(i , j , k )) * dyinv * mfsq // Contribution to z-mom eqn from diffusive flux in y-dir
87  + (tau33(i , j , k ) - tau33(i , j , k-1)) * dzinv ); // Contribution to z-mom eqn from diffusive flux in z-dir;
88  diffContrib /= 0.5*(detJ(i,j,k) + detJ(i,j,k-1));
89  rho_w_rhs(i,j,k) -= diffContrib;
90  });
91 
92  } else if (l_stretched_dz) { // Stretched dz
93 
94  auto dz_ptr = stretched_dz_d.data();
95 
96  ParallelFor(bxx, bxy, bxz,
97  [=] AMREX_GPU_DEVICE (int i, int j, int k)
98  {
99  // Inv Jacobian
100  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
101  Real dzloc = dz_ptr[k]*dzinv;
102 
103  Real diffContrib = ( (tau11(i , j , k ) - tau11(i-1, j ,k )) * dxinv * mfsq // Contribution to x-mom eqn from diffusive flux in x-dir
104  + (tau12(i , j+1, k ) - tau12(i , j ,k )) * dyinv * mfsq // Contribution to x-mom eqn from diffusive flux in y-dir
105  + (tau13(i , j , k+1) - tau13(i , j ,k )) * dzinv ); // Contribution to x-mom eqn from diffusive flux in z-dir;
106 
107  rho_u_rhs(i,j,k) -= diffContrib/dzloc;
108  },
109  [=] AMREX_GPU_DEVICE (int i, int j, int k)
110  {
111  // Inv Jacobian
112  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
113  Real dzloc = dz_ptr[k]*dzinv;
114 
115  Real diffContrib = ( (tau21(i+1, j , k ) - tau21(i , j , k )) * dxinv * mfsq // Contribution to y-mom eqn from diffusive flux in x-dir
116  + (tau22(i , j , k ) - tau22(i , j-1, k )) * dyinv * mfsq // Contribution to y-mom eqn from diffusive flux in y-dir
117  + (tau23(i , j , k+1) - tau23(i , j , k )) * dzinv ); // Contribution to y-mom eqn from diffusive flux in z-dir;
118 
119  rho_v_rhs(i,j,k) -= diffContrib/dzloc;
120  },
121  [=] AMREX_GPU_DEVICE (int i, int j, int k)
122  {
123  // Inv Jacobian
124  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
125  Real dzloc = 0.5 * (dz_ptr[k] + dz_ptr[k-1])*dzinv;
126 
127  Real diffContrib = ( (tau31(i+1, j , k ) - tau31(i , j , k )) * dxinv * mfsq // Contribution to z-mom eqn from diffusive flux in x-dir
128  + (tau32(i , j+1, k ) - tau32(i , j , k )) * dyinv * mfsq // Contribution to z-mom eqn from diffusive flux in y-dir
129  + (tau33(i , j , k ) - tau33(i , j , k-1)) * dzinv ); // Contribution to z-mom eqn from diffusive flux in z-dir;
130 
131  rho_w_rhs(i,j,k) -= diffContrib/dzloc;
132  });
133 
134  } else { // Constant Dz
135 
136  ParallelFor(bxx, bxy, bxz,
137  [=] AMREX_GPU_DEVICE (int i, int j, int k)
138  {
139  // Inv Jacobian
140  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
141 
142  // Area corrections
143  Real Imfy_hi = 1. / mf_my(i ,j,0);
144  Real Imfy_lo = 1. / mf_my(i-1,j,0);
145  Real Imfx_hi = 1. / (0.5 * (mf_vx(i,j+1,0) + mf_vx(i-1,j+1,0)));
146  Real Imfx_lo = 1. / (0.5 * (mf_vx(i,j ,0) + mf_vx(i-1,j ,0)));
147  rho_u_rhs(i,j,k) -= ( (tau11(i , j , k )*Imfy_hi - tau11(i-1, j ,k )*Imfy_lo) * dxinv * mfsq // Contribution to x-mom eqn from diffusive flux in x-dir
148  + (tau12(i , j+1, k )*Imfx_hi - tau12(i , j ,k )*Imfx_lo) * dyinv * mfsq // Contribution to x-mom eqn from diffusive flux in y-dir
149  + (tau13(i , j , k+1) - tau13(i , j ,k ) ) * dzinv ); // Contribution to x-mom eqn from diffusive flux in z-dir;
150  },
151  [=] AMREX_GPU_DEVICE (int i, int j, int k)
152  {
153  // Inv Jacobian
154  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
155 
156  // Area corrections
157  Real Imfy_hi = 1. / (0.5 * (mf_uy(i+1,j,0) + mf_uy(i+1,j-1,0)));
158  Real Imfy_lo = 1. / (0.5 * (mf_uy(i ,j,0) + mf_uy(i ,j-1,0)));
159  Real Imfx_hi = 1. / mf_mx(i ,j,0);
160  Real Imfx_lo = 1. / mf_mx(i-1,j,0);
161  rho_v_rhs(i,j,k) -= ( (tau12(i+1, j , k )*Imfy_hi - tau12(i , j , k )*Imfy_lo) * dxinv * mfsq // Contribution to y-mom eqn from diffusive flux in x-dir
162  + (tau22(i , j , k )*Imfx_hi - tau22(i , j-1, k )*Imfx_lo) * dyinv * mfsq // Contribution to y-mom eqn from diffusive flux in y-dir
163  + (tau23(i , j , k+1) - tau23(i , j , k ) ) * dzinv ); // Contribution to y-mom eqn from diffusive flux in z-dir;
164  },
165  [=] AMREX_GPU_DEVICE (int i, int j, int k)
166  {
167  // Inv Jacobian
168  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
169 
170  // Area corrections
171  Real Imfy_hi = 1. / mf_uy(i+1,j ,0);
172  Real Imfy_lo = 1. / mf_uy(i ,j ,0);
173  Real Imfx_hi = 1. / mf_vx(i ,j+1,0);
174  Real Imfx_lo = 1. / mf_vx(i ,j ,0);
175  rho_w_rhs(i,j,k) -= ( (tau13(i+1, j , k )*Imfy_hi - tau13(i , j , k )*Imfy_lo) * dxinv * mfsq // Contribution to z-mom eqn from diffusive flux in x-dir
176  + (tau23(i , j+1, k )*Imfx_hi - tau23(i , j , k )*Imfx_lo) * dyinv * mfsq // Contribution to z-mom eqn from diffusive flux in y-dir
177  + (tau33(i , j , k ) - tau33(i , j , k-1) ) * dzinv ); // Contribution to z-mom eqn from diffusive flux in z-dir;
178  });
179  }
180 }
@ 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
void DiffusionSrcForMom(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 > &tau11, const Array4< const Real > &tau22, const Array4< const Real > &tau33, const Array4< const Real > &tau12, const Array4< const Real > &tau21, const Array4< const Real > &tau13, const Array4< const Real > &tau31, const Array4< const Real > &tau23, const Array4< const Real > &tau32, const Array4< const Real > &detJ, 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 bool l_stretched_dz, const bool l_variable_dz)
Definition: ERF_DiffusionSrcForMom.cpp:31