ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Utils.H
Go to the documentation of this file.
1 #ifndef ERF_UTILS_H_
2 #define ERF_UTILS_H_
3 
4 #include <utility>
5 
6 #include "AMReX.H"
7 #include "AMReX_MultiFab.H"
8 #include "AMReX_BCRec.H"
11 #include "ERF_DataStruct.H"
12 #include "ERF_IndexDefines.H"
13 #include "ERF_SurfaceLayer.H"
14 #include "ERF_FillPatcher.H"
15 #include "ERF_ImmersedWallCell.H"
16 #include "ERF_ReadBndryPlanes.H"
17 
18 /**
19  * The real-boundary maps of the conserved state, one entry per conserved
20  * component up to NVAR_max: whether the component is read from the WRF/metgrid
21  * boundary data (read), from which boundary field (map), and from which
22  * boundary-plane slot when planes are read as well (bnd, cons_bc_comp).
23  * Density is read with erf.use_wrf_bdy_density, theta and the water vapor
24  * always; passive scalars and hydrometeors never.
25  * Built from the component layout, so every passive scalar (NSCALARS of them)
26  * sits between RhoKE_comp and RhoQ1_comp.
27  */
29 {
30  amrex::Vector<int> read;
31  amrex::Vector<int> map;
32  amrex::Vector<int> bnd;
33 };
34 
35 inline RealBdyConsMaps
36 real_bdy_cons_maps (const bool read_density)
37 {
39  m.read.assign(NVAR_max, 0);
40  m.map.resize(NVAR_max);
41  m.bnd.resize(NVAR_max);
42  for (int comp = 0; comp < NVAR_max; ++comp) {
43  m.map[comp] = comp;
44  m.bnd[comp] = cons_bc_comp(comp);
45  }
46  m.read[Rho_comp] = read_density ? 1 : 0;
47  m.map [Rho_comp] = read_density ? RealBdyVars::R : Rho_comp;
48  m.read[RhoTheta_comp] = 1;
50  m.read[RhoQ1_comp] = 1;
52  return m;
53 }
54 
55 /*
56  * Rebalance state to satisfy both EOS and HSE one column at a time
57  */
58 void
59 rebalance_columns (amrex::MultiFab& rho,
60  amrex::MultiFab& theta,
61  const amrex::MultiFab& qt,
62  const amrex::MultiFab& qv,
63  const amrex::MultiFab* z_phys,
64  const amrex::Geometry& geom,
65  const bool& maintain_Th,
66  bool use_sfc = false);
67 
68 /*
69  * Re-compute p_0 and pi_0 of a base state from rho_0, theta_0 and qv_0 over the valid region
70  */
71 void
72 recompute_p_pi_hse (amrex::MultiFab& base_state_mf, amrex::Real l_rdOcp);
73 
74 /*
75  * Create a new BoxArray in which every grid touches the bottom boundary
76  */
77 void ChopGrids2D (amrex::BoxArray& ba, const amrex::Box& domain, int target_size);
78 
79 /*
80  * Create a new BoxArray with exactly the number of boxes as MPI ranks.
81  * This is designed to work only on the base level which covers the entire domain.
82  */
83 amrex::BoxArray
84 ERFPostProcessBaseGrids (const amrex::Box& domain, bool decompose_in_z);
85 
86 /**
87  * Convert conservative state to primitive variables.
88  * @param[in] cons_state Conservative state MultiFab.
89  * @param[out] S_prim Primitive state MultiFab.
90  * @param[in] ng Number of ghost cells.
91  */
92 void
93 cons_to_prim (const amrex::MultiFab& cons_state, amrex::MultiFab& S_prim, int ng);
94 
95 /**
96  * Fill the ghost cells of the wall distance field, which is only computed on
97  * the valid region, so that operators reading from grown boxes do not see the
98  * sentinel value used to initialize it.
99  * @param[inout] wdist MultiFab holding the wall distance.
100  * @param[in] geom Geometry at this level.
101  */
102 void
103 fill_wall_dist_ghost_cells (amrex::MultiFab& wdist, const amrex::Geometry& geom);
104 
105 /**
106  * Compute total water mixing ratio from conservative state.
107  * @param[in] cons_state Conservative state MultiFab.
108  * @param[out] qt MultiFab to store total water.
109  * @param[in] n_qstate_into_total Number of components to include in total water.
110  */
111 void
112 make_qt (const amrex::MultiFab& cons_state, amrex::MultiFab& qt, int n_qstate_into_total);
113 
114 /**
115  * Average the face momenta of a fine level down onto the coarse faces it covers, as mass
116  * fluxes: (rho u) ax/m_y, (rho v) ay/m_x or (rho w)/(m_x m_y) is averaged and divided by the
117  * same weight on the coarse face. With map factors other than one, or face areas other than
118  * one over terrain, the plain average of (rho u) is not the coarse momentum whose flux is the
119  * mean of the fine fluxes. The horizontal weights are those of ERF::average_down_mass_flux.
120  * Faces the fine level does not cover are left as they are.
121  * @param[in] fine Fine face momenta.
122  * @param[in,out] crse Coarse face momenta.
123  * @param[in] rr Refinement ratio.
124  * @param[in] cper Periodicity of the coarse level.
125  * @param[in] mf_f Map factor of the fine faces (no extent in z).
126  * @param[in] mf_c Map factor of the coarse faces (no extent in z).
127  * @param[in] mf2_f Second map factor of the fine faces (the product m_x m_y on w-faces), or null.
128  * @param[in] mf2_c Second map factor of the coarse faces, or null.
129  * @param[in] area_f Area of the fine faces, or null for an area of one.
130  * @param[in] area_c Area of the coarse faces, or null for an area of one.
131  */
132 void
133 average_down_faces_mapfac (const amrex::MultiFab& fine, amrex::MultiFab& crse, const amrex::IntVect& rr,
134  const amrex::Periodicity& cper,
135  const amrex::MultiFab& mf_f, const amrex::MultiFab& mf_c,
136  const amrex::MultiFab* mf2_f, const amrex::MultiFab* mf2_c,
137  const amrex::MultiFab* area_f, const amrex::MultiFab* area_c);
138 
139 /**
140  * Average down a cell-centered state over immersed-forcing levels (erf.if_average_down =
141  * fluid_mass). The fine cells are weighted by their fluid mass,
142  * (rho S)_c = rho_c * sum (1 - beta_f) V_f (rho S)_f / sum (1 - beta_f) V_f rho_f,
143  * with beta the solid fraction, V the fine cell volume (detJ / (m_x m_y), the weight the plain
144  * average carries in the state) and rho_c the coarse density: the fluid-volume-weighted mean of
145  * the fine density, sum (1 - beta_f) V_f rho_f / sum (1 - beta_f) V_f, when the density is in the
146  * component range, else the coarse cell's own. The coarse value is the fluid mean over the whole
147  * coarse cell (intensive), not the sum over the fine cells. Coarse cells that are solid on their
148  * own level, or with no fluid fine cell under them, keep their value. The plain average mixes the
149  * values of solid fine cells into coarse fluid cells.
150  * @param[in] S_fine Fine state (unscaled).
151  * @param[in,out] S_crse Coarse state (unscaled); the covered cells are written.
152  * @param[in] beta_fine Fine solid fraction (terrain_blanking).
153  * @param[in] beta_crse Coarse solid fraction.
154  * @param[in] vol_fine Fine cell volume weight (any constant factor cancels).
155  * @param[in] scomp First component to average.
156  * @param[in] ncomp Number of components.
157  * @param[in] ratio Refinement ratio.
158  */
159 void
160 if_average_down (const amrex::MultiFab& S_fine, amrex::MultiFab& S_crse,
161  const amrex::MultiFab& beta_fine, const amrex::MultiFab& beta_crse,
162  const amrex::MultiFab& vol_fine,
163  int scomp, int ncomp, const amrex::IntVect& ratio);
164 
165 /**
166  * RANS wall distance over terrain represented by immersed forcing with the fraction-stress wall
167  * law (erf.if_wall_form = fraction_stress): measured vertically from the surface itself,
168  * h = z_bot + beta dz of the wall cell (the partial cell, or the fluid cell on a solid cell;
169  * ERF_ImmersedWallCell.H), the wall cell at its fluid centroid (1 - beta) dz / 2 above it and
170  * every other cell at |z_cc - h|; a column without solid measures from the bottom of the domain.
171  * A box that does not see the surface of a column (a fine box inside the solid, or above the
172  * surface without reaching the bottom) measures from the coarser level's wall height.
173  * @param[out] wdist Wall distance (valid cells; ghost cells are left untouched).
174  * @param[in] terrain_blank Cell-centered solid fraction.
175  * @param[in] z_phys_nd Node heights.
176  * @param[in] z_phys_cc Cell-center heights.
177  * @param[in] domain Index domain of the level.
178  * @param[in] small_volfrac Solid fraction below which a cell counts as fluid.
179  * @param[out] wall_height Optional: the height measured from in each column, on the level's
180  * BoxArray flattened to the bottom cell (same DistributionMapping).
181  * @param[in] wall_height_crse Optional, fine levels: wall_height of the coarser level brought to
182  * this level's flattened BoxArray. Without it every box must hold whole columns.
183  */
184 void
185 immersed_wall_dist (amrex::MultiFab& wdist,
186  const amrex::MultiFab& terrain_blank,
187  const amrex::MultiFab& z_phys_nd,
188  const amrex::MultiFab& z_phys_cc,
189  const amrex::Box& domain,
190  amrex::Real small_volfrac,
191  amrex::MultiFab* wall_height = nullptr,
192  const amrex::MultiFab* wall_height_crse = nullptr);
193 
194 /**
195  * Wall-face masks of the fraction-stress wall law (erf.if_wall_form = fraction_stress):
196  * zero on the xz (yz) edge that is the bottom face of the wall cell of an x-face (y-face)
197  * column, the spacing factor on the face above it, one elsewhere. The vertical flux of x (y)
198  * momentum is multiplied by them, so no resolved flux crosses the wall face (see
199  * ERF_ImmersedWallCell.H).
200  * @param[in] terrain_blank Cell-centered solid fraction; needs one more ghost cell than the masks.
201  * @param[out] mask13 On convert(ba, IntVect(1,0,1)), valid and ghost cells.
202  * @param[out] mask23 On convert(ba, IntVect(0,1,1)), valid and ghost cells.
203  * @param[out] mask33 On convert(ba, IntVect(0,0,1)): the same for the cell columns, applied to
204  * the vertical diffusive fluxes of theta and TKE (zero on the bottom face of the wall cell).
205  * @param[in] domain Index domain of the level.
206  * @param[in] small_volfrac Solid fraction below which a cell counts as fluid.
207  * @param[in] spacing erf.if_wall_face_spacing (0 grid, 1 physical, 2 log): the face ABOVE the wall
208  * cell gets ib_wall::face_above_factor instead of one.
209  * @param[in] dz Cell height (constant-dz mesh).
210  * @param[in] z0 Roughness length of the wall law.
211  */
212 void
213 make_ib_wall_face_masks (const amrex::MultiFab& terrain_blank,
214  amrex::MultiFab& mask13,
215  amrex::MultiFab& mask23,
216  amrex::MultiFab& mask33,
217  const amrex::Box& domain,
218  amrex::Real small_volfrac,
219  int spacing = 0,
220  amrex::Real dz = amrex::Real(1.0),
221  amrex::Real z0 = amrex::Real(0.1));
222 
223 /**
224  * Where the coarse and fine levels disagree on an immersed surface along the lateral coarse/fine
225  * faces of the fine level (erf.if_cf_mismatch_warning): the surface on a coarse cell's mid-plane
226  * leaves the coarse cell half solid over fine cells that are all solid and all fluid. For each
227  * coarse cell covered by the fine level and next to an uncovered one, the spread (max - min) of
228  * the fine solid fractions under it is formed; cells with a spread of at least warn are counted.
229  *
230  * @param[in] fine_tb fine solid fraction (terrain_blanking)
231  * @param[in] fine_grids fine BoxArray
232  * @param[in] crse_grids coarse BoxArray
233  * @param[in] crse_dmap coarse DistributionMapping
234  * @param[in] crse_geom coarse Geometry
235  * @param[in] ratio refinement ratio
236  * @param[in] warn spread at or above which a cell is counted
237  * @return the number of counted cells over all ranks, and the largest spread along those faces
238  */
239 std::pair<int, amrex::Real>
240 if_cf_surface_mismatch (const amrex::MultiFab& fine_tb,
241  const amrex::BoxArray& fine_grids,
242  const amrex::BoxArray& crse_grids,
243  const amrex::DistributionMapping& crse_dmap,
244  const amrex::Geometry& crse_geom,
245  const amrex::IntVect& ratio,
246  amrex::Real warn);
247 
248 
249 /*
250  * Create the Jacobian for the metric transformation when use_terrain is true
251  */
252 void make_J (const amrex::Geometry& geom,
253  amrex::MultiFab& z_phys_nd,
254  amrex::MultiFab& detJ_cc);
255 
256 void make_areas (const amrex::Geometry& geom,
257  amrex::MultiFab& z_phys_nd,
258  amrex::MultiFab& ax,
259  amrex::MultiFab& ay,
260  amrex::MultiFab& az);
261 
262 /*
263  * Average z_phys_nd on nodes to cell centers
264  */
265 void make_zcc (const amrex::Geometry& geom,
266  amrex::MultiFab& z_phys_nd,
267  amrex::MultiFab& z_phys_cc);
268 
269 /*
270  * Height of the bottom of the domain at each node of the 2D projection of z_phys_nd's
271  * grids; a box that does not reach the bottom interpolates it from z_sfc_crse, the
272  * coarser level's, which must then be given
273  */
274 void make_zsfc_nd (const amrex::Geometry& geom,
275  const amrex::MultiFab& z_phys_nd,
276  amrex::MultiFab& z_sfc_nd,
277  const amrex::MultiFab* z_sfc_crse = nullptr,
278  const amrex::IntVect& ref_ratio = amrex::IntVect(1));
279 
280 /*
281  * Convert momentum to velocity by dividing by density averaged onto faces
282  */
283 void MomentumToVelocity (amrex::MultiFab& xvel_out,
284  amrex::MultiFab& yvel_out,
285  amrex::MultiFab& zvel_out,
286  const amrex::MultiFab& cons_in,
287  const amrex::MultiFab& xmom_in,
288  const amrex::MultiFab& ymom_in,
289  const amrex::MultiFab& zmom_in,
290  const amrex::Box& domain,
291  const amrex::Vector<amrex::BCRec>& domain_bcs_type_h,
292  const amrex::MultiFab* c_vfrac = nullptr // optional
293  );
294 
295 /*
296  * Convert velocity to momentum by multiplying by density averaged onto faces
297  */
298 void VelocityToMomentum (const amrex::MultiFab& xvel_in,
299  const amrex::IntVect & xvel_ngrow,
300  const amrex::MultiFab& yvel_in,
301  const amrex::IntVect & yvel_ngrow,
302  const amrex::MultiFab& zvel_in,
303  const amrex::IntVect & zvel_ngrow,
304  const amrex::MultiFab& cons_in,
305  amrex::MultiFab& xmom_out,
306  amrex::MultiFab& ymom_out,
307  amrex::MultiFab& zmom_out,
308  const amrex::Box& domain,
309  const amrex::Vector<amrex::BCRec>& domain_bcs_type_h,
310  const amrex::MultiFab* c_vfrac = nullptr // optional
311  );
312 
313 /*
314  * Convert (den_div u) to (den_mlt u) by multiplying by (den_mlt/den_div)
315  */
316 void
317 ConvertForProjection (const amrex::MultiFab& den_div, const amrex::MultiFab& den_mlt,
318  amrex::MultiFab& xmom, amrex::MultiFab& ymom, amrex::MultiFab& zmom,
319  const amrex::Box& domain, const amrex::Vector<amrex::BCRec>& domain_bcs_type_h);
320 
321 /*
322  * Face weights beta = den_mlt/den_div with which ConvertForProjection converts the momenta
323  */
324 void
325 MakeProjectionWeights (const amrex::MultiFab& den_div, const amrex::MultiFab& den_mlt,
326  const amrex::MultiFab& xmom, const amrex::MultiFab& ymom, const amrex::MultiFab& zmom,
327  amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& beta,
328  const amrex::Box& domain, const amrex::Vector<amrex::BCRec>& domain_bcs_type_h);
329 
330 /*
331  * Face weights beta = den_mlt/den_div mapped onto faces with the advection scheme's reconstruction
332  */
333 void
334 MakeAdvectiveProjectionWeights (const amrex::MultiFab& den_div, const amrex::MultiFab& den_mlt,
335  const amrex::MultiFab& xmom, const amrex::MultiFab& ymom, const amrex::MultiFab& zmom,
336  amrex::Array<amrex::MultiFab,AMREX_SPACEDIM>& beta,
337  const AdvType horiz_adv_type, const AdvType vert_adv_type,
338  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
339  const amrex::Periodicity& period);
340 
341 /*
342  * Compute lateral boundary mass influx/outflux from base-state-density-weighted
343  * boundary normal velocities. mask_x/mask_y are owner masks of area_vec[0]/[1]
344  * (amrex::OwnerMask), so a face shared by two boxes is counted once.
345  */
346 void
347 compute_influx_outflux_bdy (amrex::FArrayBox& bdy_data_xlo, amrex::FArrayBox& bdy_data_xhi,
348  amrex::FArrayBox& bdy_data_ylo, amrex::FArrayBox& bdy_data_yhi,
349  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& area_vec,
350  const amrex::iMultiFab& mask_x, const amrex::iMultiFab& mask_y,
351  const amrex::Geometry& geom,
352  amrex::Real& influx, amrex::Real& outflux,
353  const int n);
354 
355 /*
356  * \brief Enforces solvability on lateral boundary data by scaling outflow to
357  * match with inflow.
358  */
359 void enforceInOutSolvability_bdy (const amrex::MultiFab& rho0,
360  amrex::FArrayBox& bdy_data_xlo,
361  amrex::FArrayBox& bdy_data_xhi,
362  amrex::FArrayBox& bdy_data_ylo,
363  amrex::FArrayBox& bdy_data_yhi,
364  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& area_vec,
365  const amrex::Geometry& geom,
366  const amrex::Vector<amrex::BCRec>& domain_bcs_type_h);
367 
368 /*
369  * \brief Enforces solvability by scaling outflow to match with inflow.
370  *
371  */
373  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& vels_vec,
374  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& area_vec,
375  const amrex::Geometry& geom);
376 
377 /*
378  * Compute boxes for looping over interior/exterior ghost cells
379  * for use by fillpatch, erf_slow_rhs_pre, and erf_slow_rhs_post
380  */
381 void realbdy_interior_bxs_xy (const amrex::Box& bx,
382  const amrex::Box& domain,
383  const int& width,
384  amrex::Box& bx_xlo,
385  amrex::Box& bx_xhi,
386  amrex::Box& bx_ylo,
387  amrex::Box& bx_yhi,
388  const amrex::IntVect& ng_vect=amrex::IntVect(0,0,0),
389  const bool get_int_ng=false);
390 
391 /*
392  * Compute boxes for looping over set region cells
393  * for use by fillpatch, erf_slow_rhs_pre, and erf_slow_rhs_post
394  */
395 void realbdy_bc_bxs_xy (const amrex::Box& bx,
396  const amrex::Box& domain,
397  const int& set_width,
398  amrex::Box& bx_xlo,
399  amrex::Box& bx_xhi,
400  amrex::Box& bx_ylo,
401  amrex::Box& bx_yhi,
402  const amrex::IntVect& ng_vect=amrex::IntVect(0,0,0));
403 
404 /*
405  * The two boundary-data slices that bracket a time, and the weight of the later one
406  */
408  int n_lo; // slice at or before the time
409  int n_hi; // slice after it (n_lo once the data has run out)
410  amrex::Real alpha; // weight of slice n_hi; slice n_lo gets (1 - alpha)
411 };
412 
413 /**
414  * Time interpolation weights for boundary data at fixed intervals.
415  *
416  * The time must be measured from the first slice, and formed as
417  * elapsed + (start_time - start_bdy_time), not as (elapsed + start_time) - start_bdy_time:
418  * start_time and start_bdy_time are epoch seconds (~1.7e9), where doubles are spaced
419  * ~2.4e-7 s apart, so the second form rounds the elapsed time to that spacing. The
420  * difference of the two epoch times is exact.
421  *
422  * @param[in] time_since_start time since the first slice
423  * @param[in] data_span time from the first slice to the last one
424  * @param[in] dT interval between slices
425  */
426 AMREX_FORCE_INLINE
428 bdy_time_weights (const double time_since_start, const double data_span, const double dT)
429 {
430  BdyTimeWeights w;
431  if (time_since_start >= data_span) {
432  // Do not over run the last slice
433  w.n_lo = static_cast<int>(data_span / dT);
434  w.n_hi = w.n_lo;
435  w.alpha = zero;
436  } else {
437  w.n_lo = static_cast<int>(time_since_start / dT);
438  w.n_hi = w.n_lo + 1;
439  w.alpha = static_cast<amrex::Real>((time_since_start - w.n_lo * dT) / dT);
440  }
441  AMREX_ALWAYS_ASSERT(w.alpha >= zero && w.alpha <= one);
442  return w;
443 }
444 
445 /*
446  * Compute relaxation region RHS with wrfbdy
447  */
448 void realbdy_compute_interior_ghost_rhs (const double& elapsed_time,
449  const double& start_time,
450  const double& delta_t,
451  const double& start_bdy_time,
452  const double& final_bdy_time,
453  const double& bdy_time_interval,
454  const amrex::Real& nudge_factor,
455  int width,
456  const amrex::Geometry& geom,
457  amrex::Vector<amrex::MultiFab>& S_rhs,
458  amrex::Vector<amrex::MultiFab>& S_cur_data,
459  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_xlo,
460  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_xhi,
461  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_ylo,
462  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_yhi,
463  std::unique_ptr<ReadBndryPlanes>& m_r2d,
464  const amrex::Real& c_p,
465  const amrex::Real& rdOcp,
466  const bool use_wrf_bdy_density,
467  const amrex::Real& bdy_rho_nudge_factor);
468 
469 /*
470  * Compute relaxation region RHS at fine-crse interface
471  */
472 void
474  const double& delta_t,
475  const int& width,
476  const int& set_width,
477  const amrex::Geometry& geom,
478  ERFFillPatcher* FPr_c,
479  ERFFillPatcher* FPr_u,
480  ERFFillPatcher* FPr_v,
481  ERFFillPatcher* FPr_w,
482  amrex::Vector<amrex::BCRec>& domain_bcs_type,
483  amrex::Vector<amrex::MultiFab>& S_rhs_f,
484  amrex::Vector<amrex::MultiFab>& S_data_f);
485 
486 /*
487  * Accumulate time averaged velocity fields
488  */
489 void
490 Time_Avg_Vel_atCC (double dt,
491  double& t_avg_cnt,
492  amrex::MultiFab* vel_t_avg,
493  amrex::MultiFab& xvel,
494  amrex::MultiFab& yvel,
495  amrex::MultiFab& zvel);
496 
497 /**
498  * Accumulate time-weighted cell-centered velocity/theta first and second moments.
499  * @param[in] dt accumulation interval
500  * @param[in,out] t_mean_cnt accumulated time
501  * @param[in,out] interval_means ten-component moment storage
502  * @param[in] xvel x-face velocity
503  * @param[in] yvel y-face velocity
504  * @param[in] zvel z-face velocity
505  * @param[in] cons conserved cell-centered state
506  */
507 void
509  double& t_mean_cnt,
510  amrex::MultiFab* interval_means,
511  amrex::MultiFab& xvel,
512  amrex::MultiFab& yvel,
513  amrex::MultiFab& zvel,
514  amrex::MultiFab& cons);
515 
516 /**
517  * Compute the nudging relaxation
518  *
519  * @param[in] delta_t time step
520  * @param[in] icomp component offset
521  * @param[in] num_var number of variables to loop
522  * @param[in] width width of wrf bdy file
523  * @param[in] dom_lo low bound of domain
524  * @param[in] dom_hi high bound of domain
525  * @param[in] F1 drift relaxation parameter
526  * @param[in] bx_xlo box for low x relaxation
527  * @param[in] bx_xhi box for high x relaxation
528  * @param[in] bx_ylo box for low y relaxation
529  * @param[in] bx_yhi box for high y relaxation
530  * @param[in] arr_xlo array for low x relaxation
531  * @param[in] arr_xhi array for high x relaxation
532  * @param[in] arr_ylo array for low y relaxation
533  * @param[in] arr_yhi array for high y relaxation
534  * @param[in] data_arr data array
535  * @param[out] rhs_arr RHS array
536  */
537 AMREX_GPU_HOST
538 AMREX_FORCE_INLINE
539 void
540 realbdy_compute_relaxation (const int& icomp,
541  const int& num_var,
542  const int& width,
543  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& dx,
544  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& ProbLo,
545  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& ProbHi,
546  const amrex::Real& F1,
547  const amrex::Box& bx_xlo,
548  const amrex::Box& bx_xhi,
549  const amrex::Box& bx_ylo,
550  const amrex::Box& bx_yhi,
551  const amrex::Array4<const amrex::Real>& arr_xlo,
552  const amrex::Array4<const amrex::Real>& arr_xhi,
553  const amrex::Array4<const amrex::Real>& arr_ylo,
554  const amrex::Array4<const amrex::Real>& arr_yhi,
555  const amrex::Array4<const amrex::Real>& data_arr,
556  const amrex::Array4<amrex::Real>& rhs_arr,
557  const amrex::Real& c_p,
558  const amrex::Real& rdOcp,
559  const int bdy_moist_nudge_type=0)
560 {
561  amrex::IntVect iv = bx_xlo.type();
562  amrex::Real ioff = (iv[0]==1) ? zero : myhalf;
563  amrex::Real joff = (iv[1]==1) ? zero : myhalf;
564 
565  // These are defined in ERF_Constants.H
566  amrex::Real l_rdOcp = rdOcp;
567  amrex::Real cond_fac = lcond / c_p; // condensation
568  amrex::Real sub_fac = lsub / c_p; // sublimation
569 
570  int nq = num_var;
571 
572  amrex::ParallelFor( bx_xlo, bx_xhi,
573  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
574  {
575  // Corners with x boxes
576  amrex::Real x = ProbLo[0] + (i + ioff) * dx[0];
577  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
578  amrex::Real x_end = ProbLo[0] + width * dx[0];
579  amrex::Real y_end = ProbLo[1] + width * dx[1];
580  amrex::Real y_strt = ProbHi[1] - width * dx[1];
581  amrex::Real xi = (x_end - x) / (x_end - ProbLo[0]);
582  amrex::Real eta_lo = (y < y_end ) ? (y_end - y) / (y_end - ProbLo[1]) : zero;
583  amrex::Real eta_hi = (y > y_strt) ? (y - y_strt) / (ProbHi[1] - y_strt) : zero;
584  amrex::Real eta = std::max(eta_lo,eta_hi);
585  amrex::Real Factor = std::max(xi*xi,eta*eta) * F1;
586 
587  if (icomp == RhoQ1_comp)
588  {
589  amrex::Real exner_pi = getExnergivenRTh(data_arr(i,j,k,RhoTheta_comp),l_rdOcp,
590  data_arr(i,j,k,RhoQ1_comp)/data_arr(i,j,k,Rho_comp));
591 
592  // qv
593  amrex::Real delta = arr_xlo(i,j,k,0) - data_arr(i,j,k,icomp);
594  rhs_arr(i,j,k,icomp) += Factor*delta;
595 
596  if (bdy_moist_nudge_type==2) {
597  // NOTE: we only operate on qv (above), qc and qi here; the
598  // precipitating species (qr/qs/qg) are left untouched.
599 
600  // qc and heat source term due to evaporation
601  delta = -data_arr(i,j,k,RhoQ2_comp); // This effectively nudges to 0
602  rhs_arr(i,j,k,RhoQ2_comp ) += Factor * delta;
603  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * cond_fac / exner_pi;
604 
605  // qi and heat source term due to sublimation
606  if (nq > 3) { // nq > 3 guarantees that RhoQ3 is ice
607  delta = -data_arr(i,j,k,RhoQ3_comp); // This effectively nudges to 0
608  rhs_arr(i,j,k,RhoQ3_comp ) += Factor * delta;
609  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * sub_fac / exner_pi;
610  }
611  } // moist_nudge_type
612  } else {
613  for (int n = 0; n < nq; n++) {
614  amrex::Real delta = arr_xlo(i,j,k,n) - data_arr(i,j,k,n+icomp);
615  rhs_arr(i,j,k,n+icomp) += Factor*delta;
616  }
617  }
618  },
619  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
620  {
621  // Corners with x boxes
622  amrex::Real x = ProbLo[0] + (i + ioff) * dx[0];
623  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
624  amrex::Real x_strt = ProbHi[0] - width * dx[0];
625  amrex::Real y_strt = ProbHi[1] - width * dx[1];
626  amrex::Real y_end = ProbLo[1] + width * dx[1];
627  amrex::Real xi = (x - x_strt) / (ProbHi[0] - x_strt);
628  amrex::Real eta_lo = (y < y_end ) ? (y_end - y) / (y_end - ProbLo[1]) : zero;
629  amrex::Real eta_hi = (y > y_strt) ? (y - y_strt) / (ProbHi[1] - y_strt) : zero;
630  amrex::Real eta = std::max(eta_lo,eta_hi);
631  amrex::Real Factor = std::max(xi*xi,eta*eta) * F1;
632 
633  if (icomp == RhoQ1_comp)
634  {
635  amrex::Real exner_pi = getExnergivenRTh(data_arr(i,j,k,RhoTheta_comp),l_rdOcp,
636  data_arr(i,j,k,RhoQ1_comp)/data_arr(i,j,k,Rho_comp));
637 
638  // qv
639  amrex::Real delta = arr_xhi(i,j,k,0) - data_arr(i,j,k,icomp);
640  rhs_arr(i,j,k,icomp) += Factor*delta;
641 
642  if (bdy_moist_nudge_type==2) {
643  // NOTE: we only operate on qv (above), qc and qi here; the
644  // precipitating species (qr/qs/qg) are left untouched.
645 
646  // qc and heat source term due to evaporation
647  delta = -data_arr(i,j,k,RhoQ2_comp); // This effectively nudges to 0
648  rhs_arr(i,j,k,RhoQ2_comp ) += Factor*delta;
649  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * cond_fac / exner_pi;
650 
651  // qi and heat source term due to sublimation
652  if (nq > 3) { // nq > 3 guarantees that RhoQ3 is ice
653  delta = -data_arr(i,j,k,RhoQ3_comp); // This effectively nudges to 0
654  rhs_arr(i,j,k,RhoQ3_comp ) += Factor * delta;
655  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * sub_fac / exner_pi;
656  }
657  } // moist_nudge_type
658  } else {
659  for (int n = 0; n < nq; n++) {
660  amrex::Real delta = arr_xhi(i,j,k,n) - data_arr(i,j,k,n+icomp);
661  rhs_arr(i,j,k,n+icomp) += Factor*delta;
662  }
663  }
664  });
665 
666  amrex::ParallelFor( bx_ylo, bx_yhi,
667  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
668  {
669  // No corners for y boxes
670  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
671  amrex::Real y_end = ProbLo[1] + width * dx[1];
672  amrex::Real eta = (y_end - y) / (y_end - ProbLo[1]);
673  amrex::Real Factor = eta*eta * F1;
674 
675  if (icomp == RhoQ1_comp)
676  {
677  amrex::Real exner_pi = getExnergivenRTh(data_arr(i,j,k,RhoTheta_comp),l_rdOcp,
678  data_arr(i,j,k,RhoQ1_comp)/data_arr(i,j,k,Rho_comp));
679  // qv
680  amrex::Real delta = arr_ylo(i,j,k,0) - data_arr(i,j,k,icomp);
681  rhs_arr(i,j,k,icomp) += Factor*delta;
682 
683  if (bdy_moist_nudge_type==2) {
684  // NOTE: we only operate on qv (above), qc and qi here; the
685  // precipitating species (qr/qs/qg) are left untouched.
686 
687  // qc and heat source term due to evaporation
688  delta = -data_arr(i,j,k,RhoQ2_comp); // This effectively nudges to 0
689  rhs_arr(i,j,k,RhoQ2_comp ) += Factor*delta;
690  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * cond_fac / exner_pi;
691 
692  // qi and heat source term due to sublimation
693  if (nq > 3) { // nq > 3 guarantees that RhoQ3 is ice
694  delta = -data_arr(i,j,k,RhoQ3_comp); // This effectively nudges to 0
695  rhs_arr(i,j,k,RhoQ3_comp ) += Factor * delta;
696  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * sub_fac / exner_pi;
697  }
698  } // moist_nudge_type
699  } else {
700  for (int n = 0; n < nq; n++) {
701  amrex::Real delta = arr_ylo(i,j,k,n) - data_arr(i,j,k,n+icomp);
702  rhs_arr(i,j,k,n+icomp) += Factor*delta;
703  }
704  }
705  },
706  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
707  {
708  // No corners for y boxes
709  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
710  amrex::Real y_strt = ProbHi[1] - width * dx[1];
711  amrex::Real eta = (y - y_strt) / (ProbHi[1] - y_strt);
712  amrex::Real Factor = eta*eta * F1;
713 
714  if (icomp == RhoQ1_comp)
715  {
716  amrex::Real exner_pi = getExnergivenRTh(data_arr(i,j,k,RhoTheta_comp),l_rdOcp,
717  data_arr(i,j,k,RhoQ1_comp)/data_arr(i,j,k,Rho_comp));
718  // qv
719  amrex::Real delta = arr_yhi(i,j,k,0) - data_arr(i,j,k,icomp);
720  rhs_arr(i,j,k,icomp) += Factor*delta;
721 
722  if (bdy_moist_nudge_type==2) {
723  // NOTE: we only operate on qv (above), qc and qi here; the
724  // precipitating species (qr/qs/qg) are left untouched.
725 
726  // qc and heat source term due to evaporation
727  delta = -data_arr(i,j,k,RhoQ2_comp); // This effectively nudges to 0
728  rhs_arr(i,j,k,RhoQ2_comp ) += Factor * delta;
729  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * cond_fac / exner_pi;
730 
731  // qi and heat source term due to sublimation
732  if (nq > 3) { // nq > 3 guarantees that RhoQ3 is ice
733  delta = -data_arr(i,j,k,RhoQ3_comp); // This effectively nudges to 0
734  rhs_arr(i,j,k,RhoQ3_comp ) += Factor * delta;
735  rhs_arr(i,j,k,RhoTheta_comp) += Factor * delta * sub_fac / exner_pi;
736  }
737  } // moist_nudge_type
738  } else {
739  for (int n = 0; n < nq; n++) {
740  amrex::Real delta = arr_yhi(i,j,k,n) - data_arr(i,j,k,n+icomp);
741  rhs_arr(i,j,k,n+icomp) += Factor*delta;
742  }
743  }
744  });
745 }
746 
747 /*
748  * Effectively a Multiply for a MultiFab and an iMultiFab mask
749  */
750 AMREX_GPU_HOST
751 AMREX_FORCE_INLINE
752 void
753 ApplyMask (amrex::MultiFab& dst,
754  const amrex::iMultiFab& imask,
755  const int nghost = 0)
756 {
757  for (amrex::MFIter mfi(dst,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
758  {
759  const amrex::Box& bx = mfi.growntilebox(nghost);
760  if (bx.ok())
761  {
762  auto dstFab = dst.array(mfi);
763  const auto maskFab = imask.const_array(mfi);
764  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
765  {
766  dstFab(i,j,k) *= maskFab(i,j,k);
767  });
768  }
769  }
770 }
771 
772 /**
773  * Multiply a MultiFab by the inverse of an integer mask.
774  * @param[in,out] dst MultiFab to be masked.
775  * @param[in] imask Integer mask MultiFab.
776  * @param[in] nghost Number of ghost cells to include.
777  */
778 AMREX_GPU_HOST
779 AMREX_FORCE_INLINE
780 void
781 ApplyInvertedMask (amrex::MultiFab& dst,
782  const amrex::iMultiFab& imask,
783  const int nghost = 0)
784 {
785  for (amrex::MFIter mfi(dst,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
786  {
787  const amrex::Box& bx = mfi.growntilebox(nghost);
788  if (bx.ok())
789  {
790  auto dstFab = dst.array(mfi);
791  const auto maskFab = imask.const_array(mfi);
792  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
793  {
794  dstFab(i,j,k) *= (1-maskFab(i,j,k));
795  });
796  }
797  }
798 }
799 
800 /**
801  * Compute the distance to thin-body walls.
802  * @param[out] wdist MultiFab to store wall distances.
803  * @param[in] xfaces Indices of x-faces forming walls.
804  * @param[in] yfaces Indices of y-faces forming walls.
805  * @param[in] zfaces Indices of z-faces forming walls.
806  * @param[in] geomdata Geometry used for physical distance.
807  * @param[in] z_phys_cc Cell-centered physical height.
808  */
809 void
810 thinbody_wall_dist (std::unique_ptr<amrex::MultiFab>& wdist,
811  amrex::Vector<amrex::IntVect>& xfaces,
812  amrex::Vector<amrex::IntVect>& yfaces,
813  amrex::Vector<amrex::IntVect>& zfaces,
814  const amrex::Geometry& geomdata,
815  std::unique_ptr<amrex::MultiFab>& z_phys_cc);
816 
817 
818 void WeatherDataInterpolation (const double time);
819 
820 /**
821  * Which time level(s) a fillpatch at a given time should draw from.
822  */
823 enum struct TimeLevelSel { Old, New, Interp };
824 
825 /**
826  * Decide whether data at time "time" should come from the old-time data, the new-time data,
827  * or an interpolation between the two.
828  *
829  * This is done in double precision, before any cast to Real, and with a single tolerance
830  * at both ends. The tolerance is a small fraction of (t_new - t_old), but never smaller than
831  * a few ulps of the times themselves, since those carry roundoff proportional to their
832  * magnitude -- which matters once the time is large (e.g. months measured in seconds).
833  *
834  * Times outside [t_old, t_new] are clamped to the nearer end rather than extrapolated.
835  * If t_old == t_new (to within the tolerance), Old is returned.
836  *
837  * @param[in] time time at which data are requested
838  * @param[in] t_old old time of the level
839  * @param[in] t_new new time of the level
840  */
841 inline TimeLevelSel
842 select_time_level (double time, double t_old, double t_new)
843 {
844  const double t_mag = std::max({std::abs(time), std::abs(t_old), std::abs(t_new)});
845  const double tol = std::max(1.e-8 * std::abs(t_new - t_old),
846  16.0 * std::numeric_limits<double>::epsilon() * t_mag);
847 
848  if (time <= t_old + tol) { return TimeLevelSel::Old; }
849  if (time >= t_new - tol) { return TimeLevelSel::New; }
850  return TimeLevelSel::Interp;
851 }
852 
853 /**
854  * The pair of MultiFabs to hand to an AMReX FillPatch routine for a given time-level selection.
855  * When only one time level is wanted it is passed twice, so that AMReX's own comparison of the
856  * (rounded) times can never bring in the other one.
857  *
858  * @param[in] sel which time level(s) to use
859  * @param[in] old_mf data at the old time
860  * @param[in] new_mf data at the new time
861  */
862 inline amrex::Vector<amrex::MultiFab*>
863 select_time_data (TimeLevelSel sel, amrex::MultiFab& old_mf, amrex::MultiFab& new_mf)
864 {
865  if (sel == TimeLevelSel::Old) { return {&old_mf, &old_mf}; }
866  if (sel == TimeLevelSel::New) { return {&new_mf, &new_mf}; }
867  return {&old_mf, &new_mf};
868 }
869 
870 #endif
GpuArray< Real, AMREX_SPACEDIM > period
Definition: ERF_ActuatorSpreading.cpp:131
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenRTh(const amrex::Real rhotheta, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:156
#define Rho_comp
Definition: ERF_IndexDefines.H:61
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int cons_bc_comp(int n) noexcept
Definition: ERF_IndexDefines.H:152
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79
#define NVAR_max
Definition: ERF_IndexDefines.H:45
#define RhoQ3_comp
Definition: ERF_IndexDefines.H:80
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
AdvType
Definition: ERF_IndexDefines.H:329
Real z0
Definition: ERF_InitCustomPertVels_ScalarAdvDiff.H:12
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
Physical constants and tuning parameters used only by the moisture and cloud-physics code.
constexpr amrex::Real lsub
Definition: ERF_MicrophysicsConstants.H:111
constexpr amrex::Real lcond
Definition: ERF_MicrophysicsConstants.H:109
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
void immersed_wall_dist(amrex::MultiFab &wdist, const amrex::MultiFab &terrain_blank, const amrex::MultiFab &z_phys_nd, const amrex::MultiFab &z_phys_cc, const amrex::Box &domain, amrex::Real small_volfrac, amrex::MultiFab *wall_height=nullptr, const amrex::MultiFab *wall_height_crse=nullptr)
void WeatherDataInterpolation(const double time)
void MomentumToVelocity(amrex::MultiFab &xvel_out, amrex::MultiFab &yvel_out, amrex::MultiFab &zvel_out, const amrex::MultiFab &cons_in, const amrex::MultiFab &xmom_in, const amrex::MultiFab &ymom_in, const amrex::MultiFab &zmom_in, const amrex::Box &domain, const amrex::Vector< amrex::BCRec > &domain_bcs_type_h, const amrex::MultiFab *c_vfrac=nullptr)
void make_zsfc_nd(const amrex::Geometry &geom, const amrex::MultiFab &z_phys_nd, amrex::MultiFab &z_sfc_nd, const amrex::MultiFab *z_sfc_crse=nullptr, const amrex::IntVect &ref_ratio=amrex::IntVect(1))
std::pair< int, amrex::Real > if_cf_surface_mismatch(const amrex::MultiFab &fine_tb, const amrex::BoxArray &fine_grids, const amrex::BoxArray &crse_grids, const amrex::DistributionMapping &crse_dmap, const amrex::Geometry &crse_geom, const amrex::IntVect &ratio, amrex::Real warn)
void VelocityToMomentum(const amrex::MultiFab &xvel_in, const amrex::IntVect &xvel_ngrow, const amrex::MultiFab &yvel_in, const amrex::IntVect &yvel_ngrow, const amrex::MultiFab &zvel_in, const amrex::IntVect &zvel_ngrow, const amrex::MultiFab &cons_in, amrex::MultiFab &xmom_out, amrex::MultiFab &ymom_out, amrex::MultiFab &zmom_out, const amrex::Box &domain, const amrex::Vector< amrex::BCRec > &domain_bcs_type_h, const amrex::MultiFab *c_vfrac=nullptr)
void rebalance_columns(amrex::MultiFab &rho, amrex::MultiFab &theta, const amrex::MultiFab &qt, const amrex::MultiFab &qv, const amrex::MultiFab *z_phys, const amrex::Geometry &geom, const bool &maintain_Th, bool use_sfc=false)
amrex::Vector< amrex::MultiFab * > select_time_data(TimeLevelSel sel, amrex::MultiFab &old_mf, amrex::MultiFab &new_mf)
Definition: ERF_Utils.H:863
void recompute_p_pi_hse(amrex::MultiFab &base_state_mf, amrex::Real l_rdOcp)
void cons_to_prim(const amrex::MultiFab &cons_state, amrex::MultiFab &S_prim, int ng)
void make_ib_wall_face_masks(const amrex::MultiFab &terrain_blank, amrex::MultiFab &mask13, amrex::MultiFab &mask23, amrex::MultiFab &mask33, const amrex::Box &domain, amrex::Real small_volfrac, int spacing=0, amrex::Real dz=amrex::Real(1.0), amrex::Real z0=amrex::Real(0.1))
void fill_wall_dist_ghost_cells(amrex::MultiFab &wdist, const amrex::Geometry &geom)
void Accumulate_Interval_Means(double dt, double &t_mean_cnt, amrex::MultiFab *interval_means, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::MultiFab &zvel, amrex::MultiFab &cons)
void enforceInOutSolvability_bdy(const amrex::MultiFab &rho0, amrex::FArrayBox &bdy_data_xlo, amrex::FArrayBox &bdy_data_xhi, amrex::FArrayBox &bdy_data_ylo, amrex::FArrayBox &bdy_data_yhi, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &area_vec, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type_h)
void MakeAdvectiveProjectionWeights(const amrex::MultiFab &den_div, const amrex::MultiFab &den_mlt, const amrex::MultiFab &xmom, const amrex::MultiFab &ymom, const amrex::MultiFab &zmom, amrex::Array< amrex::MultiFab, AMREX_SPACEDIM > &beta, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::Periodicity &period)
void fine_compute_interior_ghost_rhs(const double &time, const double &delta_t, const int &width, const int &set_width, const amrex::Geometry &geom, ERFFillPatcher *FPr_c, ERFFillPatcher *FPr_u, ERFFillPatcher *FPr_v, ERFFillPatcher *FPr_w, amrex::Vector< amrex::BCRec > &domain_bcs_type, amrex::Vector< amrex::MultiFab > &S_rhs_f, amrex::Vector< amrex::MultiFab > &S_data_f)
void thinbody_wall_dist(std::unique_ptr< amrex::MultiFab > &wdist, amrex::Vector< amrex::IntVect > &xfaces, amrex::Vector< amrex::IntVect > &yfaces, amrex::Vector< amrex::IntVect > &zfaces, const amrex::Geometry &geomdata, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
RealBdyConsMaps real_bdy_cons_maps(const bool read_density)
Definition: ERF_Utils.H:36
void realbdy_compute_interior_ghost_rhs(const double &elapsed_time, const double &start_time, const double &delta_t, const double &start_bdy_time, const double &final_bdy_time, const double &bdy_time_interval, const amrex::Real &nudge_factor, int width, const amrex::Geometry &geom, amrex::Vector< amrex::MultiFab > &S_rhs, amrex::Vector< amrex::MultiFab > &S_cur_data, amrex::Vector< amrex::Vector< amrex::FArrayBox >> &bdy_data_xlo, amrex::Vector< amrex::Vector< amrex::FArrayBox >> &bdy_data_xhi, amrex::Vector< amrex::Vector< amrex::FArrayBox >> &bdy_data_ylo, amrex::Vector< amrex::Vector< amrex::FArrayBox >> &bdy_data_yhi, std::unique_ptr< ReadBndryPlanes > &m_r2d, const amrex::Real &c_p, const amrex::Real &rdOcp, const bool use_wrf_bdy_density, const amrex::Real &bdy_rho_nudge_factor)
amrex::BoxArray ERFPostProcessBaseGrids(const amrex::Box &domain, bool decompose_in_z)
void make_zcc(const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &z_phys_cc)
void realbdy_bc_bxs_xy(const amrex::Box &bx, const amrex::Box &domain, const int &set_width, amrex::Box &bx_xlo, amrex::Box &bx_xhi, amrex::Box &bx_ylo, amrex::Box &bx_yhi, const amrex::IntVect &ng_vect=amrex::IntVect(0, 0, 0))
void Time_Avg_Vel_atCC(double dt, double &t_avg_cnt, amrex::MultiFab *vel_t_avg, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::MultiFab &zvel)
void realbdy_interior_bxs_xy(const amrex::Box &bx, const amrex::Box &domain, const int &width, amrex::Box &bx_xlo, amrex::Box &bx_xhi, amrex::Box &bx_ylo, amrex::Box &bx_yhi, const amrex::IntVect &ng_vect=amrex::IntVect(0, 0, 0), const bool get_int_ng=false)
AMREX_FORCE_INLINE BdyTimeWeights bdy_time_weights(const double time_since_start, const double data_span, const double dT)
Definition: ERF_Utils.H:428
AMREX_GPU_HOST AMREX_FORCE_INLINE void realbdy_compute_relaxation(const int &icomp, const int &num_var, const int &width, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &ProbLo, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &ProbHi, const amrex::Real &F1, const amrex::Box &bx_xlo, const amrex::Box &bx_xhi, const amrex::Box &bx_ylo, const amrex::Box &bx_yhi, const amrex::Array4< const amrex::Real > &arr_xlo, const amrex::Array4< const amrex::Real > &arr_xhi, const amrex::Array4< const amrex::Real > &arr_ylo, const amrex::Array4< const amrex::Real > &arr_yhi, const amrex::Array4< const amrex::Real > &data_arr, const amrex::Array4< amrex::Real > &rhs_arr, const amrex::Real &c_p, const amrex::Real &rdOcp, const int bdy_moist_nudge_type=0)
Definition: ERF_Utils.H:540
void compute_influx_outflux_bdy(amrex::FArrayBox &bdy_data_xlo, amrex::FArrayBox &bdy_data_xhi, amrex::FArrayBox &bdy_data_ylo, amrex::FArrayBox &bdy_data_yhi, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &area_vec, const amrex::iMultiFab &mask_x, const amrex::iMultiFab &mask_y, const amrex::Geometry &geom, amrex::Real &influx, amrex::Real &outflux, const int n)
AMREX_GPU_HOST AMREX_FORCE_INLINE void ApplyInvertedMask(amrex::MultiFab &dst, const amrex::iMultiFab &imask, const int nghost=0)
Definition: ERF_Utils.H:781
void make_J(const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &detJ_cc)
AMREX_GPU_HOST AMREX_FORCE_INLINE void ApplyMask(amrex::MultiFab &dst, const amrex::iMultiFab &imask, const int nghost=0)
Definition: ERF_Utils.H:753
void if_average_down(const amrex::MultiFab &S_fine, amrex::MultiFab &S_crse, const amrex::MultiFab &beta_fine, const amrex::MultiFab &beta_crse, const amrex::MultiFab &vol_fine, int scomp, int ncomp, const amrex::IntVect &ratio)
void ConvertForProjection(const amrex::MultiFab &den_div, const amrex::MultiFab &den_mlt, amrex::MultiFab &xmom, amrex::MultiFab &ymom, amrex::MultiFab &zmom, const amrex::Box &domain, const amrex::Vector< amrex::BCRec > &domain_bcs_type_h)
void ChopGrids2D(amrex::BoxArray &ba, const amrex::Box &domain, int target_size)
void MakeProjectionWeights(const amrex::MultiFab &den_div, const amrex::MultiFab &den_mlt, const amrex::MultiFab &xmom, const amrex::MultiFab &ymom, const amrex::MultiFab &zmom, amrex::Array< amrex::MultiFab, AMREX_SPACEDIM > &beta, const amrex::Box &domain, const amrex::Vector< amrex::BCRec > &domain_bcs_type_h)
void enforceInOutSolvability(int lev, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &vels_vec, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &area_vec, const amrex::Geometry &geom)
TimeLevelSel select_time_level(double time, double t_old, double t_new)
Definition: ERF_Utils.H:842
TimeLevelSel
Definition: ERF_Utils.H:823
void average_down_faces_mapfac(const amrex::MultiFab &fine, amrex::MultiFab &crse, const amrex::IntVect &rr, const amrex::Periodicity &cper, const amrex::MultiFab &mf_f, const amrex::MultiFab &mf_c, const amrex::MultiFab *mf2_f, const amrex::MultiFab *mf2_c, const amrex::MultiFab *area_f, const amrex::MultiFab *area_c)
void make_areas(const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &ax, amrex::MultiFab &ay, amrex::MultiFab &az)
void make_qt(const amrex::MultiFab &cons_state, amrex::MultiFab &qt, int n_qstate_into_total)
Definition: ERF_FillPatcher.H:9
@ ymom
Definition: ERF_IndexDefines.H:251
@ zmom
Definition: ERF_IndexDefines.H:252
@ xmom
Definition: ERF_IndexDefines.H:250
@ rho
Definition: ERF_Kessler.H:25
@ theta
Definition: ERF_Kessler.H:26
@ qt
Definition: ERF_Kessler.H:30
@ qv
Definition: ERF_Kessler.H:31
@ ng
Definition: ERF_Morrison.H:51
@ R
Definition: ERF_IndexDefines.H:182
@ QV
Definition: ERF_IndexDefines.H:181
@ T
Definition: ERF_IndexDefines.H:180
@ beta
Definition: ERF_SLM.H:154
@ xvel
Definition: ERF_IndexDefines.H:232
@ cons
Definition: ERF_IndexDefines.H:231
@ zvel
Definition: ERF_IndexDefines.H:234
@ yvel
Definition: ERF_IndexDefines.H:233
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
real(c_double), private rr
Definition: ERF_module_mp_morr_two_moment.F90:224
Definition: ERF_Utils.H:407
int n_hi
Definition: ERF_Utils.H:409
amrex::Real alpha
Definition: ERF_Utils.H:410
int n_lo
Definition: ERF_Utils.H:408
Definition: ERF_Utils.H:29
amrex::Vector< int > map
Definition: ERF_Utils.H:31
amrex::Vector< int > bnd
Definition: ERF_Utils.H:32
amrex::Vector< int > read
Definition: ERF_Utils.H:30