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

Functions

void ApplyBndryForcing_Forecast (const SolverChoice &solverChoice, const Geometry geom, const Box &tbx, const Box &tby, const Box &tbz, const Array4< const Real > &z_phys_nd, 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 > &rho_u_initial_state, const Array4< const Real > &rho_v_initial_state, const Array4< const Real > &rho_w_initial_state, const Array4< const Real > &cons_initial_state)
 

Function Documentation

◆ ApplyBndryForcing_Forecast()

void ApplyBndryForcing_Forecast ( const SolverChoice solverChoice,
const Geometry  geom,
const Box &  tbx,
const Box &  tby,
const Box &  tbz,
const Array4< const Real > &  z_phys_nd,
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 > &  rho_u_initial_state,
const Array4< const Real > &  rho_v_initial_state,
const Array4< const Real > &  rho_w_initial_state,
const Array4< const Real > &  cons_initial_state 
)
26 {
27  // Domain cell size and real bounds
28  auto dx = geom.CellSizeArray();
29  auto ProbHiArr = geom.ProbHiArray();
30  auto ProbLoArr = geom.ProbLoArray();
31 
32  amrex::ignore_unused(rho_w_initial_state);
33 
34  // Domain valid box
35  const Box& domain = geom.Domain();
36  int domlo_x = domain.smallEnd(0);
37  int domhi_x = domain.bigEnd(0) + 1;
38  int domlo_y = domain.smallEnd(1);
39  int domhi_y = domain.bigEnd(1) + 1;
40 
41  Real hindcast_lateral_sponge_length = solverChoice.hindcast_lateral_sponge_length;
42  Real hindcast_lateral_sponge_strength = solverChoice.hindcast_lateral_sponge_strength;
43 
44  bool hindcast_zhi_sponge_damping = solverChoice.hindcast_zhi_sponge_damping;
45  Real hindcast_zhi_sponge_length = solverChoice.hindcast_zhi_sponge_length;
46  Real hindcast_zhi_sponge_strength = solverChoice.hindcast_zhi_sponge_strength;
47 
48  Real xlo_sponge_end = ProbLoArr[0] + hindcast_lateral_sponge_length;
49  Real xhi_sponge_start = ProbHiArr[0] - hindcast_lateral_sponge_length;
50  Real ylo_sponge_end = ProbLoArr[1] + hindcast_lateral_sponge_length;
51  Real yhi_sponge_start = ProbHiArr[1] - hindcast_lateral_sponge_length;
52  Real zhi_sponge_start = ProbHiArr[2] - hindcast_zhi_sponge_length;
53 
54  AMREX_ALWAYS_ASSERT(xlo_sponge_end > ProbLoArr[0]);
55  AMREX_ALWAYS_ASSERT(xhi_sponge_start < ProbHiArr[0]);
56  AMREX_ALWAYS_ASSERT(ylo_sponge_end > ProbLoArr[1]);
57  AMREX_ALWAYS_ASSERT(yhi_sponge_start < ProbHiArr[1]);
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 
64  Real x = ProbLoArr[0] + ii * dx[0];
65  Real y = ProbLoArr[1] + (jj+0.5) * dx[1];
66 
67  Real rho_u_sponge = rho_u_initial_state(i,j,k)*cons_initial_state(i,j,k,0);
68  // x lo sponge
69  if (x < xlo_sponge_end) {
70  Real xi = (xlo_sponge_end - x) / hindcast_lateral_sponge_length;
71  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
72  }
73  // x hi sponge
74  if (x > xhi_sponge_start) {
75  Real xi = (x - xhi_sponge_start) / hindcast_lateral_sponge_length;
76  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
77  }
78  // y lo sponge
79  if (y < ylo_sponge_end) {
80  Real xi = (ylo_sponge_end - y) / hindcast_lateral_sponge_length;
81  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
82  }
83  // x right sponge
84  if (y > yhi_sponge_start) {
85  Real xi = (y - yhi_sponge_start) / hindcast_lateral_sponge_length;
86  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
87  }
88  });
89 
90 
91  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
92  {
93  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
94  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
95 
96  Real x = ProbLoArr[0] + (ii+0.5) * dx[0];
97  Real y = ProbLoArr[1] + jj * dx[1];
98 
99  Real rho_v_sponge = rho_v_initial_state(i,j,k)*cons_initial_state(i,j,k,0);
100 
101  // x lo sponge
102  if (x < xlo_sponge_end) {
103  Real xi = (xlo_sponge_end - x) / hindcast_lateral_sponge_length;
104  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
105  }
106  // x hi sponge
107  if (x > xhi_sponge_start) {
108  Real xi = (x - xhi_sponge_start) / hindcast_lateral_sponge_length;
109  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
110  }
111 
112  // y lo sponge
113  if (y < ylo_sponge_end) {
114  Real xi = (ylo_sponge_end - y) / hindcast_lateral_sponge_length;
115  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
116  }
117  // x right sponge
118  if (y > yhi_sponge_start) {
119  Real xi = (y - yhi_sponge_start) / hindcast_lateral_sponge_length;
120  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
121  }
122  });
123 
124  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
125  {
126  Real z = z_phys_nd(i,j,k);
127 
128  if(hindcast_zhi_sponge_damping){
129  if (z > zhi_sponge_start) {
130  Real xi = (z - zhi_sponge_start) / hindcast_zhi_sponge_length;
131  rho_w_rhs(i, j, k) -= hindcast_zhi_sponge_strength * xi * xi * (rho_w(i, j, k) - 0.0);
132  }
133  }
134  });
135 }
amrex::Real Real
Definition: ERF_ShocInterface.H:19
amrex::Real hindcast_lateral_sponge_strength
Definition: ERF_DataStruct.H:955
amrex::Real hindcast_zhi_sponge_length
Definition: ERF_DataStruct.H:956
bool hindcast_zhi_sponge_damping
Definition: ERF_DataStruct.H:957
amrex::Real hindcast_lateral_sponge_length
Definition: ERF_DataStruct.H:955
amrex::Real hindcast_zhi_sponge_strength
Definition: ERF_DataStruct.H:956

Referenced by make_mom_sources().

Here is the caller graph for this function: