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)
 
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)
 

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 
)
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  if (!use_xlo_sponge_damping &&
31  !use_xhi_sponge_damping &&
32  !use_ylo_sponge_damping &&
33  !use_yhi_sponge_damping &&
34  !use_zlo_sponge_damping &&
35  !use_zhi_sponge_damping)
36  return;
37 
38  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
39  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
40  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
41  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
42  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
43  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
44 
45  const Real sponge_density_tmp = spongeChoice.sponge_density;
46  const Real sponge_rhotheta_tmp = spongeChoice.sponge_rhotheta;
47  const Real sponge_rhomoist_tmp = spongeChoice.sponge_rhomoist;
48  const bool use_base_density = (sponge_density_tmp < zero);
49  const bool use_base_rhotheta = (sponge_rhotheta_tmp < zero);
50  const bool use_base_rhomoist = (sponge_rhomoist_tmp < zero);
51 
52  // Domain valid box
53  const Box& domain = geom.Domain();
54  int domlo_x = domain.smallEnd(0);
55  int domhi_x = domain.bigEnd(0) + 1;
56  int domlo_y = domain.smallEnd(1);
57  int domhi_y = domain.bigEnd(1) + 1;
58 
59  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
60  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
61  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
62  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
63  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
64  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
65 
66  ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
67  {
68  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
69  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
70 
71  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
72  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
73  Real z = z_phys_cc(i,j,k);
74 
75  Real sponge_density = (use_base_density) ? r0(i,j,k) : sponge_density_tmp;
76  Real sponge_rhotheta = (use_base_rhotheta) ? r0(i,j,k)*th0(i,j,k) : sponge_rhotheta_tmp;
77  Real sponge_rhomoist = (use_base_rhomoist) ? r0(i,j,k)*qv0(i,j,k) : sponge_rhomoist_tmp;
78 
79  // x left sponge
80  if(use_xlo_sponge_damping){
81  if (x < xlo_sponge_end) {
82  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
83  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
84  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
85  if (n_qstate > 0) {
86  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
87  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
88  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
89  }
90  }
91  }
92  }
93  // x right sponge
94  if(use_xhi_sponge_damping){
95  if (x > xhi_sponge_start) {
96  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
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 
108  // y left sponge
109  if(use_ylo_sponge_damping){
110  if (y < ylo_sponge_end) {
111  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
112  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
113  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
114  if (n_qstate > 0) {
115  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
116  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
117  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
118  }
119  }
120  }
121  }
122  // x right sponge
123  if(use_yhi_sponge_damping){
124  if (y > yhi_sponge_start) {
125  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
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 
137  // x left sponge
138  if(use_zlo_sponge_damping){
139  if (z < zlo_sponge_end) {
140  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
141  cell_rhs(i, j, k, 0) -= sponge_strength * xi * xi * (cell_data(i, j, k, 0) - sponge_density);
142  cell_rhs(i, j, k, 1) -= sponge_strength * xi * xi * (cell_data(i, j, k, 1) - sponge_rhotheta);
143  if (n_qstate > 0) {
144  cell_rhs(i, j, k, RhoQ1_comp) -= sponge_strength * xi * xi * (cell_data(i, j, k, RhoQ1_comp) - sponge_rhomoist);
145  for (int n = RhoQ2_comp; n < RhoQ1_comp+n_qstate; ++n) {
146  cell_rhs(i, j, k, n) -= sponge_strength * xi * xi * cell_data(i, j, k, n);
147  }
148  }
149  }
150  }
151  // x right sponge
152  if(use_zhi_sponge_damping){
153  if (z > zhi_sponge_start) {
154  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
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  });
166 }
constexpr amrex::Real zero
Definition: ERF_Constants.H:6
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:11
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:43
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=(prob_lo[0]+(i+myhalf) *dx[0])/mf_m(i, j, 0);const Real z=z_cc(i, j, k);Real L=std::sqrt(std::pow((x - x_c)/x_r, 2)+std::pow((z - z_c)/z_r, 2));if(L<=one) { Real dT=T_pert *(std::cos(PI *L)+one)/two;Real Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), rdOcp);Real theta_0=(Tbar_hse) *std::pow(p_0/p_hse(i, j, k), rdOcp);if(const_rho) { state_pert(i, j, k, RhoTheta_comp)=r_hse(i, j, k) *(theta_perturbed - theta_0);} else { state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} } })
amrex::Real Real
Definition: ERF_ShocInterface.H:19
real(kind=kind_phys), parameter, private r0
Definition: ERF_module_mp_wsm6.F90:21
bool use_xlo_sponge_damping
Definition: ERF_SpongeStruct.H:52
amrex::Real xlo_sponge_end
Definition: ERF_SpongeStruct.H:62
amrex::Real zlo_sponge_end
Definition: ERF_SpongeStruct.H:64
bool use_zlo_sponge_damping
Definition: ERF_SpongeStruct.H:56
amrex::Real sponge_strength
Definition: ERF_SpongeStruct.H:59
bool use_ylo_sponge_damping
Definition: ERF_SpongeStruct.H:54
amrex::Real zhi_sponge_start
Definition: ERF_SpongeStruct.H:64
bool use_xhi_sponge_damping
Definition: ERF_SpongeStruct.H:53
bool use_zhi_sponge_damping
Definition: ERF_SpongeStruct.H:57
amrex::Real yhi_sponge_start
Definition: ERF_SpongeStruct.H:63
amrex::Real sponge_density
Definition: ERF_SpongeStruct.H:65
bool use_yhi_sponge_damping
Definition: ERF_SpongeStruct.H:55
amrex::Real xhi_sponge_start
Definition: ERF_SpongeStruct.H:62
amrex::Real sponge_rhomoist
Definition: ERF_SpongeStruct.H:67
amrex::Real ylo_sponge_end
Definition: ERF_SpongeStruct.H:63
amrex::Real sponge_rhotheta
Definition: ERF_SpongeStruct.H:66

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 
)
183 {
184  // Domain cell size and real bounds
185  auto dx = geom.CellSizeArray();
186  auto ProbHiArr = geom.ProbHiArray();
187  auto ProbLoArr = geom.ProbLoArray();
188 
189  const Real sponge_strength = spongeChoice.sponge_strength;
190  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
191  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
192  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
193  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
194  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
195  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
196  if (!use_xlo_sponge_damping &&
197  !use_xhi_sponge_damping &&
198  !use_ylo_sponge_damping &&
199  !use_yhi_sponge_damping &&
200  !use_zlo_sponge_damping &&
201  !use_zhi_sponge_damping)
202  return;
203 
204  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
205  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
206  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
207  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
208  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
209  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
210 
211  const Real sponge_x_velocity = spongeChoice.sponge_x_velocity;
212  const Real sponge_y_velocity = spongeChoice.sponge_y_velocity;
213  const Real sponge_z_velocity = spongeChoice.sponge_z_velocity;
214 
215  const Real sponge_density_tmp = spongeChoice.sponge_density;
216  const bool use_base = (sponge_density_tmp < zero);
217 
218  // Domain valid box
219  const Box& domain = geom.Domain();
220  int domlo_x = domain.smallEnd(0);
221  int domhi_x = domain.bigEnd(0) + 1;
222  int domlo_y = domain.smallEnd(1);
223  int domhi_y = domain.bigEnd(1) + 1;
224 
225  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
226  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
227  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
228  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
229  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
230  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
231 
232  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
233  {
234  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
235  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
236 
237  Real x = ProbLoArr[0] + ii * dx[0];
238  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
239  Real z = z_phys_cc(i,j,k);
240 
241  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i-1,j,k)) : sponge_density_tmp;
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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_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_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - sponge_density*sponge_x_velocity);
287  }
288  }
289  });
290 
291 
292  ParallelFor(tby, [=] 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+myhalf) * dx[0];
298  Real y = ProbLoArr[1] + jj * dx[1];
299  Real z = z_phys_cc(i,j,k);
300 
301  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j-1,k)) : sponge_density_tmp;
302 
303  // x lo sponge
304  if(use_xlo_sponge_damping){
305  if (x < xlo_sponge_end) {
306  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
307  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
308  }
309  }
310  // x hi sponge
311  if(use_xhi_sponge_damping){
312  if (x > xhi_sponge_start) {
313  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
314  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
315  }
316  }
317 
318  // y lo sponge
319  if(use_ylo_sponge_damping){
320  if (y < ylo_sponge_end) {
321  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
322  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
323  }
324  }
325  // x right sponge
326  if(use_yhi_sponge_damping){
327  if (y > yhi_sponge_start) {
328  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
329  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
330  }
331  }
332 
333  // z lo sponge
334  if(use_zlo_sponge_damping){
335  if (z < zlo_sponge_end) {
336  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
337  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - sponge_density*sponge_y_velocity);
338  }
339  }
340 
341 
342  // z hi sponge
343  if(use_zhi_sponge_damping){
344  if (z > zhi_sponge_start) {
345  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_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 
351 
352  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
353  {
354  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
355  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
356 
357  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
358  Real y = ProbLoArr[1] + (jj+myhalf) * dx[1];
359  Real z = z_phys_nd(i,j,k);
360 
361  Real sponge_density = (use_base) ? myhalf * (r0(i,j,k) + r0(i,j,k-1)) : sponge_density_tmp;
362 
363  // x left sponge
364  if(use_xlo_sponge_damping){
365  if (x < xlo_sponge_end) {
366  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
367  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
368  }
369  }
370  // x right sponge
371  if(use_xhi_sponge_damping){
372  if (x > xhi_sponge_start) {
373  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
374  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
375  }
376  }
377 
378  // y lo sponge
379  if(use_ylo_sponge_damping){
380  if (y < ylo_sponge_end) {
381  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
382  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
383  }
384  }
385  // x right sponge
386  if(use_yhi_sponge_damping){
387  if (y > yhi_sponge_start) {
388  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
389  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
390  }
391  }
392 
393  // z lo sponge
394  if(use_zlo_sponge_damping){
395  if (z < zlo_sponge_end) {
396  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
397  rho_w_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_w(i, j, k) - sponge_density*sponge_z_velocity);
398  }
399  }
400 
401 
402  // z top sponge
403  if(use_zhi_sponge_damping){
404  if (z > zhi_sponge_start) {
405  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_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 }
amrex::Real sponge_y_velocity
Definition: ERF_SpongeStruct.H:68
amrex::Real sponge_z_velocity
Definition: ERF_SpongeStruct.H:68
amrex::Real sponge_x_velocity
Definition: ERF_SpongeStruct.H:68

Referenced by make_mom_sources().

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