ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERFPhysBCFunct_u Class Reference

#include <ERF_PhysBCFunct.H>

Collaboration diagram for ERFPhysBCFunct_u:

Public Member Functions

 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, std::unique_ptr< amrex::MultiFab > &z_phys_nd, const bool use_real_bcs, amrex::Real *u_bc_data)
 
 ~ERFPhysBCFunct_u ()
 
void operator() (amrex::MultiFab &mf, amrex::MultiFab &xvel, amrex::MultiFab &yvel, amrex::IntVect const &nghost, const amrex::Real time, int bccomp, bool do_fb)
 
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)
 
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 amrex::Real time)
 

Private Attributes

int m_lev
 
amrex::Geometry m_geom
 
amrex::Vector< amrex::BCRec > m_domain_bcs_type
 
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
 
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_maxm_bc_extdir_vals
 
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_maxm_bc_neumann_vals
 
amrex::MultiFab * m_z_phys_nd
 
bool m_use_real_bcs
 
amrex::Real * m_u_bc_data
 

Constructor & Destructor Documentation

◆ ERFPhysBCFunct_u()

ERFPhysBCFunct_u::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,
std::unique_ptr< amrex::MultiFab > &  z_phys_nd,
const bool  use_real_bcs,
amrex::Real *  u_bc_data 
)
inline
94  : m_lev(lev), m_geom(geom),
95  m_domain_bcs_type(domain_bcs_type),
96  m_domain_bcs_type_d(domain_bcs_type_d),
97  m_bc_extdir_vals(bc_extdir_vals),
98  m_bc_neumann_vals(bc_neumann_vals),
99  m_z_phys_nd(z_phys_nd.get()),
100  m_use_real_bcs(use_real_bcs),
101  m_u_bc_data(u_bc_data)
102  { }
amrex::Geometry m_geom
Definition: ERF_PhysBCFunct.H:131
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals
Definition: ERF_PhysBCFunct.H:134
amrex::Gpu::DeviceVector< amrex::BCRec > m_domain_bcs_type_d
Definition: ERF_PhysBCFunct.H:133
bool m_use_real_bcs
Definition: ERF_PhysBCFunct.H:137
amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_neumann_vals
Definition: ERF_PhysBCFunct.H:135
amrex::Real * m_u_bc_data
Definition: ERF_PhysBCFunct.H:138
int m_lev
Definition: ERF_PhysBCFunct.H:130
amrex::Vector< amrex::BCRec > m_domain_bcs_type
Definition: ERF_PhysBCFunct.H:132
amrex::MultiFab * m_z_phys_nd
Definition: ERF_PhysBCFunct.H:136

◆ ~ERFPhysBCFunct_u()

ERFPhysBCFunct_u::~ERFPhysBCFunct_u ( )
inline
104 {}

Member Function Documentation

◆ impose_lateral_xvel_bcs()

void ERFPhysBCFunct_u::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 
)
19 {
20  BL_PROFILE_VAR("impose_lateral_xvel_bcs()",impose_lateral_xvel_bcs);
21  const auto& dom_lo = lbound(domain);
22  const auto& dom_hi = ubound(domain);
23 
24  // xlo: ori = 0
25  // ylo: ori = 1
26  // zlo: ori = 2
27  // xhi: ori = 3
28  // yhi: ori = 4
29  // zhi: ori = 5
30 
31  // Based on BCRec for the domain, we need to make BCRec for this Box
32  // bccomp is used as starting index for m_domain_bcs_type
33  // 0 is used as starting index for bcrs
34  Vector<BCRec> bcrs(1);
35  setBC(enclosedCells(bx), domain, bccomp, 0, 1, m_domain_bcs_type, bcrs);
36 
37  Gpu::DeviceVector<BCRec> bcrs_d(1);
38  Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
39  const BCRec* bc_ptr = bcrs_d.data();
40 
41  GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,1> l_bc_extdir_vals_d;
42 
43  for (int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
44  l_bc_extdir_vals_d[0][ori] = m_bc_extdir_vals[bccomp][ori];
45  }
46 
47  GeometryData const& geomdata = m_geom.data();
48  bool is_periodic_in_x = geomdata.isPeriodic(0);
49  bool is_periodic_in_y = geomdata.isPeriodic(1);
50 
51  // First do all ext_dir bcs
52  if (!is_periodic_in_x)
53  {
54  Real* xvel_bc_ptr = m_u_bc_data;
55  Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
56  Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+2);
57  Box bx_xlo_face(bx); bx_xlo_face.setSmall(0,dom_lo.x ); bx_xlo_face.setBig(0,dom_lo.x );
58  Box bx_xhi_face(bx); bx_xhi_face.setSmall(0,dom_hi.x+1); bx_xhi_face.setBig(0,dom_hi.x+1);
59  ParallelFor(bx_xlo, bx_xlo_face,
60  [=] AMREX_GPU_DEVICE (int i, int j, int k)
61  {
62  int iflip = dom_lo.x - i;
63  if (bc_ptr[0].lo(0) == ERFBCType::ext_dir) {
64  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][0];
65  } else if (bc_ptr[0].lo(0) == ERFBCType::ext_dir_upwind && xvel_arr(dom_lo.x,j,k) >= 0.) {
66  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][0];
67  } else if (bc_ptr[0].lo(0) == ERFBCType::foextrap) {
68  dest_arr(i,j,k) = dest_arr(dom_lo.x,j,k);
69  } else if (bc_ptr[0].lo(0) == ERFBCType::open) {
70  dest_arr(i,j,k) = dest_arr(dom_lo.x,j,k);
71  } else if (bc_ptr[0].lo(0) == ERFBCType::reflect_even) {
72  dest_arr(i,j,k) = dest_arr(iflip,j,k);
73  } else if (bc_ptr[0].lo(0) == ERFBCType::reflect_odd) {
74  dest_arr(i,j,k) = -dest_arr(iflip,j,k);
75  } else if (bc_ptr[0].lo(0) == ERFBCType::neumann_int) {
76  dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,j,k) - dest_arr(dom_lo.x+2,j,k))/3.0;
77  }
78  },
79  // We only set the values on the domain faces themselves if EXT_DIR or neumann_int
80  [=] AMREX_GPU_DEVICE (int i, int j, int k)
81  {
82  if (bc_ptr[0].lo(0) == ERFBCType::ext_dir) {
83  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][0];
84  } else if (bc_ptr[0].lo(0) == ERFBCType::ext_dir_upwind && xvel_arr(dom_lo.x,j,k) >= 0.) {
85  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][0];
86  } else if (bc_ptr[0].lo(0) == ERFBCType::neumann_int) {
87  dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,j,k) - dest_arr(dom_lo.x+2,j,k))/3.0;
88  }
89  }
90  );
91  ParallelFor(bx_xhi, bx_xhi_face,
92  [=] AMREX_GPU_DEVICE (int i, int j, int k)
93  {
94  int iflip = 2*(dom_hi.x + 1) - i;
95  if (bc_ptr[0].hi(0) == ERFBCType::ext_dir) {
96  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][3];
97  } else if (bc_ptr[0].hi(0) == ERFBCType::ext_dir_upwind && xvel_arr(dom_hi.x+1,j,k) <= 0.) {
98  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][3];
99  } else if (bc_ptr[0].hi(0) == ERFBCType::foextrap) {
100  dest_arr(i,j,k) = dest_arr(dom_hi.x+1,j,k);
101  } else if (bc_ptr[0].hi(0) == ERFBCType::open) {
102  dest_arr(i,j,k) = dest_arr(dom_hi.x+1,j,k);
103  } else if (bc_ptr[0].hi(0) == ERFBCType::reflect_even) {
104  dest_arr(i,j,k) = dest_arr(iflip,j,k);
105  } else if (bc_ptr[0].hi(0) == ERFBCType::reflect_odd) {
106  dest_arr(i,j,k) = -dest_arr(iflip,j,k);
107  } else if (bc_ptr[0].hi(0) == ERFBCType::neumann_int) {
108  dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,j,k) - dest_arr(dom_hi.x-1,j,k))/3.0;
109  }
110  },
111  // We only set the values on the domain faces themselves if EXT_DIR or neumann_int
112  [=] AMREX_GPU_DEVICE (int i, int j, int k)
113  {
114  if (bc_ptr[0].hi(0) == ERFBCType::ext_dir) {
115  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][3];
116  } else if (bc_ptr[0].hi(0) == ERFBCType::ext_dir_upwind && xvel_arr(dom_hi.x+1,j,k) <= 0.) {
117  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][3];
118  } else if (bc_ptr[0].hi(0) == ERFBCType::neumann_int) {
119  dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,j,k) - dest_arr(dom_hi.x-1,j,k))/3.0;
120  }
121  }
122  );
123  } // not periodic in x
124 
125  if (!is_periodic_in_y)
126  {
127  // Populate ghost cells on lo-y and hi-y domain boundaries
128  Real* xvel_bc_ptr = m_u_bc_data;
129  Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
130  Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
131  ParallelFor(bx_ylo, bx_yhi,
132  [=] AMREX_GPU_DEVICE (int i, int j, int k) {
133  int jflip = dom_lo.y - 1 - j;
134  if (bc_ptr[0].lo(1) == ERFBCType::ext_dir) {
135  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][1];
136  } else if (bc_ptr[0].lo(1) == ERFBCType::ext_dir_upwind && yvel_arr(i,dom_lo.y,k) >= 0.) {
137  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][1];
138  } else if (bc_ptr[0].lo(1) == ERFBCType::foextrap) {
139  dest_arr(i,j,k) = dest_arr(i,dom_lo.y,k);
140  } else if (bc_ptr[0].lo(1) == ERFBCType::open) {
141  dest_arr(i,j,k) = dest_arr(i,dom_lo.y,k);
142  } else if (bc_ptr[0].lo(1) == ERFBCType::reflect_even) {
143  dest_arr(i,j,k) = dest_arr(i,jflip,k);
144  } else if (bc_ptr[0].lo(1) == ERFBCType::reflect_odd) {
145  dest_arr(i,j,k) = -dest_arr(i,jflip,k);
146  }
147  },
148  [=] AMREX_GPU_DEVICE (int i, int j, int k) {
149  int jflip = 2*dom_hi.y + 1 - j;
150  if (bc_ptr[0].hi(1) == ERFBCType::ext_dir) {
151  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][4];
152  } else if (bc_ptr[0].hi(1) == ERFBCType::ext_dir_upwind && yvel_arr(i,dom_hi.y+1,k) <= 0.) {
153  dest_arr(i,j,k) = (xvel_bc_ptr) ? xvel_bc_ptr[k] : l_bc_extdir_vals_d[0][4];
154  } else if (bc_ptr[0].hi(1) == ERFBCType::foextrap) {
155  dest_arr(i,j,k) = dest_arr(i,dom_hi.y,k);
156  } else if (bc_ptr[0].hi(1) == ERFBCType::open) {
157  dest_arr(i,j,k) = dest_arr(i,dom_hi.y,k);
158  } else if (bc_ptr[0].hi(1) == ERFBCType::reflect_even) {
159  dest_arr(i,j,k) = dest_arr(i,jflip,k);
160  } else if (bc_ptr[0].hi(1) == ERFBCType::reflect_odd) {
161  dest_arr(i,j,k) = -dest_arr(i,jflip,k);
162  }
163  }
164  );
165  } // not periodic in y
166 
167  Gpu::streamSynchronize();
168 }
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)
Definition: ERF_BoundaryConditionsXvel.cpp:15
@ open
Definition: ERF_IndexDefines.H:197
@ reflect_odd
Definition: ERF_IndexDefines.H:187
@ foextrap
Definition: ERF_IndexDefines.H:190
@ ext_dir
Definition: ERF_IndexDefines.H:191
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:199
@ neumann_int
Definition: ERF_IndexDefines.H:196
@ reflect_even
Definition: ERF_IndexDefines.H:189

