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 #include <set>
8 
9 #ifdef _OPENMP
10 #include <omp.h>
11 #endif
12 
13 #include <AMReX_AmrCore.H>
14 #include <AMReX_BCRec.H>
15 #include <AMReX_Print.H>
16 
17 #include <AMReX_ParallelDescriptor.H>
18 #include <AMReX_ParmParse.H>
19 #include <AMReX_MultiFabUtil.H>
20 #include <AMReX_FillPatchUtil.H>
21 #include <AMReX_VisMF.H>
22 #include <AMReX_PhysBCFunct.H>
23 #include <AMReX_YAFluxRegister.H>
24 #include <AMReX_ErrorList.H>
25 #include <AMReX_EBFabFactory.H>
26 #include <AMReX_EBMultiFabUtil.H>
27 #include <AMReX_TableData.H>
28 
29 #include <ERF_EB.H>
31 #include "Prob/ERF_CloudChamber.H"
32 
33 #ifdef ERF_USE_FFT
34 #include <AMReX_FFT_Poisson.H>
35 #endif
36 
37 #ifdef AMREX_MEM_PROFILING
38 #include <AMReX_MemProfiler.H>
39 #endif
40 
41 #include "ERF_ProbCommon.H"
42 
43 #include <ERF_NumericalConstants.H>
44 #include <ERF_IndexDefines.H>
45 #include <ERF_DataStruct.H>
46 #include <ERF_BaseStateParams.H>
47 #include <ERF_TurbPertStruct.H>
48 #include <ERF_InputSoundingData.H>
50 #include <ERF_InputSpongeData.H>
51 #include <ERF_SurfaceLayer.H>
52 #include <ERF_Derive.H>
53 #include <ERF_ReadBndryPlanes.H>
54 #include <ERF_WriteBndryPlanes.H>
55 #include <ERF_MRI.H>
56 #include <ERF_PhysBCFunct.H>
57 #include <ERF_WallScalarBC.H>
58 #include <ERF_FillPatcher.H>
59 #include <ERF_SampleData.H>
60 #include <ERF_StationSampler.H>
61 #include <ERF_ForestDrag.H>
62 #include <ERF_IBFaceSet.H>
63 #include <ERF_Provenance.H>
64 
65 #ifdef ERF_USE_PARTICLES
66 #include "ERF_ParticleData.H"
67 #endif
68 
71 #include "ERF_LandSurface.H"
72 #include "ERF_TwoStreamRadiation.H"
73 
74 #ifdef ERF_USE_WINDFARM
75 #include "ERF_WindFarm.H"
76 #endif
77 
78 #include <ERF_RadiationModels.H>
79 
80 #ifdef ERF_USE_EAMXX_SHOC
81 #include "ERF_ShocInterface.H"
82 #endif
83 
84 #include "ERF_ShocDriver.H"
85 
86 #ifdef ERF_USE_P3
87 #include "ERF_P3Interface.H"
88 #endif
89 
90 #include <iostream>
91 
92 #ifdef AMREX_LAZY
93 #include <AMReX_Lazy.H>
94 #endif
95 
96 #ifndef AMREX_USE_MPI
97 using amrex::MPI_COMM_WORLD;
98 using amrex::MPI_Comm;
99 #endif
100 
101 #ifdef ERF_USE_MULTIBLOCK
102 class MultiBlockContainer;
103 #endif
104 
105 // Describes one component of a 2D plotfile; defined in
106 // IO/ERF_Plotfile2DSampledLevel.H, which ERF.H does not need to include.
108 
109 /**
110  * Enum of possible interpolation types between coarse/fine
111 */
112 AMREX_ENUM(StateInterpType,
113  FullState, Perturbational
114 );
115 
116 /**
117  * Enum of possible plotfile types
118 */
119 AMREX_ENUM(PlotFileType,
120  None, Amrex, Netcdf
121 );
122 
123 /**
124  * Main class in ERF code, instantiated from main.cpp
125 */
126 
127 class ERF
128  : public amrex::AmrCore
129 {
130 public:
131 
132  ////////////////
133  // public member functions
134 
135  // constructor - reads in parameters from inputs file
136  // - sizes multilevel arrays and data structures
137  ERF ();
138  ~ERF () override;
139 
140  void ERF_shared ();
141 
142  // Declare a default move constructor so we ensure the destructor is
143  // not called when we return an object of this class by value
144  ERF (ERF&&) noexcept = delete;
145 
146  // Declare a default move assignment operator
147  ERF& operator=(ERF&& other) noexcept = delete;
148 
149  // Delete the copy constructor
150  ERF (const ERF& other) = delete;
151  //
152  // Delete the copy assignment operator
153  ERF& operator=(const ERF& other) = delete;
154 
155  // Advance solution to final time
156  void Evolve ();
157  double EvolveOneStep (double time, double dt_request);
158 
159  void ConfigureDriverAtmosToOceanCoupling (bool use_coupling_driver,
160  bool use_two_way_coupling,
161  bool use_state_contract);
162  void SetDriverAtmosToOceanStateContract (bool use_state_contract);
163  // Driver currently consumes BoxArray/DistributionMapping only. If we later
164  // need exact copy semantics, promote this to expose IndexType/ngrow
165  // explicitly or return the underlying MultiFab pointer/reference instead.
166  void GetOceanToAtmosSurfaceLayout (amrex::BoxArray& ba,
167  amrex::DistributionMapping& dm);
168  // Returns pointers to level-0 lon_m/lat_m coordinate MultiFabs (populated
169  // by the WRF-grid init paths, e.g. ERF_InitFromWRFInput.cpp/ERF_InitFromMetgrid.cpp)
170  // used to build ocean->atmos remap weights. Sets both to nullptr if
171  // unavailable (e.g. idealized/non-WRF configurations).
172  //
173  // Staggering contract: both MultiFabs carry CELL index type and hold
174  // mass-point values whichever init path filled them -- init_from_wrfinput
175  // reads WRF's XLONG / XLAT and init_from_metgrid reads XLONG_M / XLAT_M.
176  // Ghost cells at the domain boundary are clamped copies of the edge cell,
177  // not extrapolations. These are not corners: a caller building a corner
178  // mesh must derive the corners itself. The name says cell centers so that a
179  // caller written against the old edge-staggered contract fails to compile
180  // instead of silently building its mesh half a cell off.
181  void GetOceanToAtmosCellCenterLonLat (const amrex::MultiFab*& lon_cc,
182  const amrex::MultiFab*& lat_cc) const;
183 
184  // Returns the level-0, current-time land mask (1 = land, 0 = water) used
185  // by the driver to exclude land cells from atmos->ocean remap stencils.
186  // Sets lmask to nullptr if unavailable.
187  void GetLandMask (const amrex::iMultiFab*& lmask) const;
188 
189  // True when a radiation model is *configured* at level 0. A coupling driver
190  // needs this to know whether the SWrad/LWrad lanes it would hand an ocean
191  // model carry real values or just zeros: passing zeros is worse than passing
192  // nothing, because the ocean model then suppresses its own radiative forcing
193  // in favour of them.
194  //
195  // Note this is a configuration predicate, not a data-validity one. rad_fluxes
196  // is allocated and zero-filled as soon as solverChoice.rad_type != None, so
197  // this returns true from level-0 allocation onward - including before the
198  // first AdvanceRadiation, when the fluxes are still exactly zero. A caller
199  // that needs "the lanes hold real radiation" must additionally know that a
200  // radiation step has run.
201  [[nodiscard]] bool HasRadiation () const {
202  return (!rad_fluxes.empty() && rad_fluxes[0] != nullptr);
203  }
204 
205  // Whether ERF can pack cloud fraction on the atmos->ocean Cloud lane. The
206  // pack fills that lane only when moisture is active AND the moisture model
207  // carries cloud liquid or ice, so this mirrors that condition exactly; a
208  // driver that handed the lane over regardless would be passing its own
209  // prefill as though it were an ERF value.
210  //
211  // Like HasRadiation, this is a configuration predicate rather than a
212  // data-validity one: it says the lane will be filled, not that any moisture
213  // step has run yet.
214  [[nodiscard]] bool HasCloudWater () const {
215  return (solverChoice.moisture_type != MoistureType::None) &&
218  }
219 
220  // Which atmos->ocean lanes PackAtmosphericStates actually writes here, as
221  // 0/1 in that routine's slot order: the 9-lane state view when
222  // state_contract, else the 8-lane flux view.
223  //
224  // A lane reported 0 is one the pack leaves untouched, so handing it over
225  // would pass the driver's own prefill off as an atmospheric value.
226  // HasRadiation()/HasCloudWater() answer this for two lanes; this covers all
227  // of them, and lives beside the pack so the gates cannot drift apart.
228  void GetFillableAtmosToOceanLanes (bool state_contract,
229  amrex::Vector<int>& can_fill) const;
230 
231  // weight_mf/index_mf are keyed by WeightFamily slot order
232  // {SCALAR_CENTERED, TAUX_FACE, TAUY_FACE, WIND_FACE_TO_CENTER} as built by
233  // the driver's ERFRemoraMultiBlockContainer::BuildRemapWeights(); each
234  // lane below picks the pair matching its own destination stagger.
235  // dst_mskr/dst_msku/dst_mskv are REMORA wet/dry masks (1 = wet, 0 = land)
236  // on the rho/u-face/v-face destination layouts. dst_msku/dst_mskv are applied
237  // to the TauX/TauY lanes; dst_mskr is applied to the rho-centred *scalar* lanes
238  // (Patm, Tair, cloud, and the scalar flux lanes) but deliberately NOT to
239  // Uwind/Vwind, which are also rho-centred - so the wind lanes carry live
240  // atmospheric values over REMORA land while Patm/Tair carry fallbacks there.
241  // REMORA re-masks on its own side, so this asymmetry is currently harmless.
242  // Pass nullptr to skip masking.
243  void PackAtmosphericStates (amrex::Vector<amrex::MultiFab*>& states, double time,
244  const amrex::Vector<const amrex::MultiFab*>& weight_mf,
245  const amrex::Vector<const amrex::iMultiFab*>& index_mf,
246  int max_stencil_size,
247  const amrex::MultiFab* dst_mskr = nullptr,
248  const amrex::MultiFab* dst_msku = nullptr,
249  const amrex::MultiFab* dst_mskv = nullptr);
250  // Apply ocean-model sea-surface temperature to the ERF lower boundary.
251  //
252  // state[0] carries SST in Kelvin on the layout reported by
253  // GetOceanToAtmosSurfaceLayout. erf_coverage is the per-cell coverage flag on
254  // that same layout: nonzero where the driver's remap found at least one
255  // ocean donor for that ERF cell.
256  //
257  // Coverage is a contract, not a hint. Where erf_coverage is zero the ocean
258  // supplied nothing and state[0] holds the remap's zero fill, which is
259  // indistinguishable from a computed zero; ERF keeps its own wrflowinp SST
260  // there instead. Passing erf_coverage = nullptr therefore means "no cell is
261  // covered", not "every cell is covered" -- a driver that has coverage
262  // information must pass it.
263  void ApplyOceanSurfaceState (const amrex::Vector<amrex::MultiFab*>& state,
264  double time,
265  const amrex::iMultiFab* erf_coverage = nullptr);
266 
267  // Tag cells for refinement
268  void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;
269 
270  // Tag cells in a given box
271  void read_box_for_refinement (std::string& ref_prefix, int& lev_for_box, amrex::RealBox& real_box);
272  void update_box_for_refinement (std::string& ref_prefix, int& lev_for_box, amrex::RealBox& real_box, const double time);
273 
274  // Refinement criteria for hurricanes
275  void HurricaneTracker (int lev,
276  double time,
277  const amrex::MultiFab& cc_vel,
278  const amrex::Real velmag_threshold,
279  amrex::TagBoxArray* tags = nullptr);
280 
281  bool FindInitialEye (int lev,
282  const amrex::MultiFab& cc_vel,
283  const amrex::Real velmag_threshold,
284  amrex::Real& eye_x, amrex::Real& eye_y);
285 
286  // Hurricane track line output as VTKPolyline
287  amrex::Vector<std::array<amrex::Real, 2>> hurricane_track_xy;
288  amrex::Vector<std::array<amrex::Real, 2>> hurricane_eye_track_xy,
293  amrex::Vector<amrex::MultiFab> weather_forecast_data_1, weather_forecast_data_2;
294  amrex::Vector<amrex::Vector<amrex::MultiFab>> forecast_state_1,
297  amrex::Vector<amrex::MultiFab> surface_state_1,
300 
301  amrex::Vector<amrex::Vector<amrex::MultiFab>> bckgnd_state;
302 
303  std::string MakeVTKFilename(int nstep);
304  std::string MakeVTKFilename_TrackerCircle(int nstep);
305  std::string MakeVTKFilename_EyeTracker_xy(int nstep);
306  std::string MakeFilename_EyeTracker_latlon(int nstep);
307  std::string MakeFilename_EyeTracker_maxvel(int nstep);
308  std::string MakeFilename_EyeTracker_minpressure(int nstep);
309  void WriteVTKPolyline(const std::string& filename,
310  amrex::Vector<std::array<amrex::Real, 2>>& points_xy);
311 
312  void WriteLinePlot(const std::string& filename,
313  amrex::Vector<std::array<amrex::Real, 2>>& points_xy);
314 
316 
318  const amrex::Geometry& geom,
319  const amrex::Vector<amrex::MultiFab>& S_data,
320  const amrex::Real& hurricane_eye_latitude,
321  const amrex::Real& hurricane_eye_longitude);
322 
324  const amrex::Geometry& geom,
325  const amrex::Vector<amrex::MultiFab>& S_data,
326  MoistureType moisture_type);
327 
328  void ComputeGlobalMinLocation(const SolverChoice& sc,
329  const amrex::Geometry& geom,
330  const amrex::Vector<amrex::MultiFab>& S_data,
331  amrex::Real* d_val_min_ptr,
332  int* d_i_min_ptr,
333  int* d_j_min_ptr,
334  amrex::Real& global_val_min,
335  int& global_i_min,
336  int& global_j_min);
337 
338  void HurricaneMaxVelTracker(const amrex::Geometry& geom,
339  const amrex::MultiFab& mf_cc_vel,
340  const double& time);
341 
342  void HurricaneMinPressureTracker(MoistureType moisture_type,
343  const amrex::Geometry& geom,
344  const amrex::MultiFab& mf_cons_var,
345  const double& time);
346 
347  void HurricaneTrackerCircle();
348 
350 
351  // Initialize multilevel data
352  void InitData ();
353 
354  // Initialize multilevel data before MultiBlock
355  void InitData_pre ();
356 
357  // Initialize multilevel data after MultiBlock
358  void InitData_post ();
359 
360  // Interpolate 2D arrays lat_m, lon_m, sinPhi, cosPhi
361  void Interp2DArrays (int lev, const amrex::BoxArray& my_ba2d, const amrex::DistributionMapping& my_dm);
362 
363  // Fill the map factors at lev by interpolation from lev-1
364  void interp_mapfac_from_coarse (int lev);
365 
366  // Fill the surface pressure at lev by interpolation from lev-1
367  void interp_psfc_from_coarse (int lev);
368 
369  // Fill the land mask and the land / soil types at lev by injection from lev-1
370  void interp_land_masks_from_coarse (int lev);
371 
372  // True if this level read its own initialization file, so its map factors
373  // came from that file rather than from its parent
374  bool has_own_init_file (int lev) const;
375 
377 
378  // Compute the divergence -- whether EB, no-terrain, flat terrain or general terrain
379  void compute_divergence (int lev, amrex::MultiFab& rhs,
380  amrex::Array<amrex::MultiFab const*,AMREX_SPACEDIM> rho0_u_const,
381  amrex::MultiFab const& mf_mx, amrex::MultiFab const& mf_my,
382  amrex::MultiFab const& mf_vx, amrex::MultiFab const& mf_uy,
383  amrex::MultiFab const& ax_in, amrex::MultiFab const& ay_in,
384  amrex::MultiFab const& dJ_in,
385  amrex::Geometry const& geom_at_lev);
386 
387  // Project the velocities to be divergence-free -- this is only relevant if anelastic == 1
388  void project_initial_velocity (int lev, double time, double dt);
389  void project_momenta (int lev, double l_time, double l_dt, amrex::Vector<amrex::MultiFab >& vars);
390 
391  // Project the velocities to be divergence-free with a thin body
392  void project_velocity_tb (int lev, double dt, amrex::Vector<amrex::MultiFab >& vars);
393 
394  // Calculate wall distance by solving a Poisson equation
395  void poisson_wall_dist (int lev);
396 
397  void make_subdomains(const amrex::BoxList& ba, amrex::Vector<amrex::BoxArray>& bins);
398 
399 #ifdef ERF_USE_FFT
400  void build_fft_solvers (int lev);
401  void solve_with_fft (int lev, int isub, const amrex::Box& subdomain,
402  amrex::MultiFab& rhs, amrex::MultiFab& p,
403  amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& fluxes);
404 #endif
405  void solve_with_gmres (int lev, const amrex::Box& subdomain,
406  amrex::MultiFab& rhs, amrex::MultiFab& p,
407  amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& fluxes,
408  amrex::MultiFab& ax_sub, amrex::MultiFab& ay_sub,
409  amrex::MultiFab& az_sub,
410  amrex::MultiFab& /*dJ_sub*/, amrex::MultiFab& znd_sub);
411 
412  void ImposeBCsOnPhi (int lev, amrex::MultiFab& phi, const amrex::Box& subdomain);
413 
414  // Init (NOT restart or regrid)
415  void init_only (int lev, double time);
416 
417  // Restart
418  void restart ();
419 
420  // Check for NaNs and other bad stuff
421  void check_state_for_nans(amrex::MultiFab const& S);
422  void check_vels_for_nans(amrex::MultiFab const& xvel, amrex::MultiFab const& yvel, amrex::MultiFab const& zvel);
423  void check_for_negative_theta (amrex::MultiFab& S);
424  void check_for_low_temp (amrex::MultiFab& S);
425 
427 
428  // Max of (buoyancy - vertical gradient of perturbational pressure);
429  // this is identically zero if the state is in HSE and buoyancy_type = 1
431 
432  void check_mesh_type(int lev);
433 
434  // Is it time to write a plotfile or checkpoint?
435  // Note that "cur_time" is always in double precision
436  bool writeNow (double cur_time, const int nstep, const int plot_int,
437  const double plot_per, const double dt_0, double& last_file_time);
438 
439  // Called after every level 0 timestep
440  void post_timestep (int nstep, double time, double dt_lev);
441 
442  // Do whatever writing needs to be done at intermediate times
443  void WriteAtIntermediateTime(int nstep, double time);
444 
445  // Do whatever writing needs to be done after time-stepping is complete
446  void WriteAtFinalTime();
447 
448  // Diagnostics
449  void sum_integrated_quantities (double time);
450  void sum_derived_quantities (double time);
451  void sum_energy_quantities (double time);
452 
453  void write_1D_profiles (double time);
454  void write_1D_profiles_stag (double time);
455 
456  amrex::Real cloud_fraction (double time);
457 
458  // Fill the physical boundary conditions for cell-centered velocity (diagnostic only)
459  void FillBdyCCVels (amrex::MultiFab& mf_cc_vel, amrex::Geometry& lev_geom);
460 
461  void sample_points (int lev, double time, amrex::IntVect cell, amrex::MultiFab& mf);
462  void sample_lines (int lev, double time, amrex::IntVect cell, amrex::MultiFab& mf);
463 
464  void derive_diag_profiles (double time,
465  amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v,
466  amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
467  amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
468  amrex::Gpu::HostVector<amrex::Real>& h_avg_Kmv , amrex::Gpu::HostVector<amrex::Real>& h_avg_Khv,
469  amrex::Gpu::HostVector<amrex::Real>& h_avg_qv , amrex::Gpu::HostVector<amrex::Real>& h_avg_qc,
470  amrex::Gpu::HostVector<amrex::Real>& h_avg_qr ,
471  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqv , amrex::Gpu::HostVector<amrex::Real>& h_avg_wqc,
472  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqr ,
473  amrex::Gpu::HostVector<amrex::Real>& h_avg_qi , amrex::Gpu::HostVector<amrex::Real>& h_avg_qs,
474  amrex::Gpu::HostVector<amrex::Real>& h_avg_qg ,
475  amrex::Gpu::HostVector<amrex::Real>& h_avg_uu , amrex::Gpu::HostVector<amrex::Real>& h_avg_uv,
476  amrex::Gpu::HostVector<amrex::Real>& h_avg_uw,
477  amrex::Gpu::HostVector<amrex::Real>& h_avg_vv , amrex::Gpu::HostVector<amrex::Real>& h_avg_vw,
478  amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
479  amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
480  amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
481  amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
482  amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
483  amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
484  amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
485  amrex::Gpu::HostVector<amrex::Real>& h_avg_pw, amrex::Gpu::HostVector<amrex::Real>& h_avg_wthv);
486  void derive_diag_profiles_stag (double time,
487  amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v,
488  amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
489  amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
490  amrex::Gpu::HostVector<amrex::Real>& h_avg_Kmv , amrex::Gpu::HostVector<amrex::Real>& h_avg_Khv,
491  amrex::Gpu::HostVector<amrex::Real>& h_avg_qv , amrex::Gpu::HostVector<amrex::Real>& h_avg_qc,
492  amrex::Gpu::HostVector<amrex::Real>& h_avg_qr ,
493  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqv , amrex::Gpu::HostVector<amrex::Real>& h_avg_wqc,
494  amrex::Gpu::HostVector<amrex::Real>& h_avg_wqr ,
495  amrex::Gpu::HostVector<amrex::Real>& h_avg_qi , amrex::Gpu::HostVector<amrex::Real>& h_avg_qs,
496  amrex::Gpu::HostVector<amrex::Real>& h_avg_qg ,
497  amrex::Gpu::HostVector<amrex::Real>& h_avg_uu , amrex::Gpu::HostVector<amrex::Real>& h_avg_uv,
498  amrex::Gpu::HostVector<amrex::Real>& h_avg_uw,
499  amrex::Gpu::HostVector<amrex::Real>& h_avg_vv , amrex::Gpu::HostVector<amrex::Real>& h_avg_vw,
500  amrex::Gpu::HostVector<amrex::Real>& h_avg_ww,
501  amrex::Gpu::HostVector<amrex::Real>& h_avg_uth , amrex::Gpu::HostVector<amrex::Real>& h_avg_vth,
502  amrex::Gpu::HostVector<amrex::Real>& h_avg_wth, amrex::Gpu::HostVector<amrex::Real>& h_avg_thth,
503  amrex::Gpu::HostVector<amrex::Real>& h_avg_ku, amrex::Gpu::HostVector<amrex::Real>& h_avg_kv,
504  amrex::Gpu::HostVector<amrex::Real>& h_avg_kw,
505  amrex::Gpu::HostVector<amrex::Real>& h_avg_p,
506  amrex::Gpu::HostVector<amrex::Real>& h_avg_pu, amrex::Gpu::HostVector<amrex::Real>& h_avg_pv,
507  amrex::Gpu::HostVector<amrex::Real>& h_avg_pw, amrex::Gpu::HostVector<amrex::Real>& h_avg_wthv);
508 
509  void derive_stress_profiles (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
510  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
511  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
512  amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_q1fx3,
513  amrex::Gpu::HostVector<amrex::Real>& h_avg_q2fx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);
514  void derive_stress_profiles_stag (amrex::Gpu::HostVector<amrex::Real>& h_avg_tau11, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau12,
515  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau13, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau22,
516  amrex::Gpu::HostVector<amrex::Real>& h_avg_tau23, amrex::Gpu::HostVector<amrex::Real>& h_avg_tau33,
517  amrex::Gpu::HostVector<amrex::Real>& h_avg_hfx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_q1fx3,
518  amrex::Gpu::HostVector<amrex::Real>& h_avg_q2fx3, amrex::Gpu::HostVector<amrex::Real>& h_avg_diss);
519 
520  void derive_forcing_profiles_stag(amrex::Gpu::HostVector<amrex::Real>& h_avg_ttend, amrex::Gpu::HostVector<amrex::Real>& h_avg_qtend,
521  amrex::Gpu::HostVector<amrex::Real>& h_avg_wsub, amrex::Gpu::HostVector<amrex::Real>& h_avg_thtend,
522  amrex::Gpu::HostVector<amrex::Real>& h_avg_qhtend, amrex::Gpu::HostVector<amrex::Real>& h_avg_tvtend,
523  amrex::Gpu::HostVector<amrex::Real>& h_avg_qvtend, amrex::Gpu::HostVector<amrex::Real>& h_avg_qcvtend,
524  amrex::Gpu::HostVector<amrex::Real>& h_avg_tnudge, amrex::Gpu::HostVector<amrex::Real>& h_avg_qnudge,
525  amrex::Gpu::HostVector<amrex::Real>& h_avg_unudge, amrex::Gpu::HostVector<amrex::Real>& h_avg_vnudge);
526 
527  // Perform the volume-weighted sum
529  volWgtSumMF (int lev, const amrex::MultiFab& mf, int comp,
530  const amrex::MultiFab& dJ, const amrex::MultiFab& mfx, const amrex::MultiFab& mfy,
531  bool finemask, bool local = true);
532 
533  void
534  volWgtColumnSum (int lev, const amrex::MultiFab& mf, int comp,
535  amrex::MultiFab& mf_2d, const amrex::MultiFab& dJ);
536 
537  // Decide if it is time to take an action
538  static bool is_it_time_for_action (int nstep, double time, double dt,
539  int action_interval, double action_per);
540 
541  // Make a new level using provided BoxArray and DistributionMapping and
542  // fill with interpolated coarse level data.
543  // overrides the pure virtual function in AmrCore
544  void MakeNewLevelFromCoarse (int lev, amrex::Real time, const amrex::BoxArray& ba,
545  const amrex::DistributionMapping& dm) override;
546 
547  // Remake an existing level using provided BoxArray and DistributionMapping and
548  // fill with existing fine and coarse data.
549  // overrides the pure virtual function in AmrCore
550  void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba,
551  const amrex::DistributionMapping& dm) override;
552 
553  // Delete level data
554  // overrides the pure virtual function in AmrCore
555  void ClearLevel (int lev) override;
556 
557  // Make a new level from scratch using provided BoxArray and DistributionMapping.
558  // Only used during initialization.
559  // overrides the pure virtual function in AmrCore
560  void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba,
561  const amrex::DistributionMapping& dm) override;
562 
563  // compute dt from CFL considerations
564  double estTimeStep (int lev, long& dt_fast_ratio) const;
565 
566 #ifdef ERF_USE_WW3_COUPLING
567  //amrex::Print() << " About to call send_to_ww3 from ERF.H" << std::endl;
568  void send_to_ww3(int lev);
569  //amrex::Print() << " About to call read_waves from ERF.H" << std::endl;
570  void read_waves(int lev);
571  //void send_to_ww3 (int lev);
572  //void read_waves (int lev);
573 
574  //void send_to_ww3 (int lev);
575 #endif
576 
577  // Interface for advancing the data at one level by one "slow" timestep
578  void advance_dycore (int level,
579  amrex::Vector<amrex::MultiFab>& state_old,
580  amrex::Vector<amrex::MultiFab>& state_new,
581  amrex::MultiFab& xvel_old, amrex::MultiFab& yvel_old, amrex::MultiFab& zvel_old,
582  amrex::MultiFab& xvel_new, amrex::MultiFab& yvel_new, amrex::MultiFab& zvel_new,
583  amrex::MultiFab& source, amrex::MultiFab& xmom_src,
584  amrex::MultiFab& ymom_src, amrex::MultiFab& zmom_src,
585  amrex::MultiFab& buoyancy, amrex::Geometry fine_geom,
586  double dt, double time);
587 
588  void advance_microphysics (int lev,
589  amrex::MultiFab& cons_in,
590  const double& dt_advance,
591  const int& iteration,
592  const double& time);
593 
594  void advance_lsm (int lev,
595  amrex::MultiFab& cons_in,
596  amrex::MultiFab& xvel_in,
597  amrex::MultiFab& yvel_in,
598  const double& time,
599  const double& dt_advance);
600 
601  void advance_radiation (int lev,
602  amrex::MultiFab& cons_in,
603  const double& dt_advance);
604 
605 #ifdef ERF_USE_EAMXX_SHOC
606  void compute_shoc_tendencies (int lev,
607  amrex::MultiFab* cons,
608  amrex::MultiFab* xvel,
609  amrex::MultiFab* yvel,
610  amrex::MultiFab* zvel,
611  amrex::Real* w_subsid,
612  amrex::MultiFab* tau13,
613  amrex::MultiFab* tau23,
614  amrex::MultiFab* hfx3,
615  amrex::MultiFab* qfx3,
616  amrex::MultiFab* eddyDiffs,
617  amrex::MultiFab* z_phys_nd,
618  const double& dt_advance);
619 #endif
620 
621  void compute_native_shoc_tendencies (int lev,
622  amrex::MultiFab* cons,
623  amrex::MultiFab* xvel,
624  amrex::MultiFab* yvel,
625  amrex::MultiFab* zvel,
626  amrex::Real* w_subsid,
627  amrex::MultiFab* tau13,
628  amrex::MultiFab* tau23,
629  amrex::MultiFab* hfx3,
630  amrex::MultiFab* qfx3,
631  amrex::MultiFab* eddyDiffs,
632  amrex::MultiFab* z_phys_nd,
633  const double& dt_advance);
634 
635 #ifdef ERF_USE_P3
636  void compute_p3_tendencies (int lev,
637  amrex::MultiFab& cons_in,
638  amrex::MultiFab& source,
639  const double& dt_advance);
640 #endif
641 
642  void build_fine_mask (int lev, amrex::MultiFab& fine_mask);
643 
644  void MakeHorizontalAverages ();
645  void MakeDiagnosticAverage (amrex::Vector<amrex::Real>& h_havg, amrex::MultiFab& S, int n);
646  void derive_upwp (amrex::Vector<amrex::Real>& h_havg);
647 
648  // Write plotfile to disk
649  bool Write3DPlotFile (int which, PlotFileType plotfile_type, amrex::Vector<std::string> plot_var_names);
650  void Write2DPlotFile (int which, PlotFileType plotfile_type, amrex::Vector<std::string> plot_var_names);
651  void ResetIntervalMeansAfter3DPlotfileBatch (int plotfiles_written,
652  bool interval_diagnostic_consumed);
653  void ResetIntervalMeans ();
654 
655  // Write subvolume of data into a different "plotfile"
656  void WriteSubvolume (int isub, amrex::Vector<std::string> subvol_var_names);
657 
658  void WriteMultiLevelPlotfileWithTerrain (const std::string &plotfilename,
659  int nlevels,
660  const amrex::Vector<const amrex::MultiFab*> &mf,
661  const amrex::Vector<const amrex::MultiFab*> &mf_nd,
662  const amrex::Vector<std::string> &varnames,
663  const amrex::Vector<amrex::Geometry>& my_geom,
664  double time,
665  const amrex::Vector<int> &level_steps,
666  const amrex::Vector<amrex::IntVect>& my_ref_ratio,
667  const std::string &versionName = "HyperCLaw-V1.1",
668  const std::string &levelPrefix = "Level_",
669  const std::string &mfPrefix = "Cell",
670  const amrex::Vector<std::string>& extra_dirs = amrex::Vector<std::string>()) const;
671 
672 
673  void WriteGenericPlotfileHeaderWithTerrain (std::ostream &HeaderFile,
674  int nlevels,
675  const amrex::Vector<amrex::BoxArray> &bArray,
676  const amrex::Vector<std::string> &varnames,
677  const amrex::Vector<amrex::Geometry>& my_geom,
678  double time,
679  const amrex::Vector<int> &level_steps,
680  const amrex::Vector<amrex::IntVect>& my_ref_ratio,
681  const std::string &versionName,
682  const std::string &levelPrefix,
683  const std::string &mfPrefix) const;
684 
685  // Filling the plot variables, and the station sampling that reuses it. Split
686  // out of the plotfile writers so that a station column and the corresponding
687  // plotfile component are produced the same way. Private for the same reason
688  // canonicalizePlot3DVariables above is: this is output machinery rather than
689  // something ERF offers a caller.
690 
691  // Per-level scratch needed to evaluate the 3D plot variables. Held by the
692  // caller so that the work is done once for a set of variables and then
693  // reused for every level that is filled.
695  {
696  amrex::Vector<amrex::MultiFab> mf_cc_vel; // cell-centered velocity, 1 ghost
697  amrex::Vector<amrex::MultiFab> mf_cc_tau; // cell-centered stress tensor
698  amrex::Vector<amrex::MultiFab> mf_cc_fx; // cell-centered SFS fluxes
699  };
700 
701  void FillPlot2DVars (int lev,
702  const amrex::Vector<std::string>& plot_var_names,
703  const amrex::Vector<std::string>& varnames,
704  const amrex::Vector<plotfile2d::Plotfile2DOutputDescriptor>& output_descriptors,
705  amrex::MultiFab& mf_dst,
706  int ncomp_mf);
707 
708  void FillPlot3DVars (int lev,
709  const amrex::Vector<std::string>& plot_var_names,
710  Plot3DScratch& scratch,
711  amrex::MultiFab& mf_dst,
712  int ncomp_mf,
713  amrex::Real tnew);
714 
715  // max_lev caps the levels whose scratch is built, -1 meaning every level: a
716  // caller that reads only the coarse levels should not pay for the fine ones.
717  // sync_solution allows the microphysics average-down, which the plotfile
718  // writer wants but a diagnostic that runs at every step must not do, since
719  // it changes the coarse solution.
720  void BuildPlot3DScratch (const amrex::Vector<std::string>& plot_var_names,
721  Plot3DScratch& scratch,
722  int max_lev = -1,
723  bool sync_solution = true);
724 
725  // Station time-series output
726  void init_stations ();
728  void resolve_station_stencils ();
729  void sample_stations (amrex::Real time);
730  void flush_stations () const;
731 
732  void erf_enforce_hse (int lev,
733  amrex::MultiFab& dens, amrex::MultiFab& pres, amrex::MultiFab& pi,
734  amrex::MultiFab& th, amrex::MultiFab& qv,
735  std::unique_ptr<amrex::MultiFab>& z_cc);
736 
737 #ifdef ERF_USE_NETCDF
738  //! Write a timestep to 1D vertical column output for coupling
739  void writeToNCColumnFile (int lev,
740  const std::string& colfile_name, amrex::Real xloc, amrex::Real yloc,
741  double time);
742 #endif //ERF_USE_NETCDF
743 
744  void init_from_input_sounding (int lev);
745 
746  void init_immersed_forcing (int lev);
747 
748  // Immersed-boundary surface energy balance (Source/ImmersedBoundarySEB)
749  void init_ibseb ();
750  void ibseb_write_checkpoint (const std::string& checkpointname, int lev) const;
751  void ibseb_report (int nstep, amrex::Real time);
752  amrex::Real ibseb_bulk_richardson_height (int lev, const amrex::MultiFab& cons,
753  const amrex::MultiFab& xvel, const amrex::MultiFab& yvel);
754  void ibseb_advance (int lev, amrex::Real time, amrex::Real dt_lev, const amrex::MultiFab& cons,
755  const amrex::MultiFab& xvel, const amrex::MultiFab& yvel, const amrex::MultiFab& zvel);
756 
757  void input_sponge (int lev);
758 
759  void init_from_hse (int lev);
760 
761  void init_thin_body (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
762 
763  void FillForecastStateMultiFabs(const int lev,
764  const std::string& filename,
765  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
766  amrex::Vector<amrex::Vector<amrex::MultiFab>>& forecast_state);
767 
768  void FillSurfaceStateMultiFabs(const int lev,
769  const std::string& filename,
770  amrex::Vector<amrex::MultiFab>& surface_state);
771 
772 
773  void WeatherDataInterpolation(const int nlevs,
774  const double time,
775  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& z_phys_nd,
776  bool regrid_forces_file_read);
777 
778  void SurfaceDataInterpolation(const int nlevs,
779  const double time,
780  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& z_phys_nd,
781  bool regrid_forces_file_read);
782 
784  amrex::MultiFab& mf_cc_pert,
785  amrex::MultiFab& cons_pert,
786  amrex::MultiFab& xvel_pert,
787  amrex::MultiFab& yvel_pert,
788  amrex::MultiFab& zvel_pert);
789 
790  void create_random_perturbations (const int lev,
791  amrex::MultiFab& mf_cc_pert);
792 
793  void apply_gaussian_smoothing_to_perturbations (const int lev,
794  amrex::MultiFab& mf_cc_pert);
795 
796  void ComputeAndWriteEnsemblePerturbations (const int da_iter);
797 
798  void PerformDataAssimilation (int da_iter);
799 
800  void SetDirsForPlotfilesAndCheckpointsForDA (const int da_iter, const int ens_no);
801 
802  void GetEnsembleCheckpointName (int da_iter, int ens_no);
803 
804  void init_custom (int lev);
805 
806 #ifdef ERF_USE_MULTIBLOCK
807  // constructor used when ERF is created by a multiblock driver
808  // calls AmrCore constructor -> AmrMesh constructor
809  ERF (const amrex::RealBox& rb, int max_level_in,
810  const amrex::Vector<int>& n_cell_in, int coord,
811  const amrex::Vector<amrex::IntVect>& ref_ratio,
812  const amrex::Array<int,AMREX_SPACEDIM>& is_per,
813  std::string prefix);
814 
815  // Advance a block specified number of time steps
816  void Evolve_MB (int MBstep, int max_block_step);
817 
818  // Set parmparse prefix for MultiBlock
819  void SetParmParsePrefix (std::string name) { pp_prefix = name; }
820 
821  // Set 'this' from multiblock container
822  void SetMultiBlockPointer (MultiBlockContainer *mbc) { m_mbc = mbc; }
823 
824  // Public data copy for MB
825  std::vector<amrex::Box> domain_p;
826 
827  // Primary solution data data containers
828  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_new;
829  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_old;
830 
831  // Pressure gradient at each level
832  amrex::Vector<amrex::Vector<amrex::MultiFab> > gradp;
833 
834  // Velocity time averaged field
835  amrex::Vector<std::unique_ptr<amrex::MultiFab>> vel_t_avg;
836  amrex::Vector<double> t_avg_cnt;
837 
838  // Interval first and second moments used by mean/fluctuation plot fields
839  amrex::Vector<std::unique_ptr<amrex::MultiFab>> interval_means;
840  amrex::Vector<double> t_mean_cnt;
841  // The configured time reset is one global, one-shot event. Keep this
842  // separate from the per-level accumulation storage so regridding a level
843  // cannot re-arm an event that has already happened.
845 #endif
846 
847  std::string pp_prefix {"erf"};
848 
849  // The inputs table as the user wrote it, captured at the top of
850  // ReadParameters before anything in ERF can add to it. ParmParse::queryAdd
851  // inserts the default it was handed whenever a key is absent, so by the time
852  // initialization is under way the table no longer distinguishes a key the
853  // user typed from a key some other query defaulted (see
854  // has_surface_layer_inputs).
855  std::set<std::string> user_specified_inputs;
856 
857  void fill_from_bndryregs (const amrex::Vector<amrex::MultiFab*>& mfs,
858  double time);
859 
860 #ifdef ERF_USE_NETCDF
861  // Version in which we always set the velocity values but don't set theta
862  void fill_from_realbdy (const amrex::Vector<amrex::MultiFab*>& mfs,
863  double time,
864  bool cons_only,
865  int icomp_cons,
866  int ncomp_cons,
867  amrex::IntVect ngvect_cons,
868  amrex::IntVect ngvect_vels);
869 #endif
870 
871 #ifdef ERF_USE_NETCDF
872  // Read a wrfinput file at this level.
873  //
874  // With read_atmos_state = true (the default) this reads the full state: the
875  // atmospheric fields (U, V, W, THM, the density triple and the moisture species)
876  // as well as the surface fields, and it remaps the state onto the ERF vertical
877  // grid, builds the base state and reads the boundary data.
878  //
879  // With read_atmos_state = false only the surface fields are read -- terrain,
880  // surface pressure, surface and skin temperatures, the land/soil masks, the map
881  // factors, the lat/lon fields and the LSM variables -- and the terrain and metric
882  // terms are built from them. The atmospheric state is left untouched for the
883  // caller to fill by interpolation from the coarse level (see the
884  // erf.interp_atmos_from_coarse path in MakeNewLevelFromCoarse), which is also
885  // responsible for calling rebuild_base_state_from_wrfinput afterwards.
886  void init_from_wrfinput (int lev, amrex::MultiFab& mf_PSFC, bool read_atmos_state = true);
887  void init_from_metgrid (int lev);
888  void init_from_ncfile (int lev);
889 
890  // Rebuild the WRF base state on the grids of base_state_mf at this level, using the
891  // level-0 reference parameters (wrf_bsp) and this level's z_phys_cc. This is the same
892  // construction init_from_wrfinput performs at initialization, factored out so that a
893  // level remade by a regrid gets the same base state rather than one interpolated from
894  // its parent. Requires z_phys_cc[lev] and wrf_bsp to be valid.
895  void rebuild_base_state_from_wrfinput (int lev, amrex::MultiFab& base_state_mf);
896 
897  // Re-read the six reference parameters that define the WRF base state from the level-0
898  // wrfinput file. These are read at initialization but are not part of the checkpoint,
899  // so on restart wrf_bsp would otherwise be left unset -- and the first regrid that has
900  // to rebuild a base state would abort in init_base_state_from_wrfinput.
901  void restore_base_state_params_on_restart ();
902 #endif // ERF_USE_NETCDF
903 
904 #ifdef ERF_USE_WINDFARM
905  void init_windfarm(int lev);
906  void advance_windfarm (const amrex::Geometry& a_geom,
907  const double& dt_advance,
908  amrex::MultiFab& cons_in,
909  amrex::MultiFab& U_old,
910  amrex::MultiFab& V_old,
911  amrex::MultiFab& W_old,
912  amrex::MultiFab& mf_vars_windfarm,
913  const amrex::MultiFab& mf_Nturb,
914  const amrex::MultiFab& mf_SMark,
915  const double& time);
916 #endif
917 
918  void MakeEBGeometry ();
919  void make_eb_box ();
921 
922  // more flexible version of AverageDown() that lets you average down across multiple levels
923  void AverageDownTo (int crse_lev,
924  int scomp,
925  int ncomp,
926  bool do_perturbational_and_momenta = true); // NOLINT
927 
928  /*! \brief Conservation-preserving fine-to-coarse average of RhoTheta and
929  * the active moist conserved components using detJ/mfac weighting, reusing
930  * AverageDownTo with perturbational-state and momentum handling disabled. */
931  void AverageDownMoistStateTo (int crse_lev);
932 
933  // Write checkpoint file to disk
934  void WriteCheckpointFile () const;
935 
936  // Read checkpoint file from disk
937  void ReadCheckpointFile ();
938 
939  // Read only velocities from checkpoint file
940  void ReadVelsOnlyFromCheckpointFile (int lev_to_fill, std::string& chkfile);
941 
942  // read checkpoint file from disk -- called after instantiating m_SurfaceLayer
944 
945  void fill_terrain_surface (int lev, amrex::MultiFab& z_phys, double elapsed_time);
946  void init_zphys (int lev, double elapsed_time);
947  void remake_zphys (int lev, amrex::Real time, std::unique_ptr<amrex::MultiFab>& temp_zphys_nd);
948  void update_terrain_arrays (int lev);
949 
953 
954  // Coupled sea-surface temperature and its per-cell coverage flag, on the
955  // layout reported by GetOceanToAtmosSurfaceLayout. Allocated on the first
956  // ApplyOceanSurfaceState call and handed to the SurfaceLayer as borrowed
957  // pointers, so ERF must outlive the SurfaceLayer's use of them. Level 0
958  // only: the coupler exchanges on the base grid.
959  std::unique_ptr<amrex::MultiFab> m_coupled_sst;
960  std::unique_ptr<amrex::iMultiFab> m_coupled_sst_valid;
961 
962  // One-shot latch so a misconfigured deck says so once rather than every step.
964 
965 private:
966 
967  ///////////////////////////
968  // private member functions
969  ///////////////////////////
970 
971  // read in some parameters from inputs file
972  void ReadParameters ();
973  void ParameterSanityChecks ();
974 
975  [[nodiscard]] bool has_surface_layer_inputs (const std::string& prefix) const;
976 
977  // set covered coarse cells/faces to be the average of overlying fine cells/faces
978  void AverageDown ();
979 
980  void update_diffusive_arrays (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm);
981 
982  void Construct_ERFFillPatchers (int lev);
983 
984  void Define_ERFFillPatchers (int lev);
985 
986  void init1DArrays ();
987 
988  void init_bcs ();
989  void init_phys_bcs (bool& read_prim_theta);
990 
991  void init_stuff (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm,
992  amrex::Vector<amrex::MultiFab>& lev_new, amrex::Vector<amrex::MultiFab>& lev_old,
993  amrex::MultiFab& tmp_base_state,
994  std::unique_ptr<amrex::MultiFab>& tmp_zphys_nd);
995 
996  // Initialize the Turbulent perturbation
997  void turbPert_update (const int lev, const double dt);
998  void turbPert_amplitude (const int lev);
999  void turbPert_amplitude_w (const int lev);
1000 
1001  // Initialize the integrator object
1002  void initialize_integrator (int lev, amrex::MultiFab& cons_mf, amrex::MultiFab& vel_mf);
1003 
1004  // Create the physbcs objects
1005  void make_physbcs (int lev);
1006 
1007  // (Re)build the land surface model on this level's current grids
1008  void make_lsm_at_level (int lev, bool from_regrid [[maybe_unused]] = false);
1009 
1010  // Initialize the microphysics object
1011  void initializeMicrophysics (const int&);
1012 
1013 #ifdef ERF_USE_WINDFARM
1014  // Initialize the windfarm object
1015  void initializeWindFarm (const int&);
1016 #endif
1017 
1018  // Initialize embedded boundary geometries
1019  void initializeEB ();
1020 
1021  // Compute a vector of new MultiFabs by copying from valid region and filling ghost cells
1022  //
1023  // NOTE: FillPatch takes in an empty MF, and returns cell-centered + velocities (not momenta)
1024  //
1025  // This one works only at level = 0 (base state does not change)
1026  void FillPatchCrseLevel (int lev, double time,
1027  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
1028  bool cons_only=false);
1029 
1030  // This one works only at level > 0 (base state does change)
1031  void FillPatchFineLevel (int lev, double time,
1032  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
1033  const amrex::Vector<amrex::MultiFab*>& mfs_mom,
1034  const amrex::MultiFab& old_base_state,
1035  const amrex::MultiFab& new_base_state,
1036  bool fillset=true, bool cons_only=false);
1037 
1038  // Compute new multifabs by copying data from valid region and filling ghost cells.
1039  // Unlike FillPatch, FillIntermediatePatch will use the supplied multifabs instead of fine level data.
1040  // This is to support filling boundary cells at an intermediate time between old/new times
1041  // on the fine level when valid data at a specific time is already available (such as
1042  // at each RK stage when integrating between initial and final times at a given level).
1043  //
1044  // NOTE: FillIntermediatePatch takes in updated momenta, and returns both updated velocity and momenta
1045  //
1046  void FillIntermediatePatch (int lev, double time,
1047  const amrex::Vector<amrex::MultiFab*>& mfs_vel,
1048  const amrex::Vector<amrex::MultiFab*>& mfs_mom,
1049  int ng_cons, int ng_vel, bool cons_only, int icomp_cons, int ncomp_cons);
1050 
1051  // Fill all multifabs (and all components) in a vector of multifabs corresponding to the
1052  // grid variables defined in vars_old and vars_new just as FillCoarsePatch.
1053  void FillCoarsePatch (int lev, double time);
1054 
1055  // advance a level by dt
1056  // includes a recursive call for finer levels
1057  void timeStep (int lev, double time, int iteration);
1058 
1059  // advance a single level for a single time step
1060  void Advance (int lev, double time, double dt_lev, int iteration, int ncycle);
1061 
1062  //! Initialize HSE
1063  void initHSE ();
1064  void initHSE (int lev);
1065 
1066  // Fill base_state[lev] by conservative interpolation from base_state[lev-1], then apply
1067  // the base-state physical bc's. This is how the part of a fine level that lies inside
1068  // the domain but outside the fine grids -- and the fine ghost cells -- get their values,
1069  // so it must run before any construction that overwrites only the fine grids.
1070  void interp_base_state_from_coarse (int lev);
1071 
1072  //! Initialize Rayleigh damping profiles at a level
1073  void initRayleigh_at_level (const int& lev);
1074 
1075  //! Initialize sponge profiles
1076  void initSponge ();
1077 
1078  //! Set Rayleigh mean profiles from input sounding
1079  void setRayleighRefFromSounding (bool restarting);
1080 
1081  //! Set sponge mean profiles from input sounding
1082  void setSpongeRefFromSounding (bool restarting);
1083 
1084  // a wrapper for estTimeStep()
1085  void ComputeDt (int step = -1, double cur_time_d = 0.0);
1086 
1087  // get plotfile name
1088  [[nodiscard]] std::string PlotFileName (int lev) const;
1089 
1090  // set plotfile variable names
1091  static amrex::Vector<std::string> PlotFileVarNames (amrex::Vector<std::string> plot_var_names);
1092 
1093  // set which variables and derived quantities go into plotfiles
1094  void setPlotVariables (const std::string& pp_plot_var_names, amrex::Vector<std::string>& plot_var_names);
1095  void canonicalizePlot3DVariables (amrex::Vector<std::string>& plot_var_names);
1096  void appendPlot3DVariables (const amrex::Vector<std::string>& plot_var_names,
1097  amrex::Vector<std::string>& a_plot_var_names);
1098  void setPlotVariables2D (const std::string& pp_plot_var_names, amrex::Vector<std::string>& plot_var_names);
1099  // append variables to plot
1100  void appendPlotVariables (const std::string& pp_plot_var_names, amrex::Vector<std::string>& plot_var_names);
1101 
1102  void setSubVolVariables (const std::string& pp_subvol_var_names, amrex::Vector<std::string>& subvol_var_names);
1103 
1104 #ifdef ERF_USE_NETCDF
1105  //! Create 1D vertical column output for coupling
1106  void createNCColumnFile (int lev,
1107  const std::string& colfile_name, amrex::Real xloc, amrex::Real yloc);
1108 
1109  // Copy from the NC*fabs into the MultiFabs holding the boundary data
1110  void init_from_wrfbdy (amrex::Vector<amrex::FArrayBox*> x_vel_lateral,
1111  amrex::Vector<amrex::FArrayBox*> y_vel_lateral,
1112  amrex::Vector<amrex::FArrayBox*> z_vel_lateral,
1113  amrex::Vector<amrex::FArrayBox*> T_lateral);
1114 
1115  static double start_bdy_time;
1116  static double final_bdy_time;
1117 
1118  static double start_low_time;
1119  static double final_low_time;
1120 
1121  static double bdy_time_interval;
1122  static double low_time_interval;
1123 
1124  // *** *** FArrayBox's for holding the SURFACE data
1125  // amrex::IArrayBox NC_IVGTYP_fab; // Vegetation type (IVGTYP); Discrete numbers;
1126  // amrex::FArrayBox NC_z0_fab; // Surface Roughness, z0 = z0 (IVGTYP)
1127  // amrex::FArrayBox NC_PSFC_fab; // Surface pressure
1128 
1129  // TODO: Clarify the relation between SST and TSK
1130  // amrex::FArrayBox NC_SST_fab; // Sea Surface Temperature; Defined even for land area
1131  // amrex::FArrayBox NC_TSK_fab; // Surface Skin Temperature; Appears to be same as SST...
1132 
1133  // Vectors (over time) of Vector (over variables) of FArrayBoxs for holding the data read from the wrfbdy NetCDF file
1134  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_xlo;
1135  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_xhi;
1136  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_ylo;
1137  amrex::Vector<amrex::Vector<amrex::FArrayBox>> bdy_data_yhi;
1138 
1139  amrex::Vector<amrex::Vector<amrex::FArrayBox>> low_data_zlo;
1140 
1141  // Maximum value of terrain read in from wrfinput at level 0
1142  amrex::Real z_top = zero;
1143 
1144 #endif // ERF_USE_NETCDF
1145 
1146  // Latitude and Longitude on the grid, always at cell centers: the wrfinput
1147  // path reads XLAT / XLONG and the metgrid path reads XLAT_M / XLONG_M, both
1148  // of which are mass-point values, so a consumer that wants the mass point
1149  // can use these directly.
1150  amrex::Vector<std::unique_ptr<amrex::MultiFab>> lat_m, lon_m;
1151 
1152  amrex::Vector<std::unique_ptr<amrex::MultiFab>> sinPhi_m, cosPhi_m; // Coriolis factors on the grid
1153 
1154  // Struct for working with the sounding data we take as an input
1156 
1157  // Struct for working with the sponge data we take as an input
1159 
1160  // Vector (6 planes) of DeviceVectors (ncell in plane) for Dirichlet BC data
1161  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> xvel_bc_data;
1162  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> yvel_bc_data;
1163  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> zvel_bc_data;
1164  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> th_bc_data;
1165 
1166  // Planar averages for immersed forcing (computed on slow step, used in slow and fast steps)
1167  amrex::Vector<amrex::TableData<amrex::Real, 1>> r_plane_avg; // density planar average per level
1168  amrex::Vector<amrex::TableData<amrex::Real, 1>> t_plane_avg; // RhoTheta planar average per level
1169 
1170  // Function to read and populate above vectors (if input file exists)
1171  void init_Dirichlet_bc_data (const std::string input_file);
1172 
1173  // Read the file passed to amr.restart and use it as an initial condition for
1174  // the current simulation. Supports a different number of components and
1175  // ghost cells.
1177 
1178  // Initialize the new-time data at a level from the initial_data MultiFab
1179  void InitializeLevelFromData (int lev, const amrex::MultiFab& initial_data);
1180 
1181  // utility to skip to next line in Header
1182  static void GotoNextLine (std::istream& is);
1183 
1184  // Single level functions called by advance()
1185  void post_update (amrex::MultiFab& state_mf, double time, const amrex::Geometry& geom);
1186  void fill_rhs (amrex::MultiFab& rhs_mf, const amrex::MultiFab& state_mf, double time, const amrex::Geometry& geom);
1187 
1188  ////////////////
1189  // private data members
1190 
1191  std::unique_ptr<ProblemBase> prob = nullptr; // problem-specific functions
1192 
1193  amrex::Vector<int> num_boxes_at_level; // how many boxes specified at each level by tagging criteria
1194  amrex::Vector<int> num_files_at_level; // how many wrfinput files specified at each level
1195  amrex::Vector<amrex::Vector<amrex::Box>> boxes_at_level; // the boxes specified at each level by tagging criteria
1196 
1197  amrex::Vector<int> istep; // which step?
1198  amrex::Vector<int> nsubsteps; // how many substeps on each level?
1199 
1200  // One entry per level: set when that level has just been built by the
1201  // erf.interp_atmos_from_coarse path, whose atmospheric state comes from FillCoarsePatch
1202  // and is not yet thermodynamically consistent (rho, theta and qv are interpolated
1203  // independently). advance_radiation interpolates the radiation fields from the parent
1204  // rather than running RRTMGP on that state, and clears the entry once it has done so, so
1205  // exactly one step is skipped per level creation.
1206  //
1207  // NOTE: this is deliberately a flag owned by the level's lifetime rather than a test on
1208  // istep[lev]. istep is sized once in ReadParameters and is never reset when a
1209  // level is removed, so it carries over from a level's previous life: a level that
1210  // ran for fifty steps, was de-refined, and was then re-created would have
1211  // istep[lev] == 50 and would silently miss the skip.
1212  //
1213  // (using int instead of bool to avoid the std::vector<bool> specialization)
1215 
1216  // keep track of old time, new time, and time step at each level
1217  amrex::Vector<double> t_new;
1218  amrex::Vector<double> t_old;
1219  amrex::Vector<double> dt;
1220  amrex::Vector<long> dt_mri_ratio;
1221 
1222 #ifndef ERF_USE_MULTIBLOCK
1223  // Array of multifabs to store the solution at each level of refinement;
1224  // after advancing a level we use "swap".
1225  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_new;
1226  amrex::Vector<amrex::Vector<amrex::MultiFab> > vars_old;
1227 
1228  // Pressure gradient at each level
1229  amrex::Vector<amrex::Vector<amrex::MultiFab> > gradp;
1230 
1231  // Velocity time averaged field
1232  amrex::Vector<std::unique_ptr<amrex::MultiFab>> vel_t_avg;
1233  amrex::Vector<double> t_avg_cnt;
1234 
1235  // Interval first and second moments used by mean/fluctuation plot fields
1236  amrex::Vector<std::unique_ptr<amrex::MultiFab>> interval_means;
1237  amrex::Vector<double> t_mean_cnt;
1238  // Global one-shot time-reset state; interval_means remains per level.
1240 #endif
1241  amrex::Vector<std::unique_ptr<MRISplitIntegrator<amrex::Vector<amrex::MultiFab> > > > mri_integrator_mem;
1242 
1243  // Used for anelastic or when we impose an initial projection
1244  amrex::Vector<amrex::MultiFab> pp_inc;
1245 
1246  // Used only for fast substepping
1247  amrex::Vector<amrex::MultiFab> lagged_delta_rt;
1248  amrex::Vector<amrex::MultiFab> avg_xmom;
1249  amrex::Vector<amrex::MultiFab> avg_ymom;
1250  amrex::Vector<amrex::MultiFab> avg_zmom;
1251 
1252  // Vector over levels of routines to impose physical boundary conditions
1253  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_cons>> physbcs_cons;
1254  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_u>> physbcs_u;
1255  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_v>> physbcs_v;
1256  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_w>> physbcs_w;
1257  amrex::Vector<std::unique_ptr<ERFPhysBCFunct_base>> physbcs_base;
1258 
1259  // Store primitive variable for MOST BC
1260  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Theta_prim;
1261  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Qv_prim;
1262  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Qr_prim;
1263 
1264  // Scratch space for time integrator
1265  amrex::Vector<amrex::MultiFab> rU_old;
1266  amrex::Vector<amrex::MultiFab> rU_new;
1267  amrex::Vector<amrex::MultiFab> rV_old;
1268  amrex::Vector<amrex::MultiFab> rV_new;
1269  amrex::Vector<amrex::MultiFab> rW_old;
1270  amrex::Vector<amrex::MultiFab> rW_new;
1271 
1272  // amrex::Vector<amrex::MultiFab> xmom_crse_rhs;
1273  // amrex::Vector<amrex::MultiFab> ymom_crse_rhs;
1274  amrex::Vector<amrex::MultiFab> zmom_crse_rhs;
1275 
1276  std::unique_ptr<Microphysics> micro;
1277  std::unique_ptr<CloudChamberBudget> cloud_chamber_budget;
1279  amrex::Vector<amrex::Vector<amrex::MultiFab*>> qmoist; // (lev,ncomp) rain_accum, snow_accum, graup_accum
1280 
1281  // Variables for wind farm parametrization models
1282 
1283 #ifdef ERF_USE_WINDFARM
1284  std::unique_ptr<WindFarm> windfarm;
1285  amrex::Vector<amrex::MultiFab> Nturb;
1286  amrex::Vector<amrex::MultiFab> vars_windfarm; // Fitch: Vabs, Vabsdt, dudt, dvdt, dTKEdt
1287  // EWP: dudt, dvdt, dTKEdt
1288 
1289  amrex::Vector<amrex::MultiFab> SMark; // A multifab that holds an integer corresponding
1290  // to the number of the wind turbine to sample
1291  // velocity upstream of the turbine
1292 #endif
1293 
1295  amrex::Vector<std::string> lsm_data_name; // (ncomp) -- e.g., sw_dn_dir/dif_vis/nir, lw_dn, cos_zen
1296  amrex::Vector<amrex::Vector<amrex::MultiFab*>> lsm_data; // (lev,ncomp) Data for LSM coupling
1297  amrex::Vector<std::string> lsm_flux_name; // (ncomp) -- e.g., hfx3, q1fx3, tau13, tau23
1298  amrex::Vector<amrex::Vector<amrex::MultiFab*>> lsm_flux; // (lev,ncomp) Fluxes from LSM needed by DYCORE
1299 
1301  amrex::Vector<std::unique_ptr<amrex::MultiFab>> nudge_data; // holds nudging inputs: tnudge, qnudge, unudge, vnudge
1302  amrex::Vector<std::unique_ptr<amrex::MultiFab>> lsf_data; // holds large scale forcing tendencies: ttend, qtend, wsub
1303 
1304  amrex::Vector<std::unique_ptr<IRadiation>> rad; // Radiation model at each level
1305  amrex::Vector<std::unique_ptr<amrex::MultiFab>> qheating_rates; // radiation heating rate source terms (SW, LW) (DYCORE)
1306  // Radiation fluxes (SW up, SW down, LW up, LW down) [W/m^2] at the
1307  // interfaces (OUTPUT ONLY). Index k holds the lower interface of layer k
1308  // (k = klo is the surface); the top-of-atmosphere interface is stored in
1309  // the z-ghost cell k = khi + 1, so the array has one ghost cell in z.
1310  // Both RRTMGP and the two-stream model fill all nz + 1 levels.
1311  amrex::Vector<std::unique_ptr<amrex::MultiFab>> rad_fluxes;
1312 
1313  // Two-stream radiation model (erf.radiation_model = TwoStream): owns its
1314  // surface and SEB state; every call from ERF is behind a test of
1315  // solverChoice.rad_type == RadiationType::TwoStream.
1317 
1318 #ifdef ERF_USE_EAMXX_SHOC
1319  amrex::Vector<std::unique_ptr<SHOCInterface>> eamxx_shoc_interface; // EAMxx SHOC model at each level
1320 #endif
1321 
1322  amrex::Vector<std::unique_ptr<ShocDriver>> native_shoc_driver; // Native SHOC model at each level
1323 
1324 #ifdef ERF_USE_P3
1325  amrex::Vector<std::unique_ptr<P3Interface>> p3_interface; // P3 model at each level
1326 #endif
1327 
1328  bool plot_rad = false;
1330 
1331  // Fillpatcher classes for coarse-fine boundaries
1332  int cf_width{0};
1334  amrex::Vector<ERFFillPatcher> FPr_c;
1335  amrex::Vector<ERFFillPatcher> FPr_u;
1336  amrex::Vector<ERFFillPatcher> FPr_v;
1337  amrex::Vector<ERFFillPatcher> FPr_w;
1338 
1339  // Diffusive stresses and Smag
1340  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> Tau;
1341  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> Tau_corr; // correction to tau for implicit
1342  amrex::Vector<std::unique_ptr<amrex::MultiFab>> eddyDiffs_lev;
1343  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SmnSmn_lev;
1344 
1345  // Sea Surface Temps, Skin Temperature and Land Masks (lev, ntimes)
1346  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> sst_lev;
1347  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> tsk_lev;
1348  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::iMultiFab>>> lmask_lev;
1349 
1350  // Land grid types and urban fraction
1351  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::iMultiFab>>> land_type_lev;
1352  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::iMultiFab>>> soil_type_lev;
1353  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> urb_frac_lev;
1354 
1355  // Other SFS terms
1356  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_hfx1_lev, SFS_hfx2_lev, SFS_hfx3_lev;
1357  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_diss_lev;
1358  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_q1fx1_lev, SFS_q1fx2_lev, SFS_q1fx3_lev;
1359  amrex::Vector<std::unique_ptr<amrex::MultiFab>> SFS_q2fx3_lev;
1360 
1361  // Diffusive fluxes for EB
1362  // Tau_EB[level][component][grid_type]
1363  amrex::Vector<amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>>> Tau_EB;
1364  amrex::Vector<std::unique_ptr<amrex::MultiFab>> hfx3_EB;
1365  amrex::Vector<std::unique_ptr<amrex::MultiFab>> qfx3_EB;
1366 
1367  // Grid stretching
1368  amrex::Vector<amrex::Vector<amrex::Real>> zlevels_stag; // nominal height levels
1369 
1370  // Data structures for terrain-fitted coordinates
1371  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd;
1372  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_cc;
1373 
1374  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc;
1375  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ax;
1376  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ay;
1377  amrex::Vector<std::unique_ptr<amrex::MultiFab>> az;
1378 
1379  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd_src;
1380  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_cc_src;
1381  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc_src;
1382  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ax_src;
1383  amrex::Vector<std::unique_ptr<amrex::MultiFab>> ay_src;
1384  amrex::Vector<std::unique_ptr<amrex::MultiFab>> az_src;
1385 
1386  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_phys_nd_new;
1387  amrex::Vector<std::unique_ptr<amrex::MultiFab>> detJ_cc_new;
1388 
1389  amrex::Vector<std::unique_ptr<amrex::MultiFab>> z_t_rk;
1390 
1391  // Immersed-boundary surface energy balance: inputs and one face set per level
1393  amrex::Vector<std::unique_ptr<IBFaceSet>> m_ibseb;
1394 
1395  // Data structures for terrain immersed forcing
1396  amrex::Vector<std::unique_ptr<amrex::MultiFab>> terrain_blanking;
1397  amrex::Vector<std::unique_ptr<amrex::MultiFab>> terrain_blanking_xface;
1398  amrex::Vector<std::unique_ptr<amrex::MultiFab>> terrain_blanking_yface;
1399  amrex::Vector<std::unique_ptr<amrex::MultiFab>> terrain_blanking_zface;
1400 
1401  // Wall distance function
1402  amrex::Vector<std::unique_ptr<amrex::MultiFab>> walldist;
1403 
1404  // Map scale factors -- vector across levels of vector across types
1405  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::MultiFab>>> mapfac;
1406 
1407  // Mask to be used to identify cells covered by finer level (if level > 0)
1408  amrex::Vector<std::unique_ptr<amrex::MultiFab>> fine_mask;
1409 
1410  amrex::Vector<amrex::Vector<amrex::Real>> stretched_dz_h;
1411  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>> stretched_dz_d;
1412 
1413  amrex::Vector<amrex::MultiFab> base_state;
1414  amrex::Vector<amrex::MultiFab> base_state_new;
1415 
1416  // Wave coupling data
1417  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Hwave;
1418  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Lwave;
1419  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Hwave_onegrid;
1420  amrex::Vector<std::unique_ptr<amrex::MultiFab>> Lwave_onegrid;
1421  bool finished_wave = false;
1422 
1423  // array of flux registers
1424  amrex::Vector<amrex::YAFluxRegister*> advflux_reg;
1425 
1426  // A BCRec is essentially a 2*DIM integer array storing the boundary
1427  // condition type at each lo/hi walls in each direction. We have one BCRec
1428  // for each component of the cell-centered variables and each velocity component.
1429  amrex::Vector <amrex::BCRec> domain_bcs_type;
1430  amrex::Gpu::DeviceVector<amrex::BCRec> domain_bcs_type_d;
1431 
1432  // We store these so that we can print them out in the job_info file
1433  amrex::Array<std::string,2*AMREX_SPACEDIM> domain_bc_type;
1434 
1435  // These hold the Dirichlet values at walls which need them ...
1436  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
1437 
1438  // These hold the Neumann values at walls which need them ...
1439  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
1440 
1441  // Host-side, face-local metadata for solid-wall scalar inputs. This is
1442  // deliberately separate from the values copied into device ghost-fill
1443  // kernels so explicit zero values remain distinguishable from omission.
1444  amrex::Array<amrex::Array<erf_wall_scalar_bc::WallScalarBCIntent, AMREX_SPACEDIM*2>, NBCVAR_max>
1446 
1447  // Per-face flag: non-reflecting inflow (extrapolate RhoTheta instead of prescribing)
1448  amrex::Array<bool, AMREX_SPACEDIM*2> m_bc_nonreflecting = {{false}};
1449 
1450  // These are the "physical" boundary condition types (e.g. "inflow")
1451  amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2> phys_bc_type;
1452 
1453  // These are the masks for the thin immersed body
1454  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> xflux_imask;
1455  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> yflux_imask;
1456  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> zflux_imask;
1457  //amrex::Vector<std::unique_ptr<amrex::iMultiFab>> overset_imask;
1458 
1459  // These are the body forces that result from the thin immersed body
1460  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_xforce;
1461  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_yforce;
1462  amrex::Vector<std::unique_ptr<amrex::MultiFab>> thin_zforce;
1463 
1469 
1474  static double last_check_file_time;
1475 
1476  amrex::Vector<int> last_subvol_step;
1477  amrex::Vector<double> last_subvol_time;
1478 
1480 
1481  // Output control
1482  const int datwidth = 14;
1483  const int datprecision = 6;
1484  const int timeprecision = 13; // e.g., 1-yr LES: 31,536,000 s with dt ~ amrex::Real(0.01) ==> min prec = 10
1485  // epoch time for 2030-01-01 00:00:00 is 1,893,456,000 s with dt ~ amrex::Real(0.01) ==> min prec = 12
1486 
1487  ////////////////
1488  // runtime parameters
1489 
1490  // Maximum number of steps
1491  int max_step = -1;
1492 
1493  // Start and stop times
1494  static double start_time;
1495  static double stop_time;
1496 
1497  bool use_datetime = false;
1498  const std::string datetime_format = "%Y-%m-%d %H:%M:%S"; // ISO 8601 standard
1499 
1500  // if >= 0 we restart from a checkpoint
1501  std::string restart_chkfile = "";
1502 
1503  // Host-only metadata shared by all native output paths. It never enters
1504  // device code or changes the model state read from a checkpoint.
1506 
1507  // Time step controls
1512  static double dt_max_initial;
1513  static double dt_max;
1514 
1515  // Fixed dt at each level (only used if positive)
1516  amrex::Vector<double> fixed_dt;
1517  amrex::Vector<double> fixed_fast_dt;
1519 
1520  // how often each level regrids the higher levels of refinement
1521  // (after a level advances that many time steps)
1522  int regrid_int = -1;
1523 
1524  // Should we regrid level 0 after restart if Ngrids < Nprocs or
1525  // max_grid_size has changed?
1527 
1528  // plotfile prefix and frequency
1529  std::string plot3d_file_1 {"plt_1_"};
1530  std::string plot3d_file_2 {"plt_2_"};
1531  std::string plot2d_file_1 {"plt2d_1_"};
1532  std::string plot2d_file_2 {"plt2d_2_"};
1533  std::string subvol_file {"subvol"};
1535  int m_plot3d_int_1 = -1;
1536  int m_plot3d_int_2 = -1;
1537  int m_plot2d_int_1 = -1;
1538  int m_plot2d_int_2 = -1;
1539 
1540  amrex::Vector<int> m_subvol_int;
1541  amrex::Vector<double> m_subvol_per;
1542 
1543  double m_plot3d_per_1 = -1.0;
1544  double m_plot3d_per_2 = -1.0;
1545  double m_plot2d_per_1 = -1.0;
1546  double m_plot2d_per_2 = -1.0;
1547  bool m_plot_face_vels = false;
1549 
1550  bool plot_lsm = false;
1551 
1552  // other sampling output control
1553  int profile_int = -1;
1554  bool destag_profiles = true;
1555 
1556  // Checkpoint type, prefix and frequency
1557  std::string check_file {"chk"};
1558  int m_check_int = -1;
1559  double m_check_per = -1.0;
1560 
1561  amrex::Vector<std::string> subvol3d_var_names;
1562 
1563  amrex::Vector<std::string> plot3d_var_names_1;
1564  amrex::Vector<std::string> plot3d_var_names_2;
1565  amrex::Vector<std::string> plot2d_var_names_1;
1566  amrex::Vector<std::string> plot2d_var_names_2;
1567  const amrex::Vector<std::string> cons_names {"density", "rhotheta", "rhoKE", "rhoadv_0",
1568  "rhoQ1", "rhoQ2", "rhoQ3",
1569  "rhoQ4", "rhoQ5", "rhoQ6",
1570  "rhoQ7", "rhoQ8", "rhoQ9",
1571  "rhoQ10", "rhoQ11"};
1572 
1573  // **************************************************************************************
1574  // NOTE: The order of variable names here **MUST MATCH THE ORDER** in IO/ERF_Plotfile.cpp
1575  // **************************************************************************************
1576  const amrex::Vector<std::string> derived_names {"temp", "theta", "KE", "scalar", "soundspeed",
1577  "reflectivity","max_reflectivity", "precipitable", "mucape",
1578  "vorticity_x","vorticity_y","vorticity_z",
1579  "helicity", "local_helicity", "vort_stretching",
1580  "magvel", "divU",
1581  "pres_hse", "dens_hse", "theta_hse", "pi_hse", "qv_hse",
1582  "pressure", "pert_pres", "pert_dens",
1583  "buoyancy", "eq_pot_temp", "VPD",
1584 #ifdef ERF_USE_WINDFARM
1585  "num_turb", "SMark0", "SMark1",
1586 #endif
1587  "dpdx", "dpdy", "dpdz", "pres_hse_x", "pres_hse_y",
1588  "z_phys", "detJ", "h_xi", "h_eta", "h_zeta",
1589  "mapfac", "lat_m", "lon_m",
1590  // Time averaged velocity
1591  "u_t_avg", "v_t_avg", "w_t_avg", "umag_t_avg",
1592  // Interval means and resolved turbulence moments
1593  "u_mean", "v_mean", "w_mean", "theta_mean",
1594  "uu_mean", "vv_mean", "ww_mean", "uw_mean", "vw_mean", "wtheta_mean",
1595  "uu_fluct", "vv_fluct", "ww_fluct", "uw_fluct", "vw_fluct", "wtheta_fluct", "tke_resolved",
1596  // eddy viscosity
1597  "nut",
1598  // eddy diffusivity of momentum
1599  "Kmv","Kmh",
1600  // eddy diffusivity of heat
1601  "Khv","Khh",
1602  // turbulence lengthscale
1603  "Lturb",
1604  // k-eqn RANS: smoothed turbulent Richardson number and stability functions
1605  "Rt", "cmu", "cmu_prime",
1606  // native SHOC diagnostics
1607  "pblh", "shoc_cldfrac", "shoc_ql", "shoc_ql2", "shoc_cond",
1608  "wqls_sec", "wthv_sec", "w_sec",
1609  "thl_sec", "qw_sec", "qwthl_sec", "wthl_sec", "wqw_sec", "w3",
1610  "brunt", "isotropy", "shear_prod", "buoy_prod", "diss_tke",
1611  // wall distance
1612  "walldist",
1613  // dissipation
1614  "diss",
1615  // moisture vars
1616  "moist_density", "qv", "qc", "qi", "qrain", "qsnow", "qgraup",
1617  "qt", "qn", "qp", "qsat", "nc", "ni", "nr", "ns", "ng", "nn",
1618  "rain_accum", "snow_accum", "graup_accum",
1619  "rel_humidity", "condensation_rate",
1620  // Terrain IB mask
1621  "terrain_IB_mask",
1622  "ibseb_nfaces", "ibseb_tskin",
1623  "ibseb_sw_abs", "ibseb_shadow",
1624  "ibseb_lw_net", "ibseb_f_sky", "ibseb_H", "ibseb_G",
1625  // EB variables
1626  "volfrac"
1627 #ifdef ERF_COMPUTE_ERROR
1628  // error vars
1629  ,"xvel_err", "yvel_err", "zvel_err", "pp_err"
1630 #endif
1631  ,"qsrc_sw", "qsrc_lw",
1632  "Tau11", "Tau12", "Tau13", "Tau21", "Tau22", "Tau23", "Tau31", "Tau32", "Tau33",
1633  "hfx1", "hfx2", "hfx3", "q1fx1", "q1fx2", "q1fx3", "q2fx3"
1634  };
1635 
1636  // **************************************************************************************
1637  // NOTE: This is the set of derived variables that WriteSubvolume knows how to fill; it
1638  // is an unordered allow-list, since setSubVolVariables walks "derived_names" and
1639  // keeps the entries found here. That means the names are selected in
1640  // "derived_names" order, which is the order WriteSubvolume must compute them in.
1641  // **************************************************************************************
1642  const amrex::Vector<std::string> derived_subvol_names {"soundspeed", "temp", "theta", "KE", "scalar",
1643  "precipitable", "mucape"};
1644 
1645  // algorithm choices
1647 
1648  // Turbulent perturbation structure
1650 
1651 #ifdef ERF_USE_PARTICLES
1652  // Particle container with all particle species
1653  ParticleData particleData;
1654 
1655  // variables and functions for tracers particles
1656  bool m_use_tracer_particles; /*!< tracer particles that advect with flow with optional sedimentation */
1657 
1658  /*! Read tracer and hydro particles parameters */
1659  void readTracersParams();
1660 
1661  /*! Initialize tracer and hydro particles */
1662  void initializeTracers ( amrex::ParGDBBase*,
1663  const amrex::Vector<std::unique_ptr<amrex::MultiFab>>&,
1664  const double time);
1665 
1666  /*! Restart tracer and hydro particles */
1667  void restartTracers ( amrex::ParGDBBase*, const std::string& );
1668 
1669  /*! Evolve tracers and hydro particles */
1670  void evolveTracers( int,
1671  double,
1672  amrex::Vector<amrex::Vector<amrex::MultiFab>>&,
1673  const amrex::Vector<std::unique_ptr<amrex::MultiFab>>& );
1674 
1675 #endif
1676 
1677 #ifdef ERF_USE_MULTIBLOCK
1678  MultiBlockContainer *m_mbc = nullptr;
1679 #endif
1680 
1681  static int verbose;
1682  static int mg_verbose;
1683  static bool use_fft;
1684 
1685  static int check_for_nans;
1686 
1687  // Diagnostic output interval
1688  static int sum_interval;
1689  static int pert_interval;
1690  static double sum_per;
1691 
1692  // Write in native AMReX or NetCDF format for each plotfile
1693  static PlotFileType plotfile3d_type_1;
1694  static PlotFileType plotfile3d_type_2;
1695  static PlotFileType plotfile2d_type_1;
1696  static PlotFileType plotfile2d_type_2;
1697 
1700 
1701  static StateInterpType interpolation_type;
1702 
1703  // NetCDF initialization (wrfinput) file
1704  static amrex::Vector<amrex::Vector<std::string>> nc_init_file;
1705  static amrex::Vector<amrex::Vector<int>> have_read_nc_init_file;
1706 
1707  // NetCDF initialization (wrfbdy/met_em) file
1708  static std::string nc_bdy_file;
1709  int real_width{0};
1710  bool real_extrap_w{true};
1711 
1712  // NetCDF initialization of zlo boundary values
1713  static std::string nc_low_file;
1714 
1715  // Options for vertical interpolation of met_em*.nc data.
1718  bool metgrid_debug_dry{false};
1719  bool metgrid_debug_psfc{false};
1720  bool metgrid_debug_msf{false};
1724  bool metgrid_use_sfc{true};
1725  bool metgrid_retain_sfc{false};
1729 
1730  // Options for ERF boundary files for real simulations.
1731  bool write_erfbdy{false}; // User-settable: write erfbdy during initialization
1732  bool use_erfbdy{false}; // Internal: set during init or restart
1733  std::string erfbdy_file{"erfbdy"}; // User-settable: erfbdy file name
1734  int nvars_erfbdy{0}; // Internal: number of variables in erfbdy
1735 
1736  amrex::Vector<amrex::BoxArray> ba1d;
1737  amrex::Vector<amrex::BoxArray> ba2d;
1738 
1739  // Vertical extent of the grid column over each (i,j), stored on ba2d (so the
1740  // compressed z index is 0) with one ghost cell in x and y so that a box can also
1741  // read the extent of the column on the other side of each of its faces.
1742  // component 0 : smallEnd(2) of the box covering this column
1743  // component 1 : bigEnd(2) of the box covering this column
1744  // Ghost entries that no box covers keep the "unconstraining" sentinels below.
1745  // This is well defined only because grids may not be split in the vertical --
1746  // see ERF::grids_are_split_in_z. Used by the implicit vertical diffusion solves.
1747  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> column_kextent;
1748 
1749  static constexpr int column_kextent_lo_sentinel = std::numeric_limits<int>::min()/2;
1750  static constexpr int column_kextent_hi_sentinel = std::numeric_limits<int>::max()/2;
1751 
1752  void define_column_kextent (int lev, const amrex::BoxArray& ba,
1753  const amrex::DistributionMapping& dm);
1754 
1755  static bool grids_are_split_in_z (const amrex::BoxArray& ba);
1756 
1757  // The six parameters defining the WRF analytic reference profile, plus the layer
1758  // interfaces derived from them. These are read from the LEVEL 0 wrfinput file only
1759  // and then shared by every level: the levels of an AMR hierarchy must be built from
1760  // one reference profile, or their base states cannot agree across the coarse/fine
1761  // interface. (A nested wrfinput file that disagrees produces a warning.)
1763 
1764  std::unique_ptr<amrex::MultiFab> wrf_C1H;
1765  std::unique_ptr<amrex::MultiFab> wrf_C2H;
1766  std::unique_ptr<amrex::MultiFab> wrf_MUB;
1767  std::unique_ptr<amrex::MultiFab> wrf_RDNW;
1768  std::unique_ptr<amrex::MultiFab> wrf_PHB; // Base geopotential
1769 
1770  amrex::Vector<std::unique_ptr<amrex::MultiFab>> mf_PSFC;
1771 
1772  // 1D CDF output (for ingestion in AMR-Wind)
1773  static int output_1d_column;
1774  static int column_interval;
1775  static double column_per;
1778  static std::string column_file_name;
1779 
1780  // 2D BndryRegister output (for ingestion in AMR-Wind)
1785 
1786  // 2D BndryRegister input
1788 
1789  static int ng_dens_hse;
1790  static int ng_pres_hse;
1791 
1792  // Custom source terms
1793  amrex::Vector<std::unique_ptr<amrex::MultiFab>> rhotheta_src;
1794  amrex::Vector<std::unique_ptr<amrex::MultiFab>> rhoqt_src;
1795 
1796  amrex::Vector< amrex::Vector<amrex::Real> > h_w_subsid;
1797  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_w_subsid;
1798 
1799  amrex::Vector< amrex::Vector<amrex::Real> > h_u_geos;
1800  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_u_geos;
1801 
1802  amrex::Vector< amrex::Vector<amrex::Real> > h_v_geos;
1803  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_v_geos;
1804 
1805  // Function to read and populate above host vectors (if input file exists)
1806  void init_geo_wind_profile (const std::string input_file,
1807  amrex::Vector<amrex::Real>& u_geos,
1808  amrex::Gpu::DeviceVector<amrex::Real>& u_geos_d,
1809  amrex::Vector<amrex::Real>& v_geos,
1810  amrex::Gpu::DeviceVector<amrex::Real>& v_geos_d,
1811  const amrex::Geometry& lgeom,
1812  const amrex::Vector<amrex::Real>& zlev_stag);
1813 
1814  // This is a vector over levels of vectors across quantities of Vectors
1815  amrex::Vector<amrex::Vector<amrex::Vector<amrex::Real> > > h_rayleigh_ptrs;
1816  amrex::Vector<amrex::Vector<amrex::Vector<amrex::Real> > > h_sponge_ptrs;
1817 
1818  // These are vectors over levels of Vectors
1819  amrex::Vector<amrex::Vector<amrex::Real> > h_sinesq_ptrs;
1820  amrex::Vector<amrex::Vector<amrex::Real> > h_sinesq_stag_ptrs;
1821 
1822  // This is a vector over levels of vectors across quantities of DeviceVectors
1823  amrex::Vector<amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > > d_rayleigh_ptrs;
1824  amrex::Vector<amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > > d_sponge_ptrs;
1825 
1826  // These are vectors over levels of DeviceVectors
1827  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_sinesq_ptrs;
1828  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real> > d_sinesq_stag_ptrs;
1829 
1830  amrex::Vector<amrex::Real> h_havg_density;
1831  amrex::Vector<amrex::Real> h_havg_temperature;
1832  amrex::Vector<amrex::Real> h_havg_pressure;
1833  amrex::Vector<amrex::Real> h_havg_qv;
1834  amrex::Vector<amrex::Real> h_havg_qc;
1835 
1836  amrex::Gpu::DeviceVector<amrex::Real> d_havg_density;
1837  amrex::Gpu::DeviceVector<amrex::Real> d_havg_temperature;
1838  amrex::Gpu::DeviceVector<amrex::Real> d_havg_pressure;
1839  amrex::Gpu::DeviceVector<amrex::Real> d_havg_qv;
1840  amrex::Gpu::DeviceVector<amrex::Real> d_havg_qc;
1841 
1842  void refinement_criteria_setup ();
1843 
1844  std::unique_ptr<WriteBndryPlanes> m_w2d = nullptr;
1845  std::unique_ptr<ReadBndryPlanes> m_r2d = nullptr;
1846  amrex::Vector<std::unique_ptr<SurfaceLayer>> m_SurfaceLayer;
1847  amrex::Vector<std::unique_ptr<ForestDrag>> m_forest_drag;
1848 
1849  //
1850  // Holds info for dynamically generated tagging criteria
1851  //
1852  static amrex::Vector<amrex::AMRErrorTag> ref_tags;
1853 
1854  //
1855  // Name of the refinement indicator that generated each entry of ref_tags.
1856  // Not every indicator generates a ref_tag (e.g. "storm_tracker" does not),
1857  // so this must be carried alongside ref_tags rather than re-deriving it
1858  // from the positional index into erf.refinement_indicators.
1859  //
1860  static amrex::Vector<std::string> ref_tag_indicator_names;
1861 
1862  amrex::Vector<amrex::Vector<amrex::BoxArray>> subdomains;
1863 
1864  amrex::Vector<amrex::Real> dz_min;
1865 
1866  static AMREX_FORCE_INLINE
1867  int
1869  {
1870  // We never have fewer than 2 ghost cells
1871  int ngrow = 2;
1872 
1873  // This sets the minimum to 3 if using num_diff but we might still need more
1874  if (sc.use_num_diff) {
1875  ngrow = 3;
1876  }
1877 
1878  // With EB we always have 4 so no need to do further tests
1879  if (sc.terrain_type == TerrainType::EB) {
1880  ngrow = 4;
1881  return ngrow;
1882  }
1883 
1884  if (
1891  { ngrow = 3; }
1892  else if (
1899  { ngrow = 3; }
1900  else if (
1907  { ngrow = 3; }
1908  else if (
1915  { ngrow = 3; }
1916  else if (
1923  { ngrow = 3; }
1924  else if (
1931  { ngrow = 4; }
1932 
1933  return ngrow;
1934  }
1935 
1936  AMREX_FORCE_INLINE
1937  amrex::YAFluxRegister* getAdvFluxReg (int lev)
1938  {
1939  return advflux_reg[lev];
1940  }
1941 
1942  AMREX_FORCE_INLINE
1943  std::ostream&
1944  DataLog (int i)
1945  {
1946  return *datalog[i];
1947  }
1948 
1949  AMREX_FORCE_INLINE
1950  std::ostream&
1951  DerDataLog (int i)
1952  {
1953  return *der_datalog[i];
1954  }
1955 
1956  AMREX_FORCE_INLINE
1957  int
1958  NumDataLogs () noexcept
1959  {
1960  return static_cast<int>(datalog.size());
1961  }
1962 
1963  AMREX_FORCE_INLINE
1964  int
1965  NumDerDataLogs () noexcept
1966  {
1967  return static_cast<int>(der_datalog.size());
1968  }
1969 
1970 
1971  AMREX_FORCE_INLINE
1972  std::ostream&
1974  {
1975  return *sampleptlog[i];
1976  }
1977 
1978  AMREX_FORCE_INLINE
1979  int
1981  {
1982  return static_cast<int>(sampleptlog.size());
1983  }
1984 
1985  AMREX_FORCE_INLINE
1986  std::ostream&
1988  {
1989  return *samplelinelog[i];
1990  }
1991 
1992  AMREX_FORCE_INLINE
1993  int
1994  NumSampleLineLogs () noexcept
1995  {
1996  return static_cast<int>(samplelinelog.size());
1997  }
1998 
1999  amrex::IntVect&
2000  SamplePoint (int i)
2001  {
2002  return samplepoint[i];
2003  }
2004 
2005  AMREX_FORCE_INLINE
2006  int
2007  NumSamplePoints () noexcept
2008  {
2009  return static_cast<int>(samplepoint.size());
2010  }
2011 
2012  amrex::IntVect&
2013  SampleLine (int i)
2014  {
2015  return sampleline[i];
2016  }
2017 
2018  AMREX_FORCE_INLINE
2019  int
2020  NumSampleLines () noexcept
2021  {
2022  return static_cast<int>(sampleline.size());
2023  }
2024 
2025  static double startCPUTime;
2026  static double previousCPUTimeUsed;
2027 
2028  static double
2030  {
2031  int numCores = amrex::ParallelDescriptor::NProcs();
2032 #ifdef _OPENMP
2033  numCores = numCores * omp_get_max_threads();
2034 #endif
2035 
2036  double T =
2037  numCores * (amrex::ParallelDescriptor::second() - startCPUTime) +
2039 
2040  return T;
2041  }
2042 
2043  void setRecordDataInfo (int i, const std::string& filename) // NOLINT
2044  {
2045  if (amrex::ParallelDescriptor::IOProcessor())
2046  {
2047  datalog[i] = std::make_unique<std::fstream>();
2048  datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2049  if (!datalog[i]->good()) {
2050  amrex::FileOpenFailed(filename);
2051  }
2052  }
2053  amrex::ParallelDescriptor::Barrier("ERF::setRecordDataInfo");
2054  }
2055 
2056  void setRecordDerDataInfo (int i, const std::string& filename) // NOLINT
2057  {
2058  if (amrex::ParallelDescriptor::IOProcessor())
2059  {
2060  der_datalog[i] = std::make_unique<std::fstream>();
2061  der_datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2062  if (!der_datalog[i]->good()) {
2063  amrex::FileOpenFailed(filename);
2064  }
2065  }
2066  amrex::ParallelDescriptor::Barrier("ERF::setRecordDerDataInfo");
2067  }
2068 
2069  void setRecordEnergyDataInfo (int i, const std::string& filename) // NOLINT
2070  {
2071  if (amrex::ParallelDescriptor::IOProcessor())
2072  {
2073  tot_e_datalog[i] = std::make_unique<std::fstream>();
2074  tot_e_datalog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2075  if (!tot_e_datalog[i]->good()) {
2076  amrex::FileOpenFailed(filename);
2077  }
2078  }
2079  amrex::ParallelDescriptor::Barrier("ERF::setRecordEnergyDataInfo");
2080  }
2081 
2082  void setRecordSamplePointInfo (int i, int lev, amrex::IntVect& cell, const std::string& filename) // NOLINT
2083  {
2084  amrex::MultiFab dummy(grids[lev],dmap[lev],1,0);
2085  for (amrex::MFIter mfi(dummy); mfi.isValid(); ++mfi)
2086  {
2087  const amrex::Box& bx = mfi.validbox();
2088  if (bx.contains(cell)) {
2089  sampleptlog[i] = std::make_unique<std::fstream>();
2090  sampleptlog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2091  if (!sampleptlog[i]->good()) {
2092  amrex::FileOpenFailed(filename);
2093  }
2094  }
2095  }
2096  amrex::ParallelDescriptor::Barrier("ERF::setRecordSamplePointInfo");
2097  }
2098 
2099  void setRecordSampleLineInfo (int i, int lev, amrex::IntVect& cell, const std::string& filename) // NOLINT
2100  {
2101  amrex::MultiFab dummy(grids[lev],dmap[lev],1,0);
2102  for (amrex::MFIter mfi(dummy); mfi.isValid(); ++mfi)
2103  {
2104  const amrex::Box& bx = mfi.validbox();
2105  if (bx.contains(cell)) {
2106  samplelinelog[i] = std::make_unique<std::fstream>();
2107  samplelinelog[i]->open(filename.c_str(),std::ios::out|std::ios::app);
2108  if (!samplelinelog[i]->good()) {
2109  amrex::FileOpenFailed(filename);
2110  }
2111  }
2112  }
2113  amrex::ParallelDescriptor::Barrier("ERF::setRecordSampleLineInfo");
2114  }
2115 
2116  // Data sampler for line and plane output
2121  std::unique_ptr<LineSampler> line_sampler = nullptr;
2122  std::unique_ptr<PlaneSampler> plane_sampler = nullptr;
2123 
2124  // Station time-series output
2127  std::unique_ptr<StationSampler> station_sampler = nullptr;
2128  // The 3D and 2D plot variables the stations need, in the order the fill
2129  // routines produce their components
2130  amrex::Vector<std::string> station_vars_3d;
2131  amrex::Vector<std::string> station_vars_2d;
2132 
2133  amrex::Vector<std::unique_ptr<std::fstream> > datalog;
2134  amrex::Vector<std::unique_ptr<std::fstream> > der_datalog;
2135  amrex::Vector<std::unique_ptr<std::fstream> > tot_e_datalog;
2136  amrex::Vector<std::string> datalogname;
2137  amrex::Vector<std::string> der_datalogname;
2138  amrex::Vector<std::string> tot_e_datalogname;
2139 
2140  amrex::Vector<std::unique_ptr<std::fstream> > sampleptlog;
2141  amrex::Vector<std::string> sampleptlogname;
2142  amrex::Vector<amrex::IntVect> samplepoint;
2143 
2144  amrex::Vector<std::unique_ptr<std::fstream> > samplelinelog;
2145  amrex::Vector<std::string> samplelinelogname;
2146  amrex::Vector<amrex::IntVect> sampleline;
2147 
2148  //! The filename of the ith datalog file.
2149  [[nodiscard]] std::string DataLogName (int i) const noexcept { return datalogname[i]; }
2150  [[nodiscard]] std::string DerDataLogName (int i) const noexcept { return der_datalogname[i]; }
2151 
2152  //! The filename of the ith sampleptlog file.
2153  [[nodiscard]] std::string SamplePointLogName (int i) const noexcept { return sampleptlogname[i]; }
2154 
2155  //! The filename of the ith samplelinelog file.
2156  [[nodiscard]] std::string SampleLineLogName (int i) const noexcept { return samplelinelogname[i]; }
2157 
2158  // array of EB objects
2159  amrex::Vector<std::unique_ptr<eb_>> eb;
2160 
2161  [[nodiscard]] eb_ const& get_eb (int lev) const noexcept {
2162  AMREX_ASSERT(lev >= 0 && lev < eb.size() && eb[lev] != nullptr);
2163  return *eb[lev];
2164  }
2165 
2166  //
2167  // NOTE: this dereferences the cell-centered EB factory, which is only built when
2168  // we are using EB or immersed forcing -- see ERF::MakeNewLevelFromScratch.
2169  // Calling this in any other case is undefined behavior, so we assert here
2170  // rather than relying on the (build-dependent) libstdc++ hardening check.
2171  //
2172  [[nodiscard]] amrex::EBFArrayBoxFactory const&
2173  EBFactory (int lev) const noexcept {
2174  AMREX_ASSERT(lev >= 0 && lev < eb.size() && eb[lev] != nullptr);
2175  AMREX_ASSERT(eb[lev]->get_const_factory() != nullptr);
2176  return *(eb[lev]->get_const_factory());
2177  }
2178 
2179  [[nodiscard]] static int nghost_eb_basic ()
2180  { return 5; }
2181 
2182  // We need 5 for doing StateRedistribution; otherwise 4 would be enough
2183  [[nodiscard]] static int nghost_eb_volume ()
2184  { return 5; }
2185 
2186  [[nodiscard]] static int nghost_eb_full ()
2187  { return 4; }
2188 
2189 #ifdef ERF_USE_FFT
2190  // Vector over levels of Vector over subdomains of solvers
2191  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::FFT::Poisson<amrex::MultiFab>>>> m_3D_poisson;
2192  amrex::Vector<amrex::Vector<std::unique_ptr<amrex::FFT::PoissonHybrid<amrex::MultiFab>>>> m_2D_poisson;
2193 #endif
2194 
2195 public:
2196  void writeJobInfo (const std::string& dir,
2197  erf_provenance::ArtifactType artifact_type,
2198  int artifact_step,
2199  double artifact_time_seconds) const;
2200  static void writeBuildInfo (std::ostream& os);
2201 
2202  static void print_banner(MPI_Comm /*comm*/, std::ostream& /*out*/);
2203  static void print_usage(MPI_Comm /*comm*/, std::ostream& /*out*/);
2204  static void print_error(MPI_Comm /*comm*/, const std::string& msg);
2205  static void print_summary(std::ostream&);
2206  static void print_tpls(std::ostream& /*out*/);
2207 };
2208 
2209 #endif
AMREX_ENUM(StateInterpType, FullState, Perturbational)
@ tau23
Definition: ERF_DataStruct.H:40
@ tau13
Definition: ERF_DataStruct.H:40
Declares the embedded-boundary factory manager used by ERF levels.
Contains the Eulerian microphysics class.
Compact list of the wall faces of resolved buildings on one AMR level.
#define NBCVAR_max
Definition: ERF_IndexDefines.H:32
@ Centered_6th
Contains the Lagrangian microphysics class.
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:30
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:29
std::string name
Definition: ERF_Plotfile2DCatalog.cpp:101
amrex::Real Real
Definition: ERF_ShocInterface.H:19
amrex::Vector< std::string > station_vars_3d
Definition: ERF.H:2130
void MakeHorizontalAverages()
Definition: ERF.cpp:3392
amrex::Vector< amrex::MultiFab > rU_new
Definition: ERF.H:1266
static int last_check_file_step
Definition: ERF.H:1468
amrex::Vector< std::unique_ptr< amrex::MultiFab > > walldist
Definition: ERF.H:1402
void ConfigureDriverAtmosToOceanCoupling(bool use_coupling_driver, bool use_two_way_coupling, bool use_state_contract)
Definition: ERF_to_REMORA.cpp:247
amrex::Vector< amrex::Vector< amrex::Vector< amrex::Real > > > h_sponge_ptrs
Definition: ERF.H:1816
void GetOceanToAtmosSurfaceLayout(amrex::BoxArray &ba, amrex::DistributionMapping &dm)
Definition: ERF_to_REMORA.cpp:263
bool metgrid_basic_linear
Definition: ERF.H:1722
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
Definition: ERF.H:1195
amrex::Vector< std::string > samplelinelogname
Definition: ERF.H:2145
void MakeEBGeometry()
int max_step
Definition: ERF.H:1491
void HurricaneTracker(int lev, double time, const amrex::MultiFab &cc_vel, const amrex::Real velmag_threshold, amrex::TagBoxArray *tags=nullptr)
Definition: ERF_RefineHurricane.cpp:147
bool metgrid_debug_msf
Definition: ERF.H:1720
AMREX_FORCE_INLINE std::ostream & DerDataLog(int i)
Definition: ERF.H:1951
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > mapfac
Definition: ERF.H:1405
void setRayleighRefFromSounding(bool restarting)
Set Rayleigh mean profiles from input sounding.
Definition: ERF_InitRayleigh.cpp:85
void init_only(int lev, double time)
Definition: ERF.cpp:2425
void BuildPlot3DScratch(const amrex::Vector< std::string > &plot_var_names, Plot3DScratch &scratch, int max_lev=-1, bool sync_solution=true)
Definition: ERF_Plotfile.cpp:298
void turbPert_amplitude_w(const int lev)
Definition: ERF_InitTurbPert.cpp:72
amrex::Vector< std::unique_ptr< MRISplitIntegrator< amrex::Vector< amrex::MultiFab > > > > mri_integrator_mem
Definition: ERF.H:1241
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > column_kextent
Definition: ERF.H:1747
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_sinesq_stag_ptrs
Definition: ERF.H:1828
void check_vels_for_nans(amrex::MultiFab const &xvel, amrex::MultiFab const &yvel, amrex::MultiFab const &zvel)
Definition: ERF.cpp:3687
void ibseb_write_checkpoint(const std::string &checkpointname, int lev) const
Definition: ERF_IBSEB.cpp:195
void Evolve()
Definition: ERF.cpp:140
amrex::Vector< amrex::MultiFab > avg_xmom
Definition: ERF.H:1248
amrex::Vector< amrex::MultiFab > pp_inc
Definition: ERF.H:1244
void make_eb_box()
amrex::Vector< ERFFillPatcher > FPr_u
Definition: ERF.H:1335
amrex::Vector< amrex::IntVect > sampleline
Definition: ERF.H:2146
void PackAtmosphericStates(amrex::Vector< amrex::MultiFab * > &states, double time, const amrex::Vector< const amrex::MultiFab * > &weight_mf, const amrex::Vector< const amrex::iMultiFab * > &index_mf, int max_stencil_size, const amrex::MultiFab *dst_mskr=nullptr, const amrex::MultiFab *dst_msku=nullptr, const amrex::MultiFab *dst_mskv=nullptr)
Definition: ERF_to_REMORA.cpp:370
amrex::Vector< std::string > subvol3d_var_names
Definition: ERF.H:1561
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx3_lev
Definition: ERF.H:1358
amrex::Vector< double > t_new
Definition: ERF.H:1217
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Hwave_onegrid
Definition: ERF.H:1419
amrex::Vector< amrex::Vector< amrex::MultiFab > > vars_new
Definition: ERF.H:1225
void FillCoarsePatch(int lev, double time)
Definition: ERF_FillCoarsePatch.cpp:20
void WriteAtIntermediateTime(int nstep, double time)
Definition: ERF.cpp:239
ERF(ERF &&) noexcept=delete
bool writeNow(double cur_time, const int nstep, const int plot_int, const double plot_per, const double dt_0, double &last_file_time)
Definition: ERF.cpp:3599
static constexpr int column_kextent_hi_sentinel
Definition: ERF.H:1750
static double startCPUTime
Definition: ERF.H:2025
void FillBdyCCVels(amrex::MultiFab &mf_cc_vel, amrex::Geometry &lev_geom)
Definition: ERF_FillBdyCCVels.cpp:17
AMREX_FORCE_INLINE int NumSampleLineLogs() noexcept
Definition: ERF.H:1994
static double last_plot2d_file_time_1
Definition: ERF.H:1472
static void print_tpls(std::ostream &)
Definition: ERF_ConsoleIO.cpp:140
amrex::Vector< amrex::Real > dz_min
Definition: ERF.H:1864
amrex::Vector< amrex::MultiFab > lagged_delta_rt
Definition: ERF.H:1247
amrex::Real plane_sampling_per
Definition: ERF.H:2120
std::string DataLogName(int i) const noexcept
The filename of the ith datalog file.
Definition: ERF.H:2149
std::string plot2d_file_2
Definition: ERF.H:1532
double m_plot3d_per_2
Definition: ERF.H:1544
static double bndry_output_planes_per
Definition: ERF.H:1783
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_yforce
Definition: ERF.H:1461
void SetDriverAtmosToOceanStateContract(bool use_state_contract)
Definition: ERF_to_REMORA.cpp:257
void ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real time, int ngrow) override
Definition: ERF_Tagging.cpp:34
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx3_lev
Definition: ERF.H:1356
amrex::Vector< amrex::Vector< amrex::Real > > h_w_subsid
Definition: ERF.H:1796
static void print_banner(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:63
void volWgtColumnSum(int lev, const amrex::MultiFab &mf, int comp, amrex::MultiFab &mf_2d, const amrex::MultiFab &dJ)
Definition: ERF_VolWgtSum.cpp:92
amrex::Vector< std::unique_ptr< ShocDriver > > native_shoc_driver
Definition: ERF.H:1322
amrex::Vector< std::unique_ptr< std::fstream > > datalog
Definition: ERF.H:2133
std::string MakeFilename_EyeTracker_maxvel(int nstep)
Definition: ERF_TrackerOutput.cpp:69
BaseStateParams wrf_bsp
Definition: ERF.H:1762
amrex::Vector< ERFFillPatcher > FPr_v
Definition: ERF.H:1336
int cf_set_width
Definition: ERF.H:1333
void initializeEB()
Definition: ERF_EBInit.cpp:23
std::unique_ptr< amrex::MultiFab > wrf_MUB
Definition: ERF.H:1766
void setPlotVariables(const std::string &pp_plot_var_names, amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile.cpp:19
amrex::Gpu::DeviceVector< amrex::Real > d_havg_temperature
Definition: ERF.H:1837
void post_timestep(int nstep, double time, double dt_lev)
Definition: ERF.cpp:370
std::unique_ptr< amrex::MultiFab > wrf_C1H
Definition: ERF.H:1764
std::string erfbdy_file
Definition: ERF.H:1733
static int last_plot2d_file_step_2
Definition: ERF.H:1467
int station_sampling_interval
Definition: ERF.H:2125
IBSEBParams ibseb_params
Definition: ERF.H:1392
const int timeprecision
Definition: ERF.H:1484
void setRecordDataInfo(int i, const std::string &filename)
Definition: ERF.H:2043
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx1_lev
Definition: ERF.H:1356
void canonicalizePlot3DVariables(amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile.cpp:57
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_eye_track_xy
Definition: ERF.H:288
void SurfaceDataInterpolation(const int nlevs, const double time, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &z_phys_nd, bool regrid_forces_file_read)
Definition: ERF_SurfaceDataInterpolation.cpp:157
amrex::Vector< amrex::BoxArray > ba2d
Definition: ERF.H:1737
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF.H:1436
void init_stations()
Definition: ERF_StationSampler.cpp:684
void init_from_input_sounding(int lev)
Definition: ERF_InitFromInputSounding.cpp:95
void erf_enforce_hse(int lev, amrex::MultiFab &dens, amrex::MultiFab &pres, amrex::MultiFab &pi, amrex::MultiFab &th, amrex::MultiFab &qv, std::unique_ptr< amrex::MultiFab > &z_cc)
Definition: ERF_Init1D.cpp:228
amrex::Vector< amrex::Vector< amrex::MultiFab > > gradp
Definition: ERF.H:1229
std::string plot3d_file_1
Definition: ERF.H:1529
eb_ const & get_eb(int lev) const noexcept
Definition: ERF.H:2161
amrex::Gpu::DeviceVector< amrex::Real > d_havg_qv
Definition: ERF.H:1839
amrex::Vector< std::unique_ptr< amrex::MultiFab > > qfx3_EB
Definition: ERF.H:1365
static amrex::Real column_loc_y
Definition: ERF.H:1777
static bool plot_file_on_restart
Definition: ERF.H:1479
amrex::Vector< amrex::Vector< amrex::MultiFab > > bckgnd_state
Definition: ERF.H:301
static int mg_verbose
Definition: ERF.H:1682
double m_check_per
Definition: ERF.H:1559
void ReadParameters()
Definition: ERF.cpp:2603
static double sum_per
Definition: ERF.H:1690
static amrex::Vector< std::string > PlotFileVarNames(amrex::Vector< std::string > plot_var_names)
Definition: ERF_Plotfile.cpp:276
amrex::Vector< amrex::Vector< amrex::MultiFab > > forecast_state_interp
Definition: ERF.H:296
bool FindInitialEye(int lev, const amrex::MultiFab &cc_vel, const amrex::Real velmag_threshold, amrex::Real &eye_x, amrex::Real &eye_y)
Definition: ERF_RefineHurricane.cpp:31
void InitializeFromFile()
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_cons > > physbcs_cons
Definition: ERF.H:1253
amrex::Vector< double > dt
Definition: ERF.H:1219
static double stop_time
Definition: ERF.H:1495
void advance_lsm(int lev, amrex::MultiFab &cons_in, amrex::MultiFab &xvel_in, amrex::MultiFab &yvel_in, const double &time, const double &dt_advance)
Definition: ERF_AdvanceLSM.cpp:5
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mf_PSFC
Definition: ERF.H:1770
void flush_stations() const
Definition: ERF_StationSampler.cpp:1545
ERF()
Definition: ERF_Constructors.cpp:18
void init_Dirichlet_bc_data(const std::string input_file)
Definition: ERF_InitBCs.cpp:796
~ERF() override
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd_src
Definition: ERF.H:1379
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc
Definition: ERF.H:1374
amrex::Vector< std::string > lsm_flux_name
Definition: ERF.H:1297
void WriteMyEBSurface()
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_cc
Definition: ERF.H:1372
static double column_per
Definition: ERF.H:1775
amrex::Vector< std::unique_ptr< eb_ > > eb
Definition: ERF.H:2159
amrex::Vector< std::unique_ptr< amrex::MultiFab > > eddyDiffs_lev
Definition: ERF.H:1342
static SolverChoice solverChoice
Definition: ERF.H:1646
static constexpr int column_kextent_lo_sentinel
Definition: ERF.H:1749
amrex::Vector< std::unique_ptr< amrex::MultiFab > > hfx3_EB
Definition: ERF.H:1364
int mean_vars_time_reset_done
Definition: ERF.H:1239
amrex::Vector< ERFFillPatcher > FPr_c
Definition: ERF.H:1334
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, double 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:2506
void update_box_for_refinement(std::string &ref_prefix, int &lev_for_box, amrex::RealBox &real_box, const double time)
Definition: ERF_RefineBox.cpp:372
bool plot_rad
Definition: ERF.H:1328
TwoStreamRadiation two_stream_rad
Definition: ERF.H:1316
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_tracker_circle
Definition: ERF.H:292
static bool use_fft
Definition: ERF.H:1683
bool m_plot_face_vels
Definition: ERF.H:1547
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_maxvel_vs_time
Definition: ERF.H:290
void turbPert_update(const int lev, const double dt)
Definition: ERF_InitTurbPert.cpp:18
void sum_derived_quantities(double time)
Definition: ERF_WriteScalarProfiles.cpp:179
amrex::Vector< amrex::MultiFab > base_state_new
Definition: ERF.H:1414
std::string plot3d_file_2
Definition: ERF.H:1530
amrex::Vector< std::unique_ptr< amrex::MultiFab > > az
Definition: ERF.H:1377
int regrid_int
Definition: ERF.H:1522
void derive_diag_profiles(double 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:241
void sample_stations(amrex::Real time)
Definition: ERF_StationSampler.cpp:1301
bool write_erfbdy
Definition: ERF.H:1731
void solve_with_gmres(int lev, const amrex::Box &subdomain, amrex::MultiFab &rhs, amrex::MultiFab &p, amrex::Array< amrex::MultiFab, AMREX_SPACEDIM > &fluxes, amrex::MultiFab &ax_sub, amrex::MultiFab &ay_sub, amrex::MultiFab &az_sub, amrex::MultiFab &, amrex::MultiFab &znd_sub)
Definition: ERF_SolveWithGMRES.cpp:28
amrex::Vector< amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > > d_sponge_ptrs
Definition: ERF.H:1824
amrex::Vector< long > dt_mri_ratio
Definition: ERF.H:1220
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > Tau
Definition: ERF.H:1340
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vel_t_avg
Definition: ERF.H:1232
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q2fx3_lev
Definition: ERF.H:1359
void HurricaneEyeTrackerNotInitial(const SolverChoice &sc, const amrex::Geometry &geom, const amrex::Vector< amrex::MultiFab > &S_data, MoistureType moisture_type)
Definition: ERF_HurricaneDiagnostics.cpp:368
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::iMultiFab > > > lmask_lev
Definition: ERF.H:1348
void GetFillableAtmosToOceanLanes(bool state_contract, amrex::Vector< int > &can_fill) const
Definition: ERF_to_REMORA.cpp:300
AMREX_FORCE_INLINE int NumSamplePointLogs() noexcept
Definition: ERF.H:1980
amrex::Vector< amrex::Real > h_havg_pressure
Definition: ERF.H:1832
void update_diffusive_arrays(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Definition: ERF_MakeNewArrays.cpp:684
std::unique_ptr< amrex::MultiFab > wrf_PHB
Definition: ERF.H:1768
static int verbose
Definition: ERF.H:1681
amrex::Vector< amrex::Real > h_havg_qc
Definition: ERF.H:1834
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_w > > physbcs_w
Definition: ERF.H:1256
static int nghost_eb_basic()
Definition: ERF.H:2179
void post_update(amrex::MultiFab &state_mf, double time, const amrex::Geometry &geom)
void AverageDownMoistStateTo(int crse_lev)
Conservation-preserving fine-to-coarse average of RhoTheta and the active moist conserved components ...
Definition: ERF_AverageDown.cpp:243
amrex::Vector< double > last_subvol_time
Definition: ERF.H:1477
void FillForecastStateMultiFabs(const int lev, const std::string &filename, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, amrex::Vector< amrex::Vector< amrex::MultiFab >> &forecast_state)
Definition: ERF_WeatherDataInterpolation.cpp:72
static std::string column_file_name
Definition: ERF.H:1778
amrex::Vector< std::unique_ptr< std::fstream > > samplelinelog
Definition: ERF.H:2144
amrex::Vector< std::unique_ptr< amrex::MultiFab > > terrain_blanking
Definition: ERF.H:1396
amrex::Vector< std::unique_ptr< amrex::MultiFab > > terrain_blanking_xface
Definition: ERF.H:1397
std::unique_ptr< Microphysics > micro
Definition: ERF.H:1276
int m_plot2d_int_2
Definition: ERF.H:1538
amrex::Vector< amrex::MultiFab > base_state
Definition: ERF.H:1413
void fill_rhs(amrex::MultiFab &rhs_mf, const amrex::MultiFab &state_mf, double time, const amrex::Geometry &geom)
void GetEnsembleCheckpointName(int da_iter, int ens_no)
AMREX_FORCE_INLINE amrex::YAFluxRegister * getAdvFluxReg(int lev)
Definition: ERF.H:1937
int m_plot3d_int_1
Definition: ERF.H:1535
amrex::Vector< amrex::Real > h_havg_density
Definition: ERF.H:1830
static double last_plot2d_file_time_2
Definition: ERF.H:1473
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd_new
Definition: ERF.H:1386
void derive_diag_profiles_stag(double 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:358
void create_background_state_for_ensemble(int lev, amrex::MultiFab &mf_cc_pert, amrex::MultiFab &cons_pert, amrex::MultiFab &xvel_pert, amrex::MultiFab &yvel_pert, amrex::MultiFab &zvel_pert)
Definition: ERF_InitForEnsemble.cpp:732
const amrex::Vector< std::string > derived_subvol_names
Definition: ERF.H:1642
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_minpressure_vs_time
Definition: ERF.H:291
bool metgrid_retain_sfc
Definition: ERF.H:1725
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Qv_prim
Definition: ERF.H:1261
static int sum_interval
Definition: ERF.H:1688
static int pert_interval
Definition: ERF.H:1689
amrex::Real line_sampling_per
Definition: ERF.H:2119
void restart()
Definition: ERF.cpp:2342
void ibseb_report(int nstep, amrex::Real time)
Definition: ERF_IBSEB.cpp:218
amrex::Vector< double > t_avg_cnt
Definition: ERF.H:1233
static int last_plot3d_file_step_2
Definition: ERF.H:1465
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx2_lev
Definition: ERF.H:1358
amrex::Vector< double > fixed_fast_dt
Definition: ERF.H:1517
amrex::IntVect & SampleLine(int i)
Definition: ERF.H:2013
void build_fine_mask(int lev, amrex::MultiFab &fine_mask)
Definition: ERF_VolWgtSum.cpp:144
void HurricaneMaxVelTracker(const amrex::Geometry &geom, const amrex::MultiFab &mf_cc_vel, const double &time)
Definition: ERF_HurricaneDiagnostics.cpp:673
amrex::Real station_sampling_per
Definition: ERF.H:2126
int file_name_digits
Definition: ERF.H:1698
amrex::Vector< amrex::MultiFab > rV_new
Definition: ERF.H:1268
std::string PlotFileName(int lev) const
void initialize_integrator(int lev, amrex::MultiFab &cons_mf, amrex::MultiFab &vel_mf)
Definition: ERF_MakeNewArrays.cpp:1282
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_zforce
Definition: ERF.H:1462
amrex::Vector< std::string > plot3d_var_names_2
Definition: ERF.H:1564
void sample_points(int lev, double time, amrex::IntVect cell, amrex::MultiFab &mf)
Definition: ERF_WriteScalarProfiles.cpp:537
void WeatherDataInterpolation(const int nlevs, const double time, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &z_phys_nd, bool regrid_forces_file_read)
Definition: ERF_WeatherDataInterpolation.cpp:374
amrex::Vector< amrex::BCRec > domain_bcs_type
Definition: ERF.H:1429
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Qr_prim
Definition: ERF.H:1262
void resolve_station_stencils()
Definition: ERF_StationSampler.cpp:968
void apply_gaussian_smoothing_to_perturbations(const int lev, amrex::MultiFab &mf_cc_pert)
Definition: ERF_InitForEnsemble.cpp:117
std::string pp_prefix
Definition: ERF.H:847
std::string SampleLineLogName(int i) const noexcept
The filename of the ith samplelinelog file.
Definition: ERF.H:2156
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > sst_lev
Definition: ERF.H:1346
amrex::Vector< amrex::TableData< amrex::Real, 1 > > t_plane_avg
Definition: ERF.H:1168
amrex::Vector< std::string > plot2d_var_names_1
Definition: ERF.H:1565
void init_phys_bcs(bool &read_prim_theta)
Definition: ERF_InitBCs.cpp:26
amrex::Vector< std::unique_ptr< amrex::MultiFab > > thin_xforce
Definition: ERF.H:1460
AMREX_FORCE_INLINE int NumSamplePoints() noexcept
Definition: ERF.H:2007
static bool grids_are_split_in_z(const amrex::BoxArray &ba)
Definition: ERF_MakeNewArrays.cpp:613
bool metgrid_use_sfc
Definition: ERF.H:1724
void sample_lines(int lev, double time, amrex::IntVect cell, amrex::MultiFab &mf)
Definition: ERF_WriteScalarProfiles.cpp:573
void ComputeAndWriteEnsemblePerturbations(const int da_iter)
void setPlotVariables2D(const std::string &pp_plot_var_names, amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile2D.cpp:113
void interp_psfc_from_coarse(int lev)
Definition: ERF.cpp:1921
void init_custom(int lev)
Definition: ERF_InitCustomPertState.cpp:26
amrex::Vector< std::unique_ptr< IRadiation > > rad
Definition: ERF.H:1304
std::unique_ptr< ProblemBase > prob
Definition: ERF.H:1191
amrex::Vector< int > num_files_at_level
Definition: ERF.H:1194
void ibseb_advance(int lev, amrex::Real time, amrex::Real dt_lev, const amrex::MultiFab &cons, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &zvel)
Definition: ERF_IBSEB.cpp:145
static double last_plot3d_file_time_2
Definition: ERF.H:1471
void init_bcs()
Definition: ERF_InitBCs.cpp:321
int profile_int
Definition: ERF.H:1553
erf_cloud_chamber::Config cloud_chamber_config
Definition: ERF.H:1278
bool metgrid_debug_quiescent
Definition: ERF.H:1716
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_u > > physbcs_u
Definition: ERF.H:1254
bool destag_profiles
Definition: ERF.H:1554
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > stretched_dz_d
Definition: ERF.H:1411
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > th_bc_data
Definition: ERF.H:1164
void FillPlot2DVars(int lev, const amrex::Vector< std::string > &plot_var_names, const amrex::Vector< std::string > &varnames, const amrex::Vector< plotfile2d::Plotfile2DOutputDescriptor > &output_descriptors, amrex::MultiFab &mf_dst, int ncomp_mf)
Definition: ERF_Plotfile2D.cpp:166
std::string DerDataLogName(int i) const noexcept
Definition: ERF.H:2150
void compute_max_pressure_gradient_diagnostic(int lev)
Definition: ERF_Diagnostics.cpp:14
void HurricaneEyeTracker(const SolverChoice &solverChoice)
Definition: ERF_HurricaneDiagnostics.cpp:640
void remake_zphys(int lev, amrex::Real time, std::unique_ptr< amrex::MultiFab > &temp_zphys_nd)
Definition: ERF_MakeNewArrays.cpp:1090
void project_momenta(int lev, double l_time, double l_dt, amrex::Vector< amrex::MultiFab > &vars)
Definition: ERF_PoissonSolve.cpp:148
int m_check_int
Definition: ERF.H:1558
void HurricaneEyeTrackerInitial(const SolverChoice &sc, const amrex::Geometry &geom, const amrex::Vector< amrex::MultiFab > &S_data, const amrex::Real &hurricane_eye_latitude, const amrex::Real &hurricane_eye_longitude)
Definition: ERF_HurricaneDiagnostics.cpp:229
void ReadVelsOnlyFromCheckpointFile(int lev_to_fill, std::string &chkfile)
Definition: ERF_Checkpoint.cpp:1731
amrex::Vector< std::unique_ptr< amrex::MultiFab > > terrain_blanking_zface
Definition: ERF.H:1399
void appendPlot3DVariables(const amrex::Vector< std::string > &plot_var_names, amrex::Vector< std::string > &a_plot_var_names)
Definition: ERF_Plotfile.cpp:219
std::unique_ptr< amrex::iMultiFab > m_coupled_sst_valid
Definition: ERF.H:960
static double last_plot3d_file_time_1
Definition: ERF.H:1470
double m_plot2d_per_2
Definition: ERF.H:1546
amrex::Vector< amrex::MultiFab > surface_state_1
Definition: ERF.H:297
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_diss_lev
Definition: ERF.H:1357
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_sinesq_ptrs
Definition: ERF.H:1827
amrex::Vector< amrex::MultiFab > rU_old
Definition: ERF.H:1265
bool HasRadiation() const
Definition: ERF.H:201
AMREX_FORCE_INLINE int NumSampleLines() noexcept
Definition: ERF.H:2020
amrex::Array< bool, AMREX_SPACEDIM *2 > m_bc_nonreflecting
Definition: ERF.H:1448
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Theta_prim
Definition: ERF.H:1260
static double getCPUTime()
Definition: ERF.H:2029
void write_1D_profiles(double time)
Definition: ERF_Write1DProfiles.cpp:21
void init1DArrays()
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_t_rk
Definition: ERF.H:1389
static int check_for_nans
Definition: ERF.H:1685
void make_subdomains(const amrex::BoxList &ba, amrex::Vector< amrex::BoxArray > &bins)
Group a list of boxes into subdomains based on adjacency.
Definition: ERF_MakeSubdomains.cpp:11
std::string MakeVTKFilename(int nstep)
Definition: ERF_TrackerOutput.cpp:14
void initRayleigh_at_level(const int &lev)
Initialize Rayleigh damping profiles at a level.
Definition: ERF_InitRayleigh.cpp:16
void appendPlotVariables(const std::string &pp_plot_var_names, amrex::Vector< std::string > &plot_var_names)
Definition: ERF_Plotfile.cpp:183
void read_box_for_refinement(std::string &ref_prefix, int &lev_for_box, amrex::RealBox &real_box)
Definition: ERF_RefineBox.cpp:13
amrex::Vector< int > rad_interp_from_coarse_pending
Definition: ERF.H:1214
int nvars_erfbdy
Definition: ERF.H:1734
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_v > > physbcs_v
Definition: ERF.H:1255
void SetDirsForPlotfilesAndCheckpointsForDA(const int da_iter, const int ens_no)
amrex::Vector< double > t_old
Definition: ERF.H:1218
amrex::Vector< std::string > tot_e_datalogname
Definition: ERF.H:2138
void FillIntermediatePatch(int lev, double 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)
Definition: ERF_FillIntermediatePatch.cpp:27
static int output_bndry_planes
Definition: ERF.H:1781
void project_velocity_tb(int lev, double dt, amrex::Vector< amrex::MultiFab > &vars)
Definition: ERF_PoissonSolve_tb.cpp:35
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_v_geos
Definition: ERF.H:1803
void update_terrain_arrays(int lev)
Definition: ERF_MakeNewArrays.cpp:1265
bool HasCloudWater() const
Definition: ERF.H:214
static std::string nc_bdy_file
Definition: ERF.H:1708
bool metgrid_interp_theta
Definition: ERF.H:1721
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
Definition: ERF.H:1704
static int input_bndry_planes
Definition: ERF.H:1787
static StateInterpType interpolation_type
Definition: ERF.H:1701
LargeScaleForcingData lsf
Definition: ERF.H:1300
amrex::Gpu::DeviceVector< amrex::Real > d_havg_qc
Definition: ERF.H:1840
amrex::Real cloud_fraction(double time)
Definition: ERF_WriteScalarProfiles.cpp:458
void AverageDown()
Definition: ERF_AverageDown.cpp:16
std::set< std::string > user_specified_inputs
Definition: ERF.H:855
amrex::Vector< amrex::Vector< amrex::Real > > h_v_geos
Definition: ERF.H:1802
bool regrid_level_0_on_restart
Definition: ERF.H:1526
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Lwave_onegrid
Definition: ERF.H:1420
void advance_microphysics(int lev, amrex::MultiFab &cons_in, const double &dt_advance, const int &iteration, const double &time)
Definition: ERF_AdvanceMicrophysics.cpp:5
InputSoundingData input_sounding_data
Definition: ERF.H:1155
void write_1D_profiles_stag(double time)
Definition: ERF_Write1DProfiles_stag.cpp:29
amrex::Vector< amrex::Vector< amrex::Real > > h_sinesq_ptrs
Definition: ERF.H:1819
void create_random_perturbations(const int lev, amrex::MultiFab &mf_cc_pert)
Definition: ERF_InitForEnsemble.cpp:33
void Write2DPlotFile(int which, PlotFileType plotfile_type, amrex::Vector< std::string > plot_var_names)
Definition: ERF_Plotfile2D.cpp:645
amrex::Gpu::DeviceVector< amrex::Real > d_havg_density
Definition: ERF.H:1836
amrex::Vector< std::unique_ptr< amrex::MultiFab > > rhotheta_src
Definition: ERF.H:1793
void init_from_hse(int lev)
Definition: ERF_InitFromHSE.cpp:32
const std::string datetime_format
Definition: ERF.H:1498
void define_column_kextent(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Definition: ERF_MakeNewArrays.cpp:637
amrex::Vector< amrex::YAFluxRegister * > advflux_reg
Definition: ERF.H:1424
void check_mesh_type(int lev)
Definition: ERF.cpp:3787
erf_provenance::ExecutionProvenance execution_provenance
Definition: ERF.H:1505
int metgrid_force_sfc_k
Definition: ERF.H:1728
void setSubVolVariables(const std::string &pp_subvol_var_names, amrex::Vector< std::string > &subvol_var_names)
Definition: ERF_WriteSubvolume.cpp:13
static int ng_pres_hse
Definition: ERF.H:1790
bool real_extrap_w
Definition: ERF.H:1710
static amrex::Real cfl
Definition: ERF.H:1508
void compute_max_buoyancy_gradp_diagnostic(int lev)
Definition: ERF_Diagnostics.cpp:307
amrex::Vector< std::unique_ptr< amrex::MultiFab > > fine_mask
Definition: ERF.H:1408
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
Definition: ERF.H:1430
amrex::Vector< double > t_mean_cnt
Definition: ERF.H:1237
amrex::Vector< std::unique_ptr< ForestDrag > > m_forest_drag
Definition: ERF.H:1847
const int datwidth
Definition: ERF.H:1482
amrex::Vector< amrex::BoxArray > ba1d
Definition: ERF.H:1736
InputSpongeData input_sponge_data
Definition: ERF.H:1158
amrex::Vector< amrex::Vector< amrex::BoxArray > > subdomains
Definition: ERF.H:1862
void check_state_for_nans(amrex::MultiFab const &S)
Definition: ERF.cpp:3620
std::string restart_chkfile
Definition: ERF.H:1501
bool metgrid_use_below_sfc
Definition: ERF.H:1723
amrex::Vector< std::string > sampleptlogname
Definition: ERF.H:2141
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > xvel_bc_data
Definition: ERF.H:1161
void InitData_pre()
Definition: ERF.cpp:625
amrex::IntVect & SamplePoint(int i)
Definition: ERF.H:2000
bool use_datetime
Definition: ERF.H:1497
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_track_xy
Definition: ERF.H:287
amrex::Vector< amrex::Vector< amrex::Real > > h_u_geos
Definition: ERF.H:1799
void InitializeLevelFromData(int lev, const amrex::MultiFab &initial_data)
std::string subvol_file
Definition: ERF.H:1533
int rad_datalog_int
Definition: ERF.H:1329
amrex::Vector< std::string > datalogname
Definition: ERF.H:2136
void initHSE()
Initialize HSE.
Definition: ERF_Init1D.cpp:208
void AverageDownTo(int crse_lev, int scomp, int ncomp, bool do_perturbational_and_momenta=true)
Definition: ERF_AverageDown.cpp:36
static amrex::Real column_loc_x
Definition: ERF.H:1776
static double dt_max
Definition: ERF.H:1513
amrex::Vector< amrex::MultiFab > surface_state_2
Definition: ERF.H:298
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ax
Definition: ERF.H:1375
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_nd
Definition: ERF.H:1371
void MakeDiagnosticAverage(amrex::Vector< amrex::Real > &h_havg, amrex::MultiFab &S, int n)
Definition: ERF.cpp:3498
amrex::Real metgrid_proximity
Definition: ERF.H:1726
amrex::Real volWgtSumMF(int lev, const amrex::MultiFab &mf, int comp, const amrex::MultiFab &dJ, const amrex::MultiFab &mfx, const amrex::MultiFab &mfy, bool finemask, bool local=true)
Definition: ERF_VolWgtSum.cpp:21
void setRecordDerDataInfo(int i, const std::string &filename)
Definition: ERF.H:2056
amrex::Vector< amrex::Real > h_havg_temperature
Definition: ERF.H:1831
amrex::Vector< std::unique_ptr< std::fstream > > sampleptlog
Definition: ERF.H:2140
void poisson_wall_dist(int lev)
Definition: ERF_PoissonWallDist.cpp:28
amrex::Vector< std::array< amrex::Real, 2 > > hurricane_eye_track_latlon
Definition: ERF.H:289
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc_src
Definition: ERF.H:1381
amrex::Gpu::DeviceVector< amrex::Real > d_havg_pressure
Definition: ERF.H:1838
static bool is_it_time_for_action(int nstep, double time, double dt, int action_interval, double action_per)
Definition: ERF_WriteScalarProfiles.cpp:663
std::string plot2d_file_1
Definition: ERF.H:1531
void Advance(int lev, double time, double dt_lev, int iteration, int ncycle)
Definition: ERF_Advance.cpp:21
void ResetIntervalMeans()
Definition: ERF.cpp:358
amrex::Vector< amrex::TableData< amrex::Real, 1 > > r_plane_avg
Definition: ERF.H:1167
amrex::Vector< std::string > der_datalogname
Definition: ERF.H:2137
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SmnSmn_lev
Definition: ERF.H:1343
const amrex::Vector< std::string > derived_names
Definition: ERF.H:1576
void sum_integrated_quantities(double time)
Definition: ERF_WriteScalarProfiles.cpp:19
std::string MakeVTKFilename_TrackerCircle(int nstep)
Definition: ERF_TrackerOutput.cpp:27
void ComputeGlobalMinLocation(const SolverChoice &sc, const amrex::Geometry &geom, const amrex::Vector< amrex::MultiFab > &S_data, amrex::Real *d_val_min_ptr, int *d_i_min_ptr, int *d_j_min_ptr, amrex::Real &global_val_min, int &global_i_min, int &global_j_min)
Definition: ERF_HurricaneDiagnostics.cpp:77
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ay_src
Definition: ERF.H:1383
std::unique_ptr< StationSampler > station_sampler
Definition: ERF.H:2127
void ComputeDt(int step=-1, double cur_time_d=0.0)
Definition: ERF_ComputeTimestep.cpp:17
AMREX_FORCE_INLINE std::ostream & DataLog(int i)
Definition: ERF.H:1944
std::string MakeVTKFilename_EyeTracker_xy(int nstep)
Definition: ERF_TrackerOutput.cpp:41
amrex::Vector< double > m_subvol_per
Definition: ERF.H:1541
amrex::Vector< int > nsubsteps
Definition: ERF.H:1198
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > yflux_imask
Definition: ERF.H:1455
amrex::Vector< amrex::MultiFab > rW_new
Definition: ERF.H:1270
amrex::Vector< amrex::MultiFab > weather_forecast_data_2
Definition: ERF.H:293
amrex::Vector< std::unique_ptr< amrex::MultiFab > > lon_m
Definition: ERF.H:1150
std::unique_ptr< WriteBndryPlanes > m_w2d
Definition: ERF.H:1844
AMREX_FORCE_INLINE std::ostream & SampleLineLog(int i)
Definition: ERF.H:1987
void HurricaneMinPressureTracker(MoistureType moisture_type, const amrex::Geometry &geom, const amrex::MultiFab &mf_cons_var, const double &time)
Definition: ERF_HurricaneDiagnostics.cpp:737
amrex::Vector< amrex::Vector< amrex::MultiFab * > > lsm_flux
Definition: ERF.H:1298
double EvolveOneStep(double time, double dt_request)
Definition: ERF_to_REMORA.cpp:221
bool use_erfbdy
Definition: ERF.H:1732
amrex::Vector< std::unique_ptr< SurfaceLayer > > m_SurfaceLayer
Definition: ERF.H:1846
amrex::Vector< std::string > plot3d_var_names_1
Definition: ERF.H:1563
std::string SamplePointLogName(int i) const noexcept
The filename of the ith sampleptlog file.
Definition: ERF.H:2153
void InitData_post()
Definition: ERF.cpp:657
void init_ibseb()
Definition: ERF_IBSEB.cpp:34
void refinement_criteria_setup()
Definition: ERF_Tagging.cpp:502
double estTimeStep(int lev, long &dt_fast_ratio) const
Definition: ERF_ComputeTimestep.cpp:66
static int nghost_eb_volume()
Definition: ERF.H:2183
bool metgrid_debug_dry
Definition: ERF.H:1718
static AMREX_FORCE_INLINE int ComputeGhostCells(const SolverChoice &sc)
Definition: ERF.H:1868
static int bndry_output_planes_interval
Definition: ERF.H:1782
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:21
void ERF_shared()
Definition: ERF_Constructors.cpp:49
amrex::Vector< std::string > plot2d_var_names_2
Definition: ERF.H:1566
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > Tau_corr
Definition: ERF.H:1341
void FillPatchCrseLevel(int lev, double time, const amrex::Vector< amrex::MultiFab * > &mfs_vel, bool cons_only=false)
Definition: ERF_FillPatch.cpp:303
void WriteSubvolume(int isub, amrex::Vector< std::string > subvol_var_names)
Definition: ERF_WriteSubvolume.cpp:113
void sum_energy_quantities(double time)
Definition: ERF_WriteScalarProfiles.cpp:318
static int nghost_eb_full()
Definition: ERF.H:2186
void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:700
static void GotoNextLine(std::istream &is)
Definition: ERF_Checkpoint.cpp:138
void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:26
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:25
amrex::Vector< amrex::MultiFab > zmom_crse_rhs
Definition: ERF.H:1274
void advance_radiation(int lev, amrex::MultiFab &cons_in, const double &dt_advance)
Advance radiation diagnostics and heating rates for one time step.
Definition: ERF_AdvanceRadiation.cpp:54
bool metgrid_debug_isothermal
Definition: ERF.H:1717
void PerformDataAssimilation(int da_iter)
amrex::Vector< std::string > lsm_data_name
Definition: ERF.H:1295
amrex::Vector< std::unique_ptr< amrex::MultiFab > > rhoqt_src
Definition: ERF.H:1794
void initSponge()
Initialize sponge profiles.
Definition: ERF_InitSponge.cpp:35
std::unique_ptr< PlaneSampler > plane_sampler
Definition: ERF.H:2122
void check_for_low_temp(amrex::MultiFab &S)
Definition: ERF.cpp:3714
amrex::Vector< std::unique_ptr< std::fstream > > der_datalog
Definition: ERF.H:2134
static amrex::Vector< amrex::Vector< int > > have_read_nc_init_file
Definition: ERF.H:1705
amrex::Vector< std::unique_ptr< std::fstream > > tot_e_datalog
Definition: ERF.H:2135
amrex::Vector< std::unique_ptr< amrex::MultiFab > > sinPhi_m
Definition: ERF.H:1152
amrex::Real ibseb_bulk_richardson_height(int lev, const amrex::MultiFab &cons, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel)
Definition: ERF_IBSEB.cpp:253
static double previousCPUTimeUsed
Definition: ERF.H:2026
void writeJobInfo(const std::string &dir, erf_provenance::ArtifactType artifact_type, int artifact_step, double artifact_time_seconds) const
Definition: ERF_WriteJobInfo.cpp:15
bool m_driver_has_atm2ocn_coupling
Definition: ERF.H:950
double m_plot3d_per_1
Definition: ERF.H:1543
int real_width
Definition: ERF.H:1709
void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Definition: ERF_MakeNewLevel.cpp:323
amrex::Vector< int > last_subvol_step
Definition: ERF.H:1476
void fill_from_bndryregs(const amrex::Vector< amrex::MultiFab * > &mfs, double time)
Definition: ERF_BoundaryConditionsBndryReg.cpp:13
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ax_src
Definition: ERF.H:1382
void derive_forcing_profiles_stag(amrex::Gpu::HostVector< amrex::Real > &h_avg_ttend, amrex::Gpu::HostVector< amrex::Real > &h_avg_qtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_wsub, amrex::Gpu::HostVector< amrex::Real > &h_avg_thtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_qhtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_tvtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_qvtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_qcvtend, amrex::Gpu::HostVector< amrex::Real > &h_avg_tnudge, amrex::Gpu::HostVector< amrex::Real > &h_avg_qnudge, amrex::Gpu::HostVector< amrex::Real > &h_avg_unudge, amrex::Gpu::HostVector< amrex::Real > &h_avg_vnudge)
Definition: ERF_Write1DProfiles_stag.cpp:803
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > urb_frac_lev
Definition: ERF.H:1353
amrex::Vector< std::unique_ptr< amrex::MultiFab > > z_phys_cc_src
Definition: ERF.H:1380
void input_sponge(int lev)
Definition: ERF_InitSponge.cpp:17
amrex::Vector< std::unique_ptr< amrex::MultiFab > > nudge_data
Definition: ERF.H:1301
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_u_geos
Definition: ERF.H:1800
bool m_driver_uses_two_way_coupling
Definition: ERF.H:951
void Define_ERFFillPatchers(int lev)
Definition: ERF.cpp:3573
AMREX_FORCE_INLINE int NumDataLogs() noexcept
Definition: ERF.H:1958
static PlotFileType plotfile3d_type_2
Definition: ERF.H:1694
void setRecordEnergyDataInfo(int i, const std::string &filename)
Definition: ERF.H:2069
TurbulentPerturbation turbPert
Definition: ERF.H:1649
amrex::Vector< amrex::MultiFab > rW_old
Definition: ERF.H:1269
amrex::Vector< double > fixed_dt
Definition: ERF.H:1516
void ResetIntervalMeansAfter3DPlotfileBatch(int plotfiles_written, bool interval_diagnostic_consumed)
Definition: ERF.cpp:344
amrex::Vector< amrex::Vector< amrex::MultiFab > > forecast_state_2
Definition: ERF.H:295
bool has_own_init_file(int lev) const
Definition: ERF.cpp:1833
void check_for_negative_theta(amrex::MultiFab &S)
Definition: ERF.cpp:3749
void ImposeBCsOnPhi(int lev, amrex::MultiFab &phi, const amrex::Box &subdomain)
Definition: ERF_ImposeBCsOnPhi.cpp:19
void Interp2DArrays(int lev, const amrex::BoxArray &my_ba2d, const amrex::DistributionMapping &my_dm)
Definition: ERF.cpp:2068
amrex::Vector< std::unique_ptr< amrex::MultiFab > > lsf_data
Definition: ERF.H:1302
void ClearLevel(int lev) override
Definition: ERF_MakeNewLevel.cpp:1179
std::string MakeFilename_EyeTracker_minpressure(int nstep)
Definition: ERF_TrackerOutput.cpp:83
std::unique_ptr< amrex::MultiFab > wrf_RDNW
Definition: ERF.H:1767
static double dt_max_initial
Definition: ERF.H:1512
static PlotFileType plotfile2d_type_2
Definition: ERF.H:1696
int plane_sampling_interval
Definition: ERF.H:2118
void compute_divergence(int lev, amrex::MultiFab &rhs, amrex::Array< amrex::MultiFab const *, AMREX_SPACEDIM > rho0_u_const, amrex::MultiFab const &mf_mx, amrex::MultiFab const &mf_my, amrex::MultiFab const &mf_vx, amrex::MultiFab const &mf_uy, amrex::MultiFab const &ax_in, amrex::MultiFab const &ay_in, amrex::MultiFab const &dJ_in, amrex::Geometry const &geom_at_lev)
Definition: ERF_ComputeDivergence.cpp:18
static amrex::Vector< amrex::AMRErrorTag > ref_tags
Definition: ERF.H:1852
void make_physbcs(int lev)
Definition: ERF_MakeNewArrays.cpp:1305
amrex::Vector< std::unique_ptr< amrex::MultiFab > > terrain_blanking_yface
Definition: ERF.H:1398
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > d_w_subsid
Definition: ERF.H:1797
amrex::Vector< ERFFillPatcher > FPr_w
Definition: ERF.H:1337
void resolve_station_positions()
Definition: ERF_StationSampler.cpp:806
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_hfx2_lev
Definition: ERF.H:1356
void WriteLinePlot(const std::string &filename, amrex::Vector< std::array< amrex::Real, 2 >> &points_xy)
Definition: ERF_Write1DProfiles.cpp:642
bool m_warned_coupled_sst_declined
Definition: ERF.H:963
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::iMultiFab > > > soil_type_lev
Definition: ERF.H:1352
void make_lsm_at_level(int lev, bool from_regrid[[maybe_unused]]=false)
Definition: ERF_MakeNewLevel.cpp:1278
amrex::Vector< amrex::Vector< amrex::Real > > zlevels_stag
Definition: ERF.H:1368
void FillPlot3DVars(int lev, const amrex::Vector< std::string > &plot_var_names, Plot3DScratch &scratch, amrex::MultiFab &mf_dst, int ncomp_mf, amrex::Real tnew)
Definition: ERF_Plotfile.cpp:497
AMREX_FORCE_INLINE int NumDerDataLogs() noexcept
Definition: ERF.H:1965
amrex::EBFArrayBoxFactory const & EBFactory(int lev) const noexcept
Definition: ERF.H:2173
amrex::Vector< amrex::Vector< amrex::MultiFab * > > lsm_data
Definition: ERF.H:1296
void init_immersed_forcing(int lev)
Definition: ERF_InitImmersedForcing.cpp:15
amrex::Vector< amrex::Vector< amrex::Real > > stretched_dz_h
Definition: ERF.H:1410
bool use_real_time_in_pltname
Definition: ERF.H:1699
int m_plot2d_int_1
Definition: ERF.H:1537
void WriteCheckpointFile() const
Definition: ERF_Checkpoint.cpp:148
amrex::Array< amrex::Array< erf_wall_scalar_bc::WallScalarBCIntent, AMREX_SPACEDIM *2 >, NBCVAR_max > m_wall_scalar_bc_intent
Definition: ERF.H:1445
static int output_1d_column
Definition: ERF.H:1773
void interp_land_masks_from_coarse(int lev)
Definition: ERF.cpp:1978
bool metgrid_debug_psfc
Definition: ERF.H:1719
void ReadStormTrackerRestart()
Definition: ERF_HurricaneDiagnostics.cpp:475
bool Write3DPlotFile(int which, PlotFileType plotfile_type, amrex::Vector< std::string > plot_var_names)
Definition: ERF_Plotfile.cpp:2068
amrex::Vector< std::unique_ptr< amrex::MultiFab > > az_src
Definition: ERF.H:1384
static int fixed_mri_dt_ratio
Definition: ERF.H:1518
static amrex::Real init_shrink
Definition: ERF.H:1510
void WriteVTKPolyline(const std::string &filename, amrex::Vector< std::array< amrex::Real, 2 >> &points_xy)
Definition: ERF_TrackerOutput.cpp:97
void HurricaneTrackerCircle()
Definition: ERF_HurricaneDiagnostics.cpp:194
static double last_check_file_time
Definition: ERF.H:1474
static std::string nc_low_file
Definition: ERF.H:1713
amrex::Vector< amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > > d_rayleigh_ptrs
Definition: ERF.H:1823
void InitData()
Definition: ERF.cpp:616
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Lwave
Definition: ERF.H:1418
amrex::Vector< std::unique_ptr< amrex::MultiFab > > cosPhi_m
Definition: ERF.H:1152
amrex::Vector< std::unique_ptr< amrex::MultiFab > > interval_means
Definition: ERF.H:1236
void ParameterSanityChecks()
Definition: ERF.cpp:3284
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::iMultiFab > > > land_type_lev
Definition: ERF.H:1351
static double start_time
Definition: ERF.H:1494
void init_zphys(int lev, double elapsed_time)
Definition: ERF_MakeNewArrays.cpp:884
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:543
amrex::Vector< amrex::Vector< amrex::MultiFab > > forecast_state_1
Definition: ERF.H:294
int cf_width
Definition: ERF.H:1332
static int last_plot2d_file_step_1
Definition: ERF.H:1466
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > zflux_imask
Definition: ERF.H:1456
bool m_expand_plotvars_to_unif_rr
Definition: ERF.H:1534
std::unique_ptr< CloudChamberBudget > cloud_chamber_budget
Definition: ERF.H:1277
void Construct_ERFFillPatchers(int lev)
Definition: ERF.cpp:3547
amrex::Vector< int > num_boxes_at_level
Definition: ERF.H:1193
void compute_native_shoc_tendencies(int lev, amrex::MultiFab *cons, amrex::MultiFab *xvel, amrex::MultiFab *yvel, amrex::MultiFab *zvel, amrex::Real *w_subsid, amrex::MultiFab *tau13, amrex::MultiFab *tau23, amrex::MultiFab *hfx3, amrex::MultiFab *qfx3, amrex::MultiFab *eddyDiffs, amrex::MultiFab *z_phys_nd, const double &dt_advance)
Definition: ERF_ShocCoupling.cpp:6
amrex::Vector< std::string > station_vars_2d
Definition: ERF.H:2131
void FillSurfaceStateMultiFabs(const int lev, const std::string &filename, amrex::Vector< amrex::MultiFab > &surface_state)
Definition: ERF_SurfaceDataInterpolation.cpp:26
static amrex::Real sub_cfl
Definition: ERF.H:1509
static void print_error(MPI_Comm, const std::string &msg)
Definition: ERF_ConsoleIO.cpp:46
static int ng_dens_hse
Definition: ERF.H:1789
std::unique_ptr< ReadBndryPlanes > m_r2d
Definition: ERF.H:1845
amrex::Vector< std::unique_ptr< amrex::MultiFab > > ay
Definition: ERF.H:1376
void interp_base_state_from_coarse(int lev)
Definition: ERF_Init1D.cpp:179
amrex::Vector< amrex::Vector< amrex::MultiFab * > > qmoist
Definition: ERF.H:1279
amrex::Vector< std::unique_ptr< amrex::MultiFab > > SFS_q1fx1_lev
Definition: ERF.H:1358
void GetLandMask(const amrex::iMultiFab *&lmask) const
Definition: ERF_to_REMORA.cpp:290
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > zvel_bc_data
Definition: ERF.H:1163
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:684
LandSurface lsm
Definition: ERF.H:1294
static amrex::Real change_max
Definition: ERF.H:1511
void setRecordSampleLineInfo(int i, int lev, amrex::IntVect &cell, const std::string &filename)
Definition: ERF.H:2099
void ApplyOceanSurfaceState(const amrex::Vector< amrex::MultiFab * > &state, double time, const amrex::iMultiFab *erf_coverage=nullptr)
Definition: ERF_to_REMORA.cpp:830
void setSpongeRefFromSounding(bool restarting)
Set sponge mean profiles from input sounding.
Definition: ERF_InitSponge.cpp:65
amrex::Vector< amrex::MultiFab > avg_ymom
Definition: ERF.H:1249
int line_sampling_interval
Definition: ERF.H:2117
amrex::Vector< amrex::Vector< amrex::Real > > h_sinesq_stag_ptrs
Definition: ERF.H:1820
amrex::Vector< std::unique_ptr< amrex::MultiFab > > detJ_cc_new
Definition: ERF.H:1387
static amrex::Vector< std::string > ref_tag_indicator_names
Definition: ERF.H:1860
void project_initial_velocity(int lev, double time, double dt)
Definition: ERF_PoissonSolve.cpp:72
void interp_mapfac_from_coarse(int lev)
Definition: ERF.cpp:1856
amrex::Array< std::string, 2 *AMREX_SPACEDIM > domain_bc_type
Definition: ERF.H:1433
amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real > > yvel_bc_data
Definition: ERF.H:1162
static void writeBuildInfo(std::ostream &os)
Definition: ERF_WriteJobInfo.cpp:178
amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > phys_bc_type
Definition: ERF.H:1451
std::string check_file
Definition: ERF.H:1557
amrex::Vector< amrex::IntVect > samplepoint
Definition: ERF.H:2142
amrex::Vector< amrex::MultiFab > surface_state_interp
Definition: ERF.H:299
amrex::Vector< amrex::Real > h_havg_qv
Definition: ERF.H:1833
amrex::Vector< std::unique_ptr< IBFaceSet > > m_ibseb
Definition: ERF.H:1393
amrex::Vector< amrex::MultiFab > weather_forecast_data_1
Definition: ERF.H:293
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::MultiFab &buoyancy, amrex::Geometry fine_geom, double dt, double time)
Definition: ERF_AdvanceDycore.cpp:40
static void print_usage(MPI_Comm, std::ostream &)
Definition: ERF_ConsoleIO.cpp:29
amrex::Vector< amrex::MultiFab > rV_old
Definition: ERF.H:1267
amrex::Vector< std::unique_ptr< amrex::MultiFab > > lat_m
Definition: ERF.H:1150
void timeStep(int lev, double time, int iteration)
Definition: ERF_TimeStep.cpp:19
amrex::Vector< amrex::Vector< amrex::Vector< amrex::Real > > > h_rayleigh_ptrs
Definition: ERF.H:1815
void make_eb_regular()
static int last_plot3d_file_step_1
Definition: ERF.H:1464
void FillPatchFineLevel(int lev, double 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)
Definition: ERF_FillPatch.cpp:25
std::unique_ptr< LineSampler > line_sampler
Definition: ERF.H:2121
amrex::Vector< std::unique_ptr< amrex::MultiFab > > Hwave
Definition: ERF.H:1417
amrex::Vector< amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > > Tau_EB
Definition: ERF.H:1363
amrex::Vector< int > istep
Definition: ERF.H:1197
const int datprecision
Definition: ERF.H:1483
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > xflux_imask
Definition: ERF.H:1454
void derive_upwp(amrex::Vector< amrex::Real > &h_havg)
static PlotFileType plotfile2d_type_1
Definition: ERF.H:1695
int metgrid_order
Definition: ERF.H:1727
bool finished_wave
Definition: ERF.H:1421
void ReadCheckpointFile()
Definition: ERF_Checkpoint.cpp:823
amrex::Vector< amrex::Vector< amrex::MultiFab > > vars_old
Definition: ERF.H:1226
void WriteAtFinalTime()
Definition: ERF.cpp:296
amrex::Vector< std::unique_ptr< ERFPhysBCFunct_base > > physbcs_base
Definition: ERF.H:1257
void init_thin_body(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Definition: ERF_MakeNewLevel.cpp:1335
static PlotFileType plotfile3d_type_1
Definition: ERF.H:1693
amrex::Vector< int > m_subvol_int
Definition: ERF.H:1540
AMREX_FORCE_INLINE std::ostream & SamplePointLog(int i)
Definition: ERF.H:1973
std::string MakeFilename_EyeTracker_latlon(int nstep)
Definition: ERF_TrackerOutput.cpp:55
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, double 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:2419
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF.H:1439
bool m_driver_atm2ocn_uses_state_contract
Definition: ERF.H:952
bool m_plot_face_terrain_blanking
Definition: ERF.H:1548
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > tsk_lev
Definition: ERF.H:1347
void setRecordSamplePointInfo(int i, int lev, amrex::IntVect &cell, const std::string &filename)
Definition: ERF.H:2082
std::unique_ptr< amrex::MultiFab > m_coupled_sst
Definition: ERF.H:959
bool has_surface_layer_inputs(const std::string &prefix) const
Definition: ERF.cpp:3828
static int column_interval
Definition: ERF.H:1774
static void print_summary(std::ostream &)
int m_plot3d_int_2
Definition: ERF.H:1536
amrex::Vector< std::unique_ptr< amrex::MultiFab > > qheating_rates
Definition: ERF.H:1305
void fill_terrain_surface(int lev, amrex::MultiFab &z_phys, double elapsed_time)
Definition: ERF_MakeNewArrays.cpp:852
void turbPert_amplitude(const int lev)
Definition: ERF_InitTurbPert.cpp:42
amrex::Vector< std::unique_ptr< amrex::MultiFab > > rad_fluxes
Definition: ERF.H:1311
void initializeMicrophysics(const int &)
Definition: ERF.cpp:2308
static double bndry_output_planes_start_time
Definition: ERF.H:1784
std::unique_ptr< amrex::MultiFab > wrf_C2H
Definition: ERF.H:1765
bool plot_lsm
Definition: ERF.H:1550
amrex::Vector< amrex::MultiFab > avg_zmom
Definition: ERF.H:1250
const amrex::Vector< std::string > cons_names
Definition: ERF.H:1567
void ReadCheckpointFileSurfaceLayer()
Definition: ERF_Checkpoint.cpp:1771
void GetOceanToAtmosCellCenterLonLat(const amrex::MultiFab *&lon_cc, const amrex::MultiFab *&lat_cc) const
Definition: ERF_to_REMORA.cpp:276
double m_plot2d_per_1
Definition: ERF.H:1545
Wrapper class for managing land surface models across AMR levels.
Definition: ERF_LandSurface.H:19
The two-stream radiation model (erf.radiation_model = TwoStream).
Definition: ERF_TwoStreamRadiation.H:42
Owns and exposes cell-centered and face-centered EB factories.
Definition: ERF_EB.H:24
Definition: ERF_InterpolationUtils.H:15
@ pres
Definition: ERF_Kessler.H:28
@ qv
Definition: ERF_Kessler.H:31
@ T
Definition: ERF_IndexDefines.H:128
constexpr int S
Definition: ERF_TwoStreamColumn.H:604
@ xvel
Definition: ERF_IndexDefines.H:215
@ cons
Definition: ERF_IndexDefines.H:214
@ zvel
Definition: ERF_IndexDefines.H:217
@ yvel
Definition: ERF_IndexDefines.H:216
@ p
Definition: ERF_WSM6.H:280
Definition: ERF_ConsoleIO.cpp:15
ArtifactType
Definition: ERF_Provenance.H:37
real(c_double), parameter, private pi
Definition: ERF_module_mp_morr_two_moment.F90:100
integer, private isub
Definition: ERF_module_mp_morr_two_moment.F90:164
real(kind=kind_phys), parameter, private dens
Definition: ERF_module_mp_wdm6.F90:61
Definition: ERF.H:107
AdvType dycore_vert_adv_type
Vertical advection scheme for dynamical-core variables.
Definition: ERF_AdvStruct.H:442
AdvType moistscal_vert_adv_type
Vertical advection scheme for moist scalar variables.
Definition: ERF_AdvStruct.H:446
AdvType dryscal_horiz_adv_type
Horizontal advection scheme for dry scalar variables.
Definition: ERF_AdvStruct.H:443
AdvType dycore_horiz_adv_type
Horizontal advection scheme for dynamical-core variables.
Definition: ERF_AdvStruct.H:441
AdvType moistscal_horiz_adv_type
Horizontal advection scheme for moist scalar variables.
Definition: ERF_AdvStruct.H:445
AdvType dryscal_vert_adv_type
Vertical advection scheme for dry scalar variables.
Definition: ERF_AdvStruct.H:444
Definition: ERF_BaseStateParams.H:35
Definition: ERF.H:695
amrex::Vector< amrex::MultiFab > mf_cc_vel
Definition: ERF.H:696
amrex::Vector< amrex::MultiFab > mf_cc_fx
Definition: ERF.H:698
amrex::Vector< amrex::MultiFab > mf_cc_tau
Definition: ERF.H:697
Definition: ERF_IBSEBParams.H:25
Definition: ERF_InputSoundingData.H:23
Definition: ERF_InputSpongeData.H:19
Definition: ERF_LargeScaleForcingData.H:31
int qi
cloud ice
Definition: ERF_DataStruct.H:236
int qc
cloud liquid water
Definition: ERF_DataStruct.H:235
Definition: ERF_DataStruct.H:662
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:2237
AdvChoice advChoice
Advection-related options.
Definition: ERF_DataStruct.H:1970
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:1949
MoistureComponentIndices moisture_indices
Index map of the moisture data carried by the active scheme: conserved-state components for the speci...
Definition: ERF_DataStruct.H:2263
bool use_num_diff
Whether sixth-order numerical diffusion is enabled.
Definition: ERF_DataStruct.H:2233
Runtime state and operations for turbulent perturbation forcing.
Definition: ERF_TurbPertStruct.H:26
Configuration parameters for cloud chamber initialization.
Definition: ERF_CloudChamber.H:40
Definition: ERF_Provenance.H:66
Definition: ERF_Plotfile2DSampledLevel.H:56