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