ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PhysBCFunct.H
Go to the documentation of this file.
1 #ifndef ERF_PhysBCFunct_H_
2 #define ERF_PhysBCFunct_H_
3 
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_BCRec.H>
7 #include <AMReX_Geometry.H>
8 #include <AMReX_MultiFab.H>
9 #include <AMReX_ArrayLim.H>
10 #include <AMReX_FilCC_C.H>
11 #include <AMReX_FilND_C.H>
12 #include <AMReX_FilFC_C.H>
13 #include "AMReX_TypeTraits.H"
14 #include "AMReX_Orientation.H"
15 
16 #include <ERF_ReadBndryPlanes.H>
18 #include <ERF_IndexDefines.H>
19 #include <ERF_DataStruct.H>
20 #include <ERF_EddyViscosity.H>
21 #include <ERF_TerrainMetrics.H>
22 
23 /**
24  * Make the ghost cells below the bottom of the domain agree between boxes.
25  *
26  * On a terrain-fitted mesh the zero-gradient condition at the bottom is corrected
27  * by the slope of the terrain times the lateral gradient of the variable at the
28  * first cell (impose_vertical_*_bcs). Each box computes that for its own ghost
29  * cells, and in the outermost ring of its lateral ghost cells the gradient can
30  * only be one-sided, so the same ghost cell below the ground holds different
31  * values in different boxes. The fill of a finer level copies ghost cells of
32  * this level, taking whichever box's copy it meets, so the finer level then
33  * depends on the box decomposition.
34  *
35  * This replaces every ghost cell below the domain with the value computed by the
36  * box whose valid columns contain it (or, outside the domain laterally, the box
37  * at that boundary), where the lateral stencil is always centred. Values in the
38  * owning box are unchanged. The layout of the owning slabs is cached.
39  */
41 {
42  void operator() (amrex::MultiFab& mf, int icomp, int ncomp,
43  const amrex::IntVect& nghost, const amrex::Geometry& geom);
44 
45 private:
46  amrex::BoxArray m_src_ba;
47  amrex::DistributionMapping m_src_dm;
48  amrex::IntVect m_nghost;
49  amrex::BoxArray m_slab_ba;
50  amrex::DistributionMapping m_slab_dm;
51  amrex::Vector<int> m_src_index; // the box of mf each slab lies under
52 };
53 
55 {
56 public:
57  /**
58  * Construct the conserved-variable physical boundary-condition functor.
59  *
60  * @param[in] lev level index
61  * @param[in] geom geometry for the level
62  * @param[in] domain_bcs_type host boundary-condition records
63  * @param[in] domain_bcs_type_d device boundary-condition records
64  * @param[in] bc_extdir_vals external Dirichlet values for boundary faces
65  * @param[in] bc_neumann_vals Neumann values for boundary faces
66  * @param[in] terrain_type terrain type for the level
67  * @param[in] z_phys_nd nodal physical height MultiFab
68  * @param[in] use_real_bcs whether real-data boundary conditions are active
69  * @param[in] th_bc_data optional theta boundary data (one profile in z)
70  * @param[in] th_file_face per face: 0 the face's theta is not th_bc_data, 1 th_bc_data
71  * holds rho*theta for that face, 2 it holds theta
72  */
73  ERFPhysBCFunct_cons (const int lev,
74  const amrex::Geometry& geom, const amrex::Vector<amrex::BCRec>& domain_bcs_type,
75  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
76  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_extdir_vals,
77  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_neumann_vals,
78  const TerrainType& terrain_type,
79  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
80  const bool use_real_bcs,
81  amrex::Real* th_bc_data,
82  const amrex::Array<int,AMREX_SPACEDIM*2>& th_file_face)
83  : m_lev(lev), m_geom(geom),
84  m_domain_bcs_type(domain_bcs_type),
85  m_domain_bcs_type_d(domain_bcs_type_d),
86  m_bc_extdir_vals(bc_extdir_vals),
87  m_bc_neumann_vals(bc_neumann_vals),
88  m_terrain_type(terrain_type),
89  m_z_phys_nd(z_phys_nd.get()),
90  m_use_real_bcs(use_real_bcs),
91  m_th_bc_data(th_bc_data)
92  {
93  for (int ori = 0; ori < 2*AMREX_SPACEDIM; ++ori) { m_th_file_face[ori] = th_file_face[ori]; }
94  }
95 
96  /**
97  * Destroy the conserved-variable physical boundary-condition functor.
98  */
100 
101  /**
102  * Impose physical boundary conditions at domain boundaries
103  *
104  * @param[in,out] mf conserved-variable MultiFab to be filled
105  * @param[in] xvel x-velocity MultiFab used by upwind boundary conditions
106  * @param[in] yvel y-velocity MultiFab used by upwind boundary conditions
107  * @param[in] icomp starting component for conserved variables
108  * @param[in] ncomp number of components for conserved variables
109  * @param[in] nghost number of ghost cells to be filled for conserved variables
110  * @param[in] time time at which the data should be filled
111  * @param[in] bccomp_cons index into m_domain_bcs_type for conserved variables
112  * @param[in] do_fb whether to fill periodic/interior ghost cells first
113  * @param[in] do_terrain_adjustment whether to apply terrain-aware Neumann adjustments
114  */
115  void operator() (amrex::MultiFab& mf, amrex::MultiFab& xvel, amrex::MultiFab& yvel,
116  int icomp, int ncomp, amrex::IntVect const& nghost,
117  const double time, int bccomp_cons, bool do_fb = true, bool do_terrain_adjustment = true);
118 
119  /**
120  * Impose lateral boundary conditions on conserved variables.
121  *
122  * @param[in,out] dest_arr cell-centered data to be filled
123  * @param[in] xvel_arr x-velocity used to determine upwind inflow
124  * @param[in] yvel_arr y-velocity used to determine upwind inflow
125  * @param[in] bx box holding data to be filled
126  * @param[in] domain simulation domain
127  * @param[in] icomp starting component
128  * @param[in] ncomp number of components
129  * @param[in] ng number of ghost cells
130  * @param[in] time time at which data should be filled
131  */
132  void impose_lateral_cons_bcs (const amrex::Array4<amrex::Real>& dest_arr,
133  const amrex::Array4<amrex::Real const>& xvel_arr,
134  const amrex::Array4<amrex::Real const>& yvel_arr,
135  const amrex::Box& bx, const amrex::Box& domain,
136  int icomp, int ncomp, amrex::IntVect ng,
137  const double time);
138 
139  /**
140  * Impose vertical boundary conditions on conserved variables.
141  *
142  * @param[in,out] dest_arr cell-centered data to be filled
143  * @param[in] bx box holding data to be filled
144  * @param[in] domain simulation domain
145  * @param[in] z_nd nodal physical height
146  * @param[in] dxInv inverse cell size
147  * @param[in] icomp starting component
148  * @param[in] ncomp number of components
149  * @param[in] time time at which data should be filled
150  * @param[in] do_terrain_adjustment whether to apply terrain-aware Neumann adjustments
151  */
152  void impose_vertical_cons_bcs (const amrex::Array4<amrex::Real>& dest_arr,
153  const amrex::Box& bx, const amrex::Box& domain,
154  const amrex::Array4<amrex::Real const>& z_nd,
155  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> dxInv,
156  int icomp, int ncomp, const double time,
157  bool do_terrain_adjustment = true);
158 
159 private:
160  int m_lev;
161  amrex::Geometry m_geom;
162  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
163  amrex::Gpu::DeviceVector<amrex::BCRec> m_domain_bcs_type_d;
164  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
165  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
166  TerrainType m_terrain_type;
167  amrex::MultiFab* m_z_phys_nd;
170  amrex::GpuArray<int,AMREX_SPACEDIM*2> m_th_file_face;
172 };
173 
175 {
176 public:
177  /**
178  * Construct the x-velocity physical boundary-condition functor.
179  *
180  * @param[in] lev level index
181  * @param[in] geom geometry for the level
182  * @param[in] domain_bcs_type host boundary-condition records
183  * @param[in] domain_bcs_type_d device boundary-condition records
184  * @param[in] bc_extdir_vals external Dirichlet values for boundary faces
185  * @param[in] bc_neumann_vals Neumann values for boundary faces
186  * @param[in] terrain_type terrain type for the level
187  * @param[in] z_phys_nd nodal physical height MultiFab
188  * @param[in] use_real_bcs whether real-data boundary conditions are active
189  * @param[in] u_bc_data optional x-velocity boundary data
190  */
191  ERFPhysBCFunct_u (const int lev, const amrex::Geometry& geom,
192  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
193  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
194  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_extdir_vals,
195  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_neumann_vals,
196  const TerrainType& terrain_type,
197  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
198  const bool use_real_bcs,
199  amrex::Real* u_bc_data)
200  : m_lev(lev), m_geom(geom),
201  m_domain_bcs_type(domain_bcs_type),
202  m_domain_bcs_type_d(domain_bcs_type_d),
203  m_bc_extdir_vals(bc_extdir_vals),
204  m_bc_neumann_vals(bc_neumann_vals),
205  m_terrain_type(terrain_type),
206  m_z_phys_nd(z_phys_nd.get()),
207  m_use_real_bcs(use_real_bcs),
208  m_u_bc_data(u_bc_data)
209  { }
210 
211  /**
212  * Destroy the x-velocity physical boundary-condition functor.
213  */
215 
216  /**
217  * Impose physical boundary conditions at domain boundaries
218  *
219  * @param[in,out] mf x-velocity MultiFab to be filled
220  * @param[in] xvel x-velocity MultiFab used by upwind boundary conditions
221  * @param[in] yvel y-velocity MultiFab used by upwind boundary conditions
222  * @param[in] nghost number of ghost cells to be filled for velocity components
223  * @param[in] time time at which the data should be filled
224  * @param[in] bccomp index into m_domain_bcs_type
225  * @param[in] do_fb whether to fill periodic/interior ghost cells first
226  */
227  void operator() (amrex::MultiFab& mf, amrex::MultiFab& xvel, amrex::MultiFab& yvel,
228  amrex::IntVect const& nghost, const double time, int bccomp, bool do_fb);
229 
230  /**
231  * Impose lateral boundary conditions on x velocity.
232  *
233  * @param[in,out] dest_arr x-velocity data to be filled
234  * @param[in] xvel_arr x-velocity used to determine upwind inflow
235  * @param[in] yvel_arr y-velocity used to determine upwind inflow
236  * @param[in] bx box holding data to be filled
237  * @param[in] domain simulation domain
238  * @param[in] bccomp boundary-condition component
239  * @param[in] time time at which data should be filled
240  */
241  void impose_lateral_xvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
242  const amrex::Array4<amrex::Real const>& xvel_arr,
243  const amrex::Array4<amrex::Real const>& yvel_arr,
244  const amrex::Box& bx, const amrex::Box& domain,
245  int bccomp,
246  const double time);
247 
248  /**
249  * Impose vertical boundary conditions on x velocity.
250  *
251  * @param[in,out] dest_arr x-velocity data to be filled
252  * @param[in] bx box holding data to be filled
253  * @param[in] domain simulation domain
254  * @param[in] z_nd nodal physical height
255  * @param[in] dxInv inverse cell size
256  * @param[in] bccomp boundary-condition component
257  * @param[in] time time at which data should be filled
258  */
259  void impose_vertical_xvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
260  const amrex::Box& bx, const amrex::Box& domain,
261  const amrex::Array4<amrex::Real const>& z_nd,
262  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> dxInv,
263  int bccomp,
264  const double time);
265 
266 private:
267  int m_lev;
268  amrex::Geometry m_geom;
269  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
270  amrex::Gpu::DeviceVector<amrex::BCRec> m_domain_bcs_type_d;
271  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
272  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
273  TerrainType m_terrain_type;
274  amrex::MultiFab* m_z_phys_nd;
278 };
279 
281 {
282 public:
283  /**
284  * Construct the y-velocity physical boundary-condition functor.
285  *
286  * @param[in] lev level index
287  * @param[in] geom geometry for the level
288  * @param[in] domain_bcs_type host boundary-condition records
289  * @param[in] domain_bcs_type_d device boundary-condition records
290  * @param[in] bc_extdir_vals external Dirichlet values for boundary faces
291  * @param[in] bc_neumann_vals Neumann values for boundary faces
292  * @param[in] terrain_type terrain type for the level
293  * @param[in] z_phys_nd nodal physical height MultiFab
294  * @param[in] use_real_bcs whether real-data boundary conditions are active
295  * @param[in] v_bc_data optional y-velocity boundary data
296  */
297  ERFPhysBCFunct_v (const int lev, const amrex::Geometry& geom,
298  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
299  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
300  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_extdir_vals,
301  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_neumann_vals,
302  const TerrainType& terrain_type,
303  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
304  const bool use_real_bcs,
305  amrex::Real* v_bc_data)
306  : m_lev(lev),
307  m_geom(geom), m_domain_bcs_type(domain_bcs_type),
308  m_domain_bcs_type_d(domain_bcs_type_d),
309  m_bc_extdir_vals(bc_extdir_vals),
310  m_bc_neumann_vals(bc_neumann_vals),
311  m_terrain_type(terrain_type),
312  m_z_phys_nd(z_phys_nd.get()),
313  m_use_real_bcs(use_real_bcs),
314  m_v_bc_data(v_bc_data)
315  { }
316 
317  /**
318  * Destroy the y-velocity physical boundary-condition functor.
319  */
321 
322  /**
323  * Impose physical boundary conditions at domain boundaries
324  *
325  * @param[in,out] mf y-velocity MultiFab to be filled
326  * @param[in] xvel x-velocity MultiFab used by upwind boundary conditions
327  * @param[in] yvel y-velocity MultiFab used by upwind boundary conditions
328  * @param[in] nghost number of ghost cells to be filled for velocity components
329  * @param[in] time time at which the data should be filled
330  * @param[in] bccomp index into m_domain_bcs_type
331  * @param[in] do_fb whether to fill periodic/interior ghost cells first
332  */
333  void operator() (amrex::MultiFab& mf, amrex::MultiFab& xvel, amrex::MultiFab& yvel,
334  amrex::IntVect const& nghost, const double time, int bccomp, bool do_fb);
335 
336  /**
337  * Impose lateral boundary conditions on y velocity.
338  *
339  * @param[in,out] dest_arr y-velocity data to be filled
340  * @param[in] xvel_arr x-velocity used to determine upwind inflow
341  * @param[in] yvel_arr y-velocity used to determine upwind inflow
342  * @param[in] bx box holding data to be filled
343  * @param[in] domain simulation domain
344  * @param[in] bccomp boundary-condition component
345  * @param[in] time time at which data should be filled
346  */
347  void impose_lateral_yvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
348  const amrex::Array4<amrex::Real const>& xvel_arr,
349  const amrex::Array4<amrex::Real const>& yvel_arr,
350  const amrex::Box& bx, const amrex::Box& domain,
351  int bccomp,
352  const double time);
353 
354  /**
355  * Impose vertical boundary conditions on y velocity.
356  *
357  * @param[in,out] dest_arr y-velocity data to be filled
358  * @param[in] bx box holding data to be filled
359  * @param[in] domain simulation domain
360  * @param[in] z_nd nodal physical height
361  * @param[in] dxInv inverse cell size
362  * @param[in] bccomp boundary-condition component
363  * @param[in] time time at which data should be filled
364  */
365  void impose_vertical_yvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
366  const amrex::Box& bx, const amrex::Box& domain,
367  const amrex::Array4<amrex::Real const>& z_nd,
368  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> dxInv,
369  int bccomp,
370  const double time);
371 
372 private:
373  int m_lev;
374  amrex::Geometry m_geom;
375  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
376  amrex::Gpu::DeviceVector<amrex::BCRec> m_domain_bcs_type_d;
377  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
378  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
379  TerrainType m_terrain_type;
380  amrex::MultiFab* m_z_phys_nd;
384 };
385 
387 {
388 public:
389  /**
390  * Construct the z-velocity physical boundary-condition functor.
391  *
392  * @param[in] lev level index
393  * @param[in] geom geometry for the level
394  * @param[in] domain_bcs_type host boundary-condition records
395  * @param[in] domain_bcs_type_d device boundary-condition records
396  * @param[in] bc_extdir_vals external Dirichlet values for boundary faces
397  * @param[in] bc_neumann_vals Neumann values for boundary faces
398  * @param[in] terrain_type terrain type for the level
399  * @param[in] mapfac_lev map-factor MultiFabs for the level
400  * @param[in] z_phys_nd nodal physical height MultiFab
401  * @param[in] use_real_bcs whether real-data boundary conditions are active
402  * @param[in] w_bc_data optional z-velocity boundary data
403  */
404  ERFPhysBCFunct_w (const int lev, const amrex::Geometry& geom,
405  const amrex::Vector<amrex::BCRec>& domain_bcs_type,
406  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
407  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_extdir_vals,
408  amrex::Array<amrex::Array<amrex::Real,AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> bc_neumann_vals,
409  const TerrainType& terrain_type,
410  amrex::Vector<std::unique_ptr<amrex::MultiFab>>& mapfac_lev,
411  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
412  const bool use_real_bcs,
413  amrex::Real* w_bc_data)
414  : m_lev(lev),
415  m_geom(geom), m_domain_bcs_type(domain_bcs_type),
416  m_domain_bcs_type_d(domain_bcs_type_d),
417  m_bc_extdir_vals(bc_extdir_vals),
418  m_bc_neumann_vals(bc_neumann_vals),
419  m_terrain_type(terrain_type),
420  m_z_phys_nd(z_phys_nd.get()),
421  m_use_real_bcs(use_real_bcs),
422  m_w_bc_data(w_bc_data)
423  {
424  m_mapfac_u = mapfac_lev[MapFacType::u_x].get();
425  m_mapfac_v = mapfac_lev[MapFacType::v_y].get();
426  }
427 
428  /**
429  * Destroy the z-velocity physical boundary-condition functor.
430  */
432 
433  /**
434  * Impose physical boundary conditions at domain boundaries
435  *
436  * @param[in,out] mf z-velocity MultiFab to be filled
437  * @param[in] xvel x-velocity MultiFab used by upwind boundary conditions
438  * @param[in] yvel y-velocity MultiFab used by upwind boundary conditions
439  * @param[in] nghost number of ghost cells to be filled for velocity components
440  * @param[in] time time at which the data should be filled
441  * @param[in] bccomp index into m_domain_bcs_type for z velocity
442  * @param[in] do_fb whether to fill periodic/interior ghost cells first
443  */
444  void operator() (amrex::MultiFab& mf, amrex::MultiFab& xvel, amrex::MultiFab& yvel,
445  amrex::IntVect const& nghost, const double time, int bccomp,
446  bool do_fb);
447 
448  /**
449  * Impose lateral boundary conditions on z velocity.
450  *
451  * @param[in,out] dest_arr z-velocity data to be filled
452  * @param[in] xvel_arr x-velocity used to determine upwind inflow
453  * @param[in] yvel_arr y-velocity used to determine upwind inflow
454  * @param[in] bx box holding data to be filled
455  * @param[in] domain simulation domain
456  * @param[in] mf_u x map-factor field
457  * @param[in] mf_v y map-factor field
458  * @param[in] z_nd nodal physical height
459  * @param[in] dxInv inverse cell size
460  * @param[in] terrain_type terrain representation
461  * @param[in] bccomp boundary-condition component
462  * @param[in] time time at which data should be filled
463  */
464  void impose_lateral_zvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
465  const amrex::Array4<amrex::Real const>& xvel_arr,
466  const amrex::Array4<amrex::Real const>& yvel_arr,
467  const amrex::Box& bx, const amrex::Box& domain,
468  const amrex::Array4<amrex::Real const>& mf_u,
469  const amrex::Array4<amrex::Real const>& mf_v,
470  const amrex::Array4<amrex::Real const>& z_nd,
471  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> dxInv,
472  TerrainType terrain_type, int bccomp,
473  const double time);
474 
475  /**
476  * Impose vertical boundary conditions on z velocity.
477  *
478  * @param[in,out] dest_arr z-velocity data to be filled
479  * @param[in] xvel_arr x-velocity used by terrain-aware vertical BCs
480  * @param[in] yvel_arr y-velocity used by terrain-aware vertical BCs
481  * @param[in] bx box holding data to be filled
482  * @param[in] domain simulation domain
483  * @param[in] mf_u x map-factor field
484  * @param[in] mf_v y map-factor field
485  * @param[in] z_nd nodal physical height
486  * @param[in] dxInv inverse cell size
487  * @param[in] bccomp_u x-velocity boundary-condition component
488  * @param[in] bccomp_v y-velocity boundary-condition component
489  * @param[in] bccomp_w z-velocity boundary-condition component
490  * @param[in] terrain_type terrain representation
491  * @param[in] time time at which data should be filled
492  */
493  void impose_vertical_zvel_bcs (const amrex::Array4<amrex::Real>& dest_arr,
494  const amrex::Array4<amrex::Real const>& xvel_arr,
495  const amrex::Array4<amrex::Real const>& yvel_arr,
496  const amrex::Box& bx, const amrex::Box& domain,
497  const amrex::Array4<amrex::Real const>& mf_u,
498  const amrex::Array4<amrex::Real const>& mf_v,
499  const amrex::Array4<amrex::Real const>& z_nd,
500  const amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> dxInv,
501  int bccomp_u, int bccomp_v, int bccomp_w,
502  TerrainType terrain_type,
503  const double time);
504 
505 private:
506  int m_lev;
507  amrex::Geometry m_geom;
508  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
509  amrex::Gpu::DeviceVector<amrex::BCRec> m_domain_bcs_type_d;
510  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals;
511  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> m_bc_neumann_vals;
512  TerrainType m_terrain_type;
513  amrex::MultiFab* m_mapfac_u;
514  amrex::MultiFab* m_mapfac_v;
515  amrex::MultiFab* m_z_phys_nd;
518 };
519 
521 {
522 public:
523  /**
524  * Construct the base-state physical boundary-condition functor.
525  *
526  * @param[in] lev level index
527  * @param[in] geom geometry for the level
528  * @param[in] domain_bcs_type host boundary-condition records
529  * @param[in] domain_bcs_type_d device boundary-condition records
530  * @param[in] z_phys_nd nodal physical height MultiFab
531  * @param[in] moving_terrain whether moving terrain is active
532  * @param[in] use_terrain whether the mesh is terrain-fitted, so that the cell-centered
533  * height of a lateral ghost cell differs from that of the cell it copies from
534  * @param[in] rdOcp ratio of R_d to c_p, used to close the EOS in the ghost cells
535  * @param[in] gravity magnitude of gravity, used to transfer the base state in height
536  */
537  ERFPhysBCFunct_base (const int lev,
538  const amrex::Geometry& geom, const amrex::Vector<amrex::BCRec>& domain_bcs_type,
539  const amrex::Gpu::DeviceVector<amrex::BCRec>& domain_bcs_type_d,
540  std::unique_ptr<amrex::MultiFab>& z_phys_nd,
541  bool moving_terrain,
542  bool use_terrain,
544  amrex::Real gravity)
545  : m_lev(lev), m_geom(geom),
546  m_moving_terrain(moving_terrain),
548  m_rdOcp(rdOcp),
549  m_gravity(gravity),
550  m_domain_bcs_type(domain_bcs_type),
551  m_domain_bcs_type_d(domain_bcs_type_d),
552  m_z_phys_nd(z_phys_nd.get())
553  {}
554 
555  /**
556  * Destroy the base-state physical boundary-condition functor.
557  */
559 
560  /**
561  * Impose physical boundary conditions at domain boundaries
562  *
563  * @param[in,out] mf base-state MultiFab to be filled
564  * @param[in] icomp starting component for base-state variables
565  * @param[in] ncomp number of components for base-state variables
566  * @param[in] nghost number of ghost cells to be filled
567  */
568  void operator() (amrex::MultiFab& mf, int icomp, int ncomp, amrex::IntVect const& nghost);
569 
570  /**
571  * Impose lateral boundary conditions on base-state variables.
572  *
573  * @param[in,out] dest_arr base-state data to be filled
574  * @param[in] z_nd nodal physical height
575  * @param[in] bx box holding data to be filled
576  * @param[in] domain simulation domain
577  * @param[in] ncomp number of components
578  * @param[in] nghost number of ghost cells to be filled
579  */
580  void impose_lateral_basestate_bcs (const amrex::Array4<amrex::Real>& dest_arr,
581  const amrex::Array4<amrex::Real const>& z_nd,
582  const amrex::Box& bx, const amrex::Box& domain,
583  int ncomp, const amrex::IntVect& nghost);
584 
585  /**
586  * Impose vertical boundary conditions on base-state variables.
587  *
588  * @param[in,out] dest_arr base-state data to be filled
589  * @param[in] z_nd nodal physical height
590  * @param[in] bx box holding data to be filled
591  * @param[in] domain simulation domain
592  * @param[in] ncomp number of components
593  * @param[in] nghost number of ghost cells to be filled
594  */
595  void impose_vertical_basestate_bcs (const amrex::Array4<amrex::Real>& dest_arr,
596  const amrex::Array4<amrex::Real const>& z_nd,
597  const amrex::Box& bx, const amrex::Box& domain,
598  int ncomp, const amrex::IntVect& nghost);
599 
600 private:
601  int m_lev;
602  amrex::Geometry m_geom;
607  amrex::Vector<amrex::BCRec> m_domain_bcs_type;
608  amrex::Gpu::DeviceVector<amrex::BCRec> m_domain_bcs_type_d;
609  amrex::MultiFab* m_z_phys_nd;
610 };
611 
612 #endif
@ v_y
Definition: ERF_DataStruct.H:38
@ u_x
Definition: ERF_DataStruct.H:37
#define NBCVAR_max
Definition: ERF_IndexDefines.H:32
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:72
pp get("wavelength", wavelength)
const bool use_terrain
Definition: ERF_InitCustomPert_SLM.H:14
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_PhysBCFunct.H:521
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:608
amrex::Real m_rdOcp
Definition: ERF_PhysBCFunct.H:605
bool m_use_terrain
Definition: ERF_PhysBCFunct.H:604
void impose_vertical_basestate_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &z_nd, const amrex::Box &bx, const amrex::Box &domain, int ncomp, const amrex::IntVect &nghost)
Definition: ERF_BoundaryConditionsBaseState.cpp:380
int m_lev
Definition: ERF_PhysBCFunct.H:601
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:609
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:602
ERFPhysBCFunct_base(const int lev, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, std::unique_ptr< amrex::MultiFab > &z_phys_nd, bool moving_terrain, bool use_terrain, amrex::Real rdOcp, amrex::Real gravity)
Definition: ERF_PhysBCFunct.H:537
bool m_moving_terrain
Definition: ERF_PhysBCFunct.H:603
amrex::Real m_gravity
Definition: ERF_PhysBCFunct.H:606
void impose_lateral_basestate_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &z_nd, const amrex::Box &bx, const amrex::Box &domain, int ncomp, const amrex::IntVect &nghost)
Definition: ERF_BoundaryConditionsBaseState.cpp:20
void operator()(amrex::MultiFab &mf, int icomp, int ncomp, amrex::IntVect const &nghost)
Definition: ERF_PhysBCFunct.cpp:449
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:607
~ERFPhysBCFunct_base()
Definition: ERF_PhysBCFunct.H:558
Definition: ERF_PhysBCFunct.H:55
bool m_use_real_bcs
Definition: ERF_PhysBCFunct.H:168
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:161
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF_PhysBCFunct.H:164
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF_PhysBCFunct.H:165
void operator()(amrex::MultiFab &mf, amrex::MultiFab &xvel, amrex::MultiFab &yvel, int icomp, int ncomp, amrex::IntVect const &nghost, const double time, int bccomp_cons, bool do_fb=true, bool do_terrain_adjustment=true)
Definition: ERF_PhysBCFunct.cpp:87
void impose_vertical_cons_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, int icomp, int ncomp, const double time, bool do_terrain_adjustment=true)
Definition: ERF_BoundaryConditionsCons.cpp:397
void impose_lateral_cons_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, int icomp, int ncomp, amrex::IntVect ng, const double time)
Definition: ERF_BoundaryConditionsCons.cpp:22
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:163
BelowGroundGhostSync m_below_ground_sync
Definition: ERF_PhysBCFunct.H:171
ERFPhysBCFunct_cons(const int lev, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_extdir_vals, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_neumann_vals, const TerrainType &terrain_type, std::unique_ptr< amrex::MultiFab > &z_phys_nd, const bool use_real_bcs, amrex::Real *th_bc_data, const amrex::Array< int, AMREX_SPACEDIM *2 > &th_file_face)
Definition: ERF_PhysBCFunct.H:73
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:162
~ERFPhysBCFunct_cons()
Definition: ERF_PhysBCFunct.H:99
TerrainType m_terrain_type
Definition: ERF_PhysBCFunct.H:166
amrex::Real * m_th_bc_data
Definition: ERF_PhysBCFunct.H:169
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:167
int m_lev
Definition: ERF_PhysBCFunct.H:160
amrex::GpuArray< int, AMREX_SPACEDIM *2 > m_th_file_face
Definition: ERF_PhysBCFunct.H:170
Definition: ERF_PhysBCFunct.H:175
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:268
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF_PhysBCFunct.H:271
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:270
bool m_use_real_bcs
Definition: ERF_PhysBCFunct.H:275
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF_PhysBCFunct.H:272
amrex::Real * m_u_bc_data
Definition: ERF_PhysBCFunct.H:276
void impose_vertical_xvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, int bccomp, const double time)
Definition: ERF_BoundaryConditionsXvel.cpp:213
int m_lev
Definition: ERF_PhysBCFunct.H:267
void impose_lateral_xvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, int bccomp, const double time)
Definition: ERF_BoundaryConditionsXvel.cpp:18
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:269
ERFPhysBCFunct_u(const int lev, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_extdir_vals, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_neumann_vals, const TerrainType &terrain_type, std::unique_ptr< amrex::MultiFab > &z_phys_nd, const bool use_real_bcs, amrex::Real *u_bc_data)
Definition: ERF_PhysBCFunct.H:191
void operator()(amrex::MultiFab &mf, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::IntVect const &nghost, const double time, int bccomp, bool do_fb)
Definition: ERF_PhysBCFunct.cpp:177
~ERFPhysBCFunct_u()
Definition: ERF_PhysBCFunct.H:214
BelowGroundGhostSync m_below_ground_sync
Definition: ERF_PhysBCFunct.H:277
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:274
TerrainType m_terrain_type
Definition: ERF_PhysBCFunct.H:273
Definition: ERF_PhysBCFunct.H:281
void impose_lateral_yvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, int bccomp, const double time)
Definition: ERF_BoundaryConditionsYvel.cpp:17
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:374
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:376
void operator()(amrex::MultiFab &mf, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::IntVect const &nghost, const double time, int bccomp, bool do_fb)
Definition: ERF_PhysBCFunct.cpp:265
amrex::Real * m_v_bc_data
Definition: ERF_PhysBCFunct.H:382
int m_lev
Definition: ERF_PhysBCFunct.H:373
~ERFPhysBCFunct_v()
Definition: ERF_PhysBCFunct.H:320
TerrainType m_terrain_type
Definition: ERF_PhysBCFunct.H:379
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF_PhysBCFunct.H:378
void impose_vertical_yvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, int bccomp, const double time)
Definition: ERF_BoundaryConditionsYvel.cpp:213
ERFPhysBCFunct_v(const int lev, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_extdir_vals, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_neumann_vals, const TerrainType &terrain_type, std::unique_ptr< amrex::MultiFab > &z_phys_nd, const bool use_real_bcs, amrex::Real *v_bc_data)
Definition: ERF_PhysBCFunct.H:297
bool m_use_real_bcs
Definition: ERF_PhysBCFunct.H:381
BelowGroundGhostSync m_below_ground_sync
Definition: ERF_PhysBCFunct.H:383
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:375
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF_PhysBCFunct.H:377
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:380
Definition: ERF_PhysBCFunct.H:387
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:508
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:507
int m_lev
Definition: ERF_PhysBCFunct.H:506
amrex::Real * m_w_bc_data
Definition: ERF_PhysBCFunct.H:517
bool m_use_real_bcs
Definition: ERF_PhysBCFunct.H:516
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:509
amrex::MultiFab * m_mapfac_v
Definition: ERF_PhysBCFunct.H:514
TerrainType m_terrain_type
Definition: ERF_PhysBCFunct.H:512
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:515
amrex::MultiFab * m_mapfac_u
Definition: ERF_PhysBCFunct.H:513
void operator()(amrex::MultiFab &mf, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::IntVect const &nghost, const double time, int bccomp, bool do_fb)
Definition: ERF_PhysBCFunct.cpp:354
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF_PhysBCFunct.H:511
ERFPhysBCFunct_w(const int lev, const amrex::Geometry &geom, const amrex::Vector< amrex::BCRec > &domain_bcs_type, const amrex::Gpu::DeviceVector< amrex::BCRec > &domain_bcs_type_d, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_extdir_vals, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > bc_neumann_vals, const TerrainType &terrain_type, amrex::Vector< std::unique_ptr< amrex::MultiFab >> &mapfac_lev, std::unique_ptr< amrex::MultiFab > &z_phys_nd, const bool use_real_bcs, amrex::Real *w_bc_data)
Definition: ERF_PhysBCFunct.H:404
~ERFPhysBCFunct_w()
Definition: ERF_PhysBCFunct.H:431
void impose_vertical_zvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &mf_u, const amrex::Array4< amrex::Real const > &mf_v, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, int bccomp_u, int bccomp_v, int bccomp_w, TerrainType terrain_type, const double time)
Definition: ERF_BoundaryConditionsZvel.cpp:210
void impose_lateral_zvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &mf_u, const amrex::Array4< amrex::Real const > &mf_v, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, TerrainType terrain_type, int bccomp, const double time)
Definition: ERF_BoundaryConditionsZvel.cpp:23
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF_PhysBCFunct.H:510
@ ng
Definition: ERF_Morrison.H:50
@ xvel
Definition: ERF_IndexDefines.H:218
@ yvel
Definition: ERF_IndexDefines.H:219
Definition: ERF_PhysBCFunct.H:41
amrex::BoxArray m_slab_ba
Definition: ERF_PhysBCFunct.H:49
amrex::IntVect m_nghost
Definition: ERF_PhysBCFunct.H:48
void operator()(amrex::MultiFab &mf, int icomp, int ncomp, const amrex::IntVect &nghost, const amrex::Geometry &geom)
Definition: ERF_PhysBCFunct.cpp:19
amrex::DistributionMapping m_src_dm
Definition: ERF_PhysBCFunct.H:47
amrex::BoxArray m_src_ba
Definition: ERF_PhysBCFunct.H:46
amrex::DistributionMapping m_slab_dm
Definition: ERF_PhysBCFunct.H:50
amrex::Vector< int > m_src_index
Definition: ERF_PhysBCFunct.H:51