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.

2226  {
2227  WSMIN = wsmin;
2228  is_low = face_is_low;
2229  m_zlo = zlo;
2230  m_zhi = zhi;
2231  }
int m_zhi
Definition: ERF_MOSTStress.H:2535
int m_zlo
Definition: ERF_MOSTStress.H:2534
amrex::Real WSMIN
Definition: ERF_MOSTStress.H:2533
bool is_low
Definition: ERF_MOSTStress.H:2532

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.
2256  {
2257  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2258  amrex::Real qv = cons_arr(i,j,k,RhoQ1_comp) / rho;
2259 
2260  amrex::Real velx, vely;
2261  if (dir == 0) {
2262  // X-face: y/z velocity, velx = vely, vely = velz here
2263  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2264  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2265  } else if (dir == 1) {
2266  // Y-face: x/z velocity, vely = velz here
2267  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2268  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2269  } else {
2270  // Z face: x/y velocity
2271  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2272  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2273  }
2274 
2275  amrex::Real qv_mean = qvm_arr(i,j,k);
2276  amrex::Real ustar = u_star_arr(i,j,k);
2277  amrex::Real qstar = q_star_arr(i,j,k);
2278  amrex::Real qv_surf = q_surf_arr(i,j,k);
2279  amrex::Real wsp_mean = umm_arr(i,j,k);
2280  wsp_mean = std::max(wsp_mean, WSMIN);
2281  if (dir == 2 && !is_low) {
2282  // flip qv_mean and qv_surf for hi-z face
2283  qv_mean = qv_surf;
2284  qv_surf = qvm_arr(i, j, k);
2285  }
2286 
2287  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2288  amrex::Real num1 = wsp * (qv_mean-qv_surf);
2289  amrex::Real num2 = wsp_mean * (qv-qvm_arr(i,j,k));
2290 
2291  // NOTE: this is rho*<Qv'w'> = -K dQvdz
2292  amrex::Real moflux = (std::abs(qstar) > eps) ?
2293  -rho*qstar*ustar*(num1+num2)/((qv_mean-qv_surf)*wsp_mean) : zero;
2294 
2295  return moflux;
2296  }
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
@ ustar
Definition: ERF_SLM.H:30
@ qstar
Definition: ERF_SLM.H:32
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
const amrex::Real eps
Definition: ERF_MOSTStress.H:2530

◆ 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.
2321  {
2322  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2323  amrex::Real theta = cons_arr(i,j,k,RhoTheta_comp) / rho;
2324 
2325  amrex::Real velx, vely;
2326  if (dir == 0) {
2327  // X-face: y/z velocity, velx = vely, vely = velz here
2328  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2329  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2330  } else if (dir == 1) {
2331  // Y-face: x/z velocity, vely = velz here
2332  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2333  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2334  } else {
2335  // Z face: x/y velocity
2336  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2337  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2338  }
2339 
2340  amrex::Real theta_mean = tm_arr(i,j,k);
2341  amrex::Real ustar = u_star_arr(i,j,k);
2342  amrex::Real tstar = t_star_arr(i,j,k);
2343  amrex::Real theta_surf = t_surf_arr(i,j,k);
2344  amrex::Real wsp_mean = umm_arr(i,j,k);
2345 
2346  if (dir == 2 && !is_low) {
2347  // flip theta and surf for hi-z face
2348  theta_mean = theta_surf;
2349  theta_surf = tm_arr(i, j, k);
2350  }
2351 
2352  wsp_mean = std::max(wsp_mean, WSMIN);
2353 
2354  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2355  amrex::Real num1 = wsp * (theta_mean-theta_surf);
2356  amrex::Real num2 = wsp_mean * (theta-tm_arr(i,j,k));
2357 
2358  // NOTE: this is rho*<T'w'> = -K dTdz
2359  amrex::Real moflux = (std::abs(tstar) > eps) ?
2360  -rho*tstar*ustar*(num1+num2)/((theta_mean-theta_surf)*wsp_mean) : zero;
2361 
2362  return moflux;
2363  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
@ tstar
Definition: ERF_SLM.H:31
@ 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.
2388  {
2389  // The caller supplies indices on the stress face. On a high wall the
2390  // normal index is one past the adjacent cell, so use the interior cell
2391  // for all input fields while retaining the stress index tangentially.
2392  const int ic = (!is_low && dir == 0) ? i - 1 : i;
2393  const int jc = (!is_low && dir == 1) ? j - 1 : j;
2394  const int kc = (!is_low && dir != 0 && dir != 1) ? k - 1 : k;
2395 
2396  amrex::Real velx, vely, rho, umean, ustar, wsp_mean;
2397  if (dir == 0) {
2398  // X wall: V-momentum flux at tau21. V is already y-nodal;
2399  // interpolate W and the cell-centered fields to that y node.
2400  velx = vely_arr(ic,j,kc);
2401  vely = fourth * ( velz_arr(ic,j-1,kc ) + velz_arr(ic,j,kc )
2402  + velz_arr(ic,j-1,kc+1) + velz_arr(ic,j,kc+1) );
2403  rho = myhalf * (cons_arr(ic,j-1,kc,Rho_comp) + cons_arr(ic,j,kc,Rho_comp));
2404  umean = vm_arr(ic,j,kc);
2405  ustar = myhalf * (u_star_arr(ic,j-1,kc) + u_star_arr(ic,j,kc));
2406  wsp_mean = myhalf * (umm_arr(ic,j-1,kc) + umm_arr(ic,j,kc));
2407  } else if (dir == 1) {
2408  // Y wall: U-momentum flux at tau12. U is already x-nodal;
2409  // interpolate W and the cell-centered fields to that x node.
2410  velx = velx_arr(i,jc,kc);
2411  vely = fourth * ( velz_arr(i-1,jc,kc ) + velz_arr(i,jc,kc )
2412  + velz_arr(i-1,jc,kc+1) + velz_arr(i,jc,kc+1) );
2413  rho = myhalf * (cons_arr(i-1,jc,kc,Rho_comp) + cons_arr(i,jc,kc,Rho_comp));
2414  umean = um_arr(i,jc,kc);
2415  ustar = myhalf * (u_star_arr(i-1,jc,kc) + u_star_arr(i,jc,kc));
2416  wsp_mean = myhalf * (umm_arr(i-1,jc,kc) + umm_arr(i,jc,kc));
2417  } else {
2418  // Z wall: U-momentum flux at tau13.
2419  velx = velx_arr(i,j,kc);
2420  vely = fourth * ( vely_arr(i-1,j ,kc) + vely_arr(i,j ,kc)
2421  + vely_arr(i-1,j+1,kc) + vely_arr(i,j+1,kc) );
2422  rho = myhalf * (cons_arr(i-1,j,kc,Rho_comp) + cons_arr(i,j,kc,Rho_comp));
2423  umean = um_arr(i,j,kc);
2424  ustar = myhalf * (u_star_arr(i-1,j,kc) + u_star_arr(i,j,kc));
2425  wsp_mean = myhalf * (umm_arr(i-1,j,kc) + umm_arr(i,j,kc));
2426  }
2427  wsp_mean = std::max(wsp_mean, WSMIN);
2428 
2429  // Note: The surface mean shear stress is decomposed into tau_xz by
2430  // multiplying the modeled shear stress (rho*ustar^2) with
2431  // a factor of umean/wsp_mean for directionality; this factor
2432  // modifies the denominator from what is in Moeng amrex::Real(1984.)
2433  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2434  amrex::Real num1 = wsp * umean;
2435  amrex::Real num2 = wsp_mean * (velx-umean);
2436 
2437  // NOTE: this is rho*<u'w'> = -K dudz
2438  amrex::Real stressx = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
2439  stressx = (is_low) ? stressx : -stressx;
2440 
2441  return stressx;
2442  }
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.
2467  {
2468  // See compute_u_flux: stress indices on high walls must be mapped back
2469  // to the adjacent cell before reading cell-centered or tangential data.
2470  const int ic = (!is_low && dir == 0) ? i - 1 : i;
2471  const int jc = (!is_low && dir == 1) ? j - 1 : j;
2472  const int kc = (!is_low && dir != 0 && dir != 1) ? k - 1 : k;
2473 
2474  amrex::Real velx, vely, rho, vmean, ustar, wsp_mean;
2475  if (dir == 0) {
2476  // X wall: W-momentum flux at tau31. W is already z-nodal;
2477  // interpolate V and the cell-centered fields to that z node.
2478  const int klo = amrex::max(k - 1, m_zlo);
2479  const int khi = amrex::min(k, m_zhi);
2480  velx = fourth * ( vely_arr(ic,j ,klo) + vely_arr(ic,j+1,klo)
2481  + vely_arr(ic,j ,khi) + vely_arr(ic,j+1,khi) );
2482  vely = velz_arr(ic,j,k);
2483  rho = myhalf * (cons_arr(ic,j,klo,Rho_comp) + cons_arr(ic,j,khi,Rho_comp));
2484  vmean = wm_arr(ic,j,k);
2485  ustar = myhalf * (u_star_arr(ic,j,klo) + u_star_arr(ic,j,khi));
2486  wsp_mean = myhalf * (umm_arr(ic,j,klo) + umm_arr(ic,j,khi));
2487  } else if (dir == 1) {
2488  // Y wall: W-momentum flux at tau32. W is already z-nodal;
2489  // interpolate U and the cell-centered fields to that z node.
2490  const int klo = amrex::max(k - 1, m_zlo);
2491  const int khi = amrex::min(k, m_zhi);
2492  velx = fourth * ( velx_arr(i ,jc,klo) + velx_arr(i+1,jc,klo)
2493  + velx_arr(i ,jc,khi) + velx_arr(i+1,jc,khi) );
2494  vely = velz_arr(i,jc,k);
2495  rho = myhalf * (cons_arr(i,jc,klo,Rho_comp) + cons_arr(i,jc,khi,Rho_comp));
2496  vmean = wm_arr(i,jc,k);
2497  ustar = myhalf * (u_star_arr(i,jc,klo) + u_star_arr(i,jc,khi));
2498  wsp_mean = myhalf * (umm_arr(i,jc,klo) + umm_arr(i,jc,khi));
2499  } else {
2500  // Z wall: V-momentum flux at tau23.
2501  velx = fourth * ( velx_arr(i ,j-1,kc) + velx_arr(i+1,j-1,kc)
2502  + velx_arr(i ,j ,kc) + velx_arr(i+1,j ,kc) );
2503  vely = vely_arr(i,j,kc);
2504  rho = myhalf * (cons_arr(i,j-1,kc,Rho_comp) + cons_arr(i,j,kc,Rho_comp));
2505  vmean = vm_arr(i,j,kc);
2506  ustar = myhalf * (u_star_arr(i,j-1,kc) + u_star_arr(i,j,kc));
2507  wsp_mean = myhalf * (umm_arr(i,j-1,kc) + umm_arr(i,j,kc));
2508  }
2509  wsp_mean = std::max(wsp_mean, WSMIN);
2510 
2511  // Note: The surface mean shear stress is decomposed into tau_yz by
2512  // multiplying the modeled shear stress (rho*ustar^2) with
2513  // a factor of vmean/wsp_mean for directionality; this factor
2514  // modifies the denominator from what is in Moeng amrex::Real(1984.)
2515  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2516  amrex::Real num1 = wsp * vmean;
2517  amrex::Real num2 = wsp_mean * (vely-vmean);
2518 
2519  // NOTE: this is rho*<v'w'> = -K dvdz
2520  amrex::Real stressy = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
2521  stressy = (is_low) ? stressy : -stressy;
2522 
2523  return stressy;
2524  }
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

amrex::Real moeng_flux::WSMIN = most_min_wind_speed
private

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