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+myhalf) * dx[1];
66 
67  // Target momentum: forecast u times the forecast density on the x-face
68  Real rho_on_u_face = myhalf * (cons_initial_state(i-1,j,k,0) + cons_initial_state(i,j,k,0));
69  Real rho_u_sponge = rho_u_initial_state(i,j,k)*rho_on_u_face;
70  // x lo sponge
71  if (x < xlo_sponge_end) {
72  Real xi = (xlo_sponge_end - x) / hindcast_lateral_sponge_length;
73  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
74  }
75  // x hi sponge
76  if (x > xhi_sponge_start) {
77  Real xi = (x - xhi_sponge_start) / hindcast_lateral_sponge_length;
78  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
79  }
80  // y lo sponge
81  if (y < ylo_sponge_end) {
82  Real xi = (ylo_sponge_end - y) / hindcast_lateral_sponge_length;
83  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
84  }
85  // x right sponge
86  if (y > yhi_sponge_start) {
87  Real xi = (y - yhi_sponge_start) / hindcast_lateral_sponge_length;
88  rho_u_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_u(i, j, k) - rho_u_sponge);
89  }
90  });
91 
92 
93  ParallelFor(tby, [=] AMREX_GPU_DEVICE(int i, int j, int k)
94  {
95  int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
96  int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
97 
98  Real x = ProbLoArr[0] + (ii+myhalf) * dx[0];
99  Real y = ProbLoArr[1] + jj * dx[1];
100 
101  // Target momentum: forecast v times the forecast density on the y-face
102  Real rho_on_v_face = myhalf * (cons_initial_state(i,j-1,k,0) + cons_initial_state(i,j,k,0));
103  Real rho_v_sponge = rho_v_initial_state(i,j,k)*rho_on_v_face;
104 
105  // x lo sponge
106  if (x < xlo_sponge_end) {
107  Real xi = (xlo_sponge_end - x) / hindcast_lateral_sponge_length;
108  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
109  }
110  // x hi sponge
111  if (x > xhi_sponge_start) {
112  Real xi = (x - xhi_sponge_start) / hindcast_lateral_sponge_length;
113  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
114  }
115 
116  // y lo sponge
117  if (y < ylo_sponge_end) {
118  Real xi = (ylo_sponge_end - y) / hindcast_lateral_sponge_length;
119  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
120  }
121  // x right sponge
122  if (y > yhi_sponge_start) {
123  Real xi = (y - yhi_sponge_start) / hindcast_lateral_sponge_length;
124  rho_v_rhs(i, j, k) -= hindcast_lateral_sponge_strength * xi * xi * (rho_v(i, j, k) - rho_v_sponge);
125  }
126  });
127 
128  ParallelFor(tbz, [=] AMREX_GPU_DEVICE(int i, int j, int k)
129  {
130  Real z = z_phys_nd(i,j,k);
131 
132  if(hindcast_zhi_sponge_damping){
133  if (z > zhi_sponge_start) {
134  Real xi = (z - zhi_sponge_start) / hindcast_zhi_sponge_length;
135  rho_w_rhs(i, j, k) -= hindcast_zhi_sponge_strength * xi * xi * (rho_w(i, j, k) - zero);
136  }
137  }
138  });
139 }
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::Real Real
Definition: ERF_ShocInterface.H:19
amrex::Real hindcast_zhi_sponge_length
Length of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:3056
bool hindcast_zhi_sponge_damping
Whether upper-boundary hindcast sponge damping is enabled.
Definition: ERF_DataStruct.H:3057
amrex::Real hindcast_lateral_sponge_strength
Strength of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:3055
amrex::Real hindcast_lateral_sponge_length
Length of the hindcast lateral sponge layer.
Definition: ERF_DataStruct.H:3055
amrex::Real hindcast_zhi_sponge_strength
Strength of the upper hindcast sponge layer.
Definition: ERF_DataStruct.H:3056

Referenced by make_mom_sources().

Here is the call graph for this function:
Here is the caller graph for this function: