ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ApplySpongeZoneBCs.cpp File Reference
#include <AMReX_MultiFab.H>
#include <ERF_Src_headers.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)
 
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)
 

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

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

Referenced by make_mom_sources().

Here is the caller graph for this function: