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 "AMReX.H"
5 #include "AMReX_MultiFab.H"
6 #include "AMReX_BCRec.H"
7 #include "ERF_DataStruct.H"
8 #include "ERF_IndexDefines.H"
9 #include "ERF_SurfaceLayer.H"
10 #include "ERF_FillPatcher.H"
11 
12 /*
13  * Create a new BoxArray in which every grid touches the bottom boundary
14  */
15 void ChopGrids2D (amrex::BoxArray& ba, const amrex::Box& domain, int target_size);
16 
17 /*
18  * Create a new BoxArray with exactly the number of boxes as MPI ranks.
19  * This is designed to work only on the base level which covers the entire domain.
20  */
21 amrex::BoxArray
22 ERFPostProcessBaseGrids (const amrex::Box& domain, bool decompose_in_z);
23 
24 /*
25  * Create the Jacobian for the metric transformation when use_terrain is true
26  */
27 void make_J (const amrex::Geometry& geom,
28  amrex::MultiFab& z_phys_nd,
29  amrex::MultiFab& detJ_cc);
30 
31 void make_areas (const amrex::Geometry& geom,
32  amrex::MultiFab& z_phys_nd,
33  amrex::MultiFab& ax,
34  amrex::MultiFab& ay,
35  amrex::MultiFab& az);
36 
37 /*
38  * Average z_phys_nd on nodes to cell centers
39  */
40 void make_zcc (const amrex::Geometry& geom,
41  amrex::MultiFab& z_phys_nd,
42  amrex::MultiFab& z_phys_cc);
43 
44 /*
45  * Convert momentum to velocity by dividing by density averaged onto faces
46  */
47 void MomentumToVelocity (amrex::MultiFab& xvel_out,
48  amrex::MultiFab& yvel_out,
49  amrex::MultiFab& zvel_out,
50  const amrex::MultiFab& cons_in,
51  const amrex::MultiFab& xmom_in,
52  const amrex::MultiFab& ymom_in,
53  const amrex::MultiFab& zmom_in,
54  const amrex::Box& domain,
55  const amrex::Vector<amrex::BCRec>& domain_bcs_type_h,
56  const amrex::MultiFab* c_vfrac = nullptr // optional
57  );
58 
59 /*
60  * Convert velocity to momentum by multiplying by density averaged onto faces
61  */
62 void VelocityToMomentum (const amrex::MultiFab& xvel_in,
63  const amrex::IntVect & xvel_ngrow,
64  const amrex::MultiFab& yvel_in,
65  const amrex::IntVect & yvel_ngrow,
66  const amrex::MultiFab& zvel_in,
67  const amrex::IntVect & zvel_ngrow,
68  const amrex::MultiFab& cons_in,
69  amrex::MultiFab& xmom_out,
70  amrex::MultiFab& ymom_out,
71  amrex::MultiFab& zmom_out,
72  const amrex::Box& domain,
73  const amrex::Vector<amrex::BCRec>& domain_bcs_type_h,
74  const amrex::MultiFab* c_vfrac = nullptr // optional
75  );
76 
77 /*
78  * Convert (den_div u) to (den_mlt u) by multiplying by (den_mlt/den_div)
79  */
80 void
81 ConvertForProjection (const amrex::MultiFab& den_div, const amrex::MultiFab& den_mlt,
82  amrex::MultiFab& xmom, amrex::MultiFab& ymom, amrex::MultiFab& zmom,
83  const amrex::Box& domain, const amrex::Vector<amrex::BCRec>& domain_bcs_type_h);
84 
85 /*
86  * \brief Enforces solvablity by scaling outflow to match with inflow.
87  *
88  */
90  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& vels_vec,
91  amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>& area_vec,
92  const amrex::Geometry& geom);
93 
94 /*
95  * Compute boxes for looping over interior/exterior ghost cells
96  * for use by fillpatch, erf_slow_rhs_pre, and erf_slow_rhs_post
97  */
98 void realbdy_interior_bxs_xy (const amrex::Box& bx,
99  const amrex::Box& domain,
100  const int& width,
101  amrex::Box& bx_xlo,
102  amrex::Box& bx_xhi,
103  amrex::Box& bx_ylo,
104  amrex::Box& bx_yhi,
105  const int& set_width=0,
106  const amrex::IntVect& ng_vect=amrex::IntVect(0,0,0),
107  const bool get_int_ng=false);
108 
109 /*
110  * Compute boxes for looping over set region cells
111  * for use by fillpatch, erf_slow_rhs_pre, and erf_slow_rhs_post
112  */
113 void realbdy_bc_bxs_xy (const amrex::Box& bx,
114  const amrex::Box& domain,
115  const int& set_width,
116  amrex::Box& bx_xlo,
117  amrex::Box& bx_xhi,
118  amrex::Box& bx_ylo,
119  amrex::Box& bx_yhi,
120  const amrex::IntVect& ng_vect=amrex::IntVect(0,0,0));
121 
122 /*
123  * Compute relaxation region RHS with wrfbdy
124  */
125 void realbdy_compute_interior_ghost_rhs (const amrex::Real& bdy_time_interval,
126  const amrex::Real& time,
127  const amrex::Real& delta_t,
128  const amrex::Real& stop_time_elapsed,
129  int width,
130  int set_width,
131  bool do_upwind,
132  const amrex::Geometry& geom,
133  amrex::Vector<amrex::MultiFab>& S_rhs,
134  amrex::Vector<amrex::MultiFab>& S_old_data,
135  amrex::Vector<amrex::MultiFab>& S_cur_data,
136  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_xlo,
137  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_xhi,
138  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_ylo,
139  amrex::Vector<amrex::Vector<amrex::FArrayBox>>& bdy_data_yhi);
140 
141 /*
142  * Compute relaxation region RHS at fine-crse interface
143  */
144 void
146  const amrex::Real& delta_t,
147  const int& width,
148  const int& set_width,
149  const amrex::Geometry& geom,
150  ERFFillPatcher* FPr_c,
151  ERFFillPatcher* FPr_u,
152  ERFFillPatcher* FPr_v,
153  ERFFillPatcher* FPr_w,
154  amrex::Vector<amrex::BCRec>& domain_bcs_type,
155  amrex::Vector<amrex::MultiFab>& S_rhs_f,
156  amrex::Vector<amrex::MultiFab>& S_data_f);
157 
158 /*
159  * Accumulate time averaged velocity fields
160  */
161 void
163  amrex::Real& t_avg_cnt,
164  amrex::MultiFab* vel_t_avg,
165  amrex::MultiFab& xvel,
166  amrex::MultiFab& yvel,
167  amrex::MultiFab& zvel);
168 
169 /**
170  * Zero RHS in the set region
171  *
172  * @param[in] icomp component offset
173  * @param[in] num_var number of variables to loop
174  * @param[in] bx_xlo box for low x relaxation
175  * @param[in] bx_xhi box for high x relaxation
176  * @param[in] bx_ylo box for low y relaxation
177  * @param[in] bx_yhi box for high y relaxation
178  * @param[out] rhs_arr RHS array
179  */
180 AMREX_GPU_HOST
181 AMREX_FORCE_INLINE
182 void
184  const int& icomp,
185  const int& num_var,
186  const int& width,
187  const int& set_width_x,
188  const int& set_width_y,
189  const amrex::Box& domain,
190  const amrex::Box& domain_cc,
191  const amrex::Box& bx_xlo,
192  const amrex::Box& bx_xhi,
193  const amrex::Box& bx_ylo,
194  const amrex::Box& bx_yhi,
195  const amrex::Array4<const amrex::Real>& arr_xlo,
196  const amrex::Array4<const amrex::Real>& arr_xhi,
197  const amrex::Array4<const amrex::Real>& arr_ylo,
198  const amrex::Array4<const amrex::Real>& arr_yhi,
199  const amrex::Array4<const amrex::Real>& u_xlo,
200  const amrex::Array4<const amrex::Real>& u_xhi,
201  const amrex::Array4<const amrex::Real>& v_xlo,
202  const amrex::Array4<const amrex::Real>& v_xhi,
203  const amrex::Array4<const amrex::Real>& v_ylo,
204  const amrex::Array4<const amrex::Real>& v_yhi,
205  const amrex::Array4<const amrex::Real>& data_arr,
206  const amrex::Array4<amrex::Real>& rhs_arr,
207  const bool& do_upwind)
208 {
209  int Spec_z_x = set_width_x;
210  int Spec_z_y = set_width_y;
211  amrex::IntVect iv = bx_xlo.type();
212  const auto& dom_lo = lbound(domain);
213  const auto& dom_hi = ubound(domain);
214  const auto& dom_cc_lo = lbound(domain_cc);
215  const auto& dom_cc_hi = ubound(domain_cc);
216  amrex::ParallelFor(bx_xlo, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
217  {
218  // Corners with x boxes
219  int j_lo = std::min(j-dom_lo.y,width-1);
220  int j_hi = std::min(dom_hi.y-j,width-1);
221  int jj = std::min(j_lo,j_hi);
222  int n_ind_y = jj + 1;
223  int n_ind_x = i - dom_lo.x + 1;
224  if ((n_ind_x <= Spec_z_x) || (n_ind_y <= Spec_z_y)) {
225  amrex::Real tend = ( arr_xlo(i,j,k) - data_arr(i,j,k,n+icomp) ) / dt;
226  if (!do_upwind) {
227  rhs_arr(i,j,k,n+icomp) = tend;
228  } else {
229  int jju = std::min(std::max(j,dom_cc_lo.y),dom_cc_hi.y);
230  int iiv = std::min(std::max(i,dom_cc_lo.x),dom_cc_hi.x);
231  if ( (u_xlo(dom_cc_lo.x,jju,k) >= 0.0) ||
232  ((j == dom_cc_lo.y ) && (v_xlo(iiv,dom_cc_lo.y ,k) >= 0.0)) ||
233  ((j == dom_cc_hi.y+iv[1]) && (v_xlo(iiv,dom_cc_hi.y+1,k) <= 0.0)) ) {
234  rhs_arr(i,j,k,n+icomp) = tend;
235  }
236  }
237  }
238  },
239  bx_xhi, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
240  {
241  // Corners with x boxes
242  int j_lo = std::min(j-dom_lo.y,width-1);
243  int j_hi = std::min(dom_hi.y-j,width-1);
244  int jj = std::min(j_lo,j_hi);
245  int n_ind_y = jj + 1;
246  int n_ind_x = dom_hi.x - i + 1;
247  if ((n_ind_x <= Spec_z_x) || (n_ind_y <= Spec_z_y)) {
248  amrex::Real tend = ( arr_xhi(i,j,k) - data_arr(i,j,k,n+icomp) ) / dt;
249  if (!do_upwind) {
250  rhs_arr(i,j,k,n+icomp) = tend;
251  } else {
252  int jju = std::min(std::max(j,dom_cc_lo.y),dom_cc_hi.y);
253  int iiv = std::min(std::max(i,dom_cc_lo.x),dom_cc_hi.x);
254  if ( (u_xhi(dom_cc_hi.x+1,jju,k) <= 0.0) ||
255  ((j == dom_cc_lo.y ) && (v_xhi(iiv,dom_cc_lo.y ,k) >= 0.0)) ||
256  ((j == dom_cc_hi.y+iv[1]) && (v_xhi(iiv,dom_cc_hi.y+1,k) <= 0.0)) ) {
257  rhs_arr(i,j,k,n+icomp) = tend;
258  }
259  }
260  }
261  });
262 
263  amrex::ParallelFor(bx_ylo, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
264  {
265  // No corners for y boxes
266  int n_ind = j - dom_lo.y + 1;
267  if (n_ind <= Spec_z_y) {
268  amrex::Real tend = ( arr_ylo(i,j,k) - data_arr(i,j,k,n+icomp) ) / dt;
269  if (!do_upwind) {
270  rhs_arr(i,j,k,n+icomp) = tend;
271  } else {
272  int iiv = std::min(std::max(i,dom_cc_lo.x+width),dom_cc_hi.x-width);
273  if (v_ylo(iiv,dom_cc_lo.y,k) >= 0.0) {
274  rhs_arr(i,j,k,n+icomp) = tend;
275  }
276  }
277  }
278  },
279  bx_yhi, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
280  {
281  // No corners for y boxes
282  int n_ind = dom_hi.y - j + 1;
283  if (n_ind <= Spec_z_y) {
284  amrex::Real tend = ( arr_yhi(i,j,k) - data_arr(i,j,k,n+icomp) ) / dt;
285  if (!do_upwind) {
286  rhs_arr(i,j,k,n+icomp) = tend;
287  } else {
288  int iiv = std::min(std::max(i,dom_cc_lo.x+width),dom_cc_hi.x-width);
289  if (v_yhi(iiv,dom_cc_hi.y+1,k) >= 0.0) {
290  rhs_arr(i,j,k,n+icomp) = tend;
291  }
292  }
293  }
294  });
295 }
296 
297 /**
298  * Compute the nudging relaxation
299  *
300  * @param[in] delta_t time step
301  * @param[in] icomp component offset
302  * @param[in] num_var number of variables to loop
303  * @param[in] width width of wrf bdy file
304  * @param[in] set_width width the set region
305  * @param[in] dom_lo low bound of domain
306  * @param[in] dom_hi high bound of domain
307  * @param[in] F1 drift relaxation parameter
308  * @param[in] F2 Laplacian relaxation parameter
309  * @param[in] bx_xlo box for low x relaxation
310  * @param[in] bx_xhi box for high x relaxation
311  * @param[in] bx_ylo box for low y relaxation
312  * @param[in] bx_yhi box for high y relaxation
313  * @param[in] arr_xlo array for low x relaxation
314  * @param[in] arr_xhi array for high x relaxation
315  * @param[in] arr_ylo array for low y relaxation
316  * @param[in] arr_yhi array for high y relaxation
317  * @param[in] data_arr data array
318  * @param[out] rhs_arr RHS array
319  */
320 AMREX_GPU_HOST
321 AMREX_FORCE_INLINE
322 void
323 realbdy_compute_relaxation (const int& icomp,
324  const int& num_var,
325  const int& width,
326  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& dx,
327  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& ProbLo,
328  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM>& ProbHi,
329  const amrex::Real& F1,
330  const amrex::Box& domain_cc,
331  const amrex::Box& bx_xlo,
332  const amrex::Box& bx_xhi,
333  const amrex::Box& bx_ylo,
334  const amrex::Box& bx_yhi,
335  const amrex::Array4<const amrex::Real>& arr_xlo,
336  const amrex::Array4<const amrex::Real>& arr_xhi,
337  const amrex::Array4<const amrex::Real>& arr_ylo,
338  const amrex::Array4<const amrex::Real>& arr_yhi,
339  const amrex::Array4<const amrex::Real>& u_xlo,
340  const amrex::Array4<const amrex::Real>& u_xhi,
341  const amrex::Array4<const amrex::Real>& v_xlo,
342  const amrex::Array4<const amrex::Real>& v_xhi,
343  const amrex::Array4<const amrex::Real>& v_ylo,
344  const amrex::Array4<const amrex::Real>& v_yhi,
345  const amrex::Array4<const amrex::Real>& data_arr,
346  const amrex::Array4<amrex::Real>& rhs_arr,
347  const bool& do_upwind)
348 {
349  amrex::IntVect iv = bx_xlo.type();
350  amrex::Real ioff = (iv[0]==1) ? 0.0 : 0.5;
351  amrex::Real joff = (iv[1]==1) ? 0.0 : 0.5;
352  const auto& dom_cc_lo = lbound(domain_cc);
353  const auto& dom_cc_hi = ubound(domain_cc);
354  amrex::ParallelFor(bx_xlo, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
355  {
356  // Corners with x boxes
357  amrex::Real x = ProbLo[0] + (i + ioff) * dx[0];
358  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
359  amrex::Real x_end = ProbLo[0] + (width + ioff) * dx[0];
360  amrex::Real y_end = ProbLo[1] + (width + joff) * dx[1];
361  amrex::Real y_strt = ProbHi[1] - (width + joff) * dx[1];
362  amrex::Real xi = (x_end - x) / (x_end - ProbLo[0]);
363  amrex::Real eta_lo = (y < y_end ) ? (y_end - y) / (y_end - ProbLo[1]) : 0.0;
364  amrex::Real eta_hi = (y > y_strt) ? (y - y_strt) / (ProbHi[1] - y_strt) : 0.0;
365  amrex::Real eta = std::max(eta_lo,eta_hi);
366  amrex::Real Factor = std::max(xi*xi,eta*eta);
367 
368  amrex::Real delta = arr_xlo(i ,j ,k,n) - data_arr(i ,j ,k ,n+icomp);
369  amrex::Real Temp = Factor*F1*delta;
370  if (!do_upwind) {
371  rhs_arr(i,j,k,n+icomp) += Temp;
372  } else {
373  int jju = std::min(std::max(j,dom_cc_lo.y),dom_cc_hi.y);
374  int iiv = std::min(std::max(i,dom_cc_lo.x),dom_cc_hi.x);
375  if ( (u_xlo(dom_cc_lo.x,jju,k) >= 0.0) ||
376  ((j == dom_cc_lo.y ) && (v_xlo(iiv,dom_cc_lo.y ,k) >= 0.0)) ||
377  ((j == dom_cc_hi.y+iv[1]) && (v_xlo(iiv,dom_cc_hi.y+1,k) <= 0.0)) ) {
378  rhs_arr(i,j,k,n+icomp) += Temp;
379  }
380  }
381  },
382  bx_xhi, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
383  {
384  // Corners with x boxes
385  amrex::Real x = ProbLo[0] + (i + ioff) * dx[0];
386  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
387  amrex::Real x_strt = ProbHi[0] - (width + ioff) * dx[0];
388  amrex::Real y_strt = ProbHi[1] - (width + joff) * dx[1];
389  amrex::Real y_end = ProbLo[1] + (width + joff) * dx[1];
390  amrex::Real xi = (x - x_strt) / (ProbHi[0] - x_strt);
391  amrex::Real eta_lo = (y < y_end ) ? (y_end - y) / (y_end - ProbLo[1]) : 0.0;
392  amrex::Real eta_hi = (y > y_strt) ? (y - y_strt) / (ProbHi[1] - y_strt) : 0.0;
393  amrex::Real eta = std::max(eta_lo,eta_hi);
394  amrex::Real Factor = std::max(xi*xi,eta*eta);
395 
396  amrex::Real delta = arr_xhi(i ,j ,k,n) - data_arr(i ,j ,k ,n+icomp);
397  amrex::Real Temp = Factor*F1*delta;
398  if (!do_upwind) {
399  rhs_arr(i,j,k,n+icomp) += Temp;
400  } else {
401  int jju = std::min(std::max(j,dom_cc_lo.y),dom_cc_hi.y);
402  int iiv = std::min(std::max(i,dom_cc_lo.x),dom_cc_hi.x);
403  if ( (u_xhi(dom_cc_hi.x+1,jju,k) <= 0.0) ||
404  ((j == dom_cc_lo.y ) && (v_xhi(iiv,dom_cc_lo.y ,k) >= 0.0)) ||
405  ((j == dom_cc_hi.y+iv[1]) && (v_xhi(iiv,dom_cc_hi.y+1,k) <= 0.0)) ) {
406  rhs_arr(i,j,k,n+icomp) += Temp;
407  }
408  }
409  });
410 
411  amrex::ParallelFor(bx_ylo, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
412  {
413  // No corners for y boxes
414  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
415  amrex::Real y_end = ProbLo[1] + (width + joff) * dx[1];
416  amrex::Real eta = (y_end - y) / (y_end - ProbLo[1]);
417  amrex::Real Factor = eta*eta;
418 
419  amrex::Real delta = arr_ylo(i ,j ,k,n) - data_arr(i ,j ,k ,n+icomp);
420  amrex::Real Temp = Factor*F1*delta;
421  if (!do_upwind) {
422  rhs_arr(i,j,k,n+icomp) += Temp;
423  } else {
424  int iiv = std::min(std::max(i,dom_cc_lo.x+width),dom_cc_hi.x-width);
425  if (v_ylo(iiv,dom_cc_lo.y,k) >= 0.0) {
426  rhs_arr(i,j,k,n+icomp) += Temp;
427  }
428  }
429  },
430  bx_yhi, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
431  {
432  // No corners for y boxes
433  amrex::Real y = ProbLo[1] + (j + joff) * dx[1];
434  amrex::Real y_strt = ProbHi[1] - (width + joff) * dx[1];
435  amrex::Real eta = (y - y_strt) / (ProbHi[1] - y_strt);
436  amrex::Real Factor = eta*eta;
437 
438  amrex::Real delta = arr_yhi(i ,j ,k,n) - data_arr(i ,j ,k ,n+icomp);
439  amrex::Real Temp = Factor*F1*delta;
440  if (!do_upwind) {
441  rhs_arr(i,j,k,n+icomp) += Temp;
442  } else {
443  int iiv = std::min(std::max(i,dom_cc_lo.x+width),dom_cc_hi.x-width);
444  if (v_yhi(iiv,dom_cc_hi.y+1,k) >= 0.0) {
445  rhs_arr(i,j,k,n+icomp) += Temp;
446  }
447  }
448  });
449 }
450 
451 /*
452  * Effectively a Multiply for a MultiFab and an iMultiFab mask
453  */
454 AMREX_GPU_HOST
455 AMREX_FORCE_INLINE
456 void
457 ApplyMask (amrex::MultiFab& dst,
458  const amrex::iMultiFab& imask,
459  const int nghost = 0)
460 {
461  for (amrex::MFIter mfi(dst,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
462  {
463  const amrex::Box& bx = mfi.growntilebox(nghost);
464  if (bx.ok())
465  {
466  auto dstFab = dst.array(mfi);
467  const auto maskFab = imask.const_array(mfi);
468  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
469  {
470  dstFab(i,j,k) *= maskFab(i,j,k);
471  });
472  }
473  }
474 }
475 
476 AMREX_GPU_HOST
477 AMREX_FORCE_INLINE
478 void
479 ApplyInvertedMask (amrex::MultiFab& dst,
480  const amrex::iMultiFab& imask,
481  const int nghost = 0)
482 {
483  for (amrex::MFIter mfi(dst,amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
484  {
485  const amrex::Box& bx = mfi.growntilebox(nghost);
486  if (bx.ok())
487  {
488  auto dstFab = dst.array(mfi);
489  const auto maskFab = imask.const_array(mfi);
490  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
491  {
492  dstFab(i,j,k) *= (1-maskFab(i,j,k));
493  });
494  }
495  }
496 }
497 
498 void
499 thinbody_wall_dist (std::unique_ptr<amrex::MultiFab>& wdist,
500  amrex::Vector<amrex::IntVect>& xfaces,
501  amrex::Vector<amrex::IntVect>& yfaces,
502  amrex::Vector<amrex::IntVect>& zfaces,
503  const amrex::Geometry& geomdata,
504  std::unique_ptr<amrex::MultiFab>& z_phys_cc);
505 
506 
508 
509 AMREX_GPU_HOST_DEVICE
510 AMREX_FORCE_INLINE
514  amrex::Real z1, amrex::Real p1,
515  amrex::Real z2, amrex::Real p2)
516 {
517  return p0 * ( (z - z1) * (z - z2) ) / ( (z0 - z1) * (z0 - z2) )
518  + p1 * ( (z - z0) * (z - z2) ) / ( (z1 - z0) * (z1 - z2) )
519  + p2 * ( (z - z0) * (z - z1) ) / ( (z2 - z0) * (z2 - z1) );
520 }
521 
522 #endif
const auto & dom_hi
Definition: ERF_SetupVertDiff.H:2
const auto & dom_lo
Definition: ERF_SetupVertDiff.H:1
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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 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 WeatherDataInterpolation(const amrex::Real time)
void fine_compute_interior_ghost_rhs(const amrex::Real &time, const amrex::Real &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)
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 &domain_cc, 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 > &u_xlo, const amrex::Array4< const amrex::Real > &u_xhi, const amrex::Array4< const amrex::Real > &v_xlo, const amrex::Array4< const amrex::Real > &v_xhi, const amrex::Array4< const amrex::Real > &v_ylo, const amrex::Array4< const amrex::Real > &v_yhi, const amrex::Array4< const amrex::Real > &data_arr, const amrex::Array4< amrex::Real > &rhs_arr, const bool &do_upwind)
Definition: ERF_Utils.H:323
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real quad_interp_1d(amrex::Real z, amrex::Real z0, amrex::Real p0, amrex::Real z1, amrex::Real p1, amrex::Real z2, amrex::Real p2)
Definition: ERF_Utils.H:512
AMREX_GPU_HOST AMREX_FORCE_INLINE void realbdy_set_rhs_in_spec_region(const amrex::Real &dt, const int &icomp, const int &num_var, const int &width, const int &set_width_x, const int &set_width_y, const amrex::Box &domain, const amrex::Box &domain_cc, 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 > &u_xlo, const amrex::Array4< const amrex::Real > &u_xhi, const amrex::Array4< const amrex::Real > &v_xlo, const amrex::Array4< const amrex::Real > &v_xhi, const amrex::Array4< const amrex::Real > &v_ylo, const amrex::Array4< const amrex::Real > &v_yhi, const amrex::Array4< const amrex::Real > &data_arr, const amrex::Array4< amrex::Real > &rhs_arr, const bool &do_upwind)
Definition: ERF_Utils.H:183
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)
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 int &set_width=0, const amrex::IntVect &ng_vect=amrex::IntVect(0, 0, 0), const bool get_int_ng=false)
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(const amrex::Real &dt, amrex::Real &t_avg_cnt, amrex::MultiFab *vel_t_avg, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::MultiFab &zvel)
AMREX_GPU_HOST AMREX_FORCE_INLINE void ApplyInvertedMask(amrex::MultiFab &dst, const amrex::iMultiFab &imask, const int nghost=0)
Definition: ERF_Utils.H:479
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:457
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 realbdy_compute_interior_ghost_rhs(const amrex::Real &bdy_time_interval, const amrex::Real &time, const amrex::Real &delta_t, const amrex::Real &stop_time_elapsed, int width, int set_width, bool do_upwind, const amrex::Geometry &geom, amrex::Vector< amrex::MultiFab > &S_rhs, amrex::Vector< amrex::MultiFab > &S_old_data, 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)
void enforceInOutSolvability(int lev, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &vels_vec, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > &area_vec, const amrex::Geometry &geom)
void make_areas(const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &ax, amrex::MultiFab &ay, amrex::MultiFab &az)
Definition: ERF_FillPatcher.H:9
@ ymom
Definition: ERF_IndexDefines.H:160
@ zmom
Definition: ERF_IndexDefines.H:161
@ xmom
Definition: ERF_IndexDefines.H:159
@ xvel
Definition: ERF_IndexDefines.H:141
@ zvel
Definition: ERF_IndexDefines.H:143
@ yvel
Definition: ERF_IndexDefines.H:142
real(c_double), parameter p0
Definition: ERF_module_model_constants.F90:40