ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
1262  : zlo(l_zlo) {}
int zlo
Definition: ERF_MOSTStress.H:1557

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

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

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

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

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: