ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ShocTypes.H File Reference
#include "ERF_DataStruct.H"
#include <AMReX_FArrayBox.H>
#include <AMReX_Geometry.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_ParmParse.H>
#include <AMReX_Vector.H>
#include <algorithm>
#include <cctype>
#include <string>
Include dependency graph for ERF_ShocTypes.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ShocRuntimeOptions
 
struct  ShocColumnLayout
 
struct  ShocColumnData
 

Enumerations

enum class  ShocTransportMode { StateUpdate , HostDiffusion }
 
enum class  ShocMomentumTransport { None , StateUpdate , HostDiffusion }
 

Functions

const char * shoc_transport_mode_name (ShocTransportMode mode)
 
const char * shoc_momentum_transport_name (ShocMomentumTransport mode)
 
bool shoc_uses_state_update (ShocTransportMode mode)
 
bool shoc_uses_host_diffusion (ShocTransportMode mode)
 
bool shoc_uses_momentum_state_update (ShocMomentumTransport mode)
 
bool shoc_uses_momentum_host_diffusion (ShocMomentumTransport mode)
 
bool shoc_disables_momentum_transport (ShocMomentumTransport mode)
 
std::string shoc_lower_copy (std::string value)
 
bool parse_shoc_transport_mode_string (std::string value, ShocTransportMode &mode, std::string &error_message)
 
bool parse_shoc_momentum_transport_string (std::string value, ShocMomentumTransport &mode, std::string &error_message)
 
bool validate_shoc_runtime_options_message (const ShocRuntimeOptions &opts, std::string &error_message)
 
void read_shoc_runtime_options (ShocRuntimeOptions &opts)
 
void validate_shoc_runtime_options (const ShocRuntimeOptions &opts)
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool shoc_valid_comp (int comp, int ncomp)
 
template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T shoc_clamp (T value, T lo, T hi)
 

Enumeration Type Documentation

◆ ShocMomentumTransport

enum ShocMomentumTransport
strong
Enumerator
None 
StateUpdate 
HostDiffusion 

◆ ShocTransportMode

enum ShocTransportMode
strong
Enumerator
StateUpdate 
HostDiffusion 
17 {
20 };

Function Documentation

◆ parse_shoc_momentum_transport_string()

bool parse_shoc_momentum_transport_string ( std::string  value,
ShocMomentumTransport mode,
std::string &  error_message 
)
inline
159 {
161  if (value == "none") {
163  return true;
164  }
165  if (value == "state_update") {
167  return true;
168  }
169  if (value == "host_diffusion") {
171  return true;
172  }
173 
174  error_message = "erf.shoc.momentum_transport must be 'none', 'state_update', or 'host_diffusion'";
175  return false;
176 }
amrex::Real value
Definition: ERF_HurricaneDiagnostics.H:20
std::string shoc_lower_copy(std::string value)
Definition: ERF_ShocTypes.H:124

Referenced by read_shoc_runtime_options().

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

◆ parse_shoc_transport_mode_string()

bool parse_shoc_transport_mode_string ( std::string  value,
ShocTransportMode mode,
std::string &  error_message 
)
inline
135 {
137  if (value == "state_update") {
139  return true;
140  }
141  if (value == "host_diffusion") {
143  return true;
144  }
145  if (value == "tendencies") {
146  error_message =
147  "erf.shoc.transport_mode = tendencies has been removed for native SHOC. Use erf.shoc.transport_mode = state_update. Native SHOC now applies its coupled column increment before the dycore to avoid splitting theta and momentum from moisture.";
148  return false;
149  }
150 
151  error_message = "erf.shoc.transport_mode must be 'state_update' or 'host_diffusion'";
152  return false;
153 }

Referenced by read_shoc_runtime_options().

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

◆ read_shoc_runtime_options()

void read_shoc_runtime_options ( ShocRuntimeOptions opts)
inline
284 {
285  amrex::ParmParse pp("erf.shoc");
286 
287  pp.query("lambda_low", opts.lambda_low);
288  pp.query("lambda_high", opts.lambda_high);
289  pp.query("lambda_slope", opts.lambda_slope);
290  pp.query("lambda_thresh", opts.lambda_thresh);
291  pp.query("thl2tune", opts.thl2tune);
292  pp.query("qw2tune", opts.qw2tune);
293  pp.query("qwthl2tune", opts.qwthl2tune);
294  pp.query("w2tune", opts.w2tune);
295  pp.query("length_fac", opts.length_fac);
296  pp.query("c_diag_3rd_mom", opts.c_diag_3rd_mom);
297  pp.query("coeff_kh", opts.coeff_kh);
298  pp.query("coeff_km", opts.coeff_km);
299  pp.query("top_taper_depth", opts.top_taper_depth);
300  pp.query("top_taper_min_factor", opts.top_taper_min_factor);
301  pp.query("shoc_1p5tke", opts.shoc_1p5tke);
302  pp.query("extra_shoc_diags", opts.extra_shoc_diags);
303  pp.query("apply_tms", opts.apply_tms);
304  pp.query("check_flux_state", opts.check_flux_state);
305  pp.query("column_conservation_check", opts.column_conservation_check);
306  pp.query("debug_summary", opts.debug_summary);
307  pp.query("allow_tendency_microphysics_overlap", opts.allow_tendency_microphysics_overlap);
308  pp.query("signed_tke_production", opts.signed_tke_production);
309  pp.query("debug_bad_column", opts.debug_bad_column);
310  pp.query("debug_bad_column_abort", opts.debug_bad_column_abort);
311  pp.query("debug_bad_column_max_reports", opts.debug_bad_column_max_reports);
312  pp.query("debug_bad_column_theta_tend_threshold", opts.debug_bad_column_theta_tend_threshold);
313  pp.query("debug_bad_column_q_tend_threshold", opts.debug_bad_column_q_tend_threshold);
314  pp.query("debug_bad_column_brunt_threshold", opts.debug_bad_column_brunt_threshold);
315  pp.query("debug_bad_column_min_dz", opts.debug_bad_column_min_dz);
316  pp.query("debug_bad_column_scalar_moment_threshold", opts.debug_bad_column_scalar_moment_threshold);
317  pp.query("debug_disable_pdf_cloud_increment", opts.debug_disable_pdf_cloud_increment);
318  pp.query("debug_disable_theta_state_update", opts.debug_disable_theta_state_update);
319  pp.query("debug_disable_moisture_state_update", opts.debug_disable_moisture_state_update);
320  pp.query("debug_disable_tke_state_update", opts.debug_disable_tke_state_update);
321 
322  std::string transport_mode = shoc_transport_mode_name(opts.transport_mode);
323  if (pp.query("transport_mode", transport_mode)) {
324  std::string error_message;
325  if (!parse_shoc_transport_mode_string(transport_mode, opts.transport_mode, error_message)) {
326  amrex::Abort(error_message.c_str());
327  }
328  }
329 
330  std::string momentum_transport = shoc_momentum_transport_name(opts.momentum_transport);
331  if (pp.query("momentum_transport", momentum_transport)) {
332  std::string error_message;
333  if (!parse_shoc_momentum_transport_string(momentum_transport,
334  opts.momentum_transport,
335  error_message)) {
336  amrex::Abort(error_message.c_str());
337  }
338  }
339 }
ParmParse pp("prob")
bool parse_shoc_momentum_transport_string(std::string value, ShocMomentumTransport &mode, std::string &error_message)
Definition: ERF_ShocTypes.H:156
bool parse_shoc_transport_mode_string(std::string value, ShocTransportMode &mode, std::string &error_message)
Definition: ERF_ShocTypes.H:132
const char * shoc_transport_mode_name(ShocTransportMode mode)
Definition: ERF_ShocTypes.H:30
const char * shoc_momentum_transport_name(ShocMomentumTransport mode)
Definition: ERF_ShocTypes.H:40
int debug_bad_column_max_reports
Definition: ERF_ShocTypes.H:111
ShocTransportMode transport_mode
Definition: ERF_ShocTypes.H:107
bool debug_disable_moisture_state_update
Definition: ERF_ShocTypes.H:119
bool shoc_1p5tke
Definition: ERF_ShocTypes.H:99
amrex::Real debug_bad_column_q_tend_threshold
Definition: ERF_ShocTypes.H:113
amrex::Real coeff_kh
Definition: ERF_ShocTypes.H:94
amrex::Real top_taper_depth
Definition: ERF_ShocTypes.H:96
amrex::Real debug_bad_column_scalar_moment_threshold
Definition: ERF_ShocTypes.H:116
amrex::Real lambda_high
Definition: ERF_ShocTypes.H:83
amrex::Real w2tune
Definition: ERF_ShocTypes.H:90
amrex::Real debug_bad_column_min_dz
Definition: ERF_ShocTypes.H:115
amrex::Real qwthl2tune
Definition: ERF_ShocTypes.H:89
bool debug_disable_pdf_cloud_increment
Definition: ERF_ShocTypes.H:117
amrex::Real c_diag_3rd_mom
Definition: ERF_ShocTypes.H:93
ShocMomentumTransport momentum_transport
Definition: ERF_ShocTypes.H:108
bool column_conservation_check
Definition: ERF_ShocTypes.H:103
amrex::Real lambda_thresh
Definition: ERF_ShocTypes.H:85
bool extra_shoc_diags
Definition: ERF_ShocTypes.H:100
amrex::Real coeff_km
Definition: ERF_ShocTypes.H:95
bool debug_disable_theta_state_update
Definition: ERF_ShocTypes.H:118
amrex::Real debug_bad_column_theta_tend_threshold
Definition: ERF_ShocTypes.H:112
amrex::Real lambda_slope
Definition: ERF_ShocTypes.H:84
amrex::Real lambda_low
Definition: ERF_ShocTypes.H:82
bool debug_bad_column
Definition: ERF_ShocTypes.H:109
bool signed_tke_production
Definition: ERF_ShocTypes.H:106
amrex::Real debug_bad_column_brunt_threshold
Definition: ERF_ShocTypes.H:114
bool debug_disable_tke_state_update
Definition: ERF_ShocTypes.H:120
bool apply_tms
Definition: ERF_ShocTypes.H:101
bool debug_bad_column_abort
Definition: ERF_ShocTypes.H:110
bool allow_tendency_microphysics_overlap
Definition: ERF_ShocTypes.H:105
bool check_flux_state
Definition: ERF_ShocTypes.H:102
amrex::Real length_fac
Definition: ERF_ShocTypes.H:92
amrex::Real top_taper_min_factor
Definition: ERF_ShocTypes.H:97
amrex::Real thl2tune
Definition: ERF_ShocTypes.H:87
amrex::Real qw2tune
Definition: ERF_ShocTypes.H:88
bool debug_summary
Definition: ERF_ShocTypes.H:104

Referenced by ShocDriver::ShocDriver().

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

◆ shoc_clamp()

template<typename T >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T shoc_clamp ( T  value,
T  lo,
T  hi 
)
383 {
384  return amrex::max(lo, amrex::min(value, hi));
385 }

Referenced by ShocImplicit::advance_implicit_state(), ShocTKE::diagnose_tke_and_diffusivities(), ShocImplicit::finalize_from_pdf(), and shoc::reconstruct_pdf_state().

Here is the caller graph for this function:

◆ shoc_disables_momentum_transport()

bool shoc_disables_momentum_transport ( ShocMomentumTransport  mode)
inline
76 {
77  return mode == ShocMomentumTransport::None;
78 }

Referenced by ShocDriver::disables_momentum_transport().

Here is the caller graph for this function:

◆ shoc_lower_copy()

std::string shoc_lower_copy ( std::string  value)
inline
125 {
126  std::transform(value.begin(), value.end(), value.begin(),
127  [] (unsigned char c) { return static_cast<char>(std::tolower(c)); });
128  return value;
129 }

Referenced by parse_shoc_momentum_transport_string(), and parse_shoc_transport_mode_string().

Here is the caller graph for this function:

◆ shoc_momentum_transport_name()

const char* shoc_momentum_transport_name ( ShocMomentumTransport  mode)
inline
41 {
42  switch (mode) {
43  case ShocMomentumTransport::None: return "none";
44  case ShocMomentumTransport::StateUpdate: return "state_update";
45  case ShocMomentumTransport::HostDiffusion: return "host_diffusion";
46  }
47  return "unknown";
48 }

Referenced by ShocDriver::print_debug_summary(), and read_shoc_runtime_options().

Here is the caller graph for this function:

◆ shoc_transport_mode_name()

const char* shoc_transport_mode_name ( ShocTransportMode  mode)
inline
31 {
32  switch (mode) {
33  case ShocTransportMode::StateUpdate: return "state_update";
34  case ShocTransportMode::HostDiffusion:return "host_diffusion";
35  }
36  return "unknown";
37 }

Referenced by ShocDriver::print_debug_summary(), and read_shoc_runtime_options().

Here is the caller graph for this function:

◆ shoc_uses_host_diffusion()

bool shoc_uses_host_diffusion ( ShocTransportMode  mode)
inline
58 {
59  return mode == ShocTransportMode::HostDiffusion;
60 }

Referenced by shoc_driver_host_diffusion_moisture_supported(), ShocDriver::uses_host_diffusion(), and validate_shoc_runtime_options_message().

Here is the caller graph for this function:

◆ shoc_uses_momentum_host_diffusion()

bool shoc_uses_momentum_host_diffusion ( ShocMomentumTransport  mode)
inline
70 {
72 }

Referenced by ShocDriver::uses_momentum_host_diffusion(), and validate_shoc_runtime_options_message().

Here is the caller graph for this function:

◆ shoc_uses_momentum_state_update()

bool shoc_uses_momentum_state_update ( ShocMomentumTransport  mode)
inline
64 {
66 }

Referenced by ShocDriver::uses_momentum_state_update().

Here is the caller graph for this function:

◆ shoc_uses_state_update()

bool shoc_uses_state_update ( ShocTransportMode  mode)
inline
52 {
53  return mode == ShocTransportMode::StateUpdate;
54 }

Referenced by shoc_driver_state_update_layout_supported(), and ShocDriver::uses_state_update().

Here is the caller graph for this function:

◆ shoc_valid_comp()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool shoc_valid_comp ( int  comp,
int  ncomp 
)
375 {
376  return comp >= 0 && comp < ncomp;
377 }

Referenced by shoc_layout_requires_number_closure().

Here is the caller graph for this function:

◆ validate_shoc_runtime_options()

void validate_shoc_runtime_options ( const ShocRuntimeOptions opts)
inline
343 {
344  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.lambda_low > 0.0, "erf.shoc.lambda_low must be positive");
345  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.lambda_high >= opts.lambda_low,
346  "erf.shoc.lambda_high must be >= lambda_low");
347  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.length_fac > 0.0, "erf.shoc.length_fac must be positive");
348  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.coeff_kh >= 0.0, "erf.shoc.coeff_kh must be non-negative");
349  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.coeff_km >= 0.0, "erf.shoc.coeff_km must be non-negative");
350  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.top_taper_depth >= 0.0,
351  "erf.shoc.top_taper_depth must be non-negative");
352  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.top_taper_min_factor >= 0.0 &&
353  opts.top_taper_min_factor <= 1.0,
354  "erf.shoc.top_taper_min_factor must be in [0, 1]");
355  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_max_reports > 0,
356  "erf.shoc.debug_bad_column_max_reports must be positive");
357  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_theta_tend_threshold > 0.0,
358  "erf.shoc.debug_bad_column_theta_tend_threshold must be positive");
359  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_q_tend_threshold > 0.0,
360  "erf.shoc.debug_bad_column_q_tend_threshold must be positive");
361  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_brunt_threshold > 0.0,
362  "erf.shoc.debug_bad_column_brunt_threshold must be positive");
363  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_min_dz > 0.0,
364  "erf.shoc.debug_bad_column_min_dz must be positive");
365  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(opts.debug_bad_column_scalar_moment_threshold > 0.0,
366  "erf.shoc.debug_bad_column_scalar_moment_threshold must be positive");
367  std::string error_message;
368  AMREX_ALWAYS_ASSERT_WITH_MESSAGE(validate_shoc_runtime_options_message(opts, error_message),
369  error_message.c_str());
370 }
bool validate_shoc_runtime_options_message(const ShocRuntimeOptions &opts, std::string &error_message)
Definition: ERF_ShocTypes.H:179

Referenced by ShocDriver::ShocDriver().

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

◆ validate_shoc_runtime_options_message()

bool validate_shoc_runtime_options_message ( const ShocRuntimeOptions opts,
std::string &  error_message 
)
inline
181 {
184  error_message =
185  "erf.shoc.transport_mode = host_diffusion requires erf.shoc.momentum_transport = host_diffusion";
186  return false;
187  }
188  return true;
189 }
bool shoc_uses_host_diffusion(ShocTransportMode mode)
Definition: ERF_ShocTypes.H:57
bool shoc_uses_momentum_host_diffusion(ShocMomentumTransport mode)
Definition: ERF_ShocTypes.H:69

Referenced by validate_shoc_runtime_options().

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