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 enum struct RayleighDampingType {
13 };
14 
15 /**
16  * Container holding damping-related choices
17  */
18 
19 struct DampingChoice {
20  public:
21  void init_params(std::string pp_prefix)
22  {
23  amrex::ParmParse pp(pp_prefix);
24 
25  static std::string rayleigh_type_string = "SlowExplicit";
26  pp.query("rayleigh_damping_type",rayleigh_type_string);
27 
28  if (!rayleigh_type_string.compare("SlowExplicit")) {
30  } else if (!rayleigh_type_string.compare("FastExplicit")) {
32  } else if (!rayleigh_type_string.compare("FastImplicit")) {
34  } else {
35  amrex::Error("Don't know this rayleigh_damping_type");
36  }
37 
38  // Include Rayleigh damping (separate flags for each variable)
39  pp.query("rayleigh_damp_U", rayleigh_damp_U);
40  pp.query("rayleigh_damp_V", rayleigh_damp_V);
41  pp.query("rayleigh_damp_W", rayleigh_damp_W);
42  pp.query("rayleigh_damp_T", rayleigh_damp_T);
43  pp.query("rayleigh_dampcoef", rayleigh_dampcoef);
44  pp.query("rayleigh_zdamp", rayleigh_zdamp);
45 
46  if (pp.countval("rayleigh_damp_substep") > 0) {
47  amrex::Abort("The input rayleigh_damp_substep is deprecated. Set rayleigh_damping_type instead.");
48  }
49 
50  // Include vertical-velocity damping to improve robustness
51  pp.query("w_damping", w_damping);
52  pp.query("w_damping_cfl", w_damping_cfl);
53  pp.query("w_damping_const", w_damping_const);
54  pp.query("w_damping_coeff", w_damping_coeff);
55 
56  if (w_damping && (w_damping_const < 0 && w_damping_coeff < 0)) {
57  amrex::Abort("Need to specify vertical damping coefficient w_damping_const (like WRF) or w_damping_coeff (~ dz/dt**2)");
58  }
59  }
60 
61  void display()
62  {
63  amrex::Print() << "Rayleigh damping :";
65  if (rayleigh_damp_U) amrex::Print() << " U";
66  if (rayleigh_damp_V) amrex::Print() << " V";
67  if (rayleigh_damp_W) amrex::Print() << " W";
68  if (rayleigh_damp_T) amrex::Print() << " T";
69  amrex::Print() << " (coef=" << rayleigh_dampcoef << " 1/s,"
70  << " depth=" << rayleigh_zdamp << " m)"
71  << std::endl;
72  } else {
73  amrex::Print() << " None" << std::endl;
74  }
75 
76  amrex::Print() << "w damping : " << w_damping;
77  if (w_damping_const > 0) {
78  amrex::Print() << " (coeff = " << w_damping_const << ")" << std::endl;
79  } else {
80  amrex::Print() << " (coeff = " << w_damping_coeff << " * dz/dt**2)" << std::endl;
81  }
82  }
83 
84  bool rayleigh_damp_U = false;
85  bool rayleigh_damp_V = false;
86  bool rayleigh_damp_W = false;
87  bool rayleigh_damp_T = false;
88  amrex::Real rayleigh_dampcoef = 0.2; // inverse time scale [1/s]
89  amrex::Real rayleigh_zdamp = 500.0; // damping layer depth [m]
91 
92  bool w_damping = false;
93  amrex::Real w_damping_cfl = 1.0; // from WRF manual -- WRF source code has default
94  // w_crit_cfl=1.2
95  amrex::Real w_damping_const = -1; // damping coefficient -- to used a constant value
96  // (WRF uses 0.3 m/s2), set to a positive value;
97  // otherwise, the damping coefficient will be
98  amrex::Real w_damping_coeff = -1; // grid-dependent: coeff * dz/dt**2
99 
100  // Molecular transport model
102 };
103 #endif
RayleighDampingType
Definition: ERF_DampingStruct.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:233
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_DampingStruct.H:19
bool rayleigh_damp_V
Definition: ERF_DampingStruct.H:85
void init_params(std::string pp_prefix)
Definition: ERF_DampingStruct.H:21
amrex::Real rayleigh_ztop
Definition: ERF_DampingStruct.H:90
amrex::Real w_damping_coeff
Definition: ERF_DampingStruct.H:98
bool rayleigh_damp_T
Definition: ERF_DampingStruct.H:87
amrex::Real rayleigh_dampcoef
Definition: ERF_DampingStruct.H:88
bool rayleigh_damp_W
Definition: ERF_DampingStruct.H:86
RayleighDampingType rayleigh_damping_type
Definition: ERF_DampingStruct.H:101
bool rayleigh_damp_U
Definition: ERF_DampingStruct.H:84
bool w_damping
Definition: ERF_DampingStruct.H:92
amrex::Real rayleigh_zdamp
Definition: ERF_DampingStruct.H:89
amrex::Real w_damping_cfl
Definition: ERF_DampingStruct.H:93
amrex::Real w_damping_const
Definition: ERF_DampingStruct.H:95
void display()
Definition: ERF_DampingStruct.H:61