ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_ApplySpongeZoneBCs.cpp File Reference
#include <AMReX_MultiFab.H>
#include <ERF_SrcHeaders.H>
Include dependency graph for ERF_ApplySpongeZoneBCs.cpp:

Functions

void ApplySpongeZoneBCsForCC (const SpongeChoice &spongeChoice, const Geometry geom, const Box &bx, const Array4< Real > &cell_rhs, const Array4< const Real > &cell_data, const Array4< const Real > &z_phys_cc)
 
void ApplySpongeZoneBCsForMom (const SpongeChoice &spongeChoice, const Geometry geom, const Box &tbx, const Box &tby, const Box &tbz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &rho_w, const Array4< const Real > &z_phys_nd, const Array4< const Real > &z_phys_cc)
 

Function Documentation

◆ ApplySpongeZoneBCsForCC()

void ApplySpongeZoneBCsForCC ( const SpongeChoice spongeChoice,
const Geometry  geom,
const Box &  bx,
const Array4< Real > &  cell_rhs,
const Array4< const Real > &  cell_data,
const Array4< const Real > &  z_phys_cc 
)
14 {
15  // Domain cell size and real bounds
16  auto dx = geom.CellSizeArray();
17  auto ProbHiArr = geom.ProbHiArray();
18  auto ProbLoArr = geom.ProbLoArray();
19 
20  const Real sponge_strength = spongeChoice.sponge_strength;
21  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
22  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
23  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
24  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
25  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
26  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
27  if (!use_xlo_sponge_damping &&
28  !use_xhi_sponge_damping &&
29  !use_ylo_sponge_damping &&
30  !use_yhi_sponge_damping &&
31  !use_zlo_sponge_damping &&
32  !use_zhi_sponge_damping)
33  return;
34 
35  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
36  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
37  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
38  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
39  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
40  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
41 
42  const Real sponge_density = spongeChoice.sponge_density;
43 
44  // Domain valid box
45  const Box& domain = geom.Domain();
46  int domlo_x = domain.smallEnd(0);
47  int domhi_x = domain.bigEnd(0) + 1;
48  int domlo_y = domain.smallEnd(1);
49  int domhi_y = domain.bigEnd(1) + 1;
50 
51  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
52  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
53  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
54  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
55  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
56  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
57 
58  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
59  {
60  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
61  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
62 
63  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
64  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
65  Real z = z_phys_cc(i,j,k);
66 
67  // x left sponge
68  if(use_xlo_sponge_damping){
69  if (x < xlo_sponge_end) {
70  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
71  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
72  }
73  }
74  // x right sponge
75  if(use_xhi_sponge_damping){
76  if (x > xhi_sponge_start) {
77  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
78  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
79  }
80  }
81 
82  // y left sponge
83  if(use_ylo_sponge_damping){
84  if (y < ylo_sponge_end) {
85  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
86  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
87  }
88  }
89  // x right sponge
90  if(use_yhi_sponge_damping){
91  if (y > yhi_sponge_start) {
92  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
93  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
94  }
95  }
96 
97  // x left sponge
98  if(use_zlo_sponge_damping){
99  if (z < zlo_sponge_end) {
100  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
101  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
102  }
103  }
104  // x right sponge
105  if(use_zhi_sponge_damping){
106  if (z > zhi_sponge_start) {
107  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
108  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
109  }
110  }
111  });
112 }
bool use_xlo_sponge_damping
Definition: ERF_SpongeStruct.H:50
amrex::Real xlo_sponge_end
Definition: ERF_SpongeStruct.H:60
amrex::Real zlo_sponge_end
Definition: ERF_SpongeStruct.H:62
bool use_zlo_sponge_damping
Definition: ERF_SpongeStruct.H:54
amrex::Real sponge_strength
Definition: ERF_SpongeStruct.H:57
bool use_ylo_sponge_damping
Definition: ERF_SpongeStruct.H:52
amrex::Real zhi_sponge_start
Definition: ERF_SpongeStruct.H:62
bool use_xhi_sponge_damping
Definition: ERF_SpongeStruct.H:51
bool use_zhi_sponge_damping
Definition: ERF_SpongeStruct.H:55
amrex::Real yhi_sponge_start
Definition: ERF_SpongeStruct.H:61
amrex::Real sponge_density
Definition: ERF_SpongeStruct.H:63
bool use_yhi_sponge_damping
Definition: ERF_SpongeStruct.H:53
amrex::Real xhi_sponge_start
Definition: ERF_SpongeStruct.H:60
amrex::Real ylo_sponge_end
Definition: ERF_SpongeStruct.H:61

Referenced by make_sources().

Here is the caller graph for this function:

◆ ApplySpongeZoneBCsForMom()

void ApplySpongeZoneBCsForMom ( const SpongeChoice spongeChoice,
const Geometry  geom,
const Box &  tbx,
const Box &  tby,
const Box &  tbz,
const Array4< Real > &  rho_u_rhs,
const Array4< Real > &  rho_v_rhs,
const Array4< Real > &  rho_w_rhs,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  rho_w,
const Array4< const Real > &  z_phys_nd,
const Array4< const Real > &  z_phys_cc 
)
129 {
130  // Domain cell size and real bounds
131  auto dx = geom.CellSizeArray();
132  auto ProbHiArr = geom.ProbHiArray();
133  auto ProbLoArr = geom.ProbLoArray();
134 
135  const Real sponge_strength = spongeChoice.sponge_strength;
136  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
137  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
138  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
139  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
140  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
141  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
142  if (!use_xlo_sponge_damping &&
143  !use_xhi_sponge_damping &&
144  !use_ylo_sponge_damping &&
145  !use_yhi_sponge_damping &&
146  !use_zlo_sponge_damping &&
147  !use_zhi_sponge_damping)
148  return;
149 
150  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
151  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
152  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
153  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
154  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
155  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
156 
157  const Real sponge_density = spongeChoice.sponge_density;
158  const Real sponge_x_velocity = spongeChoice.sponge_x_velocity;
159  const Real sponge_y_velocity = spongeChoice.sponge_y_velocity;
160  const Real sponge_z_velocity = spongeChoice.sponge_z_velocity;
161 
162  // Domain valid box
163  const Box& domain = geom.Domain();
164  int domlo_x = domain.smallEnd(0);
165  int domhi_x = domain.bigEnd(0) + 1;
166  int domlo_y = domain.smallEnd(1);
167  int domhi_y = domain.bigEnd(1) + 1;
168 
169  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
170  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
171  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
172  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
173  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
174  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
175 
176  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
177  {
178  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
179  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
180 
181  Real x = ProbLoArr[0] + ii * dx[0];
182  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
183  Real z = z_phys_cc(i,j,k);
184 
185  // x lo sponge
186  if(use_xlo_sponge_damping){
187  if (x < xlo_sponge_end) {
188  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
189  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
190  }
191  }
192  // x hi sponge
193  if(use_xhi_sponge_damping){
194  if (x > xhi_sponge_start) {
195  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
196  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
197  }
198  }
199 
200  // y lo sponge
201  if(use_ylo_sponge_damping){
202  if (y < ylo_sponge_end) {
203  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
204  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
205  }
206  }
207  // x right sponge
208  if(use_yhi_sponge_damping){
209  if (y > yhi_sponge_start) {
210  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
211  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
212  }
213  }
214 
215  // z lo sponge
216  if(use_zlo_sponge_damping){
217  if (z < zlo_sponge_end) {
218  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
219  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
220  }
221  }
222 
223 
224  // z hi sponge
225  if(use_zhi_sponge_damping){
226  if (z > zhi_sponge_start) {
227  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
228  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
229  }
230  }
231  });
232 
233 
234  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
235  {
236  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
237  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
238 
239  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
240  Real y = ProbLoArr[1] + jj * dx[1];
241  Real z = z_phys_cc(i,j,k);
242 
243  // x lo sponge
244  if(use_xlo_sponge_damping){
245  if (x < xlo_sponge_end) {
246  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
247  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
248  }
249  }
250  // x hi sponge
251  if(use_xhi_sponge_damping){
252  if (x > xhi_sponge_start) {
253  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
254  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
255  }
256  }
257 
258  // y lo sponge
259  if(use_ylo_sponge_damping){
260  if (y < ylo_sponge_end) {
261  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
262  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
263  }
264  }
265  // x right sponge
266  if(use_yhi_sponge_damping){
267  if (y > yhi_sponge_start) {
268  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
269  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
270  }
271  }
272 
273  // z lo sponge
274  if(use_zlo_sponge_damping){
275  if (z < zlo_sponge_end) {
276  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
277  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
278  }
279  }
280 
281 
282  // z hi sponge
283  if(use_zhi_sponge_damping){
284  if (z > zhi_sponge_start) {
285  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
286  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
287  }
288  }
289  });
290 
291 
292  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
293  {
294  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
295  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
296 
297  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
298  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
299  Real z = z_phys_nd(i,j,k);
300 
301  // x left sponge
302  if(use_xlo_sponge_damping){
303  if (x < xlo_sponge_end) {
304  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
305  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
306  }
307  }
308  // x right sponge
309  if(use_xhi_sponge_damping){
310  if (x > xhi_sponge_start) {
311  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
312  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
313  }
314  }
315 
316  // y lo sponge
317  if(use_ylo_sponge_damping){
318  if (y < ylo_sponge_end) {
319  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
320  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
321  }
322  }
323  // x right sponge
324  if(use_yhi_sponge_damping){
325  if (y > yhi_sponge_start) {
326  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
327  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
328  }
329  }
330 
331  // z lo sponge
332  if(use_zlo_sponge_damping){
333  if (z < zlo_sponge_end) {
334  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
335  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
336  }
337  }
338 
339 
340  // z top sponge
341  if(use_zhi_sponge_damping){
342  if (z > zhi_sponge_start) {
343  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
344  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
345  }
346  }
347  });
348 }
amrex::Real sponge_y_velocity
Definition: ERF_SpongeStruct.H:63
amrex::Real sponge_z_velocity
Definition: ERF_SpongeStruct.H:63
amrex::Real sponge_x_velocity
Definition: ERF_SpongeStruct.H:63

Referenced by make_mom_sources().

Here is the caller graph for this function: