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