ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_DampingStruct.H
Go to the documentation of this file.
1 #ifndef ERF_DAMPING_STRUCT_H_
2 #define ERF_DAMPING_STRUCT_H_
3 
4 #include <string>
5 #include <iostream>
6 
7 #include <AMReX_ParmParse.H>
8 #include <AMReX_Print.H>
9 #include <AMReX_Gpu.H>
10 
11 /**
12  * @brief Time integration treatment used for Rayleigh damping.
13  */
14 enum struct RayleighDampingType {
16 };
17 
18 /**
19  * Container holding damping-related choices
20  */
21 
22 struct DampingChoice {
23  public:
24  /**
25  * @brief Read damping options from the input parameter database.
26  * @param pp_prefix ParmParse prefix for the ERF input namespace.
27  */
28  void init_params (std::string pp_prefix)
29  {
30  amrex::ParmParse pp(pp_prefix);
31 
32  static std::string rayleigh_type_string = "SlowExplicit";
33  // Whether the type was given: anelastic and pseudo-incompressible levels default to
34  // SlowImplicit for w, compressible levels to SlowExplicit (rayleigh_slow_implicit_w)
35  rayleigh_damping_type_given = pp.contains("rayleigh_damping_type");
36  pp.queryAdd("rayleigh_damping_type",rayleigh_type_string);
37 
38  if (!rayleigh_type_string.compare("SlowExplicit")) {
40  } else if (!rayleigh_type_string.compare("SlowImplicit")) {
42  } else if (!rayleigh_type_string.compare("FastExplicit")) {
44  } else if (!rayleigh_type_string.compare("FastImplicit")) {
46  } else {
47  amrex::Error("Don't know this rayleigh_damping_type");
48  }
49 
50  // Include Rayleigh damping (separate flags for each variable)
51  pp.queryAdd("rayleigh_damp_U", rayleigh_damp_U);
52  pp.queryAdd("rayleigh_damp_V", rayleigh_damp_V);
53  pp.queryAdd("rayleigh_damp_W", rayleigh_damp_W);
54  pp.queryAdd("rayleigh_damp_T", rayleigh_damp_T);
55  pp.queryAdd("rayleigh_dampcoef", rayleigh_dampcoef);
56  pp.queryAdd("rayleigh_zdamp", rayleigh_zdamp);
57 
58  if (pp.countval("rayleigh_damp_substep") > 0) {
59  amrex::Abort("The input rayleigh_damp_substep is deprecated. Set rayleigh_damping_type instead.");
60  }
61 
62  // Include vertical-velocity damping to improve robustness
63  pp.queryAdd("w_damping", w_damping);
64  pp.queryAdd("w_damping_cfl", w_damping_cfl);
65  pp.queryAdd("w_damping_const", w_damping_const);
66  pp.queryAdd("w_damping_coeff", w_damping_coeff);
67 
68  if (w_damping && (w_damping_const < 0 && w_damping_coeff < 0)) {
69  amrex::Abort("Need to specify vertical damping coefficient w_damping_const (like WRF) or w_damping_coeff (~ dz/dt**2)");
70  }
71  }
72 
73  /**
74  * @brief Print the configured damping options.
75  */
76  void display ()
77  {
78  amrex::Print() << "Rayleigh damping :";
80  if (rayleigh_damp_U) amrex::Print() << " U";
81  if (rayleigh_damp_V) amrex::Print() << " V";
82  if (rayleigh_damp_W) amrex::Print() << " W";
83  if (rayleigh_damp_T) amrex::Print() << " T";
84  amrex::Print() << " (coef=" << rayleigh_dampcoef << " 1/s,"
85  << " depth=" << rayleigh_zdamp << " m)"
86  << std::endl;
87  } else {
88  amrex::Print() << " None" << std::endl;
89  }
90 
91  amrex::Print() << "w damping : " << w_damping;
92  if (w_damping_const > 0) {
93  amrex::Print() << " (coeff = " << w_damping_const << ")" << std::endl;
94  } else {
95  amrex::Print() << " (coeff = " << w_damping_coeff << " * dz/dt**2)" << std::endl;
96  }
97  }
98 
99  bool rayleigh_damp_U = false;
100  bool rayleigh_damp_V = false;
101  bool rayleigh_damp_W = false;
102  bool rayleigh_damp_T = false;
103  amrex::Real rayleigh_dampcoef = amrex::Real(0.2); // inverse time scale [1/s]
104  amrex::Real rayleigh_zdamp = amrex::Real(500.0); // damping layer depth [m]
105  amrex::Real rayleigh_ztop;
106 
107  bool w_damping = false;
108  amrex::Real w_damping_cfl = one; // from WRF manual -- WRF source code has default
109  // w_crit_cfl=amrex::Real(1.2)
110  amrex::Real w_damping_const = -1; // damping coefficient -- to used a constant value
111  // (WRF uses amrex::Real(0.3) m/s2), set to a positive value;
112  // otherwise, the damping coefficient will be
113  amrex::Real w_damping_coeff = -1; // grid-dependent: coeff * dz/dt**2
114 
115  // Molecular transport model
118 };
119 
120 /**
121  * @var DampingChoice::rayleigh_damp_U
122  * @brief Whether Rayleigh damping is applied to x-momentum.
123  * @var DampingChoice::rayleigh_damp_V
124  * @brief Whether Rayleigh damping is applied to y-momentum.
125  * @var DampingChoice::rayleigh_damp_W
126  * @brief Whether Rayleigh damping is applied to vertical momentum.
127  * @var DampingChoice::rayleigh_damp_T
128  * @brief Whether Rayleigh damping is applied to potential temperature.
129  * @var DampingChoice::rayleigh_dampcoef
130  * @brief Rayleigh damping inverse time scale [1/s].
131  * @var DampingChoice::rayleigh_zdamp
132  * @brief Rayleigh damping layer depth [m].
133  * @var DampingChoice::rayleigh_ztop
134  * @brief Top of the Rayleigh damping layer [m].
135  * @var DampingChoice::w_damping
136  * @brief Whether vertical-velocity damping is enabled.
137  * @var DampingChoice::w_damping_cfl
138  * @brief CFL threshold used by vertical-velocity damping.
139  * @var DampingChoice::w_damping_const
140  * @brief Constant vertical damping coefficient.
141  * @var DampingChoice::w_damping_coeff
142  * @brief Grid-dependent vertical damping coefficient multiplier.
143  * @var DampingChoice::rayleigh_damping_type
144  * @brief Selected Rayleigh damping time-integration treatment.
145  */
146 #endif
RayleighDampingType
Time integration treatment used for Rayleigh damping.
Definition: ERF_DampingStruct.H:14
ParmParse pp("prob")
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
Definition: ERF_DampingStruct.H:22
RayleighDampingType rayleigh_damping_type
Selected Rayleigh damping time-integration treatment.
Definition: ERF_DampingStruct.H:116
void init_params(std::string pp_prefix)
Read damping options from the input parameter database.
Definition: ERF_DampingStruct.H:28
amrex::Real rayleigh_dampcoef
Rayleigh damping inverse time scale [1/s].
Definition: ERF_DampingStruct.H:103
bool rayleigh_damp_U
Whether Rayleigh damping is applied to x-momentum.
Definition: ERF_DampingStruct.H:99
bool rayleigh_damp_V
Whether Rayleigh damping is applied to y-momentum.
Definition: ERF_DampingStruct.H:100
bool rayleigh_damp_W
Whether Rayleigh damping is applied to vertical momentum.
Definition: ERF_DampingStruct.H:101
amrex::Real rayleigh_zdamp
Rayleigh damping layer depth [m].
Definition: ERF_DampingStruct.H:104
bool w_damping
Whether vertical-velocity damping is enabled.
Definition: ERF_DampingStruct.H:107
amrex::Real rayleigh_ztop
Top of the Rayleigh damping layer [m].
Definition: ERF_DampingStruct.H:105
bool rayleigh_damping_type_given
Definition: ERF_DampingStruct.H:117
bool rayleigh_damp_T
Whether Rayleigh damping is applied to potential temperature.
Definition: ERF_DampingStruct.H:102
void display()
Print the configured damping options.
Definition: ERF_DampingStruct.H:76
amrex::Real w_damping_cfl
CFL threshold used by vertical-velocity damping.
Definition: ERF_DampingStruct.H:108
amrex::Real w_damping_const
Constant vertical damping coefficient.
Definition: ERF_DampingStruct.H:110
amrex::Real w_damping_coeff
Grid-dependent vertical damping coefficient multiplier.
Definition: ERF_DampingStruct.H:113