ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
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 > &r0, const Array4< const Real > &th0, const Array4< const Real > &qv0, const Array4< const Real > &z_phys_cc, int n_qstate)
 Apply sponge zone damping to cell-centered state variables. More...
 
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 > &r0, const Array4< const Real > &z_phys_nd, const Array4< const Real > &z_phys_cc)
 Apply sponge zone damping to momentum variables. More...
 

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 > &  r0,
const Array4< const Real > &  th0,
const Array4< const Real > &  qv0,
const Array4< const Real > &  z_phys_cc,
int  n_qstate 
)

Apply sponge zone damping to cell-centered state variables.

Parameters
[in]spongeChoiceSponge configuration.
[in]geomDomain geometry.
[in]bxBox of indices to process.
[in,out]cell_rhsRight-hand side for state variables.
[in]cell_dataCurrent state data.
[in]r0Base state density.
[in]th0Base state potential temperature.
[in]qv0Base state moisture.
[in]z_phys_ccCell-centered physical height.
[in]n_qstateNumber of additional scalar state variables.
31 {
32  // Domain cell size and real bounds
33  auto dx = geom.CellSizeArray();
34  auto ProbHiArr = geom.ProbHiArray();
35  auto ProbLoArr = geom.ProbLoArray();
36 
37  const Real sponge_strength = spongeChoice.sponge_strength;
38  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
39  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
40  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
41  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
42  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
43  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
44  if (!use_xlo_sponge_damping &&
45  !use_xhi_sponge_damping &&
46  !use_ylo_sponge_damping &&
47  !use_yhi_sponge_damping &&
48  !use_zlo_sponge_damping &&
49  !use_zhi_sponge_damping)
50  return;
51 
52  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
53  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
54  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
55  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
56  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
57  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
58 
59  const Real sponge_density_tmp = spongeChoice.sponge_density;
60  const Real sponge_rhotheta_tmp = spongeChoice.sponge_rhotheta;
61  const Real sponge_rhomoist_tmp = spongeChoice.sponge_rhomoist;
62  const bool use_base_density = (sponge_density_tmp < zero);
63  const bool use_base_rhotheta = (sponge_rhotheta_tmp < zero);
64  const bool use_base_rhomoist = (sponge_rhomoist_tmp < zero);
65 
66  // Domain valid box
67  const Box& domain = geom.Domain();
68  int domlo_x = domain.smallEnd(0);
69  int domhi_x = domain.bigEnd(0) + 1;
70  int domlo_y = domain.smallEnd(1);
71  int domhi_y = domain.bigEnd(1) + 1;
72 
73  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
74  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
75  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
76  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
77  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
78  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
79 
80  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
81  {
82  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
83  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
84 
85  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
86  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
87  Real z = z_phys_cc(i,j,k);
88 
89  Real sponge_density = (use_base_density) ? r0(i,j,k) : sponge_density_tmp;
90  Real sponge_rhotheta = (use_base_rhotheta) ? r0(i,j,k)*th0(i,j,k) : sponge_rhotheta_tmp;
91  Real sponge_rhomoist = (use_base_rhomoist) ? r0(i,j,k)*qv0(i,j,k) : sponge_rhomoist_tmp;
92 
93  // x left sponge
94  if(use_xlo_sponge_damping){
95  if (x < xlo_sponge_end) {
96  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
97  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
98  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
99  if (n_qstate > 0) {
100  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
101  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
102  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
103  }
104  }
105  }
106  }
107  // x right sponge
108  if(use_xhi_sponge_damping){
109  if (x > xhi_sponge_start) {
110  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
111  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
112  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
113  if (n_qstate > 0) {
114  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
115  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
116  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
117  }
118  }
119  }
120  }
121 
122  // y left sponge
123  if(use_ylo_sponge_damping){
124  if (y < ylo_sponge_end) {
125  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
126  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
127  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
128  if (n_qstate > 0) {
129  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
130  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
131  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
132  }
133  }
134  }
135  }
136  // x right sponge
137  if(use_yhi_sponge_damping){
138  if (y > yhi_sponge_start) {
139  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
140  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
141  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
142  if (n_qstate > 0) {
143  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
144  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
145  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
146  }
147  }
148  }
149  }
150 
151  // x left sponge
152  if(use_zlo_sponge_damping){
153  if (z < zlo_sponge_end) {
154  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
155  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
156  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
157  if (n_qstate > 0) {
158  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
159  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
160  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
161  }
162  }
163  }
164  }
165  // x right sponge
166  if(use_zhi_sponge_damping){
167  if (z > zhi_sponge_start) {
168  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
169  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
170  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
171  if (n_qstate > 0) {
172  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
173  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
174  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
175  }
176  }
177  }
178  }
179  });
180 }
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:46
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
real(kind=kind_phys), parameter, private r0
Definition: ERF_module_mp_wdm6.F90:75
amrex::Real zlo_sponge_end
Physical end location of the low-z sponge layer.
Definition: ERF_SpongeStruct.H:104
amrex::Real xlo_sponge_end
Physical end location of the low-x sponge layer.
Definition: ERF_SpongeStruct.H:102
bool use_zlo_sponge_damping
Whether sponge damping is applied at the low-z boundary.
Definition: ERF_SpongeStruct.H:94
amrex::Real ylo_sponge_end
Physical end location of the low-y sponge layer.
Definition: ERF_SpongeStruct.H:103
amrex::Real sponge_strength
Sponge damping strength.
Definition: ERF_SpongeStruct.H:97
amrex::Real sponge_rhotheta
Target rho-theta used by sponge damping.
Definition: ERF_SpongeStruct.H:106
amrex::Real yhi_sponge_start
Physical start location of the high-y sponge layer.
Definition: ERF_SpongeStruct.H:103
bool use_zhi_sponge_damping
Whether sponge damping is applied at the high-z boundary.
Definition: ERF_SpongeStruct.H:95
amrex::Real sponge_density
Target density used by sponge damping.
Definition: ERF_SpongeStruct.H:105
bool use_xlo_sponge_damping
Whether sponge damping is applied at the low-x boundary.
Definition: ERF_SpongeStruct.H:90
amrex::Real xhi_sponge_start
Physical start location of the high-x sponge layer.
Definition: ERF_SpongeStruct.H:102
bool use_xhi_sponge_damping
Whether sponge damping is applied at the high-x boundary.
Definition: ERF_SpongeStruct.H:91
amrex::Real sponge_rhomoist
Target moist density variable used by sponge damping.
Definition: ERF_SpongeStruct.H:107
bool use_yhi_sponge_damping
Whether sponge damping is applied at the high-y boundary.
Definition: ERF_SpongeStruct.H:93
bool use_ylo_sponge_damping
Whether sponge damping is applied at the low-y boundary.
Definition: ERF_SpongeStruct.H:92
amrex::Real zhi_sponge_start
Physical start location of the high-z sponge layer.
Definition: ERF_SpongeStruct.H:104

Referenced by make_sources().

Here is the call graph for this function:
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 > &  r0,
const Array4< const Real > &  z_phys_nd,
const Array4< const Real > &  z_phys_cc 
)

Apply sponge zone damping to momentum variables.

Parameters
[in]spongeChoiceSponge configuration.
[in]geomDomain geometry.
[in]tbxProcessing box for x-momentum.
[in]tbyProcessing box for y-momentum.
[in]tbzProcessing box for z-momentum.
[in,out]rho_u_rhsRight-hand side for x-momentum.
[in,out]rho_v_rhsRight-hand side for y-momentum.
[in,out]rho_w_rhsRight-hand side for z-momentum.
[in]rho_uCurrent x-momentum data.
[in]rho_vCurrent y-momentum data.
[in]rho_wCurrent z-momentum data.
[in]r0Base state density.
[in]z_phys_ndNode-centered physical height.
[in]z_phys_ccCell-centered physical height.
215 {
216  // Domain cell size and real bounds
217  auto dx = geom.CellSizeArray();
218  auto ProbHiArr = geom.ProbHiArray();
219  auto ProbLoArr = geom.ProbLoArray();
220 
221  const Real sponge_strength = spongeChoice.sponge_strength;
222  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
223  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
224  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
225  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
226  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
227  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
228  if (!use_xlo_sponge_damping &&
229  !use_xhi_sponge_damping &&
230  !use_ylo_sponge_damping &&
231  !use_yhi_sponge_damping &&
232  !use_zlo_sponge_damping &&
233  !use_zhi_sponge_damping)
234  return;
235 
236  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
237  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
238  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
239  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
240  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
241  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
242 
243  const Real sponge_x_velocity = spongeChoice.sponge_x_velocity;
244  const Real sponge_y_velocity = spongeChoice.sponge_y_velocity;
245  const Real sponge_z_velocity = spongeChoice.sponge_z_velocity;
246 
247  const Real sponge_density_tmp = spongeChoice.sponge_density;
248  const bool use_base = (sponge_density_tmp < zero);
249 
250  // Domain valid box
251  const Box& domain = geom.Domain();
252  int domlo_x = domain.smallEnd(0);
253  int domhi_x = domain.bigEnd(0) + 1;
254  int domlo_y = domain.smallEnd(1);
255  int domhi_y = domain.bigEnd(1) + 1;
256 
257  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
258  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
259  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
260  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
261  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
262  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
263 
264  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
265  {
266  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
267  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
268 
269  Real x = ProbLoArr[0] + ii * dx[0];
270  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
271  Real z = z_phys_cc(i,j,k);
272 
273  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i-1,j,k)) : sponge_density_tmp;
274 
275  // x lo sponge
276  if(use_xlo_sponge_damping){
277  if (x < xlo_sponge_end) {
278  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
279  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
280  }
281  }
282  // x hi sponge
283  if(use_xhi_sponge_damping){
284  if (x > xhi_sponge_start) {
285  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
286  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
287  }
288  }
289 
290  // y lo sponge
291  if(use_ylo_sponge_damping){
292  if (y < ylo_sponge_end) {
293  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
294  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
295  }
296  }
297  // x right sponge
298  if(use_yhi_sponge_damping){
299  if (y > yhi_sponge_start) {
300  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
301  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
302  }
303  }
304 
305  // z lo sponge
306  if(use_zlo_sponge_damping){
307  if (z < zlo_sponge_end) {
308  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
309  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
310  }
311  }
312 
313 
314  // z hi sponge
315  if(use_zhi_sponge_damping){
316  if (z > zhi_sponge_start) {
317  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
318  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
319  }
320  }
321  });
322 
323 
324  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
325  {
326  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
327  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
328 
329  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
330  Real y = ProbLoArr[1] + jj * dx[1];
331  Real z = z_phys_cc(i,j,k);
332 
333  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j-1,k)) : sponge_density_tmp;
334 
335  // x lo sponge
336  if(use_xlo_sponge_damping){
337  if (x < xlo_sponge_end) {
338  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
339  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
340  }
341  }
342  // x hi sponge
343  if(use_xhi_sponge_damping){
344  if (x > xhi_sponge_start) {
345  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
346  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
347  }
348  }
349 
350  // y lo sponge
351  if(use_ylo_sponge_damping){
352  if (y < ylo_sponge_end) {
353  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
354  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
355  }
356  }
357  // x right sponge
358  if(use_yhi_sponge_damping){
359  if (y > yhi_sponge_start) {
360  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
361  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
362  }
363  }
364 
365  // z lo sponge
366  if(use_zlo_sponge_damping){
367  if (z < zlo_sponge_end) {
368  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
369  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
370  }
371  }
372 
373 
374  // z hi sponge
375  if(use_zhi_sponge_damping){
376  if (z > zhi_sponge_start) {
377  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
378  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
379  }
380  }
381  });
382 
383 
384  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
385  {
386  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
387  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
388 
389  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
390  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
391  Real z = z_phys_nd(i,j,k);
392 
393  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j,k-1)) : sponge_density_tmp;
394 
395  // x left sponge
396  if(use_xlo_sponge_damping){
397  if (x < xlo_sponge_end) {
398  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
399  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
400  }
401  }
402  // x right sponge
403  if(use_xhi_sponge_damping){
404  if (x > xhi_sponge_start) {
405  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
406  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
407  }
408  }
409 
410  // y lo sponge
411  if(use_ylo_sponge_damping){
412  if (y < ylo_sponge_end) {
413  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
414  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
415  }
416  }
417  // x right sponge
418  if(use_yhi_sponge_damping){
419  if (y > yhi_sponge_start) {
420  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
421  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
422  }
423  }
424 
425  // z lo sponge
426  if(use_zlo_sponge_damping){
427  if (z < zlo_sponge_end) {
428  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
429  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
430  }
431  }
432 
433 
434  // z top sponge
435  if(use_zhi_sponge_damping){
436  if (z > zhi_sponge_start) {
437  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
438  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
439  }
440  }
441  });
442 }
amrex::Real sponge_y_velocity
Target y velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:109
amrex::Real sponge_x_velocity
Target x velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:108
amrex::Real sponge_z_velocity
Target vertical velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:110

Referenced by make_mom_sources().

Here is the call graph for this function:
Here is the caller graph for this function: