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 = amrex::Real(0.1)
 
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.

2099  {
2100  WSMIN = wsmin;
2101  is_low = face_is_low;
2102  m_zlo = zlo;
2103  m_zhi = zhi;
2104  }
int m_zhi
Definition: ERF_MOSTStress.H:2408
int m_zlo
Definition: ERF_MOSTStress.H:2407
amrex::Real WSMIN
Definition: ERF_MOSTStress.H:2406
bool is_low
Definition: ERF_MOSTStress.H:2405

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.
2129  {
2130  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2131  amrex::Real qv = cons_arr(i,j,k,RhoQ1_comp) / rho;
2132 
2133  amrex::Real velx, vely;
2134  if (dir == 0) {
2135  // X-face: y/z velocity, velx = vely, vely = velz here
2136  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2137  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2138  } else if (dir == 1) {
2139  // Y-face: x/z velocity, vely = velz here
2140  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2141  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2142  } else {
2143  // Z face: x/y velocity
2144  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2145  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2146  }
2147 
2148  amrex::Real qv_mean = qvm_arr(i,j,k);
2149  amrex::Real ustar = u_star_arr(i,j,k);
2150  amrex::Real qstar = q_star_arr(i,j,k);
2151  amrex::Real qv_surf = q_surf_arr(i,j,k);
2152  amrex::Real wsp_mean = umm_arr(i,j,k);
2153  wsp_mean = std::max(wsp_mean, WSMIN);
2154  if (dir == 2 && !is_low) {
2155  // flip qv_mean and qv_surf for hi-z face
2156  qv_mean = qv_surf;
2157  qv_surf = qvm_arr(i, j, k);
2158  }
2159 
2160  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2161  amrex::Real num1 = wsp * (qv_mean-qv_surf);
2162  amrex::Real num2 = wsp_mean * (qv-qvm_arr(i,j,k));
2163 
2164  // NOTE: this is rho*<Qv'w'> = -K dQvdz
2165  amrex::Real moflux = (std::abs(qstar) > eps) ?
2166  -rho*qstar*ustar*(num1+num2)/((qv_mean-qv_surf)*wsp_mean) : zero;
2167 
2168  return moflux;
2169  }
#define Rho_comp
Definition: ERF_IndexDefines.H:39
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:34
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
const amrex::Real eps
Definition: ERF_MOSTStress.H:2403

◆ 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.
2194  {
2195  amrex::Real rho = cons_arr(i,j,k,Rho_comp);
2196  amrex::Real theta = cons_arr(i,j,k,RhoTheta_comp) / rho;
2197 
2198  amrex::Real velx, vely;
2199  if (dir == 0) {
2200  // X-face: y/z velocity, velx = vely, vely = velz here
2201  velx = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2202  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2203  } else if (dir == 1) {
2204  // Y-face: x/z velocity, vely = velz here
2205  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2206  vely = myhalf * ( velz_arr(i,j,k) + velz_arr(i ,j ,k+1) );
2207  } else {
2208  // Z face: x/y velocity
2209  velx = myhalf * ( velx_arr(i,j,k) + velx_arr(i+1,j ,k) );
2210  vely = myhalf * ( vely_arr(i,j,k) + vely_arr(i ,j+1,k) );
2211  }
2212 
2213  amrex::Real theta_mean = tm_arr(i,j,k);
2214  amrex::Real ustar = u_star_arr(i,j,k);
2215  amrex::Real tstar = t_star_arr(i,j,k);
2216  amrex::Real theta_surf = t_surf_arr(i,j,k);
2217  amrex::Real wsp_mean = umm_arr(i,j,k);
2218 
2219  if (dir == 2 && !is_low) {
2220  // flip theta and surf for hi-z face
2221  theta_mean = theta_surf;
2222  theta_surf = tm_arr(i, j, k);
2223  }
2224 
2225  wsp_mean = std::max(wsp_mean, WSMIN);
2226 
2227  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2228  amrex::Real num1 = wsp * (theta_mean-theta_surf);
2229  amrex::Real num2 = wsp_mean * (theta-tm_arr(i,j,k));
2230 
2231  // NOTE: this is rho*<T'w'> = -K dTdz
2232  amrex::Real moflux = (std::abs(tstar) > eps) ?
2233  -rho*tstar*ustar*(num1+num2)/((theta_mean-theta_surf)*wsp_mean) : zero;
2234 
2235  return moflux;
2236  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
@ theta
Definition: ERF_SLM.H:19

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

◆ 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.
2340  {
2341  // See compute_u_flux: stress indices on high walls must be mapped back
2342  // to the adjacent cell before reading cell-centered or tangential data.
2343  const int ic = (!is_low && dir == 0) ? i - 1 : i;
2344  const int jc = (!is_low && dir == 1) ? j - 1 : j;
2345  const int kc = (!is_low && dir != 0 && dir != 1) ? k - 1 : k;
2346 
2347  amrex::Real velx, vely, rho, vmean, ustar, wsp_mean;
2348  if (dir == 0) {
2349  // X wall: W-momentum flux at tau31. W is already z-nodal;
2350  // interpolate V and the cell-centered fields to that z node.
2351  const int klo = amrex::max(k - 1, m_zlo);
2352  const int khi = amrex::min(k, m_zhi);
2353  velx = fourth * ( vely_arr(ic,j ,klo) + vely_arr(ic,j+1,klo)
2354  + vely_arr(ic,j ,khi) + vely_arr(ic,j+1,khi) );
2355  vely = velz_arr(ic,j,k);
2356  rho = myhalf * (cons_arr(ic,j,klo,Rho_comp) + cons_arr(ic,j,khi,Rho_comp));
2357  vmean = wm_arr(ic,j,k);
2358  ustar = myhalf * (u_star_arr(ic,j,klo) + u_star_arr(ic,j,khi));
2359  wsp_mean = myhalf * (umm_arr(ic,j,klo) + umm_arr(ic,j,khi));
2360  } else if (dir == 1) {
2361  // Y wall: W-momentum flux at tau32. W is already z-nodal;
2362  // interpolate U and the cell-centered fields to that z node.
2363  const int klo = amrex::max(k - 1, m_zlo);
2364  const int khi = amrex::min(k, m_zhi);
2365  velx = fourth * ( velx_arr(i ,jc,klo) + velx_arr(i+1,jc,klo)
2366  + velx_arr(i ,jc,khi) + velx_arr(i+1,jc,khi) );
2367  vely = velz_arr(i,jc,k);
2368  rho = myhalf * (cons_arr(i,jc,klo,Rho_comp) + cons_arr(i,jc,khi,Rho_comp));
2369  vmean = wm_arr(i,jc,k);
2370  ustar = myhalf * (u_star_arr(i,jc,klo) + u_star_arr(i,jc,khi));
2371  wsp_mean = myhalf * (umm_arr(i,jc,klo) + umm_arr(i,jc,khi));
2372  } else {
2373  // Z wall: V-momentum flux at tau23.
2374  velx = fourth * ( velx_arr(i ,j-1,kc) + velx_arr(i+1,j-1,kc)
2375  + velx_arr(i ,j ,kc) + velx_arr(i+1,j ,kc) );
2376  vely = vely_arr(i,j,kc);
2377  rho = myhalf * (cons_arr(i,j-1,kc,Rho_comp) + cons_arr(i,j,kc,Rho_comp));
2378  vmean = vm_arr(i,j,kc);
2379  ustar = myhalf * (u_star_arr(i,j-1,kc) + u_star_arr(i,j,kc));
2380  wsp_mean = myhalf * (umm_arr(i,j-1,kc) + umm_arr(i,j,kc));
2381  }
2382  wsp_mean = std::max(wsp_mean, WSMIN);
2383 
2384  // Note: The surface mean shear stress is decomposed into tau_yz by
2385  // multiplying the modeled shear stress (rho*ustar^2) with
2386  // a factor of vmean/wsp_mean for directionality; this factor
2387  // modifies the denominator from what is in Moeng amrex::Real(1984.)
2388  amrex::Real wsp = std::sqrt(velx*velx+vely*vely);
2389  amrex::Real num1 = wsp * vmean;
2390  amrex::Real num2 = wsp_mean * (vely-vmean);
2391 
2392  // NOTE: this is rho*<v'w'> = -K dvdz
2393  amrex::Real stressy = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
2394  stressy = (is_low) ? stressy : -stressy;
2395 
2396  return stressy;
2397  }
const int klo
Definition: ERF_InitCustomPert_ABL.H:75
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21

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: