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  // Ramp lengths, computed here so that the kernels divide only by a valid length: the
81  // optimiser evaluates the guarded ramps of the sides that are switched off too, and the
82  // lengths of those sides (whose ends are never read from the inputs) can be zero
83  const Real L_xlo = use_xlo_sponge_damping ? (xlo_sponge_end - ProbLoArr[0]) : one;
84  const Real L_xhi = use_xhi_sponge_damping ? (ProbHiArr[0] - xhi_sponge_start) : one;
85  const Real L_ylo = use_ylo_sponge_damping ? (ylo_sponge_end - ProbLoArr[1]) : one;
86  const Real L_yhi = use_yhi_sponge_damping ? (ProbHiArr[1] - yhi_sponge_start) : one;
87  const Real L_zlo = use_zlo_sponge_damping ? (zlo_sponge_end - ProbLoArr[2]) : one;
88  const Real L_zhi = use_zhi_sponge_damping ? (ProbHiArr[2] - zhi_sponge_start) : one;
89 
90  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
91  {
92  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
93  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
94 
95  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
96  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
97  Real z = z_phys_cc(i,j,k);
98 
99  Real sponge_density = (use_base_density) ? r0(i,j,k) : sponge_density_tmp;
100  Real sponge_rhotheta = (use_base_rhotheta) ? r0(i,j,k)*th0(i,j,k) : sponge_rhotheta_tmp;
101  Real sponge_rhomoist = (use_base_rhomoist) ? r0(i,j,k)*qv0(i,j,k) : sponge_rhomoist_tmp;
102 
103  // x left sponge
104  if(use_xlo_sponge_damping){
105  if (x < xlo_sponge_end) {
106  Real xi = (xlo_sponge_end - x) / L_xlo;
107  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
108  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
109  if (n_qstate > 0) {
110  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
111  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
112  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
113  }
114  }
115  }
116  }
117  // x right sponge
118  if(use_xhi_sponge_damping){
119  if (x > xhi_sponge_start) {
120  Real xi = (x - xhi_sponge_start) / L_xhi;
121  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
122  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
123  if (n_qstate > 0) {
124  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
125  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
126  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
127  }
128  }
129  }
130  }
131 
132  // y left sponge
133  if(use_ylo_sponge_damping){
134  if (y < ylo_sponge_end) {
135  Real xi = (ylo_sponge_end - y) / L_ylo;
136  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
137  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
138  if (n_qstate > 0) {
139  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
140  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
141  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
142  }
143  }
144  }
145  }
146  // x right sponge
147  if(use_yhi_sponge_damping){
148  if (y > yhi_sponge_start) {
149  Real xi = (y - yhi_sponge_start) / L_yhi;
150  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
151  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
152  if (n_qstate > 0) {
153  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
154  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
155  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
156  }
157  }
158  }
159  }
160 
161  // x left sponge
162  if(use_zlo_sponge_damping){
163  if (z < zlo_sponge_end) {
164  Real xi = (zlo_sponge_end - z) / L_zlo;
165  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
166  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
167  if (n_qstate > 0) {
168  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
169  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
170  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
171  }
172  }
173  }
174  }
175  // x right sponge
176  if(use_zhi_sponge_damping){
177  if (z > zhi_sponge_start) {
178  Real xi = (z - zhi_sponge_start) / L_zhi;
179  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
180  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
181  if (n_qstate > 0) {
182  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
183  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
184  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
185  }
186  }
187  }
188  }
189  });
190 }
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:49
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:48
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);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
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:105
amrex::Real xlo_sponge_end
Physical end location of the low-x sponge layer.
Definition: ERF_SpongeStruct.H:103
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:104
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:107
amrex::Real yhi_sponge_start
Physical start location of the high-y sponge layer.
Definition: ERF_SpongeStruct.H:104
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:106
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:103
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:108
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:105

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.
225 {
226  // Domain cell size and real bounds
227  auto dx = geom.CellSizeArray();
228  auto ProbHiArr = geom.ProbHiArray();
229  auto ProbLoArr = geom.ProbLoArray();
230 
231  const Real sponge_strength = spongeChoice.sponge_strength;
232  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
233  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
234  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
235  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
236  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
237  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
238  if (!use_xlo_sponge_damping &&
239  !use_xhi_sponge_damping &&
240  !use_ylo_sponge_damping &&
241  !use_yhi_sponge_damping &&
242  !use_zlo_sponge_damping &&
243  !use_zhi_sponge_damping)
244  return;
245 
246  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
247  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
248  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
249  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
250  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
251  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
252 
253  const Real sponge_x_velocity = spongeChoice.sponge_x_velocity;
254  const Real sponge_y_velocity = spongeChoice.sponge_y_velocity;
255  const Real sponge_z_velocity = spongeChoice.sponge_z_velocity;
256 
257  const Real sponge_density_tmp = spongeChoice.sponge_density;
258  const bool use_base = (sponge_density_tmp < zero);
259 
260  // Domain valid box
261  const Box& domain = geom.Domain();
262  int domlo_x = domain.smallEnd(0);
263  int domhi_x = domain.bigEnd(0) + 1;
264  int domlo_y = domain.smallEnd(1);
265  int domhi_y = domain.bigEnd(1) + 1;
266 
267  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
268  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
269  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
270  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
271  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
272  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
273 
274  // Ramp lengths, computed here so that the kernels divide only by a valid length: the
275  // optimiser evaluates the guarded ramps of the sides that are switched off too, and the
276  // lengths of those sides (whose ends are never read from the inputs) can be zero
277  const Real L_xlo = use_xlo_sponge_damping ? (xlo_sponge_end - ProbLoArr[0]) : one;
278  const Real L_xhi = use_xhi_sponge_damping ? (ProbHiArr[0] - xhi_sponge_start) : one;
279  const Real L_ylo = use_ylo_sponge_damping ? (ylo_sponge_end - ProbLoArr[1]) : one;
280  const Real L_yhi = use_yhi_sponge_damping ? (ProbHiArr[1] - yhi_sponge_start) : one;
281  const Real L_zlo = use_zlo_sponge_damping ? (zlo_sponge_end - ProbLoArr[2]) : one;
282  const Real L_zhi = use_zhi_sponge_damping ? (ProbHiArr[2] - zhi_sponge_start) : one;
283 
284  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
285  {
286  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
287  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
288 
289  Real x = ProbLoArr[0] + ii * dx[0];
290  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
291  Real z = z_phys_cc(i,j,k);
292 
293  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i-1,j,k)) : sponge_density_tmp;
294 
295  // x lo sponge
296  if(use_xlo_sponge_damping){
297  if (x < xlo_sponge_end) {
298  Real xi = (xlo_sponge_end - x) / L_xlo;
299  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
300  }
301  }
302  // x hi sponge
303  if(use_xhi_sponge_damping){
304  if (x > xhi_sponge_start) {
305  Real xi = (x - xhi_sponge_start) / L_xhi;
306  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
307  }
308  }
309 
310  // y lo sponge
311  if(use_ylo_sponge_damping){
312  if (y < ylo_sponge_end) {
313  Real xi = (ylo_sponge_end - y) / L_ylo;
314  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
315  }
316  }
317  // x right sponge
318  if(use_yhi_sponge_damping){
319  if (y > yhi_sponge_start) {
320  Real xi = (y - yhi_sponge_start) / L_yhi;
321  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
322  }
323  }
324 
325  // z lo sponge
326  if(use_zlo_sponge_damping){
327  if (z < zlo_sponge_end) {
328  Real xi = (zlo_sponge_end - z) / L_zlo;
329  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
330  }
331  }
332 
333 
334  // z hi sponge
335  if(use_zhi_sponge_damping){
336  if (z > zhi_sponge_start) {
337  Real xi = (z - zhi_sponge_start) / L_zhi;
338  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
339  }
340  }
341  });
342 
343 
344  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
345  {
346  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
347  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
348 
349  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
350  Real y = ProbLoArr[1] + jj * dx[1];
351  Real z = z_phys_cc(i,j,k);
352 
353  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j-1,k)) : sponge_density_tmp;
354 
355  // x lo sponge
356  if(use_xlo_sponge_damping){
357  if (x < xlo_sponge_end) {
358  Real xi = (xlo_sponge_end - x) / L_xlo;
359  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
360  }
361  }
362  // x hi sponge
363  if(use_xhi_sponge_damping){
364  if (x > xhi_sponge_start) {
365  Real xi = (x - xhi_sponge_start) / L_xhi;
366  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
367  }
368  }
369 
370  // y lo sponge
371  if(use_ylo_sponge_damping){
372  if (y < ylo_sponge_end) {
373  Real xi = (ylo_sponge_end - y) / L_ylo;
374  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
375  }
376  }
377  // x right sponge
378  if(use_yhi_sponge_damping){
379  if (y > yhi_sponge_start) {
380  Real xi = (y - yhi_sponge_start) / L_yhi;
381  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
382  }
383  }
384 
385  // z lo sponge
386  if(use_zlo_sponge_damping){
387  if (z < zlo_sponge_end) {
388  Real xi = (zlo_sponge_end - z) / L_zlo;
389  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
390  }
391  }
392 
393 
394  // z hi sponge
395  if(use_zhi_sponge_damping){
396  if (z > zhi_sponge_start) {
397  Real xi = (z - zhi_sponge_start) / L_zhi;
398  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
399  }
400  }
401  });
402 
403 
404  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
405  {
406  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
407  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
408 
409  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
410  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
411  Real z = z_phys_nd(i,j,k);
412 
413  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j,k-1)) : sponge_density_tmp;
414 
415  // x left sponge
416  if(use_xlo_sponge_damping){
417  if (x < xlo_sponge_end) {
418  Real xi = (xlo_sponge_end - x) / L_xlo;
419  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
420  }
421  }
422  // x right sponge
423  if(use_xhi_sponge_damping){
424  if (x > xhi_sponge_start) {
425  Real xi = (x - xhi_sponge_start) / L_xhi;
426  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
427  }
428  }
429 
430  // y lo sponge
431  if(use_ylo_sponge_damping){
432  if (y < ylo_sponge_end) {
433  Real xi = (ylo_sponge_end - y) / L_ylo;
434  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
435  }
436  }
437  // x right sponge
438  if(use_yhi_sponge_damping){
439  if (y > yhi_sponge_start) {
440  Real xi = (y - yhi_sponge_start) / L_yhi;
441  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
442  }
443  }
444 
445  // z lo sponge
446  if(use_zlo_sponge_damping){
447  if (z < zlo_sponge_end) {
448  Real xi = (zlo_sponge_end - z) / L_zlo;
449  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
450  }
451  }
452 
453 
454  // z top sponge
455  if(use_zhi_sponge_damping){
456  if (z > zhi_sponge_start) {
457  Real xi = (z - zhi_sponge_start) / L_zhi;
458  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
459  }
460  }
461  });
462 }
amrex::Real sponge_y_velocity
Target y velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:110
amrex::Real sponge_x_velocity
Target x velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:109
amrex::Real sponge_z_velocity
Target vertical velocity used by sponge damping.
Definition: ERF_SpongeStruct.H:111

Referenced by make_mom_sources().

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