ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
moeng_flux Struct Reference

#include <ERF_MOSTStress.H>

Collaboration diagram for moeng_flux:

Public Member Functions

 moeng_flux (const amrex::Real wsmin=0.1, const bool face_is_low=true, const int zlo=0, const int zhi=0)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_q_flux (const int &i, const int &j, const int &k, const int &dir, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &velx_arr, const amrex::Array4< const amrex::Real > &vely_arr, const amrex::Array4< const amrex::Real > &velz_arr, const amrex::Array4< const amrex::Real > &umm_arr, const amrex::Array4< const amrex::Real > &qvm_arr, const amrex::Array4< const amrex::Real > &u_star_arr, const amrex::Array4< const amrex::Real > &q_star_arr, const amrex::Array4< const amrex::Real > &q_surf_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_t_flux (const int &i, const int &j, const int &k, const int &dir, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &velx_arr, const amrex::Array4< const amrex::Real > &vely_arr, const amrex::Array4< const amrex::Real > &velz_arr, const amrex::Array4< const amrex::Real > &umm_arr, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::Array4< const amrex::Real > &u_star_arr, const amrex::Array4< const amrex::Real > &t_star_arr, const amrex::Array4< const amrex::Real > &t_surf_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_u_flux (const int &i, const int &j, const int &k, const int &dir, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &velx_arr, const amrex::Array4< const amrex::Real > &vely_arr, const amrex::Array4< const amrex::Real > &velz_arr, const amrex::Array4< const amrex::Real > &umm_arr, const amrex::Array4< const amrex::Real > &um_arr, const amrex::Array4< const amrex::Real > &vm_arr, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &u_star_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_v_flux (const int &i, const int &j, const int &k, const int &dir, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &velx_arr, const amrex::Array4< const amrex::Real > &vely_arr, const amrex::Array4< const amrex::Real > &velz_arr, const amrex::Array4< const amrex::Real > &umm_arr, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &vm_arr, const amrex::Array4< const amrex::Real > &wm_arr, const amrex::Array4< const amrex::Real > &u_star_arr) const
 

Private Attributes

const amrex::Real eps = amrex::Real(1e-15)
 
bool is_low = true
 
amrex::Real WSMIN = most_min_wind_speed
 
int m_zlo = 0
 
int m_zhi = 0
 

Detailed Description

Moeng flux formulation

Constructor & Destructor Documentation

◆ moeng_flux()

moeng_flux::moeng_flux ( const amrex::Real  wsmin = 0.1,
const bool  face_is_low = true,
const int  zlo = 0,
const int  zhi = 0 
)
inline

Construct the Moeng flux calculator.

2116  {
2117  WSMIN = wsmin;
2118  is_low = face_is_low;
2119  m_zlo = zlo;
2120  m_zhi = zhi;
2121  }
int m_zhi
Definition: ERF_MOSTStress.H:2425
int m_zlo
Definition: ERF_MOSTStress.H:2424
amrex::Real WSMIN
Definition: ERF_MOSTStress.H:2423
bool is_low
Definition: ERF_MOSTStress.H:2422

Member Function Documentation

◆ compute_q_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real moeng_flux::compute_q_flux ( const int &  i,
const int &  j,
const int &  k,
const int &  dir,
const amrex::Array4< const amrex::Real > &  cons_arr,
const amrex::Array4< const amrex::Real > &  velx_arr,
const amrex::Array4< const amrex::Real > &  vely_arr,
const amrex::Array4< const amrex::Real > &  velz_arr,
const amrex::Array4< const amrex::Real > &  umm_arr,
const amrex::Array4< const amrex::Real > &  qvm_arr,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< const amrex::Real > &  q_star_arr,
const amrex::Array4< const amrex::Real > &  q_surf_arr 
) const
inline

Compute moisture flux for one surface point.

Calling sequence
i, j, k, cons_arr, velx_arr, vely_arr, umm_arr, qvm_arr, u_star_arr, q_star_arr, q_surf_arr.
2146  {
2147  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2148  amrex::Real qv = cons_arr(i,j,k,RhoQ1_comp) / rho;
2149 
2150  amrex::Real velx, vely;
2151  if (dir == 0) {
2152  // X-face: y/z velocity, velx = vely, vely = velz here
2153  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2154  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2155  } else if (dir == 1) {
2156  // Y-face: x/z velocity, vely = velz here
2157  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2158  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2159  } else {
2160  // Z face: x/y velocity
2161  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2162  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2163  }
2164 
2165  amrex::Real qv_mean = qvm_arr(i,j,k);
2166  amrex::Real ustar = u_star_arr(i,j,k);
2167  amrex::Real qstar = q_star_arr(i,j,k);
2168  amrex::Real qv_surf = q_surf_arr(i,j,k);
2169  amrex::Real wsp_mean = umm_arr(i,j,k);
2170  wsp_mean = std::max(wsp_mean, WSMIN);
2171  if (dir == 2 && !is_low) {
2172  // flip qv_mean and qv_surf for hi-z face
2173  qv_mean = qv_surf;
2174  qv_surf = qvm_arr(i, j, k);
2175  }
2176 
2177  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2178  amrex::Real num1 = wsp * (qv_mean-qv_surf);
2179  amrex::Real num2 = wsp_mean * (qv-qvm_arr(i,j,k));
2180 
2181  // NOTE: this is rho*<Qv'w'> = -K dQvdz
2182  amrex::Real moflux = (std::abs(qstar) > eps) ?
2183  -rho*qstar*ustar*(num1+num2)/((qv_mean-qv_surf)*wsp_mean) : zero;
2184 
2185  return moflux;
2186  }
#define Rho_comp
Definition: ERF_IndexDefines.H:53
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:66
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ ustar
Definition: ERF_SLM.H:28
@ qstar
Definition: ERF_SLM.H:30
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
const amrex::Real eps
Definition: ERF_MOSTStress.H:2420

◆ compute_t_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real moeng_flux::compute_t_flux ( const int &  i,
const int &  j,
const int &  k,
const int &  dir,
const amrex::Array4< const amrex::Real > &  cons_arr,
const amrex::Array4< const amrex::Real > &  velx_arr,
const amrex::Array4< const amrex::Real > &  vely_arr,
const amrex::Array4< const amrex::Real > &  velz_arr,
const amrex::Array4< const amrex::Real > &  umm_arr,
const amrex::Array4< const amrex::Real > &  tm_arr,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< const amrex::Real > &  t_star_arr,
const amrex::Array4< const amrex::Real > &  t_surf_arr 
) const
inline

Compute heat flux for one surface point.

Calling sequence
i, j, k, cons_arr, velx_arr, vely_arr, umm_arr, tm_arr, u_star_arr, t_star_arr, t_surf_arr.
2211  {
2212  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2213  amrex::Real theta = cons_arr(i,j,k,RhoTheta_comp) / rho;
2214 
2215  amrex::Real velx, vely;
2216  if (dir == 0) {
2217  // X-face: y/z velocity, velx = vely, vely = velz here
2218  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2219  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2220  } else if (dir == 1) {
2221  // Y-face: x/z velocity, vely = velz here
2222  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2223  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2224  } else {
2225  // Z face: x/y velocity
2226  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2227  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2228  }
2229 
2230  amrex::Real theta_mean = tm_arr(i,j,k);
2231  amrex::Real ustar = u_star_arr(i,j,k);
2232  amrex::Real tstar = t_star_arr(i,j,k);
2233  amrex::Real theta_surf = t_surf_arr(i,j,k);
2234  amrex::Real wsp_mean = umm_arr(i,j,k);
2235 
2236  if (dir == 2 && !is_low) {
2237  // flip theta and surf for hi-z face
2238  theta_mean = theta_surf;
2239  theta_surf = tm_arr(i, j, k);
2240  }
2241 
2242  wsp_mean = std::max(wsp_mean, WSMIN);
2243 
2244  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2245  amrex::Real num1 = wsp * (theta_mean-theta_surf);
2246  amrex::Real num2 = wsp_mean * (theta-tm_arr(i,j,k));
2247 
2248  // NOTE: this is rho*<T'w'> = -K dTdz
2249  amrex::Real moflux = (std::abs(tstar) > eps) ?
2250  -rho*tstar*ustar*(num1+num2)/((theta_mean-theta_surf)*wsp_mean) : zero;
2251 
2252  return moflux;
2253  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:54
@ tstar
Definition: ERF_SLM.H:29
@ theta
Definition: ERF_Kessler.H:26

◆ compute_u_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real moeng_flux::compute_u_flux ( const int &  i,
const int &  j,
const int &  k,
const int &  dir,
const amrex::Array4< const amrex::Real > &  cons_arr,
const amrex::Array4< const amrex::Real > &  velx_arr,
const amrex::Array4< const amrex::Real > &  vely_arr,
const amrex::Array4< const amrex::Real > &  velz_arr,
const amrex::Array4< const amrex::Real > &  umm_arr,
const amrex::Array4< const amrex::Real > &  um_arr,
const amrex::Array4< const amrex::Real > &  vm_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  u_star_arr 
) const
inline

Compute x-momentum flux for one surface face.

Calling sequence
i, j, k, cons_arr, velx_arr, vely_arr, umm_arr, um_arr, u_star_arr.
2278  {
2279  // The caller supplies indices on the stress face. On a high wall the
2280  // normal index is one past the adjacent cell, so use the interior cell
2281  // for all input fields while retaining the stress index tangentially.
2282  const int ic = (!is_low && dir == 0) ? i - 1 : i;
2283  const int jc = (!is_low && dir == 1) ? j - 1 : j;
2284  const int kc = (!is_low && dir != 0 && dir != 1) ? k - 1 : k;
2285 
2286  amrex::Real velx, vely, rho, umean, ustar, wsp_mean;
2287  if (dir == 0) {
2288  // X wall: V-momentum flux at tau21. V is already y-nodal;
2289  // interpolate W and the cell-centered fields to that y node.
2290  velx = vely_arr(ic,j,kc);
2291  vely = fourth * ( velz_arr(ic,j-1,kc ) + velz_arr(ic,j,kc )
2292  + velz_arr(ic,j-1,kc+1) + velz_arr(ic,j,kc+1) );
2293  rho = myhalf * (cons_arr(ic,j-1,kc,Rho_comp) + cons_arr(ic,j,kc,Rho_comp));
2294  umean = vm_arr(ic,j,kc);
2295  ustar = myhalf * (u_star_arr(ic,j-1,kc) + u_star_arr(ic,j,kc));
2296  wsp_mean = myhalf * (umm_arr(ic,j-1,kc) + umm_arr(ic,j,kc));
2297  } else if (dir == 1) {
2298  // Y wall: U-momentum flux at tau12. U is already x-nodal;
2299  // interpolate W and the cell-centered fields to that x node.
2300  velx = velx_arr(i,jc,kc);
2301  vely = fourth * ( velz_arr(i-1,jc,kc ) + velz_arr(i,jc,kc )
2302  + velz_arr(i-1,jc,kc+1) + velz_arr(i,jc,kc+1) );
2303  rho = myhalf * (cons_arr(i-1,jc,kc,Rho_comp) + cons_arr(i,jc,kc,Rho_comp));
2304  umean = um_arr(i,jc,kc);
2305  ustar = myhalf * (u_star_arr(i-1,jc,kc) + u_star_arr(i,jc,kc));
2306  wsp_mean = myhalf * (umm_arr(i-1,jc,kc) + umm_arr(i,jc,kc));
2307  } else {
2308  // Z wall: U-momentum flux at tau13.
2309  velx = velx_arr(i,j,kc);
2310  vely = fourth * ( vely_arr(i-1,j ,kc) + vely_arr(i,j ,kc)
2311  + vely_arr(i-1,j+1,kc) + vely_arr(i,j+1,kc) );
2312  rho = myhalf * (cons_arr(i-1,j,kc,Rho_comp) + cons_arr(i,j,kc,Rho_comp));
2313  umean = um_arr(i,j,kc);
2314  ustar = myhalf * (u_star_arr(i-1,j,kc) + u_star_arr(i,j,kc));
2315  wsp_mean = myhalf * (umm_arr(i-1,j,kc) + umm_arr(i,j,kc));
2316  }
2317  wsp_mean = std::max(wsp_mean, WSMIN);
2318 
2319  // Note: The surface mean shear stress is decomposed into tau_xz by
2320  // multiplying the modeled shear stress (rho*ustar^2) with
2321  // a factor of umean/wsp_mean for directionality; this factor
2322  // modifies the denominator from what is in Moeng amrex::Real(1984.)
2323  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2324  amrex::Real num1 = wsp * umean;
2325  amrex::Real num2 = wsp_mean * (velx-umean);
2326 
2327  // NOTE: this is rho*<u'w'> = -K dudz
2328  amrex::Real stressx = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
2329  stressx = (is_low) ? stressx : -stressx;
2330 
2331  return stressx;
2332  }
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42

◆ compute_v_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real moeng_flux::compute_v_flux ( const int &  i,
const int &  j,
const int &  k,
const int &  dir,
const amrex::Array4< const amrex::Real > &  cons_arr,
const amrex::Array4< const amrex::Real > &  velx_arr,
const amrex::Array4< const amrex::Real > &  vely_arr,
const amrex::Array4< const amrex::Real > &  velz_arr,
const amrex::Array4< const amrex::Real > &  umm_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  vm_arr,
const amrex::Array4< const amrex::Real > &  wm_arr,
const amrex::Array4< const amrex::Real > &  u_star_arr 
) const
inline

Compute y-momentum flux for one surface face.

Calling sequence
i, j, k, cons_arr, velx_arr, vely_arr, umm_arr, vm_arr, u_star_arr.
2357  {
2358  // See compute_u_flux: stress indices on high walls must be mapped back
2359  // to the adjacent cell before reading cell-centered or tangential data.
2360  const int ic = (!is_low && dir == 0) ? i - 1 : i;
2361  const int jc = (!is_low && dir == 1) ? j - 1 : j;
2362  const int kc = (!is_low && dir != 0 && dir != 1) ? k - 1 : k;
2363 
2364  amrex::Real velx, vely, rho, vmean, ustar, wsp_mean;
2365  if (dir == 0) {
2366  // X wall: W-momentum flux at tau31. W is already z-nodal;
2367  // interpolate V and the cell-centered fields to that z node.
2368  const int klo = amrex::max(k - 1, m_zlo);
2369  const int khi = amrex::min(k, m_zhi);
2370  velx = fourth * ( vely_arr(ic,j ,klo) + vely_arr(ic,j+1,klo)
2371  + vely_arr(ic,j ,khi) + vely_arr(ic,j+1,khi) );
2372  vely = velz_arr(ic,j,k);
2373  rho = myhalf * (cons_arr(ic,j,klo,Rho_comp) + cons_arr(ic,j,khi,Rho_comp));
2374  vmean = wm_arr(ic,j,k);
2375  ustar = myhalf * (u_star_arr(ic,j,klo) + u_star_arr(ic,j,khi));
2376  wsp_mean = myhalf * (umm_arr(ic,j,klo) + umm_arr(ic,j,khi));
2377  } else if (dir == 1) {
2378  // Y wall: W-momentum flux at tau32. W is already z-nodal;
2379  // interpolate U and the cell-centered fields to that z node.
2380  const int klo = amrex::max(k - 1, m_zlo);
2381  const int khi = amrex::min(k, m_zhi);
2382  velx = fourth * ( velx_arr(i ,jc,klo) + velx_arr(i+1,jc,klo)
2383  + velx_arr(i ,jc,khi) + velx_arr(i+1,jc,khi) );
2384  vely = velz_arr(i,jc,k);
2385  rho = myhalf * (cons_arr(i,jc,klo,Rho_comp) + cons_arr(i,jc,khi,Rho_comp));
2386  vmean = wm_arr(i,jc,k);
2387  ustar = myhalf * (u_star_arr(i,jc,klo) + u_star_arr(i,jc,khi));
2388  wsp_mean = myhalf * (umm_arr(i,jc,klo) + umm_arr(i,jc,khi));
2389  } else {
2390  // Z wall: V-momentum flux at tau23.
2391  velx = fourth * ( velx_arr(i ,j-1,kc) + velx_arr(i+1,j-1,kc)
2392  + velx_arr(i ,j ,kc) + velx_arr(i+1,j ,kc) );
2393  vely = vely_arr(i,j,kc);
2394  rho = myhalf * (cons_arr(i,j-1,kc,Rho_comp) + cons_arr(i,j,kc,Rho_comp));
2395  vmean = vm_arr(i,j,kc);
2396  ustar = myhalf * (u_star_arr(i,j-1,kc) + u_star_arr(i,j,kc));
2397  wsp_mean = myhalf * (umm_arr(i,j-1,kc) + umm_arr(i,j,kc));
2398  }
2399  wsp_mean = std::max(wsp_mean, WSMIN);
2400 
2401  // Note: The surface mean shear stress is decomposed into tau_yz by
2402  // multiplying the modeled shear stress (rho*ustar^2) with
2403  // a factor of vmean/wsp_mean for directionality; this factor
2404  // modifies the denominator from what is in Moeng amrex::Real(1984.)
2405  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2406  amrex::Real num1 = wsp * vmean;
2407  amrex::Real num2 = wsp_mean * (vely-vmean);
2408 
2409  // NOTE: this is rho*<v'w'> = -K dvdz
2410  amrex::Real stressy = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
2411  stressy = (is_low) ? stressy : -stressy;
2412 
2413  return stressy;
2414  }
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
const int klo
Definition: ERF_InitCustomPert_KE.H:9

Member Data Documentation

◆ eps

const amrex::Real moeng_flux::eps = amrex::Real(1e-15)
private

Referenced by compute_q_flux(), and compute_t_flux().

◆ is_low

bool moeng_flux::is_low = true
private

◆ m_zhi

int moeng_flux::m_zhi = 0
private

Referenced by compute_v_flux(), and moeng_flux().

◆ m_zlo

int moeng_flux::m_zlo = 0
private

Referenced by compute_v_flux(), and moeng_flux().

◆ WSMIN


The documentation for this struct was generated from the following file: