ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_UpdateRhoQtSources_SDMCongestus3D.H
Go to the documentation of this file.
1  ParmParse pp_prob("prob");
2 
3  Real advection_moisture_rate = 1.0e-8; pp_prob.query("advection_moisture_rate" , advection_moisture_rate);
4  Real advection_moisture_rate_base = 1.0e-8; pp_prob.query("advection_moisture_rate_base", advection_moisture_rate_base);
5 
6  auto prob_lo = geom.ProbLoArray();
7  auto prob_hi = geom.ProbHiArray();
8  auto dx = geom.CellSizeArray();
9 
10  // Define a point (xc,yc,zc) at the center of the domain
11  auto xc = 0.5 * (prob_lo[0] + prob_hi[0]);
12  auto yc = 0.5 * (prob_lo[1] + prob_hi[1]);
13 
14  // Only apply temperature source below nominal inversion height
15  for (MFIter mfi(*qsrc, TilingIfNotGPU()); mfi.isValid(); ++mfi)
16  {
17  const auto &box = mfi.tilebox();
18  const Array4<Real>& qsrc_arr = qsrc->array(mfi);
19  if (box.length(0) != 1)
20  {
21  // if z dimension size is 1, then src is a spatially varying function over x,y at k=0
22  ParallelFor( box, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
23  {
24  auto x = prob_lo[0] + (i + 0.5) * dx[0];
25  auto y = prob_lo[1] + (j + 0.5) * dx[1];
26  auto z = prob_lo[2] + (k + 0.5) * dx[2];
27 
28  //const Real c = 2.0*dx[0];
29  auto c = 1700.0*1700.0;
30  auto r = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc));
31  auto rsqr = r*r;
32  if (time < 3600) {
33  qsrc_arr(i, j, k) = (advection_moisture_rate_base)*exp(-z/100);
34  } else {
35  qsrc_arr(i, j, k) = (advection_moisture_rate*exp(-rsqr / c))*exp(-z/100);
36  }
37  });
38  } else {
39  // src is a function over Z
40  ParallelFor(box, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
41  qsrc_arr(i, j, k) = 0.0;
42  });
43  }
44  }
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=(prob_lo[0]+(i+0.5) *dx[0])/mf_m(i, j, 0);const Real z=z_cc(i, j, k);Real L=std::sqrt(std::pow((x - x_c)/x_r, 2)+std::pow((z - z_c)/z_r, 2));if(L<=1.0) { Real dT=T_pert *(std::cos(PI *L)+1.0)/2.0;Real Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), rdOcp);Real theta_0=(Tbar_hse) *std::pow(p_0/p_hse(i, j, k), rdOcp);if(const_rho) { state_pert(i, j, k, RhoTheta_comp)=r_hse(i, j, k) *(theta_perturbed - theta_0);} else { state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} } })
amrex::Real Real
Definition: ERF_ShocInterface.H:19
auto prob_lo
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:6
ParmParse pp_prob("prob")
auto yc
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:12
auto xc
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:11
Real advection_moisture_rate_base
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:4
Real advection_moisture_rate
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:3
auto prob_hi
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:7
auto dx
Definition: ERF_UpdateRhoQtSources_SDMCongestus3D.H:8