ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF.H
Go to the documentation of this file.
1 #ifndef ERF_H_
2 #define ERF_H_
3 
4 #include <string>
5 #include <limits>
6 #include <memory>
7 
8 #ifdef _OPENMP
9 #include <omp.h>
10 #endif
11 
12 #include <AMReX_AmrCore.H>
13 #include <AMReX_BCRec.H>
14 #include <AMReX_Print.H>
15 
16 #include <AMReX_ParallelDescriptor.H>
17 #include <AMReX_ParmParse.H>
18 #include <AMReX_MultiFabUtil.H>
19 #include <AMReX_FillPatchUtil.H>
20 #include <AMReX_VisMF.H>
21 #include <AMReX_PhysBCFunct.H>
22 #include <AMReX_YAFluxRegister.H>
23 #include <AMReX_ErrorList.H>
24 
25 #ifdef ERF_USE_FFT
26 #include <AMReX_FFT_Poisson.H>
27 #endif
28 
29 #ifdef AMREX_MEM_PROFILING
30 #include <AMReX_MemProfiler.H>
31 #endif
32 
33 #include "ERF_ProbCommon.H"
34 
35 #include <ERF_IndexDefines.H>
36 #include <ERF_DataStruct.H>
37 #include <ERF_TurbPertStruct.H>
38 #include <ERF_InputSoundingData.H>
39 #include <ERF_InputSpongeData.H>
40 #include <ERF_ABLMost.H>
41 #include <ERF_Derive.H>
42 #include <ERF_ReadBndryPlanes.H>
43 #include <ERF_WriteBndryPlanes.H>
44 #include <ERF_MRI.H>
45 #include <ERF_PhysBCFunct.H>
46 #include <ERF_FillPatcher.H>
47 #include <ERF_SampleData.H>
48 #include <ERF_ForestDrag.H>
49 #include <ERF_TerrainDrag.H>
50 
51 #ifdef ERF_USE_PARTICLES
52 #include "ERF_ParticleData.H"
53 #endif
54 
57 #include "ERF_LandSurface.H"
58 #ifdef ERF_USE_WINDFARM
59 #include "ERF_WindFarm.H"
60 #endif
61 
62 #ifdef ERF_USE_RRTMGP
63 #include "ERF_Radiation.H"
64 #endif
65 
66 #include <iostream>
67 
68 #ifdef AMREX_LAZY
69 #include <AMReX_Lazy.H>
70 #endif
71 
72 #ifdef ERF_USE_MULTIBLOCK
74 #endif
75 
76 /**
77  * Enum of possible initialization types
78 */
79 AMREX_ENUM(InitType,
80  None, Input_Sounding, Ideal, Real, Metgrid, Uniform
81 );
82 
83 /**
84  * Enum of possible interpolation types between coarse/fine
85 */
86 AMREX_ENUM(StateInterpType,
87  FullState, Perturbational
88 );
89 
90 /**
91  * Enum of possible plotfile types
92 */
93 AMREX_ENUM(PlotFileType,
94  None, Amrex, Netcdf
95 );
96 
97 
98 #if 0
99 /**
100  * Enum of possible coarse/fine interpolation options
101 */
102 namespace InterpType {
103  enum {
104  PCInterp = 0,
105  NodeBilinear,
106  CellConservativeLinear,
107  CellBilinear,
108  CellQuadratic,
109  CellConservativeProtected,
110  CellConservativeQuartic,
111  FaceLinear,
112  FaceConserativeLinear
113  };
114 }
115 #endif
116 
117 /**
118  * Main class in ERF code, instantiated from main.cpp
119 */
120 
121 class ERF
122  : public amrex::AmrCore
123 {
124 public:
125 
126  ////////////////
127  // public member functions
128 
129  // constructor - reads in parameters from inputs file
130  // - sizes multilevel arrays and data structures
131  ERF ();
132  ~ERF () override;
133 
134  void ERF_shared ();
135 
136  // Declare a default move constructor so we ensure the destructor is
137  // not called when we return an object of this class by value
138  ERF (ERF&&) noexcept = delete;
139 
140  // Declare a default move assignment operator
141  ERF& operator=(ERF&& other) noexcept = delete;
142 
143  // Delete the copy constructor
144  ERF (const ERF& other) = delete;
145  //
146  // Delete the copy assignment operator
147  ERF& operator=(const ERF& other) = delete;
148 
149  // Advance solution to final time
150  void Evolve ();
151 
152  // Tag cells for refinement
153  void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;
154 
155  // Initialize multilevel data
156  void InitData ();
157 
158  // Initialize multilevel data before MultiBlock
159  void InitData_pre ();
160 
161  // Initialize multilevel data after MultiBlock
162  void InitData_post ();
163 
164 #ifdef ERF_USE_EB
165  void WriteMyEBSurface ();
166 #endif
167 
168  // Compute the divergence -- whether EB, no-terrain, flat terrain or general terrain
169  void compute_divergence (int lev, amrex::MultiFab& rhs, amrex::Array<amrex::MultiFab const*,AMREX_SPACEDIM> rho0_u_const,
170  amrex::Geometry const& geom_at_lev);
171 
172  // Project the velocities to be divergence-free -- this is only relevant if anelastic == 1
173  void project_velocities (int lev, amrex::Real dt, amrex::Vector<amrex::MultiFab >& vars,
174  amrex::MultiFab& p);
175 
176  // Project the velocities to be divergence-free with a thin body
177  void project_velocities_tb (int lev, amrex::Real dt, amrex::Vector<amrex::MultiFab >& vars,
178  amrex::MultiFab& p);
179 
180  // Calculate wall distance by solving a Poisson equation
181  void poisson_wall_dist (int lev);
182 
183 #ifdef ERF_USE_FFT
184  void solve_with_fft (int lev, amrex::MultiFab& rhs, amrex::MultiFab& p,
185  amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& fluxes);
186 #endif
187 #ifdef ERF_USE_EB
188  void solve_with_EB_mlmg (int lev, amrex::Vector<amrex::MultiFab>& rhs, amrex::Vector<amrex::MultiFab>& p,
189  amrex::Vector<amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>>& fluxes);
190 #endif
191 
192  void solve_with_gmres (int lev, amrex::Vector<amrex::MultiFab>& rhs, amrex::Vector<amrex::MultiFab>& p,
193  amrex::Vector<amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>>& fluxes);
194  void solve_with_mlmg (int lev, amrex::Vector<amrex::MultiFab>& rhs, amrex::Vector<amrex::MultiFab>& p,
195  amrex::Vector<amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>>& fluxes);
196 
197  // Define the projection bc's based on the domain bc types
198  amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM>
199  get_projection_bc (amrex::Orientation::Side side) const noexcept;
200  bool projection_has_dirichlet (amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> bcs) const;
201 
202  // Init (NOT restart or regrid)
203  void init_only (int lev, amrex::Real time);
204 
205  // Restart
206  void restart ();
207 
208  // Is it time to write a plotfile or checkpoint?
209  bool writeNow (const amrex::Real cur_time, const amrex::Real dt, const int nstep,
210  const int plot_int, const amrex::Real plot_per);
211 
212  // Called after every level 0 timestep
213  void post_timestep (int nstep, amrex::Real time, amrex::Real dt_lev);
214 
215  // Diagnostics
216  void sum_integrated_quantities (amrex::Real time);
217  void write_1D_profiles (amrex::Real time);
218  void write_1D_profiles_stag (amrex::Real time);
219 
220  amrex::Real cloud_fraction (amrex::Real time);
221 
222  // Fill the physical boundary conditions for cell-centered velocity (diagnostic only)
223  void FillBdyCCVels (amrex::Vector<amrex::MultiFab>& mf_cc_vel);
224 
225  void sample_points (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);
226  void sample_lines (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);
227 
228  void derive_diag_profiles (amrex::Real time,
229  amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v,
230  amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
231  amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
232  amrex::Gpu::HostVector<amrex::Real>& h_avg_Kmv , amrex::Gpu::HostVector<amrex::Real>& h_avg_Khv,
233  amrex::Gpu::HostVector<amrex::Real>& h_avg_qv , amrex::Gpu::HostVector<amrex::Real>& h_avg_qc,
234  amrex::Gpu::HostVector<amrex::Real>& h_avg_qr ,
235  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqv , amrex::Gpu::HostVector<amrex::Real>& h_avg_wqc,
236  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqr ,
237  amrex::Gpu::HostVector<amrex::Real>& h_avg_qi , amrex::Gpu::HostVector<amrex::Real>& h_avg_qs,
238  amrex::Gpu::HostVector<amrex::Real>& h_avg_qg ,
239  amrex::Gpu::HostVector<amrex::Real>& h_avg_uu , amrex::Gpu::HostVector<amrex::Real>& h_avg_uv,
240  amrex::Gpu::HostVector<amrex::Real>& h_avg_uw,
241  amrex::Gpu::HostVector<amrex::Real>& h_avg_vv , amrex::Gpu::HostVector<amrex::Real>& h_avg_vw,
242  amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
243  amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
244  amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
245  amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
246  amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
247  amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
248  amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
249  amrex::Gpu::HostVector<amrex::Real>& h_avg_pw, amrex::Gpu::HostVector<amrex::Real>& h_avg_wthv);
250  void derive_diag_profiles_stag (amrex::Real time,
251  amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v,
252  amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
253  amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
254  amrex::Gpu::HostVector<amrex::Real>& h_avg_Kmv , amrex::Gpu::HostVector<amrex::Real>& h_avg_Khv,
255  amrex::Gpu::HostVector<amrex::Real>& h_avg_qv , amrex::Gpu::HostVector<amrex::Real>& h_avg_qc,
256  amrex::Gpu::HostVector<amrex::Real>& h_avg_qr ,
257  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqv , amrex::Gpu::HostVector<amrex::Real>& h_avg_wqc,
258  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqr ,
259  amrex::Gpu::HostVector<amrex::Real>& h_avg_qi , amrex::Gpu::HostVector<amrex::Real>& h_avg_qs,
260  amrex::Gpu::HostVector<amrex::Real>& h_avg_qg ,
261  amrex::Gpu::HostVector<amrex::Real>& h_avg_uu , amrex::Gpu::HostVector<amrex::Real>& h_avg_uv,
262  amrex::Gpu::HostVector<amrex::Real>& h_avg_uw,
263  amrex::Gpu::HostVector<amrex::Real>& h_avg_vv , amrex::Gpu::HostVector<amrex::Real>& h_avg_vw,
264  amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
265  amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
266  amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
267  amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
268  amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
269  amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
270  amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
271  amrex::Gpu::HostVector<amrex::Real>& h_avg_pw, amrex::Gpu::HostVector<amrex::Real>& h_avg_wthv);
272 
273  void derive_stress_profiles (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
274  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
275  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
276  amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_q1fx3,
277  amrex::Gpu::HostVector<amrex::Real>& h_avg_q2fx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);
278  void derive_stress_profiles_stag (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
279  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
280  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
281  amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_q1fx3,
282  amrex::Gpu::HostVector<amrex::Real>& h_avg_q2fx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);
283 
284  // Perform the volume-weighted sum
285  amrex::Real
286  volWgtSumMF (int lev, const amrex::MultiFab& mf, int comp,
287  const amrex::MultiFab& mapfac,
288  bool local, bool finemask);
289 
290  // Decide if it is time to take an action
291  static bool is_it_time_for_action (int nstep, amrex::Real time, amrex::Real dt,
292  int action_interval, amrex::Real action_per);
293 
294  // Make a new level using provided BoxArray and DistributionMapping and
295  // fill with interpolated coarse level data.
296  // overrides the pure virtual function in AmrCore
297  void MakeNewLevelFromCoarse (int lev, amrex::Real time, const amrex::BoxArray& ba,
298  const amrex::DistributionMapping& dm) override;
299 
300  // Remake an existing level using provided BoxArray and DistributionMapping and
301  // fill with existing fine and coarse data.
302  // overrides the pure virtual function in AmrCore
303  void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba,
304  const amrex::DistributionMapping& dm) override;
305 
306  // Delete level data
307  // overrides the pure virtual function in AmrCore
308  void ClearLevel (int lev) override;
309 
310  // Make a new level from scratch using provided BoxArray and DistributionMapping.
311  // Only used during initialization.
312  // overrides the pure virtual function in AmrCore
313  void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba,
314  const amrex::DistributionMapping& dm) override;
315 
316  // compute dt from CFL considerations
317  amrex::Real estTimeStep (int lev, long& dt_fast_ratio) const;
318 
319 #ifdef ERF_USE_WW3_COUPLING
320  //amrex::Print() << " About to call send_to_ww3 from ERF.H" << std::endl;
321  void send_to_ww3(int lev);
322  //amrex::Print() << " About to call read_waves from ERF.H" << std::endl;
323  void read_waves(int lev);
324  //void send_to_ww3 (int lev);
325  //void read_waves (int lev);
326 
327  //void send_to_ww3 (int lev);
328 #endif
329 
330  // Interface for advancing the data at one level by one "slow" timestep
331  void advance_dycore (int level,
332  amrex::Vector<amrex::MultiFab>& state_old,
333  amrex::Vector<amrex::MultiFab>& state_new,
334  amrex::MultiFab& xvel_old, amrex::MultiFab& yvel_old, amrex::MultiFab& zvel_old,
335  amrex::MultiFab& xvel_new, amrex::MultiFab& yvel_new, amrex::MultiFab& zvel_new,
336  amrex::MultiFab& source, amrex::MultiFab& xmom_src,
337  amrex::MultiFab& ymom_src, amrex::MultiFab& zmom_src,
338  amrex::Geometry fine_geom,
339  amrex::Real dt, amrex::Real time);
340 
341  void advance_microphysics (int lev,
342  amrex::MultiFab& cons_in,
343  const amrex::Real& dt_advance,
344  const int& iteration,
345  const amrex::Real& time);
346 
347  void advance_lsm (int lev,
348  amrex::MultiFab& /*cons_in*/,
349  const amrex::Real& dt_advance);
350 
351 #if defined(ERF_USE_RRTMGP)
352  void advance_radiation (int lev,
353  amrex::MultiFab& cons_in,
354  const amrex::Real& dt_advance);
355 #endif
356 
357  amrex::MultiFab& build_fine_mask (int lev);
358 
359  void MakeHorizontalAverages ();
360  void MakeDiagnosticAverage (amrex::Vector<amrex::Real>& h_havg, amrex::MultiFab& S, int n);
361  void derive_upwp (amrex::Vector<amrex::Real>& h_havg);
362 
363  // write plotfile to disk
364  void WritePlotFile (int which, PlotFileType plotfile_type, amrex::Vector<std::string> plot_var_names);
365 
366  void WriteMultiLevelPlotfileWithTerrain (const std::string &plotfilename,
367  int nlevels,
368  const amrex::Vector<const amrex::MultiFab*> &mf,
369  const amrex::Vector<const amrex::MultiFab*> &mf_nd,
370  const amrex::Vector<std::string> &varnames,
371  const amrex::Vector<amrex::Geometry>& my_geom,
372  amrex::Real time,
373  const amrex::Vector<int> &level_steps,
374  const amrex::Vector<amrex::IntVect>& my_ref_ratio,
375  const std::string &versionName = "HyperCLaw-V1.1",
376  const std::string &levelPrefix = "Level_",
377  const std::string &mfPrefix = "Cell",
378  const amrex::Vector<std::string>& extra_dirs = amrex::Vector<std::string>()) const;
379 
380 
381  void WriteGenericPlotfileHeaderWithTerrain (std::ostream &HeaderFile,
382  int nlevels,
383  const amrex::Vector<amrex::BoxArray> &bArray,
384  const amrex::Vector<std::string> &varnames,
385  const amrex::Vector<amrex::Geometry>& my_geom,
386  amrex::Real time,
387  const amrex::Vector<int> &level_steps,
388  const amrex::Vector<amrex::IntVect>& my_ref_ratio,
389  const std::string &versionName,
390  const std::string &levelPrefix,
391  const std::string &mfPrefix) const;
392 
393  void erf_enforce_hse (int lev,
394  amrex::MultiFab& dens, amrex::MultiFab& pres, amrex::MultiFab& pi, amrex::MultiFab& th,
395  std::unique_ptr<amrex::MultiFab>& z_cc);
396 
397 #ifdef ERF_USE_NETCDF
398  //! Write a timestep to 1D vertical column output for coupling
399  void writeToNCColumnFile (int lev,
400  const std::string& colfile_name, amrex::Real xloc, amrex::Real yloc,
401  amrex::Real time);
402 #endif //ERF_USE_NETCDF
403 
404  void init_from_input_sounding (int lev);
405 
406  void input_sponge (int lev);
407 
408  void init_from_hse (int lev);
409 
410  void init_thin_body (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
411 
412 #ifdef ERF_USE_MULTIBLOCK
413  // constructor used when ERF is created by a multiblock driver
414  // calls AmrCore constructor -> AmrMesh constructor
415  ERF (const amrex::RealBox& rb, int max_level_in,
416  const amrex::Vector<int>& n_cell_in, int coord,
417  const amrex::Vector<amrex::IntVect>& ref_ratio,
418  const amrex::Array<int,AMREX_SPACEDIM>& is_per,
419  std::string prefix);
420 
421  // Advance a block specified number of time steps
422  void Evolve_MB (int MBstep, int max_block_step);
423 
424  // get the current time values and dt
425  amrex::Real get_t_old (int lev) { return t_old[lev]; }
426  amrex::Real get_t_new (int lev) { return t_new[lev]; }
427  amrex::Real get_dt (int lev) { return dt[lev]; }
428 
429  // Set parmparse prefix for MultiBlock
430  void SetParmParsePrefix (std::string name) { pp_prefix = name; }
431 
432  // Set 'this' from multiblock container
433  void SetMultiBlockPointer (MultiBlockContainer *mbc) { m_mbc = mbc; }
434 
435  // Public data copy for MB
436  std::vector<amrex::Box> domain_p;
437  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_new;
438  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_old;
439 
440  // Velocity time averaged field
441  amrex::Vector<std::unique_ptr<amrex::MultiFab>> vel_t_avg;
442  amrex::Vector<amrex::Real> t_avg_cnt;
443 #endif
444 
445  std::string pp_prefix {"erf"};
446 
447  void fill_from_bndryregs (const amrex::Vector<amrex::MultiFab*>& mfs,
448  amrex::Real time);
449 
450 #ifdef ERF_USE_NETCDF
451  void fill_from_realbdy (const amrex::Vector<amrex::MultiFab*>& mfs,
452  amrex::Real time,
453  bool cons_only,
454  int icomp_cons,
455  int ncomp_cons,
456  amrex::IntVect ngvect_cons,
457  amrex::IntVect ngvect_vels);
458 #endif
459 
460 #ifdef ERF_USE_NETCDF
461  void init_from_wrfinput (int lev);
462  void init_from_metgrid (int lev);
463 #endif // ERF_USE_NETCDF
464 
465 #ifdef ERF_USE_WINDFARM
466  void init_windfarm(int lev);
467  void advance_windfarm (const amrex::Geometry& a_geom,
468  const amrex::Real& dt_advance,
469  amrex::MultiFab& cons_in,
470  amrex::MultiFab& U_old, amrex::MultiFab& V_old, amrex::MultiFab& W_old,
471  amrex::MultiFab& mf_vars_windfarm,
472  const amrex::MultiFab& mf_Nturb,
473  const amrex::MultiFab& mf_SMark,
474  const amrex::Real& time);
475 #endif
476 
477 #ifdef ERF_USE_EB
478  void MakeEBGeometry ();
479  void make_eb_box ();
480  void make_eb_cylinder ();
481  void make_eb_regular ();
482  void redistribute_term ( int lev,
483  amrex::MultiFab& result,
484  amrex::MultiFab& result_tmp,
485  amrex::MultiFab const& state,
486  amrex::BCRec const* bc,
487  amrex::Real const dt);
488  void redistribute_term ( amrex::MFIter const& mfi, int lev,
489  amrex::MultiFab& result,
490  amrex::MultiFab& result_tmp,
491  amrex::MultiFab const& state,
492  amrex::BCRec const* bc,
493  amrex::Real const dt);
494 #endif
495 
496  // more flexible version of AverageDown() that lets you average down across multiple levels
497  void AverageDownTo (int crse_lev, int scomp, int ncomp); // NOLINT
498 
499  // write checkpoint file to disk
500  void WriteCheckpointFile () const;
501 
502  // read checkpoint file from disk
503  void ReadCheckpointFile ();
504 
505  // read checkpoint file from disk -- called after instantiating m_most
506  void ReadCheckpointFileMOST ();
507 
508 private:
509 
510  ///////////////////////////
511  // private member functions
512  ///////////////////////////
513 
514  // read in some parameters from inputs file
515  void ReadParameters ();
516  void ParameterSanityChecks ();
517 
518  // set covered coarse cells/faces to be the average of overlying fine cells/faces
519  void AverageDown ();
520 
521  void update_diffusive_arrays (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
522 
523  void init_zphys (int lev, amrex::Real time);
524  void remake_zphys (int lev, std::unique_ptr<amrex::MultiFab>& temp_zphys_nd);
525  void update_terrain_arrays (int lev);
526 
527  void Construct_ERFFillPatchers (int lev);
528 
529  void Define_ERFFillPatchers (int lev);
530 
531  void init1DArrays ();
532 
533  void init_bcs ();
534 
535  void init_custom (int lev);
536 
537  void init_uniform (int lev);
538 
539  void init_stuff (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm,
540  amrex::Vector<amrex::MultiFab>& lev_new, amrex::Vector<amrex::MultiFab>& lev_old,
541  amrex::MultiFab& tmp_base_state,
542  std::unique_ptr<amrex::MultiFab>& tmp_zphys_nd);
543 
544  // Initialize the Turbulent perturbation
545  void turbPert_update (const int lev, const amrex::Real dt);
546  void turbPert_amplitude (const int lev);
547 
548  // Initialize the integrator object
549  void initialize_integrator (int lev, amrex::MultiFab& cons_mf, amrex::MultiFab& vel_mf);
550 
551  // Create the physbcs objects
552  void make_physbcs (int lev);
553 
554  // Initialize the microphysics object
555  void initializeMicrophysics (const int&);
556 
557 #ifdef ERF_USE_WINDFARM
558  // Initialize the windfarm object
559  void initializeWindFarm (const int&);
560 #endif
561 
562  // Compute a vector of new MultiFabs by copying from valid region and filling ghost cells
563  //
564  // NOTE: FillPatch takes in an empty MF, and returns cell-centered + velocities (not momenta)
565  //
566  // This one works only at level = 0 (base state does not change)
567  void FillPatch (int lev, amrex::Real time,
568  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
569  bool cons_only=false);
570 
571  // This one works only at level > 0 (base state does change)
572  void FillPatch (int lev, amrex::Real time,
573  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
574  const amrex::Vector<amrex::MultiFab*>& mfs_mom,
575  const amrex::MultiFab& old_base_state,
576  const amrex::MultiFab& new_base_state,
577  bool fillset=true, bool cons_only=false);
578 
579  // Compute new multifabs by copying data from valid region and filling ghost cells.
580  // Unlike FillPatch, FillIntermediatePatch will use the supplied multifabs instead of fine level data.
581  // This is to support filling boundary cells at an intermediate time between old/new times
582  // on the fine level when valid data at a specific time is already available (such as
583  // at each RK stage when integrating between initial and final times at a given level).
584  //
585  // NOTE: FillIntermediatePatch takes in updated momenta, and returns both updated velocity and momenta
586  //
587  void FillIntermediatePatch (int lev, amrex::Real time,
588  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
589  const amrex::Vector<amrex::MultiFab*>& mfs_mom,
590  int ng_cons, int ng_vel, bool cons_only, int icomp_cons, int ncomp_cons,
591  bool allow_most_bcs = true);
592 
593  // Fill all multifabs (and all components) in a vector of multifabs corresponding to the
594  // grid variables defined in vars_old and vars_new just as FillCoarsePatch.
595  void FillCoarsePatch (int lev, amrex::Real time);
596 
597  // advance a level by dt
598  // includes a recursive call for finer levels
599  void timeStep (int lev, amrex::Real time, int iteration);
600 
601  // advance a single level for a single time step
602  void Advance (int lev, amrex::Real time, amrex::Real dt_lev, int iteration, int ncycle);
603 
604  //! Initialize HSE
605  void initHSE ();
606  void initHSE (int lev);
607 
608  //! Initialize Rayleigh damping profiles
609  void initRayleigh ();
610 
611  //! Initialize sponge profiles
612  void initSponge ();
613 
614  //! Set Rayleigh mean profiles from input sounding
615  void setRayleighRefFromSounding (bool restarting);
616 
617  //! Set sponge mean profiles from input sounding
618  void setSpongeRefFromSounding (bool restarting);
619 
620  // a wrapper for estTimeStep()
621  void ComputeDt (int step = -1);
622 
623  // get plotfile name
624  [[nodiscard]] std::string PlotFileName (int lev) const;
625 
626  // set plotfile variables names
627  static amrex::Vector<std::string> PlotFileVarNames (amrex::Vector<std::string> plot_var_names) ;
628 
629  // set which variables and derived quantities go into plotfiles
630  void setPlotVariables (const std::string& pp_plot_var_names, amrex::Vector<std::string>& plot_var_names);
631  // append variables to plot
632  void appendPlotVariables (const std::string& pp_plot_var_names, amrex::Vector<std::string>& plot_var_names);
633 
634 #ifdef ERF_USE_NETCDF
635  //! Write plotfile using NETCDF
636  void writeNCPlotFile (int lev, int which, const std::string& dir,
637  const amrex::Vector<const amrex::MultiFab*> &mf,
638  const amrex::Vector<std::string> &plot_var_names,
639  const amrex::Vector<int>& level_steps, amrex::Real time) const;
640 
641  //! Write checkpointFile using NetCdf
642  void WriteNCCheckpointFile () const;
643 
644  //! Read checkpointFile for restart
645  void ReadNCCheckpointFile ();
646 
647  //! Write MultiFab in NetCDF format
648  static void WriteNCMultiFab (const amrex::FabArray<amrex::FArrayBox> &fab,
649  const std::string& name,
650  bool set_ghost = false) ;
651 
652  //! Read MultiFab in NetCDF format
653  void ReadNCMultiFab (amrex::FabArray<amrex::FArrayBox> &mf,
654  const std::string &name,
655  int coordinatorProc = amrex::ParallelDescriptor::IOProcessorNumber(),
656  int allow_empty_mf = 0);
657 
658  //! Create 1D vertical column output for coupling
659  void createNCColumnFile (int lev,
660  const std::string& colfile_name, amrex::Real xloc, amrex::Real yloc);
661 
662  // Copy from the NC*fabs into the MultiFabs holding the boundary data
663  void init_from_wrfbdy (amrex::Vector<amrex::FArrayBox*> x_vel_lateral,
664  amrex::Vector<amrex::FArrayBox*> y_vel_lateral,
665  amrex::Vector<amrex::FArrayBox*> z_vel_lateral,
666  amrex::Vector<amrex::FArrayBox*> T_lateral);
667 
668  amrex::Real start_bdy_time;
669 
670  // *** *** FArrayBox's for holding the SURFACE data
671  // amrex::IArrayBox NC_IVGTYP_fab; // Vegetation type (IVGTYP); Discrete numbers;
672  // amrex::FArrayBox NC_z0_fab; // Surface Roughness, z0 = z0 (IVGTYP)
673  // amrex::FArrayBox NC_PSFC_fab; // Surface pressure
674 
675  // TODO: Clarify the relation between SST and TSK
676  // amrex::FArrayBox NC_SST_fab; // Sea Surface Temperature; Defined even for land area
677  // amrex::FArrayBox NC_TSK_fab; // Surface Skin Temperature; Appears to be same as SST...
678 
679  // Vectors (over time) of Vector (over variables) of FArrayBoxs for holding the data read from the wrfbdy NetCDF file
680  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_xlo;
681  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_xhi;
682  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_ylo;
683  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_yhi;
684 
685  amrex::Real bdy_time_interval;
686  amrex::Vector<std::unique_ptr<amrex::MultiFab>> lat_m, lon_m;
687  amrex::Real Latitude;
688  amrex::Real Longitude;
689 #endif // ERF_USE_NETCDF
690 
691  // Struct for working with the sounding data we take as an input
693 
694  // Struct for working with the sponge data we take as an input
696 
697  // Vector (6 planes) of DeviceVectors (ncell in plane) for Dirichlet BC data
698  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> xvel_bc_data;
699  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> yvel_bc_data;
700  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> zvel_bc_data;
701 
702  // Function to read and populate above vectors (if input file exists)
703  void init_Dirichlet_bc_data (const std::string input_file);
704 
705  // Read the file passed to amr.restart and use it as an initial condition for
706  // the current simulation. Supports a different number of components and
707  // ghost cells.
709 
710  // Initialize the new-time data at a level from the initial_data MultiFab
711  void InitializeLevelFromData (int lev, const amrex::MultiFab& initial_data);
712 
713  // utility to skip to next line in Header
714  static void GotoNextLine (std::istream& is);
715 
716  // Single level functions called by advance()
717  void post_update (amrex::MultiFab& state_mf, amrex::Real time, const amrex::Geometry& geom);
718  void fill_rhs (amrex::MultiFab& rhs_mf, const amrex::MultiFab& state_mf, amrex::Real time, const amrex::Geometry& geom);
719 
720  ////////////////
721  // private data members
722 
723  std::unique_ptr<ProblemBase> prob = nullptr; // problem-specific functions
724 
725  amrex::Vector<int> num_boxes_at_level; // how many boxes specified at each level by tagging criteria
726  amrex::Vector<int> num_files_at_level; // how many wrfinput files specified at each level
727  amrex::Vector<amrex::Vector<amrex::Box>> boxes_at_level; // the boxes specified at each level by tagging criteria
728 
729  amrex::Vector<int> istep; // which step?
730  amrex::Vector<int> nsubsteps; // how many substeps on each level?
731 
732  // keep track of old time, new time, and time step at each level
733  amrex::Vector<amrex::Real> t_new;
734  amrex::Vector<amrex::Real> t_old;
735  amrex::Vector<amrex::Real> dt;
736  amrex::Vector<long> dt_mri_ratio;
737 
738  // array of multifabs to store the solution at each level of refinement
739  // after advancing a level we use "swap".
740 #ifndef ERF_USE_MULTIBLOCK
741  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_new;
742  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_old;
743 
744  // Velocity time averaged field
745  amrex::Vector<std::unique_ptr<amrex::MultiFab>> vel_t_avg;
746  amrex::Vector<amrex::Real> t_avg_cnt;
747 #endif
748  amrex::Vector<std::unique_ptr<MRISplitIntegrator<amrex::Vector<amrex::MultiFab> > > > mri_integrator_mem;
749 
750  amrex::Vector<amrex::MultiFab> pp_inc;
751 
752  // Vector over levels of routines to impose physical boundary conditions
753  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_cons>> physbcs_cons;
754  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_u>> physbcs_u;
755  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_v>> physbcs_v;
756  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_w>> physbcs_w;
757  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_base>> physbcs_base;
758 
759  // Store primitive variable for MOST BC
760  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Theta_prim;
761  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Qv_prim;
762  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Qr_prim;
763 
764  // Scratch space for time integrator
765  amrex::Vector<amrex::MultiFab> rU_old;
766  amrex::Vector<amrex::MultiFab> rU_new;
767  amrex::Vector<amrex::MultiFab> rV_old;
768  amrex::Vector<amrex::MultiFab> rV_new;
769  amrex::Vector<amrex::MultiFab> rW_old;
770  amrex::Vector<amrex::MultiFab> rW_new;
771 
772  // amrex::Vector<amrex::MultiFab> xmom_crse_rhs;
773  // amrex::Vector<amrex::MultiFab> ymom_crse_rhs;
774  amrex::Vector<amrex::MultiFab> zmom_crse_rhs;
775 
776  std::unique_ptr<Microphysics> micro;
777  amrex::Vector<amrex::Vector<amrex::MultiFab*>> qmoist; // (lev,ncomp) This has up to 8 components: qt, qv, qc, qi, qp, qr, qs, qg
778 
779  // Variables for wind farm parametrization models
780 
781 #ifdef ERF_USE_WINDFARM
782  std::unique_ptr<WindFarm> windfarm;
783  amrex::Vector<amrex::MultiFab> Nturb;
784  amrex::Vector<amrex::MultiFab> vars_windfarm; // Fitch: Vabs, Vabsdt, dudt, dvdt, dTKEdt
785  // EWP: dudt, dvdt, dTKEdt
786 
787  amrex::Vector<amrex::MultiFab> SMark; // A multifab that holds an integer corresponding
788  // to the number of the wind turbine to sample
789  // velocity upstream of the turbine
790 #endif
791 
793  amrex::Vector<amrex::Vector<amrex::MultiFab*>> lsm_data; // (lev,ncomp) Components: theta, q1, q2
794  amrex::Vector<amrex::Vector<amrex::MultiFab*>> lsm_flux; // (lev,ncomp) Components: theta, q1, q2
795 
796 #if defined(ERF_USE_RRTMGP)
797  Radiation rad;
798  amrex::Vector<std::unique_ptr<amrex::MultiFab>> qheating_rates; // radiation heating rate source terms
799 
800  // Containers for additional SLM inputs
801  amrex::Vector<std::unique_ptr<amrex::MultiFab>> sw_lw_fluxes; // Direct SW (visible, NIR), Diffuse SW (visible, NIR), LW flux
802  amrex::Vector<std::unique_ptr<amrex::MultiFab>> solar_zenith; // Solar zenith angle
803 
804  bool plot_rad = false;
805 #endif
806 
807  // Fillpatcher classes for coarse-fine boundaries
808  int cf_width{0};
809  int cf_set_width{0};
810  amrex::Vector<ERFFillPatcher> FPr_c;
811  amrex::Vector<ERFFillPatcher> FPr_u;
812  amrex::Vector<ERFFillPatcher> FPr_v;
813  amrex::Vector<ERFFillPatcher> FPr_w;
814 
815  // Diffusive stresses and Smag
816  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Tau11_lev, Tau22_lev, Tau33_lev;
817  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Tau12_lev, Tau21_lev;
818  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Tau13_lev, Tau31_lev;
819  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Tau23_lev, Tau32_lev;
820  amrex::Vector<std::unique_ptr<amrex::MultiFab>> eddyDiffs_lev;
821  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SmnSmn_lev;
822 
823  // Sea Surface Temps and Land Masks (lev, ntimes)
824  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> sst_lev;
825  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::iMultiFab>>> lmask_lev;
826 
827  // Other SFS terms
828  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_hfx1_lev, SFS_hfx2_lev, SFS_hfx3_lev;
829  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_diss_lev;
830  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_q1fx1_lev, SFS_q1fx2_lev, SFS_q1fx3_lev;
831  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_q2fx3_lev;
832 
833  // Grid stretching
834  amrex::Vector<amrex::Vector<amrex::Real>> zlevels_stag; // nominal height levels
835 
836  // Terrain data structures
837  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd;
838  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_cc;
839 
840  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc;
841  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ax;
842  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ay;
843  amrex::Vector<std::unique_ptr<amrex::MultiFab>> az;
844 
845  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd_src;
846  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc_src;
847  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ax_src;
848  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ay_src;
849  amrex::Vector<std::unique_ptr<amrex::MultiFab>> az_src;
850 
851  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd_new;
852  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc_new;
853  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ax_new;
854  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ay_new;
855  amrex::Vector<std::unique_ptr<amrex::MultiFab>> az_new;
856 
857  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_t_rk;
858 
859  // Wall distance function
860  amrex::Vector<std::unique_ptr<amrex::MultiFab>> walldist;
861 
862  // Map scale factors
863  amrex::Vector<std::unique_ptr<amrex::MultiFab>> mapfac_m;
864  amrex::Vector<std::unique_ptr<amrex::MultiFab>> mapfac_u;
865  amrex::Vector<std::unique_ptr<amrex::MultiFab>> mapfac_v;
866 
867  amrex::Vector<amrex::Vector<amrex::Real>> stretched_dz_h;
868  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> stretched_dz_d;
869 
870  amrex::Vector<amrex::MultiFab> base_state;
871  amrex::Vector<amrex::MultiFab> base_state_new;
872 
873  // Wave coupling data
874  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Hwave;
875  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Lwave;
876  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Hwave_onegrid;
877  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Lwave_onegrid;
878  bool finished_wave = false;
879 
880  // array of flux registers
881  amrex::Vector<amrex::YAFluxRegister*> advflux_reg;
882 
883  // A BCRec is essentially a 2*DIM integer array storing the boundary
884  // condition type at each lo/hi walls in each direction. We have one BCRec
885  // for each component of the cell-centered variables and each velocity component.
886  amrex::Vector <amrex::BCRec> domain_bcs_type;
887  amrex::Gpu::DeviceVector<amrex::BCRec> domain_bcs_type_d;
888 
889  // We store these so that we can print them out in the job_info file
890  amrex::Array<std::string,2*AMREX_SPACEDIM> domain_bc_type;
891 
892  // These hold the Dirichlet values at walls which need them ...
893  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
894 
895  // These hold the Neumann values at walls which need them ...
896  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
897 
898  // These are the "physical" boundary condition types (e.g. "inflow")
899  amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2> phys_bc_type;
900 
901  // These are the masks for the thin immersed body
902  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> xflux_imask;
903  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> yflux_imask;
904  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> zflux_imask;
905  //amrex::Vector<std::unique_ptr<amrex::iMultiFab>> overset_imask;
906 
907  // These are the body forces that result from the thin immersed body
908  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_xforce;
909  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_yforce;
910  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_zforce;
911 
914 
917 
918  ////////////////
919  // runtime parameters
920 
921  // maximum number of steps and stop time
922  int max_step = std::numeric_limits<int>::max();
923  amrex::Real start_time = 0.0;
924  amrex::Real stop_time = std::numeric_limits<amrex::Real>::max();
925 
926  // if >= 0 we restart from a checkpoint
927  std::string restart_chkfile = "";
928 
929  // Time step controls
930  static amrex::Real cfl;
931  static amrex::Real sub_cfl;
932  static amrex::Real init_shrink;
933  static amrex::Real change_max;
934 
935  // Fixed dt for level 0 timesteps (only used if positive)
936  amrex::Vector<amrex::Real> fixed_dt;
937  amrex::Vector<amrex::Real> fixed_fast_dt;
938  static int fixed_mri_dt_ratio;
939 
940  // how often each level regrids the higher levels of refinement
941  // (after a level advances that many time steps)
942  int regrid_int = -1;
943 
944  // plotfile prefix and frequency
945  std::string plot_file_1 {"plt_1_"};
946  std::string plot_file_2 {"plt_2_"};
948  int m_plot_int_1 = -1;
949  int m_plot_int_2 = -1;
950  amrex::Real m_plot_per_1 = -1.0;
951  amrex::Real m_plot_per_2 = -1.0;
952  bool m_plot_face_vels = false;
953 
954  bool plot_lsm = false;
955 
956  // other sampling output control
957  int profile_int = -1;
958  bool destag_profiles = true;
959 
960  // Checkpoint type, prefix and frequency
961  std::string check_file {"chk"};
962  std::string check_type {"native"};
963  std::string restart_type {"native"};
964  int m_check_int = -1;
965  amrex::Real m_check_per = -1.0;
966 
967  amrex::Vector<std::string> plot_var_names_1;
968  amrex::Vector<std::string> plot_var_names_2;
969  const amrex::Vector<std::string> cons_names {"density", "rhotheta", "rhoKE", "rhoadv_0",
970  "rhoQ1", "rhoQ2", "rhoQ3",
971  "rhoQ4", "rhoQ5", "rhoQ6"};
972 
973  // Note that the order of variable names here must match the order in ERF_Derive.cpp
974  const amrex::Vector<std::string> derived_names {"soundspeed", "temp", "theta", "KE", "scalar",
975  "vorticity_x","vorticity_y","vorticity_z",
976  "magvel", "divU",
977  "pres_hse", "dens_hse", "theta_hse", "pressure", "pert_pres", "pert_dens",
978  "eq_pot_temp", "num_turb", "SMark0", "SMark1",
979  "dpdx", "dpdy", "pres_hse_x", "pres_hse_y",
980  "z_phys", "detJ" , "mapfac", "lat_m", "lon_m",
981  // Time averaged velocity
982  "u_t_avg", "v_t_avg", "w_t_avg", "umag_t_avg",
983  // eddy viscosity
984  "nut",
985  // eddy diffusivity of momentum
986  "Kmv","Kmh",
987  // eddy diffusivity of heat
988  "Khv","Khh",
989  // turbulence lengthscale
990  "Lturb",
991  // wall distance
992  "walldist",
993  // moisture vars
994  "qt", "qv", "qc", "qi", "qp", "qrain", "qsnow", "qgraup", "qsat",
995  "rain_accum", "snow_accum", "graup_accum",
996  // Terrain IB mask
997  "terrain_IB_mask"
998 #ifdef ERF_USE_EB
999  // EB variables
1000  ,"volfrac",
1001 #endif
1002 #ifdef ERF_COMPUTE_ERROR
1003  // error vars
1004  ,"xvel_err", "yvel_err", "zvel_err", "pp_err"
1005 #endif
1006 #ifdef ERF_USE_RRTMGP
1007  ,"qsrc_sw", "qsrc_lw"
1008 #endif
1009  };
1010 
1011  // algorithm choices
1013 
1014  // Turbulent perturbation structure
1016 
1017 #ifdef ERF_USE_PARTICLES
1018  // Particle container with all particle species
1019  ParticleData particleData;
1020 
1021  // variables and functions for tracers particles
1022  bool m_use_tracer_particles; /*!< tracer particles that advect with flow */
1023  bool m_use_hydro_particles; /*!< tracer particles that fall with gravity */
1024 
1025  /*! Read tracer and hydro particles parameters */
1026  void readTracersParams();
1027 
1028  /*! Initialize tracer and hydro particles */
1029  void initializeTracers ( amrex::ParGDBBase*,
1030  const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
1031 
1032  /*! Restart tracer and hydro particles */
1033  void restartTracers ( amrex::ParGDBBase*, const std::string& );
1034 
1035  /*! Evolve tracers and hydro particles */
1036  void evolveTracers( int,
1037  amrex::Real,
1038  amrex::Vector<amrex::Vector<amrex::MultiFab>>&,
1039  const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
1040 
1041 #endif
1042 
1043 #ifdef ERF_USE_MULTIBLOCK
1044  MultiBlockContainer *m_mbc = nullptr;
1045 #endif
1046 
1047  static int verbose;
1048  static int mg_verbose;
1049  static bool use_fft;
1050 
1051  // Diagnostic output interval
1052  static int sum_interval;
1053  static int pert_interval;
1054  static amrex::Real sum_per;
1055 
1056  // Write in native AMReX or NetCDF format for each plotfile
1057  static PlotFileType plotfile_type_1;
1058  static PlotFileType plotfile_type_2;
1059 
1060  static InitType init_type;
1061  static StateInterpType interpolation_type;
1062 
1063  // sponge_type: "input_sponge"
1064  static std::string sponge_type;
1065 
1066  // use_real_bcs: only true if 1) ( (init_type == InitType::Real) or (init_type == InitType::Metgrid) )
1067  // AND 2) we want to use the bc's from the WRF bdy file
1068  static bool use_real_bcs;
1069 
1070  // NetCDF initialization (wrfinput) file
1071  static amrex::Vector<amrex::Vector<std::string>> nc_init_file;
1072 
1073  // NetCDF initialization (wrfbdy/met_em) file
1074  static std::string nc_bdy_file;
1075  int real_width{0};
1077 
1078  // Flag to trigger initialization from input_sounding like WRF's ideal.exe
1079  // used with init_type == InitType::Input_Sounding
1080  static bool init_sounding_ideal;
1081 
1082  // Options for vertical interpolation of met_em*.nc data.
1085  bool metgrid_debug_dry{false};
1086  bool metgrid_debug_psfc{false};
1087  bool metgrid_debug_msf{false};
1091  bool metgrid_use_sfc{true};
1092  bool metgrid_retain_sfc{false};
1093  amrex::Real metgrid_proximity{1000.0};
1096 
1097  // 1D CDF output (for ingestion in AMR-Wind)
1098  static int output_1d_column;
1099  static int column_interval;
1100  static amrex::Real column_per;
1101  static amrex::Real column_loc_x;
1102  static amrex::Real column_loc_y;
1103  static std::string column_file_name;
1104 
1105  // 2D BndryRegister output (for ingestion in AMR-Wind)
1108  static amrex::Real bndry_output_planes_per;
1110 
1111  // 2D BndryRegister input
1113 
1114  static int ng_dens_hse;
1115  static int ng_pres_hse;
1116 
1117  // Custom source terms
1118  amrex::Vector< amrex::Vector<amrex::Real> > h_rhotheta_src;
1119  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_rhotheta_src;
1120 
1121  amrex::Vector< amrex::Vector<amrex::Real> > h_rhoqt_src;
1122  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_rhoqt_src;
1123 
1124  amrex::Vector< amrex::Vector<amrex::Real> > h_w_subsid;
1125  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_w_subsid;
1126 
1127  amrex::Vector< amrex::Vector<amrex::Real> > h_u_geos;
1128  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_u_geos;
1129 
1130  amrex::Vector< amrex::Vector<amrex::Real> > h_v_geos;
1131  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_v_geos;
1132 
1133  // Function to read and populate above host vectors (if input file exists)
1134  void init_geo_wind_profile (const std::string input_file,
1135  amrex::Vector<amrex::Real>& u_geos,
1136  amrex::Gpu::DeviceVector<amrex::Real>& u_geos_d,
1137  amrex::Vector<amrex::Real>& v_geos,
1138  amrex::Gpu::DeviceVector<amrex::Real>& v_geos_d,
1139  const amrex::Geometry& lgeom,
1140  const amrex::Vector<amrex::Real>& zlev_stag);
1141 
1142  // This is a vector over levels of vectors across quantities of Vectors
1143  amrex::Vector<amrex::Vector< amrex::Vector<amrex::Real> > > h_rayleigh_ptrs;
1144 
1145  // This is a vector over levels of vectors across quantities of Vectors
1146  amrex::Vector<amrex::Vector< amrex::Vector<amrex::Real> > > h_sponge_ptrs;
1147 
1148  // This is a vector over levels of vectors across quantities of DeviceVectors
1149  amrex::Vector<amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > > d_rayleigh_ptrs;
1150 
1151  // This is a vector over levels of vectors across quantities of DeviceVectors
1152  amrex::Vector<amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > > d_sponge_ptrs;
1153 
1154  amrex::Vector<amrex::Real> h_havg_density;
1155  amrex::Vector<amrex::Real> h_havg_temperature;
1156  amrex::Vector<amrex::Real> h_havg_pressure;
1157  amrex::Vector<amrex::Real> h_havg_qv;
1158  amrex::Vector<amrex::Real> h_havg_qc;
1159 
1160  amrex::Gpu::DeviceVector<amrex::Real> d_havg_density;
1161  amrex::Gpu::DeviceVector<amrex::Real> d_havg_temperature;
1162  amrex::Gpu::DeviceVector<amrex::Real> d_havg_pressure;
1163  amrex::Gpu::DeviceVector<amrex::Real> d_havg_qv;
1164  amrex::Gpu::DeviceVector<amrex::Real> d_havg_qc;
1165 
1166  void refinement_criteria_setup ();
1167 
1168  std::unique_ptr<WriteBndryPlanes> m_w2d = nullptr;
1169  std::unique_ptr<ReadBndryPlanes> m_r2d = nullptr;
1170  std::unique_ptr<ABLMost> m_most = nullptr;
1171  amrex::Vector<std::unique_ptr<ForestDrag>> m_forest_drag;
1172  amrex::Vector<std::unique_ptr<TerrainDrag>> m_terrain_drag;
1173 
1174  //
1175  // Holds info for dynamically generated tagging criteria
1176  //
1177  static amrex::Vector<amrex::AMRErrorTag> ref_tags;
1178 
1179  //
1180  // Build a mask that zeroes out values on a coarse level underlying
1181  // grids on the next finest level
1182  //
1183  amrex::MultiFab fine_mask;
1184 
1185  amrex::Vector<amrex::Real> dz_min;
1186 
1187  static AMREX_FORCE_INLINE
1188  int
1189  ComputeGhostCells (const AdvChoice& advChoice, bool use_num_diff)
1190  {
1191  if (use_num_diff)
1192  {
1193  return 3;
1194  } else {
1195  if (
1201  || (advChoice.dryscal_vert_adv_type == AdvType::Centered_6th) )
1202  { return 3; }
1203  else if (
1205  || (advChoice.dycore_vert_adv_type == AdvType::Upwind_5th)
1209  || (advChoice.dryscal_vert_adv_type == AdvType::Upwind_5th) )
1210  { return 3; }
1211  else if (
1213  || (advChoice.dryscal_vert_adv_type == AdvType::Weno_5)
1214  || (advChoice.moistscal_horiz_adv_type == AdvType::Weno_5)
1215  || (advChoice.moistscal_vert_adv_type == AdvType::Weno_5)
1216  || (advChoice.moistscal_horiz_adv_type == AdvType::Weno_5Z)
1217  || (advChoice.moistscal_vert_adv_type == AdvType::Weno_5Z)
1218  || (advChoice.dryscal_horiz_adv_type == AdvType::Weno_5Z)
1219  || (advChoice.dryscal_vert_adv_type == AdvType::Weno_5Z) )
1220  { return 3; }
1221  else if (
1223  || (advChoice.dryscal_vert_adv_type == AdvType::Weno_7)
1224  || (advChoice.moistscal_horiz_adv_type == AdvType::Weno_7)
1225  || (advChoice.moistscal_vert_adv_type == AdvType::Weno_7)
1226  || (advChoice.moistscal_horiz_adv_type == AdvType::Weno_7Z)
1227  || (advChoice.moistscal_vert_adv_type == AdvType::Weno_7Z)
1228  || (advChoice.dryscal_horiz_adv_type == AdvType::Weno_7Z)
1229  || (advChoice.dryscal_vert_adv_type == AdvType::Weno_7Z) )
1230  { return 4; }
1231  else
1232  { return 2; }
1233  }
1234  }
1235 
1236  AMREX_FORCE_INLINE
1237  amrex::YAFluxRegister* getAdvFluxReg (int lev)
1238  {
1239  return advflux_reg[lev];
1240  }
1241 
1242  AMREX_FORCE_INLINE
1243  std::ostream&
1244  DataLog (int i)
1245  {
1246  return *datalog[i];
1247  }
1248 
1249  AMREX_FORCE_INLINE
1250  int
1251  NumDataLogs () noexcept
1252  {
1253  return datalog.size();
1254  }
1255 
1256  AMREX_FORCE_INLINE
1257  std::ostream&
1259  {
1260  return *sampleptlog[i];
1261  }
1262 
1263  AMREX_FORCE_INLINE
1264  int
1266  {
1267  return sampleptlog.size();
1268  }
1269 
1270  AMREX_FORCE_INLINE
1271  std::ostream&
1273  {
1274  return *samplelinelog[i];
1275  }
1276 
1277  AMREX_FORCE_INLINE
1278  int
1279  NumSampleLineLogs () noexcept
1280  {
1281  return samplelinelog.size();
1282  }
1283 
1284  amrex::IntVect&
1285  SamplePoint (int i)
1286  {
1287  return samplepoint[i];
1288  }
1289 
1290  AMREX_FORCE_INLINE
1291  int
1292  NumSamplePoints () noexcept
1293  {
1294  return samplepoint.size();
1295  }
1296 
1297  amrex::IntVect&
1298  SampleLine (int i)
1299  {
1300  return sampleline[i];
1301  }
1302 
1303  AMREX_FORCE_INLINE
1304  int
1305  NumSampleLines () noexcept
1306  {
1307  return sampleline.size();
1308  }
1309 
1310  static amrex::Real startCPUTime;
1311  static amrex::Real previousCPUTimeUsed;
1312 
1313  static amrex::Real
1315  {
1316  int numCores = amrex::ParallelDescriptor::NProcs();
1317 #ifdef _OPENMP
1318  numCores = numCores * omp_get_max_threads();
1319 #endif
1320 
1321  amrex::Real T =
1322  numCores * (amrex::ParallelDescriptor::second() - startCPUTime) +
1324 
1325  return T;
1326  }
1327 
1328  void setRecordDataInfo (int i, const std::string& filename) // NOLINT
1329  {
1330  if (amrex::ParallelDescriptor::IOProcessor())
1331  {
1332  datalog[i] = std::make_unique<std::fstream>();
1333  datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
1334  if (!datalog[i]->good()) {
1335  amrex::FileOpenFailed(filename);
1336  }
1337  }
1338  amrex::ParallelDescriptor::Barrier("ERF::setRecordDataInfo");
1339  }
1340 
1341  void setRecordSamplePointInfo (int i, int lev, amrex::IntVect& cell, const std::string& filename) // NOLINT
1342  {
1343  amrex::MultiFab dummy(grids[lev],dmap[lev],1,0);
1344  for (amrex::MFIter mfi(dummy); mfi.isValid(); ++mfi)
1345  {
1346  const amrex::Box& bx = mfi.validbox();
1347  if (bx.contains(cell)) {
1348  sampleptlog[i] = std::make_unique<std::fstream>();
1349  sampleptlog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
1350  if (!sampleptlog[i]->good()) {
1351  amrex::FileOpenFailed(filename);
1352  }
1353  }
1354  }
1355  amrex::ParallelDescriptor::Barrier("ERF::setRecordSamplePointInfo");
1356  }
1357 
1358  void setRecordSampleLineInfo (int i, int lev, amrex::IntVect& cell, const std::string& filename) // NOLINT
1359  {
1360  amrex::MultiFab dummy(grids[lev],dmap[lev],1,0);
1361  for (amrex::MFIter mfi(dummy); mfi.isValid(); ++mfi)
1362  {
1363  const amrex::Box& bx = mfi.validbox();
1364  if (bx.contains(cell)) {
1365  samplelinelog[i] = std::make_unique<std::fstream>();
1366  samplelinelog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
1367  if (!samplelinelog[i]->good()) {
1368  amrex::FileOpenFailed(filename);
1369  }
1370  }
1371  }
1372  amrex::ParallelDescriptor::Barrier("ERF::setRecordSampleLineInfo");
1373  }
1374 
1375  // Data sampler for line and plane output
1377  amrex::Real sampler_per = -1.0;
1378  std::unique_ptr<SampleData> data_sampler = nullptr;
1379 
1380  amrex::Vector<std::unique_ptr<std::fstream> > datalog;
1381  amrex::Vector<std::string> datalogname;
1382 
1383  amrex::Vector<std::unique_ptr<std::fstream> > sampleptlog;
1384  amrex::Vector<std::string> sampleptlogname;
1385  amrex::Vector<amrex::IntVect> samplepoint;
1386 
1387  amrex::Vector<std::unique_ptr<std::fstream> > samplelinelog;
1388  amrex::Vector<std::string> samplelinelogname;
1389  amrex::Vector<amrex::IntVect> sampleline;
1390 
1391  //! The filename of the ith datalog file.
1392  [[nodiscard]] std::string DataLogName (int i) const noexcept { return datalogname[i]; }
1393 
1394  //! The filename of the ith sampleptlog file.
1395  [[nodiscard]] std::string SamplePointLogName (int i) const noexcept { return sampleptlogname[i]; }
1396 
1397  //! The filename of the ith samplelinelog file.
1398  [[nodiscard]] std::string SampleLineLogName (int i) const noexcept { return samplelinelogname[i]; }
1399 
1400 #ifdef ERF_USE_EB
1401 
1402  amrex::Vector<std::unique_ptr<amrex::EBFArrayBoxFactory> > m_factory;
1403 
1404  [[nodiscard]] amrex::FabFactory<amrex::FArrayBox> const&
1405  Factory (int lev) const noexcept { return *m_factory[lev]; }
1406  [[nodiscard]] amrex::EBFArrayBoxFactory const&
1407  EBFactory (int lev) const noexcept {
1408  return static_cast<amrex::EBFArrayBoxFactory const&>(*m_factory[lev]);
1409  }
1410 
1411  [[nodiscard]] static int nghost_eb_basic ()
1412  { return 5; }
1413 
1414  // We need 5 for doing StateRedistribution; otherwise 4 would be enough
1415  [[nodiscard]] static int nghost_eb_volume ()
1416  { return 5; }
1417 
1418  [[nodiscard]] static int nghost_eb_full ()
1419  { return 4; }
1420 #else
1421  amrex::Vector<std::unique_ptr<amrex::FabFactory<amrex::FArrayBox> > > m_factory;
1422 #endif
1423 
1424 #ifdef ERF_USE_FFT
1425  amrex::Vector<std::unique_ptr<amrex::FFT::Poisson<amrex::MultiFab>>> m_3D_poisson;
1426  amrex::Vector<std::unique_ptr<amrex::FFT::PoissonHybrid<amrex::MultiFab>>> m_2D_poisson;
1427 #endif
1428 
1429 public:
1430  void writeJobInfo (const std::string& dir) const;
1431  static void writeBuildInfo (std::ostream& os);
1432 
1433  static void print_banner(MPI_Comm /*comm*/, std::ostream& /*out*/);
1434  static void print_usage(MPI_Comm /*comm*/, std::ostream& /*out*/);
1435  static void print_error(MPI_Comm /*comm*/, const std::string& msg);
1436  static void print_summary(std::ostream&);
1437  static void print_tpls(std::ostream& /*out*/);
1438 };
1439 
1440 #endif
AMREX_ENUM(InitType, None, Input_Sounding, Ideal, Real, Metgrid, Uniform)
Contains the Eulerian microphysics class.
#define NBCVAR_max
Definition: ERF_IndexDefines.H:29
@ Centered_6th
Contains the Lagrangian microphysics class.
Definition: ERF.H:123
void MakeHorizontalAverages()
Definition: ERF.cpp:1722
amrex::Vector< amrex::MultiFab > rU_new
Definition: ERF.H:766
int last_check_file_step
Definition: ERF.H:915
amrex::Vector< std::unique_ptr< amrex::MultiFab > > walldist
Definition: ERF.H:860
void initRayleigh()
Initialize Rayleigh damping profiles.
Definition: ERF_InitRayleigh.cpp:14
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau23_lev
Definition: ERF.H:819
bool metgrid_basic_linear
Definition: ERF.H:1089
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
Definition: ERF.H:727
std::unique_ptr< ABLMost > m_most
Definition: ERF.H:1170
amrex::Vector< std::string > samplelinelogname
Definition: ERF.H:1388
int max_step
Definition: ERF.H:922
bool metgrid_debug_msf
Definition: ERF.H:1087
void setRayleighRefFromSounding(bool restarting)
Set Rayleigh mean profiles from input sounding.
Definition: ERF_InitRayleigh.cpp:55
int last_plot_file_step_2
Definition: ERF.H:913
amrex::Vector< std::unique_ptr< MRISplitIntegrator< amrex::Vector< amrex::MultiFab > > > > mri_integrator_mem
Definition: ERF.H:748
void Evolve()
Definition: ERF.cpp:374
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_rhotheta_src
Definition: ERF.H:1119
amrex::Vector< amrex::MultiFab > pp_inc
Definition: ERF.H:750
amrex::Vector< ERFFillPatcher > FPr_u
Definition: ERF.H:811
amrex::Real cloud_fraction(amrex::Real time)
Definition: ERF_WriteScalarProfiles.cpp:173
amrex::Vector< amrex::IntVect > sampleline
Definition: ERF.H:1389
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx3_lev
Definition: ERF.H:830
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Hwave_onegrid
Definition: ERF.H:876
amrex::Vector< amrex::Vector< amrex::MultiFab > > vars_new
Definition: ERF.H:741
ERF(ERF &&) noexcept=delete
AMREX_FORCE_INLINE int NumSampleLineLogs() noexcept
Definition: ERF.H:1279
static void print_tpls(std::ostream &)
Definition: ERF_ConsoleIO.cpp:137
amrex::Vector< amrex::Real > dz_min
Definition: ERF.H:1185
std::string DataLogName(int i) const noexcept
The filename of the ith datalog file.
Definition: ERF.H:1392
static PlotFileType plotfile_type_1
Definition: ERF.H:1057
void remake_zphys(int lev, std::unique_ptr< amrex::MultiFab > &temp_zphys_nd)
Definition: ERF_MakeNewArrays.cpp:503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_yforce
Definition: ERF.H:909
void ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real time, int ngrow) override
Definition: ERF_Tagging.cpp:15
std::string plot_file_2
Definition: ERF.H:946
void FillBdyCCVels(amrex::Vector< amrex::MultiFab > &mf_cc_vel)
Definition: ERF_FillBdyCCVels.cpp:11
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx3_lev
Definition: ERF.H:828
amrex::Vector< amrex::Vector< amrex::Real > > h_w_subsid
Definition: ERF.H:1124
static void print_banner(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:60
amrex::Vector< std::unique_ptr< std::fstream > > datalog
Definition: ERF.H:1380
static amrex::Real sum_per
Definition: ERF.H:1054
amrex::Vector< ERFFillPatcher > FPr_v
Definition: ERF.H:812
int cf_set_width
Definition: ERF.H:809
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mapfac_u
Definition: ERF.H:864
static amrex::Real previousCPUTimeUsed
Definition: ERF.H:1311
void setPlotVariables(const std::string &pp_plot_var_names, amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile.cpp:17
amrex::Gpu::DeviceVector< amrex::Real > d_havg_temperature
Definition: ERF.H:1161
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau31_lev
Definition: ERF.H:818
amrex::Vector< amrex::Vector< amrex::Vector< amrex::Real > > > h_sponge_ptrs
Definition: ERF.H:1146
void fill_from_bndryregs(const amrex::Vector< amrex::MultiFab * > &mfs, amrex::Real time)
Definition: ERF_BoundaryConditionsBndryReg.cpp:13
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mapfac_m
Definition: ERF.H:863
void setRecordDataInfo(int i, const std::string &filename)
Definition: ERF.H:1328
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx1_lev
Definition: ERF.H:828
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF.H:893
void project_velocities_tb(int lev, amrex::Real dt, amrex::Vector< amrex::MultiFab > &vars, amrex::MultiFab &p)
Definition: ERF_PoissonSolve_tb.cpp:20
void init_from_input_sounding(int lev)
Definition: ERF_InitFromInputSounding.cpp:50
amrex::Gpu::DeviceVector< amrex::Real > d_havg_qv
Definition: ERF.H:1163
static amrex::Real column_loc_y
Definition: ERF.H:1102
static int mg_verbose
Definition: ERF.H:1048
void ReadParameters()
Definition: ERF.cpp:1366
static amrex::Vector< std::string > PlotFileVarNames(amrex::Vector< std::string > plot_var_names)
Definition: ERF_Plotfile.cpp:174
void InitializeFromFile()
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_cons > > physbcs_cons
Definition: ERF.H:753
static bool init_sounding_ideal
Definition: ERF.H:1080
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ay_new
Definition: ERF.H:854
ERF()
Definition: ERF.cpp:87
void init_Dirichlet_bc_data(const std::string input_file)
Definition: ERF_InitBCs.cpp:599
~ERF() override
std::string restart_type
Definition: ERF.H:963
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd_src
Definition: ERF.H:845
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc
Definition: ERF.H:840
amrex::Real m_plot_per_1
Definition: ERF.H:950
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_cc
Definition: ERF.H:838
amrex::Vector< std::unique_ptr< amrex::MultiFab > > eddyDiffs_lev
Definition: ERF.H:820
static SolverChoice solverChoice
Definition: ERF.H:1012
std::string check_type
Definition: ERF.H:962
amrex::Vector< ERFFillPatcher > FPr_c
Definition: ERF.H:810
static bool use_fft
Definition: ERF.H:1049
bool m_plot_face_vels
Definition: ERF.H:952
amrex::Vector< amrex::MultiFab > base_state_new
Definition: ERF.H:871
amrex::Vector< std::unique_ptr< amrex::MultiFab > > az
Definition: ERF.H:843
int regrid_int
Definition: ERF.H:942
amrex::Vector< amrex::Real > fixed_dt
Definition: ERF.H:936
void write_1D_profiles_stag(amrex::Real time)
Definition: ERF_Write1DProfiles_stag.cpp:23
void WriteGenericPlotfileHeaderWithTerrain(std::ostream &HeaderFile, int nlevels, const amrex::Vector< amrex::BoxArray > &bArray, const amrex::Vector< std::string > &varnames, const amrex::Vector< amrex::Geometry > &my_geom, amrex::Real time, const amrex::Vector< int > &level_steps, const amrex::Vector< amrex::IntVect > &my_ref_ratio, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix) const
Definition: ERF_Plotfile.cpp:1706
amrex::Vector< amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > > d_sponge_ptrs
Definition: ERF.H:1152
amrex::Vector< amrex::Vector< amrex::Real > > h_rhoqt_src
Definition: ERF.H:1121
amrex::Vector< long > dt_mri_ratio
Definition: ERF.H:736
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vel_t_avg
Definition: ERF.H:745
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q2fx3_lev
Definition: ERF.H:831
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::iMultiFab > > > lmask_lev
Definition: ERF.H:825
amrex::Real stop_time
Definition: ERF.H:924
AMREX_FORCE_INLINE int NumSamplePointLogs() noexcept
Definition: ERF.H:1265
amrex::Vector< amrex::Real > h_havg_pressure
Definition: ERF.H:1156
void update_diffusive_arrays(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Definition: ERF_MakeNewArrays.cpp:374
static int verbose
Definition: ERF.H:1047
amrex::Vector< amrex::Real > h_havg_qc
Definition: ERF.H:1158
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_w > > physbcs_w
Definition: ERF.H:756
void Advance(int lev, amrex::Real time, amrex::Real dt_lev, int iteration, int ncycle)
Definition: ERF_Advance.cpp:20
static std::string column_file_name
Definition: ERF.H:1103
amrex::Vector< std::unique_ptr< std::fstream > > samplelinelog
Definition: ERF.H:1387
std::unique_ptr< Microphysics > micro
Definition: ERF.H:776
amrex::Vector< amrex::MultiFab > base_state
Definition: ERF.H:870
AMREX_FORCE_INLINE amrex::YAFluxRegister * getAdvFluxReg(int lev)
Definition: ERF.H:1237
amrex::Vector< amrex::Real > h_havg_density
Definition: ERF.H:1154
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd_new
Definition: ERF.H:851
amrex::Vector< amrex::Real > fixed_fast_dt
Definition: ERF.H:937
bool metgrid_retain_sfc
Definition: ERF.H:1092
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Qv_prim
Definition: ERF.H:761
static int sum_interval
Definition: ERF.H:1052
static int pert_interval
Definition: ERF.H:1053
void restart()
Definition: ERF.cpp:1223
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau13_lev
Definition: ERF.H:818
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx2_lev
Definition: ERF.H:830
void ReadCheckpointFileMOST()
Definition: ERF_Checkpoint.cpp:627
void FillIntermediatePatch(int lev, amrex::Real time, const amrex::Vector< amrex::MultiFab * > &mfs_vel, const amrex::Vector< amrex::MultiFab * > &mfs_mom, int ng_cons, int ng_vel, bool cons_only, int icomp_cons, int ncomp_cons, bool allow_most_bcs=true)
Definition: ERF_FillIntermediatePatch.cpp:28
amrex::IntVect & SampleLine(int i)
Definition: ERF.H:1298
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau21_lev
Definition: ERF.H:817
amrex::Vector< amrex::MultiFab > rV_new
Definition: ERF.H:768
std::string PlotFileName(int lev) const
void write_1D_profiles(amrex::Real time)
Definition: ERF_Write1DProfiles.cpp:15
void initialize_integrator(int lev, amrex::MultiFab &cons_mf, amrex::MultiFab &vel_mf)
Definition: ERF_MakeNewArrays.cpp:541
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_zforce
Definition: ERF.H:910
static InitType init_type
Definition: ERF.H:1060
amrex::Vector< amrex::BCRec > domain_bcs_type
Definition: ERF.H:886
amrex::Array< amrex::LinOpBCType, AMREX_SPACEDIM > get_projection_bc(amrex::Orientation::Side side) const noexcept
Definition: ERF_SolveWithMLMG.cpp:17
int m_plot_int_1
Definition: ERF.H:948
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Qr_prim
Definition: ERF.H:762
void post_timestep(int nstep, amrex::Real time, amrex::Real dt_lev)
Definition: ERF.cpp:461
std::string pp_prefix
Definition: ERF.H:445
std::string SampleLineLogName(int i) const noexcept
The filename of the ith samplelinelog file.
Definition: ERF.H:1398
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > sst_lev
Definition: ERF.H:824
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_xforce
Definition: ERF.H:908
AMREX_FORCE_INLINE int NumSamplePoints() noexcept
Definition: ERF.H:1292
bool metgrid_use_sfc
Definition: ERF.H:1091
void erf_enforce_hse(int lev, amrex::MultiFab &dens, amrex::MultiFab &pres, amrex::MultiFab &pi, amrex::MultiFab &th, std::unique_ptr< amrex::MultiFab > &z_cc)
Definition: ERF_Init1D.cpp:149
static amrex::Real bndry_output_planes_per
Definition: ERF.H:1108
amrex::Real m_check_per
Definition: ERF.H:965
void init_custom(int lev)
Definition: ERF_InitCustom.cpp:26
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau33_lev
Definition: ERF.H:816
std::unique_ptr< ProblemBase > prob
Definition: ERF.H:723
amrex::Vector< int > num_files_at_level
Definition: ERF.H:726
void WriteMultiLevelPlotfileWithTerrain(const std::string &plotfilename, int nlevels, const amrex::Vector< const amrex::MultiFab * > &mf, const amrex::Vector< const amrex::MultiFab * > &mf_nd, const amrex::Vector< std::string > &varnames, const amrex::Vector< amrex::Geometry > &my_geom, amrex::Real time, const amrex::Vector< int > &level_steps, const amrex::Vector< amrex::IntVect > &my_ref_ratio, const std::string &versionName="HyperCLaw-V1.1", const std::string &levelPrefix="Level_", const std::string &mfPrefix="Cell", const amrex::Vector< std::string > &extra_dirs=amrex::Vector< std::string >()) const
Definition: ERF_Plotfile.cpp:1619
void init_bcs()
Definition: ERF_InitBCs.cpp:20
int profile_int
Definition: ERF.H:957
bool metgrid_debug_quiescent
Definition: ERF.H:1083
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_u > > physbcs_u
Definition: ERF.H:754
amrex::Vector< amrex::Real > t_new
Definition: ERF.H:733
bool destag_profiles
Definition: ERF.H:958
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > stretched_dz_d
Definition: ERF.H:868
amrex::Vector< amrex::Real > t_avg_cnt
Definition: ERF.H:746
amrex::Vector< std::string > plot_var_names_1
Definition: ERF.H:967
int m_check_int
Definition: ERF.H:964
amrex::Real estTimeStep(int lev, long &dt_fast_ratio) const
Definition: ERF_ComputeTimestep.cpp:55
static std::string sponge_type
Definition: ERF.H:1064
static amrex::Real startCPUTime
Definition: ERF.H:1310
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_diss_lev
Definition: ERF.H:829
amrex::Vector< amrex::MultiFab > rU_old
Definition: ERF.H:765
amrex::Vector< amrex::Real > t_old
Definition: ERF.H:734
AMREX_FORCE_INLINE int NumSampleLines() noexcept
Definition: ERF.H:1305
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Theta_prim
Definition: ERF.H:760
void init1DArrays()
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_t_rk
Definition: ERF.H:857
amrex::Vector< std::unique_ptr< TerrainDrag > > m_terrain_drag
Definition: ERF.H:1172
void compute_divergence(int lev, amrex::MultiFab &rhs, amrex::Array< amrex::MultiFab const *, AMREX_SPACEDIM > rho0_u_const, amrex::Geometry const &geom_at_lev)
Definition: ERF_ComputeDivergence.cpp:10
void fill_rhs(amrex::MultiFab &rhs_mf, const amrex::MultiFab &state_mf, amrex::Real time, const amrex::Geometry &geom)
void appendPlotVariables(const std::string &pp_plot_var_names, amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile.cpp:128
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_v > > physbcs_v
Definition: ERF.H:755
amrex::Vector< std::string > plot_var_names_2
Definition: ERF.H:968
static amrex::Real column_per
Definition: ERF.H:1100
static int output_bndry_planes
Definition: ERF.H:1106
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_v_geos
Definition: ERF.H:1131
int last_plot_file_step_1
Definition: ERF.H:912
void update_terrain_arrays(int lev)
Definition: ERF_MakeNewArrays.cpp:530
static std::string nc_bdy_file
Definition: ERF.H:1074
bool metgrid_interp_theta
Definition: ERF.H:1088
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
Definition: ERF.H:1071
void init_only(int lev, amrex::Real time)
Definition: ERF.cpp:1254
static int input_bndry_planes
Definition: ERF.H:1112
static StateInterpType interpolation_type
Definition: ERF.H:1061
amrex::Gpu::DeviceVector< amrex::Real > d_havg_qc
Definition: ERF.H:1164
void AverageDown()
Definition: ERF_AverageDown.cpp:16
amrex::Vector< amrex::Vector< amrex::Real > > h_v_geos
Definition: ERF.H:1130
bool projection_has_dirichlet(amrex::Array< amrex::LinOpBCType, AMREX_SPACEDIM > bcs) const
Definition: ERF_PoissonSolve_tb.cpp:8
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Lwave_onegrid
Definition: ERF.H:877
InputSoundingData input_sounding_data
Definition: ERF.H:692
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_rhoqt_src
Definition: ERF.H:1122
std::unique_ptr< SampleData > data_sampler
Definition: ERF.H:1378
amrex::MultiFab fine_mask
Definition: ERF.H:1183
amrex::Gpu::DeviceVector< amrex::Real > d_havg_density
Definition: ERF.H:1160
void init_from_hse(int lev)
Definition: ERF_InitFromHSE.cpp:32
static bool use_real_bcs
Definition: ERF.H:1068
amrex::Vector< amrex::YAFluxRegister * > advflux_reg
Definition: ERF.H:881
int metgrid_force_sfc_k
Definition: ERF.H:1095
amrex::Vector< amrex::Vector< amrex::Real > > h_rhotheta_src
Definition: ERF.H:1118
static int ng_pres_hse
Definition: ERF.H:1115
static amrex::Real bndry_output_planes_start_time
Definition: ERF.H:1109
static amrex::Real cfl
Definition: ERF.H:930
void solve_with_mlmg(int lev, amrex::Vector< amrex::MultiFab > &rhs, amrex::Vector< amrex::MultiFab > &p, amrex::Vector< amrex::Array< amrex::MultiFab, AMREX_SPACEDIM >> &fluxes)
Definition: ERF_SolveWithMLMG.cpp:40
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
Definition: ERF.H:887
amrex::Vector< std::unique_ptr< ForestDrag > > m_forest_drag
Definition: ERF.H:1171
void derive_diag_profiles_stag(amrex::Real time, amrex::Gpu::HostVector< amrex::Real > &h_avg_u, amrex::Gpu::HostVector< amrex::Real > &h_avg_v, amrex::Gpu::HostVector< amrex::Real > &h_avg_w, amrex::Gpu::HostVector< amrex::Real > &h_avg_rho, amrex::Gpu::HostVector< amrex::Real > &h_avg_th, amrex::Gpu::HostVector< amrex::Real > &h_avg_ksgs, amrex::Gpu::HostVector< amrex::Real > &h_avg_Kmv, amrex::Gpu::HostVector< amrex::Real > &h_avg_Khv, amrex::Gpu::HostVector< amrex::Real > &h_avg_qv, amrex::Gpu::HostVector< amrex::Real > &h_avg_qc, amrex::Gpu::HostVector< amrex::Real > &h_avg_qr, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqv, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqc, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqr, amrex::Gpu::HostVector< amrex::Real > &h_avg_qi, amrex::Gpu::HostVector< amrex::Real > &h_avg_qs, amrex::Gpu::HostVector< amrex::Real > &h_avg_qg, amrex::Gpu::HostVector< amrex::Real > &h_avg_uu, amrex::Gpu::HostVector< amrex::Real > &h_avg_uv, amrex::Gpu::HostVector< amrex::Real > &h_avg_uw, amrex::Gpu::HostVector< amrex::Real > &h_avg_vv, amrex::Gpu::HostVector< amrex::Real > &h_avg_vw, amrex::Gpu::HostVector< amrex::Real > &h_avg_ww, amrex::Gpu::HostVector< amrex::Real > &h_avg_uth, amrex::Gpu::HostVector< amrex::Real > &h_avg_vth, amrex::Gpu::HostVector< amrex::Real > &h_avg_wth, amrex::Gpu::HostVector< amrex::Real > &h_avg_thth, amrex::Gpu::HostVector< amrex::Real > &h_avg_ku, amrex::Gpu::HostVector< amrex::Real > &h_avg_kv, amrex::Gpu::HostVector< amrex::Real > &h_avg_kw, amrex::Gpu::HostVector< amrex::Real > &h_avg_p, amrex::Gpu::HostVector< amrex::Real > &h_avg_pu, amrex::Gpu::HostVector< amrex::Real > &h_avg_pv, amrex::Gpu::HostVector< amrex::Real > &h_avg_pw, amrex::Gpu::HostVector< amrex::Real > &h_avg_wthv)
Definition: ERF_Write1DProfiles_stag.cpp:298
amrex::Real sampler_per
Definition: ERF.H:1377
InputSpongeData input_sponge_data
Definition: ERF.H:695
std::string restart_chkfile
Definition: ERF.H:927
bool metgrid_use_below_sfc
Definition: ERF.H:1090
void init_zphys(int lev, amrex::Real time)
Definition: ERF_MakeNewArrays.cpp:464
amrex::Vector< std::string > sampleptlogname
Definition: ERF.H:1384
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > xvel_bc_data
Definition: ERF.H:698
void InitData_pre()
Definition: ERF.cpp:615
amrex::IntVect & SamplePoint(int i)
Definition: ERF.H:1285
amrex::Vector< amrex::Vector< amrex::Real > > h_u_geos
Definition: ERF.H:1127
void InitializeLevelFromData(int lev, const amrex::MultiFab &initial_data)
void sum_integrated_quantities(amrex::Real time)
Definition: ERF_WriteScalarProfiles.cpp:14
amrex::Vector< std::string > datalogname
Definition: ERF.H:1381
void initHSE()
Initialize HSE.
Definition: ERF_Init1D.cpp:130
static amrex::Real column_loc_x
Definition: ERF.H:1101
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ax
Definition: ERF.H:841
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd
Definition: ERF.H:837
void MakeDiagnosticAverage(amrex::Vector< amrex::Real > &h_havg, amrex::MultiFab &S, int n)
Definition: ERF.cpp:1828
amrex::Real metgrid_proximity
Definition: ERF.H:1093
amrex::Vector< amrex::Real > h_havg_temperature
Definition: ERF.H:1155
amrex::Vector< std::unique_ptr< std::fstream > > sampleptlog
Definition: ERF.H:1383
static PlotFileType plotfile_type_2
Definition: ERF.H:1058
void poisson_wall_dist(int lev)
Definition: ERF_PoissonWallDist.cpp:16
void solve_with_gmres(int lev, amrex::Vector< amrex::MultiFab > &rhs, amrex::Vector< amrex::MultiFab > &p, amrex::Vector< amrex::Array< amrex::MultiFab, AMREX_SPACEDIM >> &fluxes)
Definition: ERF_SolveWithGMRES.cpp:12
void WritePlotFile(int which, PlotFileType plotfile_type, amrex::Vector< std::string > plot_var_names)
Definition: ERF_Plotfile.cpp:186
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc_src
Definition: ERF.H:846
amrex::Gpu::DeviceVector< amrex::Real > d_havg_pressure
Definition: ERF.H:1162
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SmnSmn_lev
Definition: ERF.H:821
const amrex::Vector< std::string > derived_names
Definition: ERF.H:974
amrex::Real start_time
Definition: ERF.H:923
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ay_src
Definition: ERF.H:848
void sample_points(int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab &mf)
Definition: ERF_WriteScalarProfiles.cpp:249
AMREX_FORCE_INLINE std::ostream & DataLog(int i)
Definition: ERF.H:1244
void writeJobInfo(const std::string &dir) const
Definition: ERF_WriteJobInfo.cpp:9
void ComputeDt(int step=-1)
Definition: ERF_ComputeTimestep.cpp:11
amrex::Vector< int > nsubsteps
Definition: ERF.H:730
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > yflux_imask
Definition: ERF.H:903
amrex::Vector< amrex::MultiFab > rW_new
Definition: ERF.H:770
amrex::Vector< std::unique_ptr< amrex::MultiFab > > az_new
Definition: ERF.H:855
std::unique_ptr< WriteBndryPlanes > m_w2d
Definition: ERF.H:1168
std::string plot_file_1
Definition: ERF.H:945
AMREX_FORCE_INLINE std::ostream & SampleLineLog(int i)
Definition: ERF.H:1272
amrex::Vector< amrex::Vector< amrex::MultiFab * > > lsm_flux
Definition: ERF.H:794
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau32_lev
Definition: ERF.H:819
std::string SamplePointLogName(int i) const noexcept
The filename of the ith sampleptlog file.
Definition: ERF.H:1395
void turbPert_update(const int lev, const amrex::Real dt)
Definition: ERF_InitTurbPert.cpp:12
void InitData_post()
Definition: ERF.cpp:652
void refinement_criteria_setup()
Definition: ERF_Tagging.cpp:105
bool metgrid_debug_dry
Definition: ERF.H:1085
static int bndry_output_planes_interval
Definition: ERF.H:1107
void init_geo_wind_profile(const std::string input_file, amrex::Vector< amrex::Real > &u_geos, amrex::Gpu::DeviceVector< amrex::Real > &u_geos_d, amrex::Vector< amrex::Real > &v_geos, amrex::Gpu::DeviceVector< amrex::Real > &v_geos_d, const amrex::Geometry &lgeom, const amrex::Vector< amrex::Real > &zlev_stag)
Definition: ERF_InitGeowind.cpp:10
void ERF_shared()
Definition: ERF.cpp:102
void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:310
static void GotoNextLine(std::istream &is)
Definition: ERF_Checkpoint.cpp:15
void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:23
void init_stuff(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, amrex::Vector< amrex::MultiFab > &lev_new, amrex::Vector< amrex::MultiFab > &lev_old, amrex::MultiFab &tmp_base_state, std::unique_ptr< amrex::MultiFab > &tmp_zphys_nd)
Definition: ERF_MakeNewArrays.cpp:23
amrex::Vector< amrex::MultiFab > zmom_crse_rhs
Definition: ERF.H:774
bool metgrid_debug_isothermal
Definition: ERF.H:1084
void initSponge()
Initialize sponge profiles.
Definition: ERF_InitSponge.cpp:35
void derive_diag_profiles(amrex::Real time, amrex::Gpu::HostVector< amrex::Real > &h_avg_u, amrex::Gpu::HostVector< amrex::Real > &h_avg_v, amrex::Gpu::HostVector< amrex::Real > &h_avg_w, amrex::Gpu::HostVector< amrex::Real > &h_avg_rho, amrex::Gpu::HostVector< amrex::Real > &h_avg_th, amrex::Gpu::HostVector< amrex::Real > &h_avg_ksgs, amrex::Gpu::HostVector< amrex::Real > &h_avg_Kmv, amrex::Gpu::HostVector< amrex::Real > &h_avg_Khv, amrex::Gpu::HostVector< amrex::Real > &h_avg_qv, amrex::Gpu::HostVector< amrex::Real > &h_avg_qc, amrex::Gpu::HostVector< amrex::Real > &h_avg_qr, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqv, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqc, amrex::Gpu::HostVector< amrex::Real > &h_avg_wqr, amrex::Gpu::HostVector< amrex::Real > &h_avg_qi, amrex::Gpu::HostVector< amrex::Real > &h_avg_qs, amrex::Gpu::HostVector< amrex::Real > &h_avg_qg, amrex::Gpu::HostVector< amrex::Real > &h_avg_uu, amrex::Gpu::HostVector< amrex::Real > &h_avg_uv, amrex::Gpu::HostVector< amrex::Real > &h_avg_uw, amrex::Gpu::HostVector< amrex::Real > &h_avg_vv, amrex::Gpu::HostVector< amrex::Real > &h_avg_vw, amrex::Gpu::HostVector< amrex::Real > &h_avg_ww, amrex::Gpu::HostVector< amrex::Real > &h_avg_uth, amrex::Gpu::HostVector< amrex::Real > &h_avg_vth, amrex::Gpu::HostVector< amrex::Real > &h_avg_wth, amrex::Gpu::HostVector< amrex::Real > &h_avg_thth, amrex::Gpu::HostVector< amrex::Real > &h_avg_ku, amrex::Gpu::HostVector< amrex::Real > &h_avg_kv, amrex::Gpu::HostVector< amrex::Real > &h_avg_kw, amrex::Gpu::HostVector< amrex::Real > &h_avg_p, amrex::Gpu::HostVector< amrex::Real > &h_avg_pu, amrex::Gpu::HostVector< amrex::Real > &h_avg_pv, amrex::Gpu::HostVector< amrex::Real > &h_avg_pw, amrex::Gpu::HostVector< amrex::Real > &h_avg_wthv)
Definition: ERF_Write1DProfiles.cpp:192
int real_width
Definition: ERF.H:1075
void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:195
amrex::Vector< std::unique_ptr< amrex::FabFactory< amrex::FArrayBox > > > m_factory
Definition: ERF.H:1421
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ax_src
Definition: ERF.H:847
void input_sponge(int lev)
Definition: ERF_InitSponge.cpp:17
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_u_geos
Definition: ERF.H:1128
void Define_ERFFillPatchers(int lev)
Definition: ERF.cpp:1900
AMREX_FORCE_INLINE int NumDataLogs() noexcept
Definition: ERF.H:1251
TurbulentPerturbation turbPert
Definition: ERF.H:1015
amrex::Vector< amrex::MultiFab > rW_old
Definition: ERF.H:769
void advance_lsm(int lev, amrex::MultiFab &, const amrex::Real &dt_advance)
Definition: ERF_AdvanceLSM.cpp:5
void FillCoarsePatch(int lev, amrex::Real time)
Definition: ERF_FillCoarsePatch.cpp:21
void ClearLevel(int lev) override
Definition: ERF_MakeNewLevel.cpp:468
static amrex::Vector< amrex::AMRErrorTag > ref_tags
Definition: ERF.H:1177
void make_physbcs(int lev)
Definition: ERF_MakeNewArrays.cpp:563
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_w_subsid
Definition: ERF.H:1125
amrex::Vector< ERFFillPatcher > FPr_w
Definition: ERF.H:813
int real_set_width
Definition: ERF.H:1076
void FillPatch(int lev, amrex::Real time, const amrex::Vector< amrex::MultiFab * > &mfs_vel, const amrex::Vector< amrex::MultiFab * > &mfs_mom, const amrex::MultiFab &old_base_state, const amrex::MultiFab &new_base_state, bool fillset=true, bool cons_only=false)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx2_lev
Definition: ERF.H:828
amrex::Vector< amrex::Vector< amrex::Real > > zlevels_stag
Definition: ERF.H:834
amrex::Vector< amrex::Vector< amrex::MultiFab * > > lsm_data
Definition: ERF.H:793
amrex::Vector< amrex::Vector< amrex::Real > > stretched_dz_h
Definition: ERF.H:867
void WriteCheckpointFile() const
Definition: ERF_Checkpoint.cpp:25
int sampler_interval
Definition: ERF.H:1376
static int output_1d_column
Definition: ERF.H:1098
bool metgrid_debug_psfc
Definition: ERF.H:1086
amrex::Vector< std::unique_ptr< amrex::MultiFab > > az_src
Definition: ERF.H:849
static int fixed_mri_dt_ratio
Definition: ERF.H:938
int m_plot_int_2
Definition: ERF.H:949
amrex::Vector< amrex::Real > dt
Definition: ERF.H:735
static amrex::Real init_shrink
Definition: ERF.H:932
static bool is_it_time_for_action(int nstep, amrex::Real time, amrex::Real dt, int action_interval, amrex::Real action_per)
Definition: ERF_WriteScalarProfiles.cpp:466
amrex::Vector< amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > > d_rayleigh_ptrs
Definition: ERF.H:1149
void InitData()
Definition: ERF.cpp:606
void advance_microphysics(int lev, amrex::MultiFab &cons_in, const amrex::Real &dt_advance, const int &iteration, const amrex::Real &time)
Definition: ERF_AdvanceMicrophysics.cpp:5
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Lwave
Definition: ERF.H:875
void project_velocities(int lev, amrex::Real dt, amrex::Vector< amrex::MultiFab > &vars, amrex::MultiFab &p)
Definition: ERF_PoissonSolve.cpp:10
void ParameterSanityChecks()
Definition: ERF.cpp:1656
void derive_stress_profiles(amrex::Gpu::HostVector< amrex::Real > &h_avg_tau11, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau12, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau13, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau22, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau23, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau33, amrex::Gpu::HostVector< amrex::Real > &h_avg_hfx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_q1fx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_q2fx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_diss)
Definition: ERF_Write1DProfiles.cpp:480
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau12_lev
Definition: ERF.H:817
int cf_width
Definition: ERF.H:808
amrex::Vector< amrex::Vector< amrex::Vector< amrex::Real > > > h_rayleigh_ptrs
Definition: ERF.H:1143
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > zflux_imask
Definition: ERF.H:904
bool m_expand_plotvars_to_unif_rr
Definition: ERF.H:947
int plot_file_on_restart
Definition: ERF.H:916
void Construct_ERFFillPatchers(int lev)
Definition: ERF.cpp:1874
void post_update(amrex::MultiFab &state_mf, amrex::Real time, const amrex::Geometry &geom)
amrex::Vector< int > num_boxes_at_level
Definition: ERF.H:725
static amrex::Real sub_cfl
Definition: ERF.H:931
static void print_error(MPI_Comm, const std::string &msg)
Definition: ERF_ConsoleIO.cpp:43
static int ng_dens_hse
Definition: ERF.H:1114
std::unique_ptr< ReadBndryPlanes > m_r2d
Definition: ERF.H:1169
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ay
Definition: ERF.H:842
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ax_new
Definition: ERF.H:853
amrex::Vector< amrex::Vector< amrex::MultiFab * > > qmoist
Definition: ERF.H:777
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx1_lev
Definition: ERF.H:830
static amrex::Real getCPUTime()
Definition: ERF.H:1314
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > zvel_bc_data
Definition: ERF.H:700
void derive_stress_profiles_stag(amrex::Gpu::HostVector< amrex::Real > &h_avg_tau11, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau12, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau13, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau22, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau23, amrex::Gpu::HostVector< amrex::Real > &h_avg_tau33, amrex::Gpu::HostVector< amrex::Real > &h_avg_hfx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_q1fx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_q2fx3, amrex::Gpu::HostVector< amrex::Real > &h_avg_diss)
Definition: ERF_Write1DProfiles_stag.cpp:610
LandSurface lsm
Definition: ERF.H:792
static amrex::Real change_max
Definition: ERF.H:933
void AverageDownTo(int crse_lev, int scomp, int ncomp)
Definition: ERF_AverageDown.cpp:36
void setRecordSampleLineInfo(int i, int lev, amrex::IntVect &cell, const std::string &filename)
Definition: ERF.H:1358
void setSpongeRefFromSounding(bool restarting)
Set sponge mean profiles from input sounding.
Definition: ERF_InitSponge.cpp:65
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc_new
Definition: ERF.H:852
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mapfac_v
Definition: ERF.H:865
amrex::Array< std::string, 2 *AMREX_SPACEDIM > domain_bc_type
Definition: ERF.H:890
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > yvel_bc_data
Definition: ERF.H:699
void init_uniform(int lev)
Definition: ERF_InitUniform.cpp:17
static AMREX_FORCE_INLINE int ComputeGhostCells(const AdvChoice &advChoice, bool use_num_diff)
Definition: ERF.H:1189
static void writeBuildInfo(std::ostream &os)
Definition: ERF_WriteJobInfo.cpp:137
amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > phys_bc_type
Definition: ERF.H:899
std::string check_file
Definition: ERF.H:961
amrex::Vector< amrex::IntVect > samplepoint
Definition: ERF.H:1385
amrex::Vector< amrex::Real > h_havg_qv
Definition: ERF.H:1157
amrex::Real volWgtSumMF(int lev, const amrex::MultiFab &mf, int comp, const amrex::MultiFab &mapfac, bool local, bool finemask)
Definition: ERF_WriteScalarProfiles.cpp:378
static void print_usage(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:26
amrex::Vector< amrex::MultiFab > rV_old
Definition: ERF.H:767
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau11_lev
Definition: ERF.H:816
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Hwave
Definition: ERF.H:874
amrex::Vector< int > istep
Definition: ERF.H:729
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > xflux_imask
Definition: ERF.H:902
void derive_upwp(amrex::Vector< amrex::Real > &h_havg)
int metgrid_order
Definition: ERF.H:1094
bool finished_wave
Definition: ERF.H:878
void ReadCheckpointFile()
Definition: ERF_Checkpoint.cpp:273
bool writeNow(const amrex::Real cur_time, const amrex::Real dt, const int nstep, const int plot_int, const amrex::Real plot_per)
Definition: ERF.cpp:1951
amrex::Vector< amrex::Vector< amrex::MultiFab > > vars_old
Definition: ERF.H:742
amrex::MultiFab & build_fine_mask(int lev)
Definition: ERF_WriteScalarProfiles.cpp:429
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_base > > physbcs_base
Definition: ERF.H:757
void init_thin_body(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Definition: ERF_MakeNewLevel.cpp:507
AMREX_FORCE_INLINE std::ostream & SamplePointLog(int i)
Definition: ERF.H:1258
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF.H:896
void advance_dycore(int level, amrex::Vector< amrex::MultiFab > &state_old, amrex::Vector< amrex::MultiFab > &state_new, amrex::MultiFab &xvel_old, amrex::MultiFab &yvel_old, amrex::MultiFab &zvel_old, amrex::MultiFab &xvel_new, amrex::MultiFab &yvel_new, amrex::MultiFab &zvel_new, amrex::MultiFab &source, amrex::MultiFab &xmom_src, amrex::MultiFab &ymom_src, amrex::MultiFab &zmom_src, amrex::Geometry fine_geom, amrex::Real dt, amrex::Real time)
Definition: ERF_AdvanceDycore.cpp:37
void setRecordSamplePointInfo(int i, int lev, amrex::IntVect &cell, const std::string &filename)
Definition: ERF.H:1341
static int column_interval
Definition: ERF.H:1099
static void print_summary(std::ostream &)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Tau22_lev
Definition: ERF.H:816
void turbPert_amplitude(const int lev)
Definition: ERF_InitTurbPert.cpp:41
void sample_lines(int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab &mf)
Definition: ERF_WriteScalarProfiles.cpp:287
void initializeMicrophysics(const int &)
Definition: ERF.cpp:1187
bool plot_lsm
Definition: ERF.H:954
const amrex::Vector< std::string > cons_names
Definition: ERF.H:969
void FillPatch(int lev, amrex::Real time, const amrex::Vector< amrex::MultiFab * > &mfs_vel, bool cons_only=false)
void timeStep(int lev, amrex::Real time, int iteration)
Definition: ERF_TimeStep.cpp:16
amrex::Real m_plot_per_2
Definition: ERF.H:951
Definition: ERF_LandSurface.H:14
Definition: ERF_MultiBlockContainer.H:8
Definition: ERF_Radiation.H:36
@ pres
Definition: ERF_Kessler.H:33
@ T
Definition: ERF_IndexDefines.H:99
Definition: ERF_ConsoleIO.cpp:12
Definition: ERF_AdvStruct.H:19
AdvType moistscal_horiz_adv_type
Definition: ERF_AdvStruct.H:286
AdvType dycore_vert_adv_type
Definition: ERF_AdvStruct.H:283
AdvType moistscal_vert_adv_type
Definition: ERF_AdvStruct.H:287
AdvType dryscal_horiz_adv_type
Definition: ERF_AdvStruct.H:284
AdvType dycore_horiz_adv_type
Definition: ERF_AdvStruct.H:282
AdvType dryscal_vert_adv_type
Definition: ERF_AdvStruct.H:285
Definition: ERF_InputSoundingData.H:22
Definition: ERF_InputSpongeData.H:19
Definition: ERF_DataStruct.H:82
Definition: ERF_TurbPertStruct.H:18