ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_CanopyTurbulence.H File Reference
#include <cmath>
#include <limits>
#include <string>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_Array4.H>
#include <AMReX_Box.H>
#include <AMReX_GpuLaunch.H>
#include <AMReX_REAL.H>
#include <ERF_CanopyTurbStruct.H>
#include <ERF_IndexDefines.H>
Include dependency graph for ERF_CanopyTurbulence.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 canopy_turbulence
 

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real canopy_turbulence::limited_length (amrex::Real length, amrex::Real f_drag, amrex::Real alpha)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real canopy_turbulence::tke_source (amrex::Real rho, amrex::Real rhok_old, amrex::Real f_drag, amrex::Real wind, amrex::Real beta_p, amrex::Real beta_d, amrex::Real dt)
 
AMREX_INLINE void AddCanopyTKESources (const amrex::Box &bx, const amrex::Array4< amrex::Real > &cell_src, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_old, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &f_arr, const amrex::Array4< const amrex::Real > &t_blank_arr, const CanopyTurbulence &canopy, amrex::Real dt)
 

Function Documentation

◆ AddCanopyTKESources()

AMREX_INLINE void AddCanopyTKESources ( const amrex::Box &  bx,
const amrex::Array4< amrex::Real > &  cell_src,
const amrex::Array4< const amrex::Real > &  cell_data,
const amrex::Array4< const amrex::Real > &  cell_old,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
const amrex::Array4< const amrex::Real > &  f_arr,
const amrex::Array4< const amrex::Real > &  t_blank_arr,
const CanopyTurbulence &  canopy,
amrex::Real  dt 
)

Add the canopy TKE source to the RhoKE component of the staged cell source on one box. Called by make_sources inside its loop over the boxes, so it adds no pass over the level; cells outside the forest (f <= 0) return before the velocities are read. Fully immersed cells (terrain_blank = 1) get no source, where ERF_AdvanceDycore.cpp also zeroes the eddy diffusivities.

Parameters
[in]bxcell-centred box to fill
[in,out]cell_srcstaged source terms for the conserved state
[in]cell_dataconserved state of the stage (Rho_comp is read)
[in]cell_oldconserved state at the start of the step (RhoKE_comp is read)
[in]ux-face velocity
[in]vy-face velocity
[in]wz-face velocity
[in]f_arrcell-centred forest drag field f = C_d LAD
[in]t_blank_arrimmersed-forcing blanking, or an empty Array4 without immersed forcing
[in]canopycanopy turbulence inputs
[in]dttime step of the stage the source enters
139 {
140  const amrex::Real beta_p = canopy.beta_p;
141  const amrex::Real beta_d = canopy.beta_d;
142  const bool use_blank = static_cast<bool>(t_blank_arr);
143 
144  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
145  {
146  const amrex::Real f_drag = f_arr(i, j, k);
147  if (f_drag <= amrex::Real(0.0)) {
148  return;
149  }
150  if (use_blank && t_blank_arr(i, j, k) == amrex::Real(1.0)) {
151  return;
152  }
153  const amrex::Real rho = cell_data(i, j, k, Rho_comp);
154  const amrex::Real rhok_old = amrex::max(cell_old(i, j, k, RhoKE_comp), amrex::Real(0.0));
155  const amrex::Real u_cc = amrex::Real(0.5) * (u(i, j, k) + u(i+1, j, k));
156  const amrex::Real v_cc = amrex::Real(0.5) * (v(i, j, k) + v(i, j+1, k));
157  const amrex::Real w_cc = amrex::Real(0.5) * (w(i, j, k) + w(i, j, k+1));
158  const amrex::Real wind = std::sqrt(u_cc*u_cc + v_cc*v_cc + w_cc*w_cc);
159  cell_src(i, j, k, RhoKE_comp) +=
160  canopy_turbulence::tke_source(rho, rhok_old, f_drag, wind, beta_p, beta_d, dt);
161  });
162 }
#define Rho_comp
Definition: ERF_IndexDefines.H:53
#define RhoKE_comp
Definition: ERF_IndexDefines.H:55
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
Real w
Definition: ERF_Plotfile2DInterpolator.cpp:23
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ rho
Definition: ERF_Kessler.H:25
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tke_source(amrex::Real rho, amrex::Real rhok_old, amrex::Real f_drag, amrex::Real wind, amrex::Real beta_p, amrex::Real beta_d, amrex::Real dt)
Definition: ERF_CanopyTurbulence.H:92
amrex::Real beta_d
erf.forest_canopy_beta_d: short-circuit dissipation coefficient
Definition: ERF_CanopyTurbStruct.H:22
amrex::Real beta_p
erf.forest_canopy_beta_p: fraction of the drag work that becomes TKE
Definition: ERF_CanopyTurbStruct.H:20

Referenced by make_sources().

Here is the call graph for this function:
Here is the caller graph for this function: