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

#include <ERF_MOSTStress.H>

Collaboration diagram for custom_flux:

Public Member Functions

 custom_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 > &q_star_arr, 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 > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &t_star_arr, const amrex::Array4< const amrex::Real > &, 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 > &, const amrex::Array4< const amrex::Real > &, 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 > &, const amrex::Array4< const amrex::Real > &, 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
 

Detailed Description

Custom flux formulation

Constructor & Destructor Documentation

◆ custom_flux()

custom_flux::custom_flux ( int  l_zlo)
inline
1851  : zlo(l_zlo) {}
int zlo
Definition: ERF_MOSTStress.H:2097

Member Function Documentation

◆ compute_q_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real custom_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 > &  q_star_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1875  {
1876  amrex::Real rho, eta;
1877 
1878  int ic, jc;
1879  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1880  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1881  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1882  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1883 
1884  rho = cons_arr(ic,jc,zlo,Rho_comp);
1885 
1886  amrex::Real qstar = q_star_arr(ic,jc,zlo);
1887  amrex::Real deltaz = dz * (zlo - k);
1888 
1889  // NOTE: this is rho*<q'w'> = -K dqdz
1890  amrex::Real moflux = (std::abs(qstar) > eps) ? rho * qstar : 0.0;
1891 
1892  if (exp_most) {
1893  // surface gradient equal to gradient at first zface
1894  amrex::Real rqvgrad = ( cons_arr(ic,jc,zlo+1,RhoQ1_comp) - cons_arr(ic,jc,zlo ,RhoQ1_comp) ) / (0.5*(dz+dz1));
1895  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoQ1_comp) - rqvgrad * deltaz;
1896  } else {
1897  int ie, je;
1898  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1899  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1900  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1901  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1902  eta = eta_arr(ie,je,zlo,EddyDiff::Q_v); // == rho * alpha [kg/m^3 * m^2/s]
1903  eta = amrex::max(eta,eta_eps);
1904  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1905  }
1906 
1907  return moflux;
1908  }
#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:2099
const amrex::Real eps
Definition: ERF_MOSTStress.H:2098

◆ compute_t_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real custom_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  t_star_arr,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1931  {
1932  amrex::Real rho, eta;
1933 
1934  int ic, jc;
1935  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1936  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1937  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1938  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1939 
1940  rho = cons_arr(ic,jc,zlo,Rho_comp);
1941 
1942  amrex::Real tstar = t_star_arr(ic,jc,zlo);
1943  amrex::Real deltaz = dz * (zlo - k);
1944 
1945  // NOTE: this is rho*<T'w'> = -K dTdz
1946  amrex::Real moflux = (std::abs(tstar) > eps) ? rho * tstar : 0.0;
1947 
1948  if (exp_most) {
1949  // surface gradient equal to gradient at first zface
1950  amrex::Real rthetagrad = ( cons_arr(ic,jc,zlo+1,RhoTheta_comp) - cons_arr(ic,jc,zlo ,RhoTheta_comp) ) / (0.5*(dz+dz1));
1951  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoTheta_comp) - rthetagrad * deltaz;
1952  } else {
1953  int ie, je;
1954  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1955  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1956  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1957  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1958  eta = eta_arr(ie,je,zlo,EddyDiff::Theta_v); // == rho * alpha [kg/m^3 * m^2/s]
1959  eta = amrex::max(eta,eta_eps);
1960  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1961  }
1962 
1963  return moflux;
1964  }
#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 custom_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
1984  {
1985  amrex::Real velx, vely, rho, eta;
1986  int jy, ic, jc;
1987 
1988  int iylo = i <= lbound(vely_arr).x ? lbound(vely_arr).x : i-1;
1989  int iyhi = i > ubound(vely_arr).x ? ubound(vely_arr).x : i;
1990 
1991  jy = j < lbound(vely_arr).y ? lbound(vely_arr).y : j;
1992  jy = jy > ubound(vely_arr).y-1 ? ubound(vely_arr).y-1 : jy;
1993 
1994  ic = i < lbound(cons_arr).x+1 ? lbound(cons_arr).x+1 : i;
1995  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1996  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1997  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1998 
1999  velx = velx_arr(i,j,zlo);
2000  vely = 0.25*( vely_arr(iyhi,jy,zlo)+vely_arr(iyhi,jy+1,zlo)
2001  + vely_arr(iylo,jy,zlo)+vely_arr(iylo,jy+1,zlo) );
2002  rho = 0.5 *( cons_arr(ic-1,jc,zlo,Rho_comp)
2003  + cons_arr(ic ,jc,zlo,Rho_comp) );
2004 
2005  amrex::Real ustar = 0.5 * ( u_star_arr(ic-1,jc,zlo) + u_star_arr(ic,jc,zlo) );
2006  amrex::Real wsp = sqrt(velx*velx+vely*vely);
2007  amrex::Real deltaz = dz * (zlo - k);
2008 
2009  // NOTE: this is rho*<u'w'> = -K dudz
2010  amrex::Real stressx = -rho * ustar * ustar * velx / wsp;
2011 
2012  if (exp_most) {
2013  // surface gradient equal to gradient at first zface
2014  amrex::Real ugrad = (velx_arr(i,j,zlo+1) - velx) / (0.5*(dz+dz1));
2015  dest_arr(i,j,k,icomp) = velx - ugrad * deltaz;
2016  } else {
2017  int ie, je;
2018  ie = i < lbound(eta_arr).x+1 ? lbound(eta_arr).x+1 : i;
2019  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
2020  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
2021  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
2022  eta = 0.5 *( eta_arr(ie-1,je,zlo,EddyDiff::Mom_v)
2023  + eta_arr(ie ,je,zlo,EddyDiff::Mom_v) );
2024  eta = amrex::max(eta,eta_eps);
2025  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressx/eta*deltaz;
2026  }
2027 
2028  return stressx;
2029  }
@ Mom_v
Definition: ERF_IndexDefines.H:167

◆ compute_v_flux()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real custom_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 > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  u_star_arr,
const amrex::Array4< amrex::Real > &  dest_arr 
) const
inline
2049  {
2050  amrex::Real velx, vely, rho, eta;
2051  int ix, ic, jc;
2052 
2053  ix = i < lbound(velx_arr).x ? lbound(velx_arr).x : i;
2054  ix = ix > ubound(velx_arr).x ? ubound(velx_arr).x : ix;
2055 
2056  int jxlo = j <= lbound(velx_arr).y ? lbound(velx_arr).y : j-1;
2057  int jxhi = j > ubound(velx_arr).y ? ubound(velx_arr).y : j;
2058 
2059  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
2060  jc = j < lbound(cons_arr).y+1 ? lbound(cons_arr).y+1 : j;
2061  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
2062  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
2063 
2064  velx = 0.25*( velx_arr(ix,jxhi,zlo)+velx_arr(ix+1,jxhi,zlo)
2065  + velx_arr(ix,jxlo,zlo)+velx_arr(ix+1,jxlo,zlo) );
2066  vely = vely_arr(i,j,zlo);
2067  rho = 0.5*( cons_arr(ic,jc-1,zlo,Rho_comp)
2068  + cons_arr(ic,jc ,zlo,Rho_comp) );
2069 
2070  amrex::Real ustar = 0.5 * ( u_star_arr(ic,jc-1,zlo) + u_star_arr(ic,jc,zlo) );
2071  amrex::Real wsp = sqrt(velx*velx+vely*vely);
2072  amrex::Real deltaz = dz * (zlo - k);
2073 
2074  // NOTE: this is rho*<v'w'> = -K dvdz
2075  amrex::Real stressy = -rho * ustar * ustar * vely / wsp;
2076 
2077  if (exp_most) {
2078  // surface gradient equal to gradient at first zface
2079  amrex::Real vgrad = (vely_arr(i,j,zlo+1) - vely) / (0.5*(dz+dz1));
2080  dest_arr(i,j,k,icomp) = vely - vgrad * deltaz;
2081  } else {
2082  int ie, je;
2083  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
2084  je = j < lbound(eta_arr).y+1 ? lbound(eta_arr).y+1 : j;
2085  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
2086  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
2087  eta = 0.5*( eta_arr(ie,je-1,zlo,EddyDiff::Mom_v)
2088  + eta_arr(ie,je ,zlo,EddyDiff::Mom_v) );
2089  eta = amrex::max(eta,eta_eps);
2090  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressy/eta*deltaz;
2091  }
2092 
2093  return stressy;
2094  }

Member Data Documentation

◆ eps

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

Referenced by compute_q_flux(), and compute_t_flux().

◆ eta_eps

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

◆ zlo

int custom_flux::zlo
private

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