◆ impose_vertical_xvel_bcs()

void ERFPhysBCFunct_u::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 amrex::Real  time 
)
190 {
191  BL_PROFILE_VAR("impose_vertical_xvel_bcs()",impose_vertical_xvel_bcs);
192  const auto& dom_lo = lbound(domain);
193  const auto& dom_hi = ubound(domain);
194 
195  Box per_grown_domain(domain);
196  int growx = (m_geom.isPeriodic(0)) ? 1 : 0;
197  int growy = (m_geom.isPeriodic(1)) ? 1 : 0;
198  per_grown_domain.grow(IntVect(growx,growy,0));
199  const auto& perdom_lo = lbound(per_grown_domain);
200  const auto& perdom_hi = ubound(per_grown_domain);
201 
202  GeometryData const& geomdata = m_geom.data();
203 
204  // Based on BCRec for the domain, we need to make BCRec for this Box
205  // bccomp is used as starting index for m_domain_bcs_type
206  // 0 is used as starting index for bcrs
207  Vector<BCRec> bcrs(1);
208  setBC(enclosedCells(bx), domain, bccomp, 0, 1, m_domain_bcs_type, bcrs);
209 
210  Gpu::DeviceVector<BCRec> bcrs_d(1);
211  Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
212  const BCRec* bc_ptr = bcrs_d.data();
213 
214  GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,1> l_bc_extdir_vals_d;
215 
216  for (int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
217  l_bc_extdir_vals_d[0][ori] = m_bc_extdir_vals[bccomp][ori];
218  }
219 
220  {
221  // Populate ghost cells on lo-z and hi-z domain boundaries
222  Box bx_zlo(bx); bx_zlo.setBig (2,dom_lo.z-1);
223  Box bx_zhi(bx); bx_zhi.setSmall(2,dom_hi.z+1);
224  ParallelFor(bx_zlo, bx_zhi,
225  [=] AMREX_GPU_DEVICE (int i, int j, int k) {
226  int kflip = dom_lo.z - 1 - k;
227  if (bc_ptr[0].lo(2) == ERFBCType::ext_dir) {
228  #ifdef ERF_USE_TERRAIN_VELOCITY
229  dest_arr(i,j,k) = prob->compute_terrain_velocity(time);
230  #else
231  dest_arr(i,j,k) = l_bc_extdir_vals_d[0][2];
232  #endif
233  } else if (bc_ptr[0].lo(2) == ERFBCType::foextrap) {
234  dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
235  } else if (bc_ptr[0].lo(2) == ERFBCType::open) {
236  dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
237  } else if (bc_ptr[0].lo(2) == ERFBCType::reflect_even) {
238  dest_arr(i,j,k) = dest_arr(i,j,kflip);
239  } else if (bc_ptr[0].lo(2) == ERFBCType::reflect_odd) {
240  dest_arr(i,j,k) = -dest_arr(i,j,kflip);
241  }
242  },
243  [=] AMREX_GPU_DEVICE (int i, int j, int k) {
244  int kflip = 2*dom_hi.z + 1 - k;
245  if (bc_ptr[0].hi(2) == ERFBCType::ext_dir) {
246  dest_arr(i,j,k) = l_bc_extdir_vals_d[0][5];
247  } else if (bc_ptr[0].hi(2) == ERFBCType::foextrap) {
248  dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
249  } else if (bc_ptr[0].hi(2) == ERFBCType::open) {
250  dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
251  } else if (bc_ptr[0].hi(2) == ERFBCType::reflect_even) {
252  dest_arr(i,j,k) = dest_arr(i,j,kflip);
253  } else if (bc_ptr[0].hi(2) == ERFBCType::reflect_odd) {
254  dest_arr(i,j,k) = -dest_arr(i,j,kflip);
255  }
256  }
257  );
258  } // z
259 
260  if (m_z_phys_nd) {
261  const auto& bx_lo = lbound(bx);
262  const auto& bx_hi = ubound(bx);
263 
264  const auto& zphys_lo = lbound(Box(z_phys_nd));
265  const auto& zphys_hi = ubound(Box(z_phys_nd));
266 
267  // Neumann conditions (d<var>/dn = 0) must be aware of the surface normal with terrain.
268  // An additional source term arises from d<var>/dx & d<var>/dy & met_h_xi/eta/zeta.
269  //=====================================================================================
270  // Only modify scalars, U, or V
271  // Loop over each component
272  // Hit for Neumann condition at kmin
273  if (bcrs[0].lo(2) == ERFBCType::foextrap) {
274  // Loop over ghost cells in bottom XY-plane (valid box)
275  Box xybx = bx;
276  xybx.setBig(2,-1);
277  xybx.setSmall(2,bx.smallEnd()[2]);
278  int k0 = 0;
279 
280  // Get the dz cell size
281  Real dz = geomdata.CellSize(2);
282 
283  // Fill all the Neumann srcs with terrain
284  ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
285  {
286  // Clip indices for ghost-cells
287  int ii = amrex::min(amrex::max(i,perdom_lo.x),perdom_hi.x);
288  ii = amrex::min(amrex::max(ii,zphys_lo.x),zphys_hi.x);
289  int jj = amrex::min(amrex::max(j,perdom_lo.y),perdom_hi.y);
290  jj = amrex::min(amrex::max(jj,zphys_lo.y),zphys_hi.y);
291 
292  // Get metrics
293  Real met_h_xi = Compute_h_xi_AtIface (ii, jj, k0, dxInv, z_phys_nd);
294  Real met_h_eta = Compute_h_eta_AtIface (ii, jj, k0, dxInv, z_phys_nd);
295  Real met_h_zeta = Compute_h_zeta_AtIface(ii, jj, k0, dxInv, z_phys_nd);
296 
297  // GradX at IJK location inside domain -- this relies on the assumption that we have
298  // used foextrap for quantities outside the domain to define the gradient as zero
299  Real GradVarx, GradVary;
300  if ( i < dom_lo.x-1 || i > dom_hi.x+1 || (i+1 > bx_hi.x && i-1 < bx_lo.x) ) {
301  GradVarx = 0.0;
302  } else if (i+1 > bx_hi.x) {
303  GradVarx = dxInv[0] * (dest_arr(i ,j,k0) - dest_arr(i-1,j,k0));
304  } else if (i-1 < bx_lo.x) {
305  GradVarx = dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i ,j,k0));
306  } else {
307  GradVarx = 0.5 * dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i-1,j,k0));
308  }
309 
310  // GradY at IJK location inside domain -- this relies on the assumption that we have
311  // used foextrap for quantities outside the domain to define the gradient as zero
312  if ( j < dom_lo.y-1 || j > dom_hi.y+1 || (j+1 > bx_hi.y && j-1 < bx_lo.y) ) {
313  GradVary = 0.0;
314  } else if (j+1 > bx_hi.y) {
315  GradVary = dxInv[1] * (dest_arr(i,j ,k0) - dest_arr(i,j-1,k0));
316  } else if (j-1 < bx_lo.y) {
317  GradVary = dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j ,k0));
318  } else {
319  GradVary = 0.5 * dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j-1,k0));
320  }
321 
322  // Prefactor
323  Real met_fac = met_h_zeta / ( met_h_xi*met_h_xi + met_h_eta*met_h_eta + 1. );
324 
325  // Accumulate in bottom ghost cell (EXTRAP already populated)
326  dest_arr(i,j,k) -= dz * met_fac * ( met_h_xi * GradVarx + met_h_eta * GradVary );
327  });
328  } // foextrap
329  } //m_z_phys_nd
330  Gpu::streamSynchronize();
331 }
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:108
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:94
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:123
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 amrex::Real time)
Definition: ERF_BoundaryConditionsXvel.cpp:180
Here is the call graph for this function:

◆ operator()()

void ERFPhysBCFunct_u::operator() ( amrex::MultiFab &  mf,
amrex::MultiFab &  xvel,
amrex::MultiFab &  yvel,
amrex::IntVect const &  nghost,
const amrex::Real  time,
int  bccomp,
bool  do_fb 
)
92 {
93  BL_PROFILE("ERFPhysBCFunct_u::()");
94 
95  if (m_geom.isAllPeriodic()) return;
96 
97  const auto& domain = m_geom.Domain();
98  const auto dxInv = m_geom.InvCellSizeArray();
99 
100  Box gdomainx = surroundingNodes(domain,0);
101  for (int i = 0; i < AMREX_SPACEDIM; ++i) {
102  if (m_geom.isPeriodic(i)) {
103  gdomainx.grow(i, nghost[i]);
104  }
105  }
106 
107  //
108  // We fill all of the interior and periodic ghost cells first, so we can fill
109  // those directly inside the lateral and vertical calls.
110  //
111  if (do_fb) {
112  mf.FillBoundary(m_geom.periodicity());
113  }
114 
115 #ifdef AMREX_USE_OMP
116 #pragma omp parallel if (Gpu::notInLaunchRegion())
117 #endif
118  {
119  for (MFIter mfi(mf,false); mfi.isValid(); ++mfi)
120  {
121  //
122  // This is the box we pass to the different routines
123  // NOTE -- this is the full grid NOT the tile box
124  //
125  Box bx = mfi.validbox();
126 
127  //
128  // These are the boxes we use to test on relative to the domain
129  //
130  Box xbx1 = surroundingNodes(bx,0); xbx1.grow(nghost);
131  if(xbx1.smallEnd(2) < domain.smallEnd(2)) xbx1.setSmall(2,domain.smallEnd(2));
132  if(xbx1.bigEnd(2) > domain.bigEnd(2)) xbx1.setBig(2,domain.bigEnd(2));
133 
134  Box xbx2 = surroundingNodes(bx,0); xbx2.grow(nghost);
135 
136  Array4<const Real> z_nd_arr;
137 
138  if (m_z_phys_nd)
139  {
140  z_nd_arr = m_z_phys_nd->const_array(mfi);
141  }
142 
143  if (!gdomainx.contains(xbx2))
144  {
145  Array4< Real> const& dest_arr = mf.array(mfi);
146  Array4<const Real> const& velx_arr = xvel.const_array(mfi);
147  Array4<const Real> const& vely_arr = yvel.const_array(mfi);
148 
149  if (!m_use_real_bcs)
150  {
151  if (!gdomainx.contains(xbx1))
152  {
153  impose_lateral_xvel_bcs(dest_arr,velx_arr,vely_arr,xbx1,domain,bccomp);
154  }
155  }
156 
157  impose_vertical_xvel_bcs(dest_arr,xbx2,domain,z_nd_arr,dxInv,bccomp,time);
158  }
159  } // MFIter
160  } // OpenMP
161 } // operator()
@ xvel
Definition: ERF_IndexDefines.H:141
@ yvel
Definition: ERF_IndexDefines.H:142

Member Data Documentation

◆ m_bc_extdir_vals

amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> ERFPhysBCFunct_u::m_bc_extdir_vals
private

◆ m_bc_neumann_vals

amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>,AMREX_SPACEDIM+NBCVAR_max> ERFPhysBCFunct_u::m_bc_neumann_vals
private

◆ m_domain_bcs_type

amrex::Vector<amrex::BCRec> ERFPhysBCFunct_u::m_domain_bcs_type
private

◆ m_domain_bcs_type_d

amrex::Gpu::DeviceVector<amrex::BCRec> ERFPhysBCFunct_u::m_domain_bcs_type_d
private

◆ m_geom

amrex::Geometry ERFPhysBCFunct_u::m_geom
private

◆ m_lev

int ERFPhysBCFunct_u::m_lev
private

◆ m_u_bc_data

amrex::Real* ERFPhysBCFunct_u::m_u_bc_data
private

◆ m_use_real_bcs

bool ERFPhysBCFunct_u::m_use_real_bcs
private

◆ m_z_phys_nd

amrex::MultiFab* ERFPhysBCFunct_u::m_z_phys_nd
private

The documentation for this class was generated from the following files: