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 (int l_zlo)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_q_flux (const int &i, const int &j, const int &k, const int &n, const int &icomp, const amrex::Real &dz, const amrex::Real &dz1, const bool &exp_most, const amrex::Array4< const amrex::Real > &eta_arr, const amrex::Array4< const amrex::Real > &cons_arr, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< amrex::Real > &dest_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_t_flux (const int &i, const int &j, const int &k, const int &n, const int &icomp, const amrex::Real &dz, const amrex::Real &dz1, const bool &exp_most, const amrex::Array4< const amrex::Real > &eta_arr, 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 > &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::Array4< amrex::Real > &dest_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_u_flux (const int &i, const int &j, const int &k, const int &icomp, const amrex::Real &dz, const amrex::Real &dz1, const bool &exp_most, const amrex::Array4< const amrex::Real > &eta_arr, 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 > &umm_arr, const amrex::Array4< const amrex::Real > &um_arr, const amrex::Array4< const amrex::Real > &u_star_arr, const amrex::Array4< amrex::Real > &dest_arr) const
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real compute_v_flux (const int &i, const int &j, const int &k, const int &icomp, const amrex::Real &dz, const amrex::Real &dz1, const bool &exp_most, const amrex::Array4< const amrex::Real > &eta_arr, 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 > &umm_arr, const amrex::Array4< const amrex::Real > &vm_arr, const amrex::Array4< const amrex::Real > &u_star_arr, const amrex::Array4< amrex::Real > &dest_arr) const
 

Private Attributes

int zlo
 
const amrex::Real eps = 1e-15
 
const amrex::Real eta_eps = 1e-8
 
const amrex::Real WSMIN = 0.1
 

Detailed Description

Moeng flux formulation

Constructor & Destructor Documentation

◆ moeng_flux()

moeng_flux::moeng_flux ( int  l_zlo)
inline
1261  : zlo(l_zlo) {}
int zlo
Definition: ERF_MOSTStress.H:1556

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 &  n,
const int &  icomp,
const amrex::Real &  dz,
const amrex::Real &  dz1,
const bool &  exp_most,
const amrex::Array4< const amrex::Real > &  eta_arr,
const amrex::Array4< const amrex::Real > &  cons_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1285  {
1286  amrex::Real rho, eta;
1287 
1288  int ic, jc;
1289  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1290  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1291  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1292  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1293 
1294  rho = cons_arr(ic,jc,zlo,Rho_comp);
1295 
1296  // TODO: Integrate MOST with moisture and MOENG FLUX type
1297  amrex::Real deltaz = dz * (zlo - k);
1298 
1299  // NOTE: this is rho*<q'w'> = -K dqdz
1300  amrex::Real moflux = 0.0;
1301 
1302  if (exp_most) {
1303  // surface gradient equal to gradient at first zface
1304  amrex::Real rqvgrad = (cons_arr(ic,jc,zlo+1,RhoQ1_comp) - cons_arr(ic,jc,zlo ,RhoQ1_comp)) / (0.5*(dz+dz1));
1305  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoQ1_comp) - rqvgrad * deltaz;
1306  } else {
1307  int ie, je;
1308  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1309  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1310  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1311  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1312  eta = eta_arr(ie,je,zlo,EddyDiff::Q_v); // == rho * alpha [kg/m^3 * m^2/s]
1313  eta = amrex::max(eta,eta_eps);
1314  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1315  }
1316 
1317  return moflux;
1318  }
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
@ Q_v
Definition: ERF_IndexDefines.H:160
@ rho
Definition: ERF_Kessler.H:30
const amrex::Real eta_eps
Definition: ERF_MOSTStress.H:1558

◆ 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 &  n,
const int &  icomp,
const amrex::Real &  dz,
const amrex::Real &  dz1,
const bool &  exp_most,
const amrex::Array4< const amrex::Real > &  eta_arr,
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 > &  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::Array4< amrex::Real > &  dest_arr 
) const
inline
1341  {
1342  amrex::Real velx, vely, rho, theta, eta;
1343  int ix, jx, iy, jy, ic, jc;
1344 
1345  ix = i < lbound(velx_arr).x ? lbound(velx_arr).x : i;
1346  jx = j < lbound(velx_arr).y ? lbound(velx_arr).y : j;
1347  ix = ix > ubound(velx_arr).x-1 ? ubound(velx_arr).x-1 : ix;
1348  jx = jx > ubound(velx_arr).y ? ubound(velx_arr).y : jx;
1349 
1350  iy = i < lbound(vely_arr).x ? lbound(vely_arr).x : i;
1351  jy = j < lbound(vely_arr).y ? lbound(vely_arr).y : j;
1352  iy = iy > ubound(vely_arr).x ? ubound(vely_arr).x : iy;
1353  jy = jy > ubound(vely_arr).y-1 ? ubound(vely_arr).y-1 : jy;
1354 
1355  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1356  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1357  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1358  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1359 
1360  velx = 0.5 *( velx_arr(ix,jx,zlo) + velx_arr(ix+1,jx ,zlo) );
1361  vely = 0.5 *( vely_arr(iy,jy,zlo) + vely_arr(iy ,jy+1,zlo) );
1362  rho = cons_arr(ic,jc,zlo,Rho_comp);
1363  theta = cons_arr(ic,jc,zlo,RhoTheta_comp) / rho;
1364 
1365  amrex::Real theta_mean = tm_arr(ic,jc,zlo);
1366  amrex::Real wsp_mean = umm_arr(ic,jc,zlo);
1367  amrex::Real ustar = u_star_arr(ic,jc,zlo);
1368  amrex::Real tstar = t_star_arr(ic,jc,zlo);
1369  amrex::Real theta_surf = t_surf_arr(ic,jc,zlo);
1370 
1371  amrex::Real wsp = sqrt(velx*velx+vely*vely);
1372  amrex::Real num1 = wsp * (theta_mean-theta_surf);
1373  amrex::Real num2 = wsp_mean * (theta-theta_mean);
1374  amrex::Real deltaz = dz * (zlo - k);
1375 
1376  wsp_mean = std::max(wsp_mean, WSMIN);
1377 
1378  // NOTE: this is rho*<T'w'> = -K dTdz
1379  amrex::Real moflux = (std::abs(tstar) > eps) ?
1380  -rho*tstar*ustar*(num1+num2)/((theta_mean-theta_surf)*wsp_mean) : 0.0;
1381 
1382  if (exp_most) {
1383  // surface gradient equal to gradient at first zface
1384  amrex::Real rthetagrad = (cons_arr(ic,jc,zlo+1,RhoTheta_comp) - cons_arr(ic,jc,zlo,RhoTheta_comp)) / (0.5*(dz+dz1));
1385  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoTheta_comp) - rthetagrad * deltaz;
1386  } else {
1387  int ie, je;
1388  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1389  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1390  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1391  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1392  eta = eta_arr(ie,je,zlo,EddyDiff::Theta_v); // == rho * alpha [kg/m^3 * m^2/s]
1393  eta = amrex::max(eta,eta_eps);
1394  // Note: Kh = eta/rho
1395  // hfx = -Kh dT/dz ==> +ve hfx corresponds to heating from the surface
1396  // Extrapolate from klo to ghost cell a distance of -deltaz; negative signs cancel
1397  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1398  }
1399 
1400  return moflux;
1401  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
@ Theta_v
Definition: ERF_IndexDefines.H:157
@ theta
Definition: ERF_MM5.H:20
const amrex::Real eps
Definition: ERF_MOSTStress.H:1557
const amrex::Real WSMIN
Definition: ERF_MOSTStress.H:1559

◆ 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 &  icomp,
const amrex::Real &  dz,
const amrex::Real &  dz1,
const bool &  exp_most,
const amrex::Array4< const amrex::Real > &  eta_arr,
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 > &  umm_arr,
const amrex::Array4< const amrex::Real > &  um_arr,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1421  {
1422  amrex::Real velx, vely, rho, eta;
1423  int jy, ic, jc;
1424 
1425  int iylo = i <= lbound(vely_arr).x ? lbound(vely_arr).x : i-1;
1426  int iyhi = i > ubound(vely_arr).x ? ubound(vely_arr).x : i;
1427 
1428  jy = j < lbound(vely_arr).y ? lbound(vely_arr).y : j;
1429  jy = jy > ubound(vely_arr).y-1 ? ubound(vely_arr).y-1 : jy;
1430 
1431  ic = i < lbound(cons_arr).x+1 ? lbound(cons_arr).x+1 : i;
1432  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1433  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1434  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1435 
1436  velx = velx_arr(i,j,zlo);
1437  vely = 0.25*( vely_arr(iyhi,jy,zlo)+vely_arr(iyhi,jy+1,zlo)
1438  + vely_arr(iylo,jy,zlo)+vely_arr(iylo,jy+1,zlo) );
1439  rho = 0.5 *( cons_arr(ic-1,jc,zlo,Rho_comp)
1440  + cons_arr(ic ,jc,zlo,Rho_comp) );
1441 
1442  amrex::Real umean = um_arr(i,j,zlo);
1443  amrex::Real wsp_mean = 0.5 * ( umm_arr(ic-1,jc,zlo) + umm_arr(ic,jc,zlo) );
1444  amrex::Real ustar = 0.5 * ( u_star_arr(ic-1,jc,zlo) + u_star_arr(ic,jc,zlo) );
1445 
1446  // Note: The surface mean shear stress is decomposed into tau_xz by
1447  // multiplying the modeled shear stress (rho*ustar^2) with
1448  // a factor of umean/wsp_mean for directionality; this factor
1449  // modifies the denominator from what is in Moeng 1984.
1450  amrex::Real wsp = sqrt(velx*velx+vely*vely);
1451  amrex::Real num1 = wsp * umean;
1452  amrex::Real num2 = wsp_mean * (velx-umean);
1453  amrex::Real deltaz = dz * (zlo - k);
1454 
1455  wsp_mean = std::max(wsp_mean, WSMIN);
1456 
1457  // NOTE: this is rho*<u'w'> = -K dudz
1458  amrex::Real stressx = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
1459 
1460  if (exp_most) {
1461  // surface gradient equal to gradient at first zface
1462  amrex::Real ugrad = (velx_arr(i,j,zlo+1) - velx) / (0.5*(dz+dz1));
1463  dest_arr(i,j,k,icomp) = velx - ugrad * deltaz;
1464  } else {
1465  int ie, je;
1466  ie = i < lbound(eta_arr).x+1 ? lbound(eta_arr).x+1 : i;
1467  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1468  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1469  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1470  eta = 0.5 *( eta_arr(ie-1,je,zlo,EddyDiff::Mom_v)
1471  + eta_arr(ie ,je,zlo,EddyDiff::Mom_v) );
1472  eta = amrex::max(eta,eta_eps);
1473  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressx/eta*deltaz;
1474  }
1475 
1476  return stressx;
1477  }
@ Mom_v
Definition: ERF_IndexDefines.H:156

◆ 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 &  icomp,
const amrex::Real &  dz,
const amrex::Real &  dz1,
const bool &  exp_most,
const amrex::Array4< const amrex::Real > &  eta_arr,
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 > &  umm_arr,
const amrex::Array4< const amrex::Real > &  vm_arr,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1497  {
1498  amrex::Real velx, vely, rho, eta;
1499  int ix, ic, jc;
1500 
1501  ix = i < lbound(velx_arr).x ? lbound(velx_arr).x : i;
1502  ix = ix > ubound(velx_arr).x ? ubound(velx_arr).x : ix;
1503 
1504  int jxlo = j <= lbound(velx_arr).y ? lbound(velx_arr).y : j-1;
1505  int jxhi = j > ubound(velx_arr).y ? ubound(velx_arr).y : j;
1506 
1507  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1508  jc = j < lbound(cons_arr).y+1 ? lbound(cons_arr).y+1 : j;
1509  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1510  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1511 
1512  velx = 0.25*( velx_arr(ix,jxhi,zlo)+velx_arr(ix+1,jxhi,zlo)
1513  + velx_arr(ix,jxlo,zlo)+velx_arr(ix+1,jxlo,zlo) );
1514  vely = vely_arr(i,j,zlo);
1515  rho = 0.5*( cons_arr(ic,jc-1,zlo,Rho_comp)
1516  + cons_arr(ic,jc ,zlo,Rho_comp) );
1517 
1518  amrex::Real vmean = vm_arr(i,j,zlo);
1519  amrex::Real wsp_mean = 0.5 * ( umm_arr(ic,jc-1,zlo) + umm_arr(ic,jc,zlo) );
1520  amrex::Real ustar = 0.5 * ( u_star_arr(ic,jc-1,zlo) + u_star_arr(ic,jc,zlo) );
1521 
1522  // Note: The surface mean shear stress is decomposed into tau_yz by
1523  // multiplying the modeled shear stress (rho*ustar^2) with
1524  // a factor of vmean/wsp_mean for directionality; this factor
1525  // modifies the denominator from what is in Moeng 1984.
1526  amrex::Real wsp = sqrt(velx*velx+vely*vely);
1527  amrex::Real num1 = wsp * vmean;
1528  amrex::Real num2 = wsp_mean * (vely-vmean);
1529  amrex::Real deltaz = dz * (zlo - k);
1530 
1531  wsp_mean = std::max(wsp_mean, WSMIN);
1532 
1533  // NOTE: this is rho*<v'w'> = -K dvdz
1534  amrex::Real stressy = -rho*ustar*ustar * (num1+num2)/(wsp_mean*wsp_mean);
1535 
1536  if (exp_most) {
1537  // surface gradient equal to gradient at first zface
1538  amrex::Real vgrad = (vely_arr(i,j,zlo+1) - vely) / (0.5*(dz+dz1));
1539  dest_arr(i,j,k,icomp) = vely - vgrad * deltaz;
1540  } else {
1541  int ie, je;
1542  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1543  je = j < lbound(eta_arr).y+1 ? lbound(eta_arr).y+1 : j;
1544  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1545  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1546  eta = 0.5*( eta_arr(ie,je-1,zlo,EddyDiff::Mom_v)
1547  + eta_arr(ie,je ,zlo,EddyDiff::Mom_v) );
1548  eta = amrex::max(eta,eta_eps);
1549  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressy/eta*deltaz;
1550  }
1551 
1552  return stressy;
1553  }

Member Data Documentation

◆ eps

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

Referenced by compute_t_flux().

◆ eta_eps

const amrex::Real moeng_flux::eta_eps = 1e-8
private

◆ WSMIN

const amrex::Real moeng_flux::WSMIN = 0.1
private

◆ zlo

int moeng_flux::zlo
private

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