ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ApplySpongeZoneBCs_ReadFromFile.cpp File Reference
#include <AMReX_MultiFab.H>
#include <ERF_SrcHeaders.H>
#include <ERF_InputSpongeData.H>
Include dependency graph for ERF_ApplySpongeZoneBCs_ReadFromFile.cpp:

Functions

void ApplySpongeZoneBCsForMom_ReadFromFile (const SpongeChoice &spongeChoice, const Geometry geom, const Box &tbx, const Box &tby, const Array4< const Real > &cell_data, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Vector< Real * > d_sponge_ptrs_at_lev)
 

Function Documentation

◆ ApplySpongeZoneBCsForMom_ReadFromFile()

void ApplySpongeZoneBCsForMom_ReadFromFile ( const SpongeChoice spongeChoice,
const Geometry  geom,
const Box &  tbx,
const Box &  tby,
const Array4< const Real > &  cell_data,
const Array4< Real > &  rho_u_rhs,
const Array4< Real > &  rho_v_rhs,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Vector< Real * >  d_sponge_ptrs_at_lev 
)
19 {
20  // Domain cell size and real bounds
21  auto dx = geom.CellSizeArray();
22  auto ProbHiArr = geom.ProbHiArray();
23  auto ProbLoArr = geom.ProbLoArray();
24 
25  const Real sponge_strength = spongeChoice.sponge_strength;
26  const int use_xlo_sponge_damping = spongeChoice.use_xlo_sponge_damping;
27  const int use_xhi_sponge_damping = spongeChoice.use_xhi_sponge_damping;
28  const int use_ylo_sponge_damping = spongeChoice.use_ylo_sponge_damping;
29  const int use_yhi_sponge_damping = spongeChoice.use_yhi_sponge_damping;
30  const int use_zlo_sponge_damping = spongeChoice.use_zlo_sponge_damping;
31  const int use_zhi_sponge_damping = spongeChoice.use_zhi_sponge_damping;
32 
33  const Real xlo_sponge_end = spongeChoice.xlo_sponge_end;
34  const Real xhi_sponge_start = spongeChoice.xhi_sponge_start;
35  const Real ylo_sponge_end = spongeChoice.ylo_sponge_end;
36  const Real yhi_sponge_start = spongeChoice.yhi_sponge_start;
37  const Real zlo_sponge_end = spongeChoice.zlo_sponge_end;
38  const Real zhi_sponge_start = spongeChoice.zhi_sponge_start;
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  Real* ubar_sponge = d_sponge_ptrs_at_lev[Sponge::ubar_sponge];
50  Real* vbar_sponge = d_sponge_ptrs_at_lev[Sponge::vbar_sponge];
51 
52  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
53  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
54  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
55  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
56  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
57  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
58 
59  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
60  {
61  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
62  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
63  int kk = amrex::min(amrex::max(k, domlo_z), domhi_z);
64 
65  Real x = ProbLoArr[0] + ii * dx[0];
66  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
67  Real z = ProbLoArr[2] + (kk+0.5) * dx[2];
68 
69  // x lo sponge
70  if(use_xlo_sponge_damping){
71  if (x < xlo_sponge_end) {
72  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
73  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
74  }
75  }
76  // x hi sponge
77  if(use_xhi_sponge_damping){
78  if (x > xhi_sponge_start) {
79  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
80  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
81  }
82  }
83 
84  // y lo sponge
85  if(use_ylo_sponge_damping){
86  if (y < ylo_sponge_end) {
87  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
88  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
89  }
90  }
91  // x right sponge
92  if(use_yhi_sponge_damping){
93  if (y > yhi_sponge_start) {
94  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
95  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
96  }
97  }
98 
99  // z lo sponge
100  if(use_zlo_sponge_damping){
101  if (z < zlo_sponge_end) {
102  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
103  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
104  }
105  }
106 
107 
108  // z hi sponge
109  if(use_zhi_sponge_damping){
110  if (z > zhi_sponge_start) {
111  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
112  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
113  }
114  }
115  });
116 
117 
118  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
119  {
120  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
121  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
122  int kk = amrex::min(amrex::max(k, domlo_z), domhi_z);
123 
124  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
125  Real y = ProbLoArr[1] + jj * dx[1];
126  Real z = ProbLoArr[2] + (kk+0.5) * dx[2];
127 
128  // x lo sponge
129  if(use_xlo_sponge_damping){
130  if (x < xlo_sponge_end) {
131  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
132  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
133  }
134  }
135  // x hi sponge
136  if(use_xhi_sponge_damping){
137  if (x > xhi_sponge_start) {
138  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
139  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
140  }
141  }
142 
143  // y lo sponge
144  if(use_ylo_sponge_damping){
145  if (y < ylo_sponge_end) {
146  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
147  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
148  }
149  }
150  // x right sponge
151  if(use_yhi_sponge_damping){
152  if (y > yhi_sponge_start) {
153  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
154  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
155  }
156  }
157 
158  // z lo sponge
159  if(use_zlo_sponge_damping){
160  if (z < zlo_sponge_end) {
161  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
162  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
163  }
164  }
165 
166 
167  // z hi sponge
168  if(use_zhi_sponge_damping){
169  if (z > zhi_sponge_start) {
170  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
171  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
172  }
173  }
174  });
175 }
@ vbar_sponge
Definition: ERF_DataStruct.H:75
@ ubar_sponge
Definition: ERF_DataStruct.H:75
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
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_mom_sources().

Here is the caller graph for this function: