ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
donelan_flux Struct Reference

#include <ERF_MOSTStress.H>

Collaboration diagram for donelan_flux:

Public Member Functions

 donelan_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 > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &umm_arr, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, 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 > &, const amrex::Array4< const amrex::Real > &, 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 > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< amrex::Real > &dest_arr) const
 

Private Attributes

int zlo
 
const amrex::Real eta_eps = 1e-8
 

Detailed Description

Donelan flux formulation

Constructor & Destructor Documentation

◆ donelan_flux()

donelan_flux::donelan_flux ( int  l_zlo)
inline
1570  : zlo(l_zlo) {}
int zlo
Definition: ERF_MOSTStress.H:1840

Member Function Documentation

◆ compute_q_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real donelan_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
1594  {
1595  amrex::Real rho, eta;
1596 
1597  int ic, jc;
1598  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1599  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1600  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1601  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1602 
1603  rho = cons_arr(ic,jc,zlo,Rho_comp);
1604 
1605  // TODO: Integrate MOST with moisture and DONELAN FLUX type
1606  amrex::Real deltaz = dz * (zlo - k);
1607 
1608  // NOTE: this is rho*<q'w'> = -K dqdz
1609  amrex::Real moflux = 0.0;
1610 
1611  if (exp_most) {
1612  // surface gradient equal to gradient at first zface
1613  amrex::Real rqvgrad = (cons_arr(ic,jc,zlo+1,RhoQ1_comp) - cons_arr(ic,jc,zlo ,RhoQ1_comp)) / (0.5*(dz+dz1));
1614  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoQ1_comp) - rqvgrad * deltaz;
1615  } else {
1616  int ie, je;
1617  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1618  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1619  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1620  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1621  eta = eta_arr(ie,je,zlo,EddyDiff::Q_v); // == rho * alpha [kg/m^3 * m^2/s]
1622  eta = amrex::max(eta,eta_eps);
1623  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1624  }
1625 
1626  return moflux;
1627  }
#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:1841

◆ compute_t_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real donelan_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  umm_arr,
const amrex::Array4< const amrex::Real > &  tm_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  t_surf_arr,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1650  {
1651  amrex::Real rho, eta;
1652 
1653  int ic, jc;
1654  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1655  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1656  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1657  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1658 
1659  rho = cons_arr(ic,jc,zlo,Rho_comp);
1660 
1661  amrex::Real Ch = 0.0012;
1662  amrex::Real wsp_mean = umm_arr(ic,jc,zlo);
1663  amrex::Real theta_surf = t_surf_arr(ic,jc,zlo);
1664  amrex::Real theta_mean = tm_arr(ic,jc,zlo);
1665  amrex::Real deltaz = dz * (zlo - k);
1666 
1667  // NOTE: this is rho*<T'w'> = -K dTdz
1668  amrex::Real moflux = -rho * Ch * wsp_mean * (theta_mean - theta_surf);
1669 
1670  if (exp_most) {
1671  // surface gradient equal to gradient at first zface
1672  amrex::Real rthetagrad = (cons_arr(ic,jc,zlo+1,RhoTheta_comp) - cons_arr(ic,jc,zlo,RhoTheta_comp)) / (0.5*(dz+dz1));
1673  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoTheta_comp) - rthetagrad * deltaz;
1674  } else {
1675  int ie, je;
1676  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1677  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1678  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1679  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1680  eta = eta_arr(ie,je,zlo,EddyDiff::Theta_v); // == rho * alpha [kg/m^3 * m^2/s]
1681  eta = amrex::max(eta,eta_eps);
1682  // Note: Kh = eta/rho
1683  // hfx = -Kh dT/dz ==> +ve hfx corresponds to heating from the surface
1684  // Extrapolate from klo to ghost cell a distance of -deltaz; negative signs cancel
1685  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1686  }
1687 
1688  return moflux;
1689  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
@ Theta_v
Definition: ERF_IndexDefines.H:168

◆ compute_u_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real donelan_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1709  {
1710  amrex::Real velx, vely, rho, eta;
1711  int jy, ic, jc;
1712 
1713  int iylo = i <= lbound(vely_arr).x ? lbound(vely_arr).x : i-1;
1714  int iyhi = i > ubound(vely_arr).x ? ubound(vely_arr).x : i;
1715 
1716  jy = j < lbound(vely_arr).y ? lbound(vely_arr).y : j;
1717  jy = jy > ubound(vely_arr).y-1 ? ubound(vely_arr).y-1 : jy;
1718 
1719  ic = i < lbound(cons_arr).x+1 ? lbound(cons_arr).x+1 : i;
1720  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1721  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1722  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1723 
1724  velx = velx_arr(i,j,zlo);
1725  vely = 0.25*( vely_arr(iyhi,jy,zlo)+vely_arr(iyhi,jy+1,zlo)
1726  + vely_arr(iylo,jy,zlo)+vely_arr(iylo,jy+1,zlo) );
1727  rho = 0.5 *( cons_arr(ic-1,jc,zlo,Rho_comp)
1728  + cons_arr(ic ,jc,zlo,Rho_comp) );
1729 
1730  amrex::Real Cd = 0.001;
1731  const amrex::Real c = 7e-5;
1732  amrex::Real wsp = sqrt(velx*velx+vely*vely);
1733  amrex::Real wsp_mean = 0.5 * ( umm_arr(ic-1,jc,zlo) + umm_arr(ic,jc,zlo) );
1734  if (wsp_mean <= 5.0) {
1735  Cd = 0.001;
1736  } else if (wsp_mean < 25.0 && wsp_mean > 5.0) {
1737  Cd = 0.001 + c * (wsp_mean - 5.0);
1738  } else {
1739  Cd = 0.0024;
1740  }
1741  amrex::Real deltaz = dz * (zlo - k);
1742 
1743  // NOTE: this is rho*<u'w'> = -K dudz
1744  amrex::Real stressx = -rho * Cd * velx * wsp;
1745 
1746  if (exp_most) {
1747  // surface gradient equal to gradient at first zface
1748  amrex::Real ugrad = (velx_arr(i,j,zlo+1) - velx) / (0.5*(dz+dz1));
1749  dest_arr(i,j,k,icomp) = velx - ugrad * deltaz;
1750  } else {
1751  int ie, je;
1752  ie = i < lbound(eta_arr).x+1 ? lbound(eta_arr).x+1 : i;
1753  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1754  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1755  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1756  eta = 0.5 *( eta_arr(ie-1,je,zlo,EddyDiff::Mom_v)
1757  + eta_arr(ie ,je,zlo,EddyDiff::Mom_v) );
1758  eta = amrex::max(eta,eta_eps);
1759  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressx/eta*deltaz;
1760  }
1761 
1762  return stressx;
1763  }
@ Mom_v
Definition: ERF_IndexDefines.H:167

◆ compute_v_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real donelan_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1783  {
1784  amrex::Real velx, vely, rho, eta;
1785  int ix, ic, jc;
1786 
1787  ix = i < lbound(velx_arr).x ? lbound(velx_arr).x : i;
1788  ix = ix > ubound(velx_arr).x ? ubound(velx_arr).x : ix;
1789 
1790  int jxlo = j <= lbound(velx_arr).y ? lbound(velx_arr).y : j-1;
1791  int jxhi = j > ubound(velx_arr).y ? ubound(velx_arr).y : j;
1792 
1793  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1794  jc = j < lbound(cons_arr).y+1 ? lbound(cons_arr).y+1 : j;
1795  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1796  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1797 
1798  velx = 0.25*( velx_arr(ix,jxhi,zlo)+velx_arr(ix+1,jxhi,zlo)
1799  + velx_arr(ix,jxlo,zlo)+velx_arr(ix+1,jxlo,zlo) );
1800  vely = vely_arr(i,j,zlo);
1801  rho = 0.5*( cons_arr(ic,jc-1,zlo,Rho_comp)
1802  + cons_arr(ic,jc ,zlo,Rho_comp) );
1803 
1804  amrex::Real Cd = 0.001;
1805  const amrex::Real c = 7e-5;
1806  amrex::Real wsp = sqrt(velx*velx+vely*vely);
1807  amrex::Real wsp_mean = 0.5 * ( umm_arr(ic,jc-1,zlo) + umm_arr(ic,jc,zlo) );
1808  if (wsp_mean <= 5.0) {
1809  Cd = 0.001;
1810  } else if (wsp_mean < 25.0 && wsp_mean > 5.0) {
1811  Cd = 0.001 + c * (wsp_mean - 5.0);
1812  } else {
1813  Cd = 0.0024;
1814  }
1815  amrex::Real deltaz = dz * (zlo - k);
1816 
1817  // NOTE: this is rho*<v'w'> = -K dvdz
1818  amrex::Real stressy = -rho * Cd * vely * wsp;
1819 
1820  if (exp_most) {
1821  // surface gradient equal to gradient at first zface
1822  amrex::Real vgrad = (vely_arr(i,j,zlo+1) - vely) / (0.5*(dz+dz1));
1823  dest_arr(i,j,k,icomp) = vely - vgrad * deltaz;
1824  } else {
1825  int ie, je;
1826  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1827  je = j < lbound(eta_arr).y+1 ? lbound(eta_arr).y+1 : j;
1828  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1829  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1830  eta = 0.5*( eta_arr(ie,je-1,zlo,EddyDiff::Mom_v)
1831  + eta_arr(ie,je ,zlo,EddyDiff::Mom_v) );
1832  eta = amrex::max(eta,eta_eps);
1833  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressy/eta*deltaz;
1834  }
1835 
1836  return stressy;
1837  }

Member Data Documentation

◆ eta_eps

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

◆ zlo

int donelan_flux::zlo
private

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