ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_SurfaceLayer.H
Go to the documentation of this file.
1 #ifndef ERF_SURFACELAYER_H
2 #define ERF_SURFACELAYER_H
3 
4 #include "AMReX_Geometry.H"
5 #include "AMReX_ParmParse.H"
6 #include "AMReX_FArrayBox.H"
7 #include "AMReX_MultiFab.H"
8 #include "AMReX_iMultiFab.H"
9 #include "AMReX_Interpolater.H"
10 
11 #include "ERF_IndexDefines.H"
12 #include "ERF_Constants.H"
13 #include "ERF_MOSTAverage.H"
14 #include "ERF_MOSTStress.H"
15 #include "ERF_TerrainMetrics.H"
16 #include "ERF_PBLHeight.H"
17 
18 /** Abstraction layer for different surface layer schemes (e.g. MOST, Cd)
19  *
20  * van der Laan, P., Kelly, M. C., & Sørensen, N. N. (2017). A new k-epsilon
21  * model consistent with Monin-Obukhov similarity theory. Wind Energy,
22  * 20(3), 479–489. https://doi.org/10.1002/we.2017
23  *
24  * Consistent with Dyer (1974) formulation from page 57, Chapter 2, Modeling
25  * the vertical ABL structure in Modelling of Atmospheric Flow Fields,
26  * Demetri P Lalas and Corrado F Ratto, January 1996,
27  * https://doi.org/10.1142/2975.
28  */
30 {
31 
32 public:
33  // Constructor
34  explicit SurfaceLayer (const amrex::Vector<amrex::Geometry>& geom,
35  bool& use_rot_surface_flux,
36  std::string a_pp_prefix,
37  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
38  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& z_phys_nd,
39  const TerrainType& a_terrain_type,
40  amrex::Real start_bdy_time = 0.0,
41  amrex::Real bdy_time_interval = 0.0)
42  : m_geom(geom),
43  m_rotate(use_rot_surface_flux),
44  m_start_bdy_time(start_bdy_time),
45  m_bdy_time_interval(bdy_time_interval),
46  m_ma(geom, (z_phys_nd[0] != nullptr), a_pp_prefix, a_terrain_type)
47  {
48  // We have a moisture model if Qv_prim is a valid pointer
49  use_moisture = (Qv_prim[0].get());
50 
51  // Get roughness
52  amrex::ParmParse pp("erf");
53  pp.query("most.z0", z0_const);
54 
55  // Specify how to compute the flux
56  if (use_rot_surface_flux) {
58  } else {
59  std::string flux_string_in;
60  std::string flux_string{"moeng"};
61  auto read_flux = pp.query("surface_layer.flux_type", flux_string_in);
62  if (read_flux) {
63  flux_string = amrex::toLower(flux_string_in);
64  }
65  if (flux_string == "donelan") {
67  } else if (flux_string == "moeng") {
69  } else if (flux_string == "custom") {
71  } else {
72  amrex::Abort("Undefined MOST flux type!");
73  }
74  }
75 
76  // Include w* to handle free convection (Beljaars 1995, QJRMS)
77  pp.query("most.include_wstar", m_include_wstar);
78 
79  std::string pblh_string_in;
80  std::string pblh_string{"none"};
81  auto read_pblh = pp.query("most.pblh_calc", pblh_string_in);
82  if (read_pblh) {
83  pblh_string = amrex::toLower(pblh_string_in);
84  }
85  if (pblh_string == "none") {
87  } else if (pblh_string == "mynn25") {
89  } else if (pblh_string == "mynnedmf") {
91  } else if (pblh_string == "ysu") {
93  } else if (pblh_string == "mrf") {
95  } else {
96  amrex::Abort("Undefined PBLH calc type!");
97  }
98 
99  // Get surface temperature
100  auto erf_st = pp.query("most.surf_temp", surf_temp);
101  if (erf_st) { default_land_surf_temp = surf_temp; }
102 
103  // Get surface moisture
104  bool erf_sq = false;
105  if (use_moisture) { erf_sq = pp.query("most.surf_moist", surf_moist); }
106  if (erf_sq) { default_land_surf_moist = surf_moist; }
107 
108  // Custom type user must specify the fluxes
112  pp.query("most.ustar", custom_ustar);
113  pp.query("most.tstar", custom_tstar);
114  pp.query("most.qstar", custom_qstar);
115  if (custom_qstar != 0) {
116  AMREX_ASSERT_WITH_MESSAGE(use_moisture,
117  "Specified custom MOST qv flux without moisture model!");
118  }
119  amrex::Print() << "Using specified ustar, tstar, qstar for MOST = "
120  << custom_ustar << " " << custom_tstar << " "
121  << custom_qstar << std::endl;
122 
123  // Specify surface temperature/moisture or surface flux
124  } else {
125  if (erf_st) {
127  pp.query("most.surf_heating_rate", surf_heating_rate); // [K/h]
128  surf_heating_rate = surf_heating_rate / 3600.0; // [K/s]
129  if (pp.query("most.surf_temp_flux", surf_temp_flux)) {
130  amrex::Abort("Can only specify one of surf_temp_flux or surf_heating_rate");
131  }
132  } else {
133  pp.query("most.surf_temp_flux", surf_temp_flux);
134 
135  if (pp.query("most.surf_heating_rate", surf_heating_rate)) {
136  amrex::Abort("Can only specify one of surf_temp_flux or surf_heating_rate");
137  }
138  if (std::abs(surf_temp_flux) >
141  } else {
143  }
144 
145  }
146 
147  if (erf_sq) {
149  } else {
150  pp.query("most.surf_moist_flux", surf_moist_flux);
151  if (std::abs(surf_moist_flux) >
154  } else {
156  }
157  }
158  }
159 
160  // Make sure the inputs file doesn't try to use most.roughness_type
161  std::string bogus_input;
162  if (pp.query("most.roughness_type", bogus_input) > 0) {
163  amrex::Abort("most.roughness_type is deprecated; use "
164  "most.roughness_type_land and/or most.roughness_type_sea");
165  }
166 
167  // Specify how to compute the surface flux over land (if there is any)
168  std::string rough_land_string_in;
169  std::string rough_land_string{"constant"};
170  auto read_rough_land =
171  pp.query("most.roughness_type_land", rough_land_string_in);
172  if (read_rough_land) {
173  rough_land_string = amrex::toLower(rough_land_string_in);
174  }
175  if (rough_land_string == "constant") {
177  } else {
178  amrex::Abort("Undefined MOST roughness type for land!");
179  }
180 
181  // Specify how to compute the surface flux over sea (if there is any)
182  std::string rough_sea_string_in;
183  std::string rough_sea_string{"charnock"};
184  auto read_rough_sea = pp.query("most.roughness_type_sea", rough_sea_string_in);
185  if (read_rough_sea) {
186  rough_sea_string = amrex::toLower(rough_sea_string_in);
187  }
188  if (rough_sea_string == "charnock") {
190  pp.query("most.charnock_constant", cnk_a);
191  pp.query("most.charnock_viscosity", cnk_visc);
192  if (cnk_a > 0) {
193  amrex::Print() << "If there is water, Charnock relation with C_a="
194  << cnk_a << (cnk_visc ? " and viscosity" : "")
195  << " will be used" << std::endl;
196  } else {
197  amrex::Print() << "If there is water, Charnock relation with variable "
198  "Charnock parameter (COARE3.0)"
199  << (cnk_visc ? " and viscosity" : "") << " will be used"
200  << std::endl;
201  }
202  } else if (rough_sea_string == "coare3.0") {
204  amrex::Print() << "If there is water, Charnock relation with variable "
205  "Charnock parameter (COARE3.0)"
206  << (cnk_visc ? " and viscosity" : "") << " will be used"
207  << std::endl;
208  cnk_a = -1;
209  } else if (rough_sea_string == "donelan") {
211  } else if (rough_sea_string == "modified_charnock") {
213  pp.query("most.modified_charnock_depth", depth);
214  } else if (rough_sea_string == "wave_coupled") {
216  } else if (rough_sea_string == "constant") {
218  } else {
219  amrex::Abort("Undefined MOST roughness type for sea!");
220  }
221  } // constructor
222 
223  void make_SurfaceLayer_at_level (const int& lev,
224  int nlevs,
225  const amrex::Vector<amrex::MultiFab*>& mfv,
226  std::unique_ptr<amrex::MultiFab>& Theta_prim,
227  std::unique_ptr<amrex::MultiFab>& Qv_prim,
228  std::unique_ptr<amrex::MultiFab>& Qr_prim,
229  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
230  amrex::MultiFab* Hwave,
231  amrex::MultiFab* Lwave,
232  amrex::MultiFab* eddyDiffs,
233  amrex::Vector<amrex::MultiFab*> lsm_data,
234  amrex::Vector<amrex::MultiFab*> lsm_flux,
235  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& sst_lev,
236  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& tsk_lev,
237  amrex::Vector<std::unique_ptr<amrex::iMultiFab>>& lmask_lev)
238  {
239  // Update MOST Average
241  Theta_prim, Qv_prim, Qr_prim,
242  z_phys_nd);
243 
244  // Get CC vars
245  amrex::MultiFab& mf = *(mfv[0]);
246 
247  amrex::ParmParse pp("erf");
248 
249  // Do we have a time-varying surface roughness that needs to be saved?
250  if (lev == 0) {
251  const int nghost = 0; // ghost cells not included
252  int lmask_min = lmask_min_reduce(*lmask_lev[0].get(), nghost);
253  amrex::ParallelDescriptor::ReduceIntMin(lmask_min);
254 
255  m_var_z0 = (lmask_min < 1) & (rough_type_sea != RoughCalcType::CONSTANT);
256  if (m_var_z0) {
257  std::string rough_sea_string{"charnock"};
258  pp.query("most.roughness_type_sea", rough_sea_string);
259  amrex::Print() << "Variable sea roughness (type " << rough_sea_string
260  << ")" << std::endl;
261  }
262  }
263 
264  if ((lev == 0) || (lev > nlevs - 1)) {
265  m_Hwave_lev.resize(nlevs);
266  m_Lwave_lev.resize(nlevs);
267  m_eddyDiffs_lev.resize(nlevs);
268 
269  m_lsm_data_lev.resize(nlevs);
270  m_lsm_flux_lev.resize(nlevs);
271 
272  m_sst_lev.resize(nlevs);
273  m_tsk_lev.resize(nlevs);
274  m_lmask_lev.resize(nlevs);
275 
276  // Size the MOST params for all levels
277  z_0.resize(nlevs);
278  u_star.resize(nlevs);
279  w_star.resize(nlevs);
280  t_star.resize(nlevs);
281  q_star.resize(nlevs);
282  t_surf.resize(nlevs);
283  q_surf.resize(nlevs);
284  olen.resize(nlevs);
285  pblh.resize(nlevs);
286  }
287 
288  // Get pointers to SST,TSK and LANDMASK data
289  int nt_tot_sst = sst_lev.size();
290  m_sst_lev[lev].resize(nt_tot_sst);
291  for (int nt(0); nt < nt_tot_sst; ++nt) {
292  m_sst_lev[lev][nt] = sst_lev[nt].get();
293  }
294  int nt_tot_tsk = tsk_lev.size();
295  m_tsk_lev[lev].resize(nt_tot_tsk);
296  for (int nt(0); nt < nt_tot_tsk; ++nt) {
297  m_tsk_lev[lev][nt] = tsk_lev[nt].get();
298  }
299  int nt_tot_lmask = lmask_lev.size();
300  m_lmask_lev[lev].resize(nt_tot_lmask);
301  for (int nt(0); nt < nt_tot_lmask; ++nt) {
302  m_lmask_lev[lev][nt] = lmask_lev[nt].get();
303  }
304 
305  // Get pointers to wave data
306  m_Hwave_lev[lev] = Hwave;
307  m_Lwave_lev[lev] = Lwave;
308  m_eddyDiffs_lev[lev] = eddyDiffs;
309 
310  // Get pointers to LSM data and Fluxes
311  int nvar = lsm_data.size();
312  m_lsm_data_lev[lev].resize(nvar);
313  m_lsm_flux_lev[lev].resize(nvar);
314  for (int n(0); n < nvar; ++n) {
315  m_lsm_data_lev[lev][n] = lsm_data[n];
316  m_lsm_flux_lev[lev][n] = lsm_flux[n];
317  }
318 
319  // Check if there is a user-specified roughness file to be read
320  std::string fname;
321  bool read_z0 = false;
322  if ( (flux_type == FluxCalcType::MOENG) ||
324  read_z0 = pp.query("most.roughness_file_name", fname);
325  }
326 
327  // Attributes for MFs and FABs
328  //--------------------------------------------------------
329  // Create a 2D ba, dm, & ghost cells
330  amrex::BoxArray ba = mf.boxArray();
331  amrex::BoxList bl2d = ba.boxList();
332  for (auto& b : bl2d) {
333  b.setRange(2, 0);
334  }
335  amrex::BoxArray ba2d(std::move(bl2d));
336  const amrex::DistributionMapping& dm = mf.DistributionMap();
337  const int ncomp = 1;
338  amrex::IntVect ng = mf.nGrowVect();
339  ng[2] = 0;
340 
341  // Z0 heights FAB
342  //--------------------------------------------------------
343  amrex::Arena* Arena_Used = amrex::The_Arena();
344 #ifdef AMREX_USE_GPU
345  Arena_Used = amrex::The_Pinned_Arena();
346 #endif
347  amrex::Box bx = amrex::grow(m_geom[lev].Domain(), ng);
348  bx.setSmall(2, 0);
349  bx.setBig(2, 0);
350  z_0[lev].resize(bx, 1, Arena_Used);
351  z_0[lev].setVal<amrex::RunOn::Device>(z0_const);
352  if (read_z0) {
353  read_custom_roughness(lev, fname);
354  }
355 
356  // 2D MFs for U*, T*, T_surf
357  //--------------------------------------------------------
358  u_star[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
359  u_star[lev]->setVal(1.E34);
360 
361  w_star[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
362  w_star[lev]->setVal(1.E34);
363 
364  t_star[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
365  t_star[lev]->setVal(0.0); // default to neutral
366 
367  q_star[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
368  q_star[lev]->setVal(0.0); // default to dry
369 
370  olen[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
371  olen[lev]->setVal(1.E34);
372 
373  pblh[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
374  pblh[lev]->setVal(1.E34);
375 
376  t_surf[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
377  t_surf[lev]->setVal(default_land_surf_temp);
378 
379  q_surf[lev] = std::make_unique<amrex::MultiFab>(ba2d, dm, ncomp, ng);
380  q_surf[lev]->setVal(default_land_surf_moist);
381 
382  // TODO: Do we want lsm_data to have theta at 0 index always?
383  // Do we want an external enum struct for indexing?
384  if (m_sst_lev[lev][0] || m_tsk_lev[lev][0] || m_lsm_data_lev[lev][0]) {
385  // Valid SST, TSK or LSM data; t_surf set before computing fluxes (avoids
386  // extended lambda capture) Note that land temp will be set from m_tsk_lev
387  // while sea temp will be set from m_sst_lev
389  }
390 
391 
392  }
393 
394  void
395  update_fluxes (const int& lev,
396  const amrex::Real& time,
397  int max_iters = 500);
398 
399  template <typename FluxIter>
400  void compute_fluxes (const int& lev,
401  const int& max_iters,
402  const FluxIter& most_flux,
403  bool is_land);
404 
405  void impose_SurfaceLayer_bcs (const int& lev,
406  amrex::Vector<const amrex::MultiFab*> mfs,
407  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_lev,
408  amrex::MultiFab* xheat_flux,
409  amrex::MultiFab* yheat_flux,
410  amrex::MultiFab* zheat_flux,
411  amrex::MultiFab* xqv_flux,
412  amrex::MultiFab* yqv_flux,
413  amrex::MultiFab* zqv_flux,
414  const amrex::MultiFab* z_phys);
415 
416  template <typename FluxCalc>
417  void compute_SurfaceLayer_bcs (const int& lev,
418  amrex::Vector<const amrex::MultiFab*> mfs,
419  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Tau_lev,
420  amrex::MultiFab* xheat_flux,
421  amrex::MultiFab* yheat_flux,
422  amrex::MultiFab* zheat_flux,
423  amrex::MultiFab* xqv_flux,
424  amrex::MultiFab* yqv_flux,
425  amrex::MultiFab* zqv_flux,
426  const amrex::MultiFab* z_phys,
427  const FluxCalc& flux_comp);
428 
429  void fill_tsurf_with_sst_and_tsk (const int& lev,
430  const amrex::Real& time);
431 
432  void get_lsm_tsurf (const int& lev);
433 
434  /* wrapper around compute_pblh */
435  void update_pblh (const int& lev,
436  amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars,
437  amrex::MultiFab* z_phys_cc,
438  const int RhoQv_comp,
439  const int RhoQc_comp,
440  const int RhoQr_comp);
441 
442  template <typename PBLHeightEstimator>
443  void compute_pblh (const int& lev,
444  amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars,
445  amrex::MultiFab* z_phys_cc,
446  const PBLHeightEstimator& est,
447  const int RhoQv_comp,
448  const int RhoQc_comp,
449  const int RhoQr_comp);
450 
451  void read_custom_roughness (const int& lev,
452  const std::string& fname);
453 
454  void update_surf_temp (const amrex::Real& time)
455  {
456  if (surf_heating_rate != 0) {
457  int nlevs = m_geom.size();
458  for (int lev = 0; lev < nlevs; lev++) {
459  t_surf[lev]->setVal(surf_temp + surf_heating_rate * time);
460  amrex::Print() << "Surface temp at t=" << time << ": "
461  << surf_temp + surf_heating_rate * time << std::endl;
462  }
463  }
464  }
465 
466  void update_mac_ptrs (const int& lev,
467  amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_old,
468  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Theta_prim,
469  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qv_prim,
470  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& Qr_prim)
471  {
472  m_ma.update_field_ptrs(lev, vars_old, Theta_prim, Qv_prim, Qr_prim);
473  }
474 
475  amrex::MultiFab* get_u_star (const int& lev) { return u_star[lev].get(); }
476 
477  amrex::MultiFab* get_w_star (const int& lev) { return w_star[lev].get(); }
478 
479  amrex::MultiFab* get_t_star (const int& lev) { return t_star[lev].get(); }
480 
481  amrex::MultiFab* get_q_star (const int& lev) { return q_star[lev].get(); }
482 
483  amrex::MultiFab* get_olen (const int& lev) { return olen[lev].get(); }
484 
485  amrex::MultiFab* get_pblh (const int& lev) { return pblh[lev].get(); }
486 
487  const amrex::MultiFab* get_mac_avg (const int& lev, int comp)
488  {
489  return m_ma.get_average(lev, comp);
490  }
491 
492  amrex::MultiFab* get_t_surf (const int& lev) { return t_surf[lev].get(); }
493 
494  amrex::MultiFab* get_q_surf (const int& lev) { return q_surf[lev].get(); }
495 
496  amrex::Real get_zref () { return m_ma.get_zref(); }
497 
498  amrex::FArrayBox* get_z0 (const int& lev) { return &z_0[lev]; }
499 
501 
502  amrex::iMultiFab* get_lmask (const int& lev) { return m_lmask_lev[lev][0]; }
503 
504  int lmask_min_reduce (amrex::iMultiFab& lmask,
505  const int& nghost)
506  {
507  int lmask_min = amrex::ReduceMin(lmask, nghost, [=] AMREX_GPU_HOST_DEVICE(
508  amrex::Box const& bx, amrex::Array4<int const> const& lm_arr) -> int
509  {
510  int locmin = std::numeric_limits<int>::max();
511  const auto lo = lbound(bx);
512  const auto hi = ubound(bx);
513  for (int j = lo.y; j <= hi.y; ++j) {
514  for (int i = lo.x; i <= hi.x; ++i) {
515  locmin = std::min(locmin, lm_arr(i, j, 0));
516  }
517  }
518  return locmin;
519  });
520 
521  return lmask_min;
522  }
523 
524  enum struct FluxCalcType {
525  MOENG = 0, ///< Moeng functional form
526  DONELAN, ///< Donelan functional form
527  CUSTOM, ///< Custom constant flux functional form
528  ROTATE ///< Terrain rotation flux functional form
529  };
530 
531  enum struct ThetaCalcType {
532  ADIABATIC = 0,
533  HEAT_FLUX, ///< Heat-flux specified
534  SURFACE_TEMPERATURE ///< Surface temperature specified
535  };
536 
537  enum struct MoistCalcType {
538  ADIABATIC = 0,
539  MOISTURE_FLUX, ///< Qv-flux specified
540  SURFACE_MOISTURE ///< Surface Qv specified
541  };
542 
543  enum struct RoughCalcType {
544  CONSTANT = 0, ///< Constant z0
545  CHARNOCK,
547  DONELAN,
549  };
550 
551  enum struct PBLHeightCalcType { None, MYNN25, YSU, MRF };
552 
559 
560 private:
561  // Set in constructor
562  amrex::Vector<amrex::Geometry> m_geom;
563  bool m_rotate = false;
564  amrex::Real m_start_bdy_time;
565  amrex::Real m_bdy_time_interval;
566 
567  bool m_include_wstar = false;
568  amrex::Real z0_const{0.1};
569  amrex::Real default_land_surf_temp{300.};
570  amrex::Real surf_temp;
571  amrex::Real surf_heating_rate{0};
572  amrex::Real surf_temp_flux{0};
573  amrex::Real default_land_surf_moist{0.};
574  amrex::Real surf_moist;
575  amrex::Real surf_moist_flux{0};
576  amrex::Real custom_ustar{0};
577  amrex::Real custom_tstar{0};
578  amrex::Real custom_qstar{0};
579  amrex::Real cnk_a{0.0185};
580  bool cnk_visc{false};
581  amrex::Real depth{30.0};
582  amrex::Vector<amrex::FArrayBox> z_0;
583  bool m_var_z0{false};
584 
586 
588  amrex::Vector<std::unique_ptr<amrex::MultiFab>> u_star;
589  amrex::Vector<std::unique_ptr<amrex::MultiFab>> w_star;
590  amrex::Vector<std::unique_ptr<amrex::MultiFab>> t_star;
591  amrex::Vector<std::unique_ptr<amrex::MultiFab>> q_star;
592  amrex::Vector<std::unique_ptr<amrex::MultiFab>> olen;
593  amrex::Vector<std::unique_ptr<amrex::MultiFab>> pblh;
594  amrex::Vector<std::unique_ptr<amrex::MultiFab>> t_surf;
595  amrex::Vector<std::unique_ptr<amrex::MultiFab>> q_surf;
596 
597  amrex::Vector<amrex::Vector<amrex::MultiFab*>> m_sst_lev;
598  amrex::Vector<amrex::Vector<amrex::MultiFab*>> m_tsk_lev;
599  amrex::Vector<amrex::Vector<amrex::iMultiFab*>> m_lmask_lev;
600  amrex::Vector<amrex::Vector<amrex::MultiFab*>> m_lsm_data_lev;
601  amrex::Vector<amrex::Vector<amrex::MultiFab*>> m_lsm_flux_lev;
602  amrex::Vector<amrex::MultiFab*> m_Hwave_lev;
603  amrex::Vector<amrex::MultiFab*> m_Lwave_lev;
604  amrex::Vector<amrex::MultiFab*> m_eddyDiffs_lev;
605 };
606 
607 #endif /* SURFACELAYER_H */
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:230
Definition: ERF_MOSTAverage.H:14
amrex::Real get_zref() const
Definition: ERF_MOSTAverage.H:104
const amrex::MultiFab * get_average(const int &lev, const int &comp) const
Definition: ERF_MOSTAverage.H:101
void update_field_ptrs(const int &lev, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars_old, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Theta_prim, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Qv_prim, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Qr_prim)
Definition: ERF_MOSTAverage.cpp:246
void make_MOSTAverage_at_level(const int &lev, const amrex::Vector< amrex::MultiFab * > &vars_old, std::unique_ptr< amrex::MultiFab > &Theta_prim, std::unique_ptr< amrex::MultiFab > &Qv_prim, std::unique_ptr< amrex::MultiFab > &Qr_prim, std::unique_ptr< amrex::MultiFab > &z_phys_nd)
Definition: ERF_MOSTAverage.cpp:70
Definition: ERF_SurfaceLayer.H:30
ThetaCalcType theta_type
Definition: ERF_SurfaceLayer.H:554
int lmask_min_reduce(amrex::iMultiFab &lmask, const int &nghost)
Definition: ERF_SurfaceLayer.H:504
bool m_include_wstar
Definition: ERF_SurfaceLayer.H:567
bool m_rotate
Definition: ERF_SurfaceLayer.H:563
void compute_pblh(const int &lev, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars, amrex::MultiFab *z_phys_cc, const PBLHeightEstimator &est, const int RhoQv_comp, const int RhoQc_comp, const int RhoQr_comp)
PBLHeightCalcType pblh_type
Definition: ERF_SurfaceLayer.H:558
amrex::Vector< amrex::Vector< amrex::iMultiFab * > > m_lmask_lev
Definition: ERF_SurfaceLayer.H:599
amrex::iMultiFab * get_lmask(const int &lev)
Definition: ERF_SurfaceLayer.H:502
bool use_moisture
Definition: ERF_SurfaceLayer.H:585
amrex::MultiFab * get_q_surf(const int &lev)
Definition: ERF_SurfaceLayer.H:494
SurfaceLayer(const amrex::Vector< amrex::Geometry > &geom, bool &use_rot_surface_flux, std::string a_pp_prefix, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Qv_prim, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &z_phys_nd, const TerrainType &a_terrain_type, amrex::Real start_bdy_time=0.0, amrex::Real bdy_time_interval=0.0)
Definition: ERF_SurfaceLayer.H:34
amrex::MultiFab * get_w_star(const int &lev)
Definition: ERF_SurfaceLayer.H:477
void update_surf_temp(const amrex::Real &time)
Definition: ERF_SurfaceLayer.H:454
RoughCalcType rough_type_land
Definition: ERF_SurfaceLayer.H:556
amrex::Vector< std::unique_ptr< amrex::MultiFab > > t_surf
Definition: ERF_SurfaceLayer.H:594
amrex::Real z0_const
Definition: ERF_SurfaceLayer.H:568
amrex::Real cnk_a
Definition: ERF_SurfaceLayer.H:579
amrex::Vector< amrex::FArrayBox > z_0
Definition: ERF_SurfaceLayer.H:582
void update_pblh(const int &lev, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars, amrex::MultiFab *z_phys_cc, const int RhoQv_comp, const int RhoQc_comp, const int RhoQr_comp)
Definition: ERF_SurfaceLayer.cpp:551
amrex::Real surf_temp
Definition: ERF_SurfaceLayer.H:570
void update_mac_ptrs(const int &lev, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars_old, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Theta_prim, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Qv_prim, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Qr_prim)
Definition: ERF_SurfaceLayer.H:466
void make_SurfaceLayer_at_level(const int &lev, int nlevs, const amrex::Vector< amrex::MultiFab * > &mfv, std::unique_ptr< amrex::MultiFab > &Theta_prim, std::unique_ptr< amrex::MultiFab > &Qv_prim, std::unique_ptr< amrex::MultiFab > &Qr_prim, std::unique_ptr< amrex::MultiFab > &z_phys_nd, amrex::MultiFab *Hwave, amrex::MultiFab *Lwave, amrex::MultiFab *eddyDiffs, amrex::Vector< amrex::MultiFab * > lsm_data, amrex::Vector< amrex::MultiFab * > lsm_flux, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &sst_lev, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &tsk_lev, amrex::Vector< std::unique_ptr< amrex::iMultiFab >> &lmask_lev)
Definition: ERF_SurfaceLayer.H:223
amrex::Vector< std::unique_ptr< amrex::MultiFab > > q_star
Definition: ERF_SurfaceLayer.H:591
amrex::Real m_start_bdy_time
Definition: ERF_SurfaceLayer.H:564
amrex::Vector< amrex::MultiFab * > m_Lwave_lev
Definition: ERF_SurfaceLayer.H:603
void get_lsm_tsurf(const int &lev)
Definition: ERF_SurfaceLayer.cpp:518
amrex::MultiFab * get_olen(const int &lev)
Definition: ERF_SurfaceLayer.H:483
amrex::Real surf_moist_flux
Definition: ERF_SurfaceLayer.H:575
void compute_SurfaceLayer_bcs(const int &lev, amrex::Vector< const amrex::MultiFab * > mfs, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_lev, amrex::MultiFab *xheat_flux, amrex::MultiFab *yheat_flux, amrex::MultiFab *zheat_flux, amrex::MultiFab *xqv_flux, amrex::MultiFab *yqv_flux, amrex::MultiFab *zqv_flux, const amrex::MultiFab *z_phys, const FluxCalc &flux_comp)
RoughCalcType rough_type_sea
Definition: ERF_SurfaceLayer.H:557
void update_fluxes(const int &lev, const amrex::Real &time, int max_iters=500)
Definition: ERF_SurfaceLayer.cpp:12
amrex::Real surf_moist
Definition: ERF_SurfaceLayer.H:574
amrex::Vector< std::unique_ptr< amrex::MultiFab > > w_star
Definition: ERF_SurfaceLayer.H:589
amrex::MultiFab * get_u_star(const int &lev)
Definition: ERF_SurfaceLayer.H:475
amrex::Real m_bdy_time_interval
Definition: ERF_SurfaceLayer.H:565
amrex::Vector< amrex::Vector< amrex::MultiFab * > > m_lsm_data_lev
Definition: ERF_SurfaceLayer.H:600
amrex::Real custom_qstar
Definition: ERF_SurfaceLayer.H:578
amrex::Vector< std::unique_ptr< amrex::MultiFab > > u_star
Definition: ERF_SurfaceLayer.H:588
amrex::Vector< std::unique_ptr< amrex::MultiFab > > q_surf
Definition: ERF_SurfaceLayer.H:595
amrex::Vector< amrex::Vector< amrex::MultiFab * > > m_sst_lev
Definition: ERF_SurfaceLayer.H:597
FluxCalcType
Definition: ERF_SurfaceLayer.H:524
@ MOENG
Moeng functional form.
@ CUSTOM
Custom constant flux functional form.
@ ROTATE
Terrain rotation flux functional form.
@ DONELAN
Donelan functional form.
MoistCalcType
Definition: ERF_SurfaceLayer.H:537
@ SURFACE_MOISTURE
Surface Qv specified.
@ MOISTURE_FLUX
Qv-flux specified.
amrex::Real depth
Definition: ERF_SurfaceLayer.H:581
amrex::Vector< amrex::MultiFab * > m_Hwave_lev
Definition: ERF_SurfaceLayer.H:602
amrex::Real default_land_surf_moist
Definition: ERF_SurfaceLayer.H:573
bool m_var_z0
Definition: ERF_SurfaceLayer.H:583
amrex::MultiFab * get_t_star(const int &lev)
Definition: ERF_SurfaceLayer.H:479
bool have_variable_sea_roughness()
Definition: ERF_SurfaceLayer.H:500
void compute_fluxes(const int &lev, const int &max_iters, const FluxIter &most_flux, bool is_land)
Definition: ERF_SurfaceLayer.cpp:171
amrex::MultiFab * get_q_star(const int &lev)
Definition: ERF_SurfaceLayer.H:481
amrex::Vector< amrex::Vector< amrex::MultiFab * > > m_lsm_flux_lev
Definition: ERF_SurfaceLayer.H:601
PBLHeightCalcType
Definition: ERF_SurfaceLayer.H:551
amrex::MultiFab * get_pblh(const int &lev)
Definition: ERF_SurfaceLayer.H:485
void fill_tsurf_with_sst_and_tsk(const int &lev, const amrex::Real &time)
Definition: ERF_SurfaceLayer.cpp:445
amrex::Real surf_temp_flux
Definition: ERF_SurfaceLayer.H:572
amrex::Vector< amrex::Geometry > m_geom
Definition: ERF_SurfaceLayer.H:562
amrex::Vector< std::unique_ptr< amrex::MultiFab > > t_star
Definition: ERF_SurfaceLayer.H:590
amrex::Vector< amrex::Vector< amrex::MultiFab * > > m_tsk_lev
Definition: ERF_SurfaceLayer.H:598
amrex::Real custom_tstar
Definition: ERF_SurfaceLayer.H:577
bool cnk_visc
Definition: ERF_SurfaceLayer.H:580
amrex::Real surf_heating_rate
Definition: ERF_SurfaceLayer.H:571
RoughCalcType
Definition: ERF_SurfaceLayer.H:543
FluxCalcType flux_type
Definition: ERF_SurfaceLayer.H:553
MoistCalcType moist_type
Definition: ERF_SurfaceLayer.H:555
void impose_SurfaceLayer_bcs(const int &lev, amrex::Vector< const amrex::MultiFab * > mfs, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &Tau_lev, amrex::MultiFab *xheat_flux, amrex::MultiFab *yheat_flux, amrex::MultiFab *zheat_flux, amrex::MultiFab *xqv_flux, amrex::MultiFab *yqv_flux, amrex::MultiFab *zqv_flux, const amrex::MultiFab *z_phys)
Definition: ERF_SurfaceLayer.cpp:238
amrex::Vector< amrex::MultiFab * > m_eddyDiffs_lev
Definition: ERF_SurfaceLayer.H:604
const amrex::MultiFab * get_mac_avg(const int &lev, int comp)
Definition: ERF_SurfaceLayer.H:487
amrex::Real custom_ustar
Definition: ERF_SurfaceLayer.H:576
amrex::Vector< std::unique_ptr< amrex::MultiFab > > olen
Definition: ERF_SurfaceLayer.H:592
amrex::FArrayBox * get_z0(const int &lev)
Definition: ERF_SurfaceLayer.H:498
amrex::MultiFab * get_t_surf(const int &lev)
Definition: ERF_SurfaceLayer.H:492
amrex::Vector< std::unique_ptr< amrex::MultiFab > > pblh
Definition: ERF_SurfaceLayer.H:593
amrex::Real default_land_surf_temp
Definition: ERF_SurfaceLayer.H:569
amrex::Real get_zref()
Definition: ERF_SurfaceLayer.H:496
ThetaCalcType
Definition: ERF_SurfaceLayer.H:531
@ SURFACE_TEMPERATURE
Surface temperature specified.
@ HEAT_FLUX
Heat-flux specified.
void read_custom_roughness(const int &lev, const std::string &fname)
Definition: ERF_SurfaceLayer.cpp:582
MOSTAverage m_ma
Definition: ERF_SurfaceLayer.H:587
@ ng
Definition: ERF_Morrison.H:48
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12