ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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< const Real > &z_phys_cc, 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< const Real > &  z_phys_cc,
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 
47  Real* ubar_sponge = d_sponge_ptrs_at_lev[Sponge::ubar_sponge];
48  Real* vbar_sponge = d_sponge_ptrs_at_lev[Sponge::vbar_sponge];
49 
50  if(use_xlo_sponge_damping)AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
51  if(use_xhi_sponge_damping)AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
52  if(use_ylo_sponge_damping)AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
53  if(use_yhi_sponge_damping)AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
54  if(use_zlo_sponge_damping)AMREX_ALWAYS_ASSERT(zlo_sponge_end > ProbLoArr[2]);
55  if(use_zhi_sponge_damping)AMREX_ALWAYS_ASSERT(zhi_sponge_start < ProbHiArr[2]);
56 
57  ParallelFor(tbx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
58  {
59  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
60  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
61 
62  Real x = ProbLoArr[0] + ii * dx[0];
63  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
64  Real z = z_phys_cc(i,j,k);
65 
66  // x lo sponge
67  if(use_xlo_sponge_damping){
68  if (x < xlo_sponge_end) {
69  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
70  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
71  }
72  }
73  // x hi sponge
74  if(use_xhi_sponge_damping){
75  if (x > xhi_sponge_start) {
76  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
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 
81  // y lo sponge
82  if(use_ylo_sponge_damping){
83  if (y < ylo_sponge_end) {
84  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
85  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
86  }
87  }
88  // x right sponge
89  if(use_yhi_sponge_damping){
90  if (y > yhi_sponge_start) {
91  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
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 
96  // z lo sponge
97  if(use_zlo_sponge_damping){
98  if (z < zlo_sponge_end) {
99  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
100  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
101  }
102  }
103 
104 
105  // z hi sponge
106  if(use_zhi_sponge_damping){
107  if (z > zhi_sponge_start) {
108  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
109  rho_u_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_u(i, j, k) - cell_data(i,j,k,0)*ubar_sponge[k]);
110  }
111  }
112  });
113 
114 
115  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
116  {
117  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
118  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
119 
120  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
121  Real y = ProbLoArr[1] + jj * dx[1];
122  Real z = z_phys_cc(i,j,k);
123 
124  // x lo sponge
125  if(use_xlo_sponge_damping){
126  if (x < xlo_sponge_end) {
127  Real xi = (xlo_sponge_end - x) / (xlo_sponge_end - ProbLoArr[0]);
128  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
129  }
130  }
131  // x hi sponge
132  if(use_xhi_sponge_damping){
133  if (x > xhi_sponge_start) {
134  Real xi = (x - xhi_sponge_start) / (ProbHiArr[0] - xhi_sponge_start);
135  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
136  }
137  }
138 
139  // y lo sponge
140  if(use_ylo_sponge_damping){
141  if (y < ylo_sponge_end) {
142  Real xi = (ylo_sponge_end - y) / (ylo_sponge_end - ProbLoArr[1]);
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  // x right sponge
147  if(use_yhi_sponge_damping){
148  if (y > yhi_sponge_start) {
149  Real xi = (y - yhi_sponge_start) / (ProbHiArr[1] - yhi_sponge_start);
150  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
151  }
152  }
153 
154  // z lo sponge
155  if(use_zlo_sponge_damping){
156  if (z < zlo_sponge_end) {
157  Real xi = (zlo_sponge_end - z) / (zlo_sponge_end - ProbLoArr[2]);
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 
163  // z hi sponge
164  if(use_zhi_sponge_damping){
165  if (z > zhi_sponge_start) {
166  Real xi = (z - zhi_sponge_start) / (ProbHiArr[2] - zhi_sponge_start);
167  rho_v_rhs(i, j, k) -= sponge_strength * xi * xi * (rho_v(i, j, k) - cell_data(i,j,k,0)*vbar_sponge[k]);
168  }
169  }
170  });
171 }
@ vbar_sponge
Definition: ERF_DataStruct.H:84
@ ubar_sponge
Definition: ERF_DataStruct.H:84
bool use_xlo_sponge_damping
Definition: ERF_SpongeStruct.H:50
amrex::Real xlo_sponge_end
Definition: ERF_SpongeStruct.H:60
amrex::Real zlo_sponge_end
Definition: ERF_SpongeStruct.H:62
bool use_zlo_sponge_damping
Definition: ERF_SpongeStruct.H:54
amrex::Real sponge_strength
Definition: ERF_SpongeStruct.H:57
bool use_ylo_sponge_damping
Definition: ERF_SpongeStruct.H:52
amrex::Real zhi_sponge_start
Definition: ERF_SpongeStruct.H:62
bool use_xhi_sponge_damping
Definition: ERF_SpongeStruct.H:51
bool use_zhi_sponge_damping
Definition: ERF_SpongeStruct.H:55
amrex::Real yhi_sponge_start
Definition: ERF_SpongeStruct.H:61
bool use_yhi_sponge_damping
Definition: ERF_SpongeStruct.H:53
amrex::Real xhi_sponge_start
Definition: ERF_SpongeStruct.H:60
amrex::Real ylo_sponge_end
Definition: ERF_SpongeStruct.H:61

Referenced by make_mom_sources().

Here is the caller graph for this function: