ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
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
1850  : zlo(l_zlo) {}
int zlo
Definition: ERF_MOSTStress.H:2096

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

◆ 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
1930  {
1931  amrex::Real rho, eta;
1932 
1933  int ic, jc;
1934  ic = i < lbound(cons_arr).x ? lbound(cons_arr).x : i;
1935  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1936  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1937  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1938 
1939  rho = cons_arr(ic,jc,zlo,Rho_comp);
1940 
1941  amrex::Real tstar = t_star_arr(ic,jc,zlo);
1942  amrex::Real deltaz = dz * (zlo - k);
1943 
1944  // NOTE: this is rho*<T'w'> = -K dTdz
1945  amrex::Real moflux = (std::abs(tstar) > eps) ? rho * tstar : 0.0;
1946 
1947  if (exp_most) {
1948  // surface gradient equal to gradient at first zface
1949  amrex::Real rthetagrad = ( cons_arr(ic,jc,zlo+1,RhoTheta_comp) - cons_arr(ic,jc,zlo ,RhoTheta_comp) ) / (0.5*(dz+dz1));
1950  dest_arr(i,j,k,icomp+n) = cons_arr(ic,jc,zlo,RhoTheta_comp) - rthetagrad * deltaz;
1951  } else {
1952  int ie, je;
1953  ie = i < lbound(eta_arr).x ? lbound(eta_arr).x : i;
1954  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
1955  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
1956  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
1957  eta = eta_arr(ie,je,zlo,EddyDiff::Theta_v); // == rho * alpha [kg/m^3 * m^2/s]
1958  eta = amrex::max(eta,eta_eps);
1959  dest_arr(i,j,k,icomp+n) = dest_arr(i,j,zlo,icomp+n) + moflux*rho/eta*deltaz;
1960  }
1961 
1962  return moflux;
1963  }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
@ Theta_v
Definition: ERF_IndexDefines.H:157

◆ 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
1983  {
1984  amrex::Real velx, vely, rho, eta;
1985  int jy, ic, jc;
1986 
1987  int iylo = i <= lbound(vely_arr).x ? lbound(vely_arr).x : i-1;
1988  int iyhi = i > ubound(vely_arr).x ? ubound(vely_arr).x : i;
1989 
1990  jy = j < lbound(vely_arr).y ? lbound(vely_arr).y : j;
1991  jy = jy > ubound(vely_arr).y-1 ? ubound(vely_arr).y-1 : jy;
1992 
1993  ic = i < lbound(cons_arr).x+1 ? lbound(cons_arr).x+1 : i;
1994  jc = j < lbound(cons_arr).y ? lbound(cons_arr).y : j;
1995  ic = ic > ubound(cons_arr).x ? ubound(cons_arr).x : ic;
1996  jc = jc > ubound(cons_arr).y ? ubound(cons_arr).y : jc;
1997 
1998  velx = velx_arr(i,j,zlo);
1999  vely = 0.25*( vely_arr(iyhi,jy,zlo)+vely_arr(iyhi,jy+1,zlo)
2000  + vely_arr(iylo,jy,zlo)+vely_arr(iylo,jy+1,zlo) );
2001  rho = 0.5 *( cons_arr(ic-1,jc,zlo,Rho_comp)
2002  + cons_arr(ic ,jc,zlo,Rho_comp) );
2003 
2004  amrex::Real ustar = 0.5 * ( u_star_arr(ic-1,jc,zlo) + u_star_arr(ic,jc,zlo) );
2005  amrex::Real wsp = sqrt(velx*velx+vely*vely);
2006  amrex::Real deltaz = dz * (zlo - k);
2007 
2008  // NOTE: this is rho*<u'w'> = -K dudz
2009  amrex::Real stressx = -rho * ustar * ustar * velx / wsp;
2010 
2011  if (exp_most) {
2012  // surface gradient equal to gradient at first zface
2013  amrex::Real ugrad = (velx_arr(i,j,zlo+1) - velx) / (0.5*(dz+dz1));
2014  dest_arr(i,j,k,icomp) = velx - ugrad * deltaz;
2015  } else {
2016  int ie, je;
2017  ie = i < lbound(eta_arr).x+1 ? lbound(eta_arr).x+1 : i;
2018  je = j < lbound(eta_arr).y ? lbound(eta_arr).y : j;
2019  ie = ie > ubound(eta_arr).x ? ubound(eta_arr).x : ie;
2020  je = je > ubound(eta_arr).y ? ubound(eta_arr).y : je;
2021  eta = 0.5 *( eta_arr(ie-1,je,zlo,EddyDiff::Mom_v)
2022  + eta_arr(ie ,je,zlo,EddyDiff::Mom_v) );
2023  eta = amrex::max(eta,eta_eps);
2024  dest_arr(i,j,k,icomp) = dest_arr(i,j,zlo,icomp) + stressx/eta*deltaz;
2025  }
2026 
2027  return stressx;
2028  }
@ Mom_v
Definition: ERF_IndexDefines.H:156

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

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: