ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_detail_ShocMoments Namespace Reference

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_min_tke () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_large_neg () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_w3clip () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_base_temp () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_ufmin () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real eps ()
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real weighted_linear_interp (Real x0, Real x1, Real y0, Real y1, Real x)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real signed_denominator (Real value, Real eps_in=eps())
 
void interpolate_cc_to_iface (const ShocColumnData &col, const FArrayBox &cc_in, FArrayBox &iface_out, Real min_thresh)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real cell_spacing_at_iface (const Array4< const Real > &zt, const Array4< const Real > &zi, const ShocColumnLayout &layout, int ic, int k)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_from_distance (const ShocRuntimeOptions &opts, Real distance_from_top)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_cell (const Array4< const Real > &zt, const Array4< const Real > &zi, const ShocColumnLayout &layout, const ShocRuntimeOptions &opts, int ic, int k)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_iface (const Array4< const Real > &zi, const ShocColumnLayout &layout, const ShocRuntimeOptions &opts, int ic, int k)
 
void apply_second_moment_boundary_conditions (ShocColumnData &col)
 
void apply_top_taper_to_second_moments (ShocColumnData &col, const ShocRuntimeOptions &opts)
 
void apply_top_taper_to_third_moments (ShocColumnData &col, const ShocRuntimeOptions &opts)
 

Function Documentation

◆ apply_second_moment_boundary_conditions()

void erf_detail_ShocMoments::apply_second_moment_boundary_conditions ( ShocColumnData &  col)
131  {
132  auto thl_sec = col.thl_sec.array();
133  auto qw_sec = col.qw_sec.array();
134  auto qwthl_sec = col.qwthl_sec.array();
135  auto wthl_sec = col.wthl_sec.array();
136  auto wqw_sec = col.wqw_sec.array();
137  auto uw_sec = col.uw_sec.array();
138  auto vw_sec = col.vw_sec.array();
139  auto wtke_sec = col.wtke_sec.array();
140 
141  const auto sflux = col.surf_sens_flux.const_array();
142  const auto lflux = col.surf_lat_flux.const_array();
143  const auto tauu = col.surf_tau_u.const_array();
144  const auto tauv = col.surf_tau_v.const_array();
145  const auto pblh = col.pblh.const_array();
146 
147  const auto layout = col.layout;
148  const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
149  ParallelFor(col_box, [=] AMREX_GPU_DEVICE (int ic, int, int) noexcept
150  {
151  const Real wthl_sfc = sflux(ic,0,0);
152  const Real wqw_sfc = lflux(ic,0,0);
153  const Real uw_sfc = tauu(ic,0,0);
154  const Real vw_sfc = tauv(ic,0,0);
155  const Real ustar2 = std::sqrt(uw_sfc * uw_sfc + vw_sfc * vw_sfc);
156  const Real convective_depth = amrex::max(0.0_rt, pblh(ic,0,0));
157  const Real wstar = (wthl_sfc > 0.0_rt)
158  ? std::cbrt((CONST_GRAV / shoc_base_temp()) * wthl_sfc * convective_depth)
159  : 0.0_rt;
160  const Real uf = amrex::max(shoc_ufmin(),
161  std::sqrt(ustar2 + 0.3_rt * wstar * wstar));
162  const Real wthl_ratio = wthl_sfc / uf;
163  const Real wqw_ratio = wqw_sfc / uf;
164  const Real wtke_scale = amrex::max(std::sqrt(ustar2), shoc_ufmin());
165 
166  thl_sec(ic,0,0) = 0.72_rt * wthl_ratio * wthl_ratio;
167  qw_sec(ic,0,0) = 0.72_rt * wqw_ratio * wqw_ratio;
168  qwthl_sec(ic,0,0) = 0.36_rt * wthl_ratio * wqw_ratio;
169  wthl_sec(ic,0,0) = wthl_sfc;
170  wqw_sec(ic,0,0) = wqw_sfc;
171  uw_sec(ic,0,0) = uw_sfc;
172  vw_sec(ic,0,0) = vw_sfc;
173  wtke_sec(ic,0,0) = wtke_scale * wtke_scale * wtke_scale;
174 
175  const int ktop = layout.nlev;
176  thl_sec(ic,ktop,0) = 0.0_rt;
177  qw_sec(ic,ktop,0) = 0.0_rt;
178  qwthl_sec(ic,ktop,0) = 0.0_rt;
179  wthl_sec(ic,layout.nlev,0) = 0.0_rt;
180  wqw_sec(ic,layout.nlev,0) = 0.0_rt;
181  uw_sec(ic,layout.nlev,0) = 0.0_rt;
182  vw_sec(ic,layout.nlev,0) = 0.0_rt;
183  wtke_sec(ic,layout.nlev,0) = 0.0_rt;
184  });
185  }
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
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);})
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_base_temp() noexcept
Definition: ERF_ShocMoments.cpp:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_ufmin() noexcept
Definition: ERF_ShocMoments.cpp:15
amrex::FArrayBox vw_sec
Definition: ERF_ShocTypes.H:125
amrex::FArrayBox surf_lat_flux
Definition: ERF_ShocTypes.H:147
amrex::FArrayBox wqw_sec
Definition: ERF_ShocTypes.H:123
amrex::FArrayBox uw_sec
Definition: ERF_ShocTypes.H:124
amrex::FArrayBox pblh
Definition: ERF_ShocTypes.H:100
amrex::FArrayBox surf_tau_v
Definition: ERF_ShocTypes.H:149
amrex::FArrayBox qw_sec
Definition: ERF_ShocTypes.H:120
ShocColumnLayout layout
Definition: ERF_ShocTypes.H:71
amrex::FArrayBox surf_sens_flux
Definition: ERF_ShocTypes.H:146
amrex::FArrayBox wtke_sec
Definition: ERF_ShocTypes.H:126
amrex::FArrayBox surf_tau_u
Definition: ERF_ShocTypes.H:148
amrex::FArrayBox wthl_sec
Definition: ERF_ShocTypes.H:122
amrex::FArrayBox thl_sec
Definition: ERF_ShocTypes.H:119
amrex::FArrayBox qwthl_sec
Definition: ERF_ShocTypes.H:121

Referenced by ShocMoments::diagnose_second_moments().

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

◆ apply_top_taper_to_second_moments()

void erf_detail_ShocMoments::apply_top_taper_to_second_moments ( ShocColumnData &  col,
const ShocRuntimeOptions &  opts 
)
189  {
190  if (opts.top_taper_depth <= 0.0) {
191  return;
192  }
193 
194  auto thl_sec = col.thl_sec.array();
195  auto qw_sec = col.qw_sec.array();
196  auto qwthl_sec = col.qwthl_sec.array();
197  auto wthl_sec = col.wthl_sec.array();
198  auto wqw_sec = col.wqw_sec.array();
199  auto uw_sec = col.uw_sec.array();
200  auto vw_sec = col.vw_sec.array();
201  auto wtke_sec = col.wtke_sec.array();
202  auto w_sec = col.w_sec.array();
203 
204  const auto zt = col.zt.const_array();
205  const auto zi = col.zi.const_array();
206  const auto layout = col.layout;
207  const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
208  ParallelFor(col_box, [=] AMREX_GPU_DEVICE (int ic, int, int) noexcept
209  {
210  for (int k = 0; k < layout.nlev; ++k) {
211  w_sec(ic,k,0) *= top_taper_cell(zt, zi, layout, opts, ic, k);
212  }
213  for (int k = 0; k <= layout.nlev; ++k) {
214  const Real factor = top_taper_iface(zi, layout, opts, ic, k);
215  thl_sec(ic,k,0) *= factor;
216  qw_sec(ic,k,0) *= factor;
217  qwthl_sec(ic,k,0) *= factor;
218  wthl_sec(ic,k,0) *= factor;
219  wqw_sec(ic,k,0) *= factor;
220  uw_sec(ic,k,0) *= factor;
221  vw_sec(ic,k,0) *= factor;
222  wtke_sec(ic,k,0) *= factor;
223  }
224  });
225  }
@ zi
Definition: ERF_AdvanceWDM6.cpp:277
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_iface(const Array4< const Real > &zi, const ShocColumnLayout &layout, const ShocRuntimeOptions &opts, int ic, int k)
Definition: ERF_ShocMoments.cpp:121
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_cell(const Array4< const Real > &zt, const Array4< const Real > &zi, const ShocColumnLayout &layout, const ShocRuntimeOptions &opts, int ic, int k)
Definition: ERF_ShocMoments.cpp:110
amrex::FArrayBox w_sec
Definition: ERF_ShocTypes.H:128
amrex::FArrayBox zi
Definition: ERF_ShocTypes.H:75
amrex::FArrayBox zt
Definition: ERF_ShocTypes.H:74
amrex::Real top_taper_depth
Definition: ERF_ShocTypes.H:32

Referenced by ShocMoments::diagnose_second_moments().

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

◆ apply_top_taper_to_third_moments()

void erf_detail_ShocMoments::apply_top_taper_to_third_moments ( ShocColumnData &  col,
const ShocRuntimeOptions &  opts 
)
229  {
230  if (opts.top_taper_depth <= 0.0) {
231  return;
232  }
233 
234  auto w3 = col.w3.array();
235  const auto zi = col.zi.const_array();
236  const auto layout = col.layout;
237  const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
238  ParallelFor(col_box, [=] AMREX_GPU_DEVICE (int ic, int, int) noexcept
239  {
240  for (int k = 0; k <= layout.nlev; ++k) {
241  w3(ic,k,0) *= top_taper_iface(zi, layout, opts, ic, k);
242  }
243  });
244  }
amrex::FArrayBox w3
Definition: ERF_ShocTypes.H:127

Referenced by ShocMoments::diagnose_third_moments().

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

◆ cell_spacing_at_iface()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::cell_spacing_at_iface ( const Array4< const Real > &  zt,
const Array4< const Real > &  zi,
const ShocColumnLayout &  layout,
int  ic,
int  k 
)
85  {
86  if (k <= 0) {
87  return amrex::max(zt(ic,0,0) - zi(ic,0,0), eps());
88  }
89  if (k >= layout.nlev) {
90  return amrex::max(zi(ic,layout.nlev,0) - zt(ic,layout.nlev-1,0), eps());
91  }
92  return amrex::max(zt(ic,k,0) - zt(ic,k-1,0), eps());
93  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real eps()
Definition: ERF_ShocMoments.cpp:19
int nlev
Definition: ERF_ShocTypes.H:62

Referenced by ShocMoments::calc_var_or_covar(), ShocMoments::calc_vertflux(), and ShocMoments::diagnose_third_moments().

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

◆ eps()

◆ interpolate_cc_to_iface()

void erf_detail_ShocMoments::interpolate_cc_to_iface ( const ShocColumnData &  col,
const FArrayBox &  cc_in,
FArrayBox &  iface_out,
Real  min_thresh 
)
45  {
46  const auto zt = col.zt.const_array();
47  const auto zi = col.zi.const_array();
48  const auto in = cc_in.const_array();
49  auto out = iface_out.array();
50 
51  const auto layout = col.layout;
52  const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
53  ParallelFor(col_box, [=] AMREX_GPU_DEVICE (int ic, int, int) noexcept
54  {
55  if (layout.nlev == 1) {
56  out(ic,0,0) = amrex::max(min_thresh, in(ic,0,0));
57  out(ic,1,0) = amrex::max(min_thresh, in(ic,0,0));
58  return;
59  }
60 
61  out(ic,0,0) = amrex::max(min_thresh,
62  weighted_linear_interp(zt(ic,0,0), zt(ic,1,0),
63  in(ic,0,0), in(ic,1,0),
64  zi(ic,0,0)));
65  for (int k = 1; k < layout.nlev; ++k) {
66  const Real interp = weighted_linear_interp(zt(ic,k-1,0), zt(ic,k,0),
67  in(ic,k-1,0), in(ic,k,0),
68  zi(ic,k,0));
69  out(ic,k,0) = amrex::max(min_thresh, interp);
70  }
71  out(ic,layout.nlev,0) = amrex::max(min_thresh,
72  weighted_linear_interp(zt(ic,layout.nlev-2,0),
73  zt(ic,layout.nlev-1,0),
74  in(ic,layout.nlev-2,0),
75  in(ic,layout.nlev-1,0),
76  zi(ic,layout.nlev,0)));
77  });
78  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real weighted_linear_interp(Real x0, Real x1, Real y0, Real y1, Real x)
Definition: ERF_ShocMoments.cpp:23

Referenced by ShocMoments::diagnose_second_moments(), and ShocMoments::diagnose_third_moments().

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

◆ shoc_base_temp()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::shoc_base_temp ( )
noexcept
14 { return 300.0_rt; }

Referenced by apply_second_moment_boundary_conditions().

Here is the caller graph for this function:

◆ shoc_large_neg()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::shoc_large_neg ( )
noexcept
12 { return -99999999.99_rt; }

Referenced by ShocMoments::diagnose_third_moments().

Here is the caller graph for this function:

◆ shoc_min_tke()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::shoc_min_tke ( )
noexcept
11 { return 4.0e-4_rt; }

Referenced by ShocMoments::diagnose_third_moments().

Here is the caller graph for this function:

◆ shoc_ufmin()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::shoc_ufmin ( )
noexcept
15 { return 0.01_rt; }

Referenced by apply_second_moment_boundary_conditions().

Here is the caller graph for this function:

◆ shoc_w3clip()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::shoc_w3clip ( )
noexcept
13 { return 1.2_rt; }

Referenced by ShocMoments::clip_third_moments().

Here is the caller graph for this function:

◆ signed_denominator()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::signed_denominator ( Real  value,
Real  eps_in = eps() 
)
34  {
35  if (amrex::Math::abs(value) >= eps_in) {
36  return value;
37  }
38  return std::copysign(eps_in, value == zero ? one : value);
39  }
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36

Referenced by ShocMoments::diagnose_third_moments().

Here is the caller graph for this function:

◆ top_taper_cell()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::top_taper_cell ( const Array4< const Real > &  zt,
const Array4< const Real > &  zi,
const ShocColumnLayout &  layout,
const ShocRuntimeOptions &  opts,
int  ic,
int  k 
)
116  {
117  return top_taper_from_distance(opts, zi(ic,layout.nlev,0) - zt(ic,k,0));
118  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real top_taper_from_distance(const ShocRuntimeOptions &opts, Real distance_from_top)
Definition: ERF_ShocMoments.cpp:96

Referenced by apply_top_taper_to_second_moments().

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

◆ top_taper_from_distance()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::top_taper_from_distance ( const ShocRuntimeOptions &  opts,
Real  distance_from_top 
)
98  {
99  if (opts.top_taper_depth <= 0.0) {
100  return 1.0;
101  }
102 
103  const Real x = shoc_clamp(amrex::max(0.0_rt, distance_from_top) / opts.top_taper_depth,
104  0.0_rt, 1.0_rt);
105  const Real smooth = x * x * (3.0_rt - 2.0_rt * x);
106  return opts.top_taper_min_factor + (1.0_rt - opts.top_taper_min_factor) * smooth;
107  }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T shoc_clamp(T value, T lo, T hi)
Definition: ERF_ShocTypes.H:242
amrex::Real top_taper_min_factor
Definition: ERF_ShocTypes.H:33

Referenced by top_taper_cell(), and top_taper_iface().

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

◆ top_taper_iface()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::top_taper_iface ( const Array4< const Real > &  zi,
const ShocColumnLayout &  layout,
const ShocRuntimeOptions &  opts,
int  ic,
int  k 
)
126  {
127  return top_taper_from_distance(opts, zi(ic,layout.nlev,0) - zi(ic,k,0));
128  }

Referenced by apply_top_taper_to_second_moments(), and apply_top_taper_to_third_moments().

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

◆ weighted_linear_interp()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real erf_detail_ShocMoments::weighted_linear_interp ( Real  x0,
Real  x1,
Real  y0,
Real  y1,
Real  x 
)
24  {
25  const Real denom = x1 - x0;
26  if (amrex::Math::abs(denom) <= eps()) {
27  return 0.5_rt * (y0 + y1);
28  }
29  return y0 + (y1 - y0) * (x - x0) / denom;
30  }

Referenced by interpolate_cc_to_iface().

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