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  pp.query("rayleigh_damping_type",rayleigh_type_string);
34 
35  if (!rayleigh_type_string.compare("SlowExplicit")) {
37  } else if (!rayleigh_type_string.compare("FastExplicit")) {
39  } else if (!rayleigh_type_string.compare("FastImplicit")) {
41  } else {
42  amrex::Error("Don't know this rayleigh_damping_type");
43  }
44 
45  // Include Rayleigh damping (separate flags for each variable)
46  pp.query("rayleigh_damp_U", rayleigh_damp_U);
47  pp.query("rayleigh_damp_V", rayleigh_damp_V);
48  pp.query("rayleigh_damp_W", rayleigh_damp_W);
49  pp.query("rayleigh_damp_T", rayleigh_damp_T);
50  pp.query("rayleigh_dampcoef", rayleigh_dampcoef);
51  pp.query("rayleigh_zdamp", rayleigh_zdamp);
52 
53  if (pp.countval("rayleigh_damp_substep") > 0) {
54  amrex::Abort("The input rayleigh_damp_substep is deprecated. Set rayleigh_damping_type instead.");
55  }
56 
57  // Include vertical-velocity damping to improve robustness
58  pp.query("w_damping", w_damping);
59  pp.query("w_damping_cfl", w_damping_cfl);
60  pp.query("w_damping_const", w_damping_const);
61  pp.query("w_damping_coeff", w_damping_coeff);
62 
63  if (w_damping && (w_damping_const < 0 && w_damping_coeff < 0)) {
64  amrex::Abort("Need to specify vertical damping coefficient w_damping_const (like WRF) or w_damping_coeff (~ dz/dt**2)");
65  }
66  }
67 
68  /**
69  * @brief Print the configured damping options.
70  */
71  void display()
72  {
73  amrex::Print() << "Rayleigh damping :";
75  if (rayleigh_damp_U) amrex::Print() << " U";
76  if (rayleigh_damp_V) amrex::Print() << " V";
77  if (rayleigh_damp_W) amrex::Print() << " W";
78  if (rayleigh_damp_T) amrex::Print() << " T";
79  amrex::Print() << " (coef=" << rayleigh_dampcoef << " 1/s,"
80  << " depth=" << rayleigh_zdamp << " m)"
81  << std::endl;
82  } else {
83  amrex::Print() << " None" << std::endl;
84  }
85 
86  amrex::Print() << "w damping : " << w_damping;
87  if (w_damping_const > 0) {
88  amrex::Print() << " (coeff = " << w_damping_const << ")" << std::endl;
89  } else {
90  amrex::Print() << " (coeff = " << w_damping_coeff << " * dz/dt**2)" << std::endl;
91  }
92  }
93 
94  bool rayleigh_damp_U = false;
95  bool rayleigh_damp_V = false;
96  bool rayleigh_damp_W = false;
97  bool rayleigh_damp_T = false;
98  amrex::Real rayleigh_dampcoef = amrex::Real(0.2); // inverse time scale [1/s]
99  amrex::Real rayleigh_zdamp = amrex::Real(500.0); // damping layer depth [m]
101 
102  bool w_damping = false;
103  amrex::Real w_damping_cfl = one; // from WRF manual -- WRF source code has default
104  // w_crit_cfl=amrex::Real(1.2)
105  amrex::Real w_damping_const = -1; // damping coefficient -- to used a constant value
106  // (WRF uses amrex::Real(0.3) m/s2), set to a positive value;
107  // otherwise, the damping coefficient will be
108  amrex::Real w_damping_coeff = -1; // grid-dependent: coeff * dz/dt**2
109 
110  // Molecular transport model
112 };
113 
114 /**
115  * @var DampingChoice::rayleigh_damp_U
116  * @brief Whether Rayleigh damping is applied to x-momentum.
117  * @var DampingChoice::rayleigh_damp_V
118  * @brief Whether Rayleigh damping is applied to y-momentum.
119  * @var DampingChoice::rayleigh_damp_W
120  * @brief Whether Rayleigh damping is applied to vertical momentum.
121  * @var DampingChoice::rayleigh_damp_T
122  * @brief Whether Rayleigh damping is applied to potential temperature.
123  * @var DampingChoice::rayleigh_dampcoef
124  * @brief Rayleigh damping inverse time scale [1/s].
125  * @var DampingChoice::rayleigh_zdamp
126  * @brief Rayleigh damping layer depth [m].
127  * @var DampingChoice::rayleigh_ztop
128  * @brief Top of the Rayleigh damping layer [m].
129  * @var DampingChoice::w_damping
130  * @brief Whether vertical-velocity damping is enabled.
131  * @var DampingChoice::w_damping_cfl
132  * @brief CFL threshold used by vertical-velocity damping.
133  * @var DampingChoice::w_damping_const
134  * @brief Constant vertical damping coefficient.
135  * @var DampingChoice::w_damping_coeff
136  * @brief Grid-dependent vertical damping coefficient multiplier.
137  * @var DampingChoice::rayleigh_damping_type
138  * @brief Selected Rayleigh damping time-integration treatment.
139  */
140 #endif
constexpr amrex::Real one
Definition: ERF_Constants.H:9
RayleighDampingType
Time integration treatment used for Rayleigh damping.
Definition: ERF_DampingStruct.H:14
ParmParse pp("prob")
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_DampingStruct.H:22
RayleighDampingType rayleigh_damping_type
Selected Rayleigh damping time-integration treatment.
Definition: ERF_DampingStruct.H:111
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:98
bool rayleigh_damp_U
Whether Rayleigh damping is applied to x-momentum.
Definition: ERF_DampingStruct.H:94
bool rayleigh_damp_V
Whether Rayleigh damping is applied to y-momentum.
Definition: ERF_DampingStruct.H:95
bool rayleigh_damp_W
Whether Rayleigh damping is applied to vertical momentum.
Definition: ERF_DampingStruct.H:96
amrex::Real rayleigh_zdamp
Rayleigh damping layer depth [m].
Definition: ERF_DampingStruct.H:99
bool w_damping
Whether vertical-velocity damping is enabled.
Definition: ERF_DampingStruct.H:102
amrex::Real rayleigh_ztop
Top of the Rayleigh damping layer [m].
Definition: ERF_DampingStruct.H:100
bool rayleigh_damp_T
Whether Rayleigh damping is applied to potential temperature.
Definition: ERF_DampingStruct.H:97
void display()
Print the configured damping options.
Definition: ERF_DampingStruct.H:71
amrex::Real w_damping_cfl
CFL threshold used by vertical-velocity damping.
Definition: ERF_DampingStruct.H:103
amrex::Real w_damping_const
Constant vertical damping coefficient.
Definition: ERF_DampingStruct.H:105
amrex::Real w_damping_coeff
Grid-dependent vertical damping coefficient multiplier.
Definition: ERF_DampingStruct.H:108