12 std::unique_ptr<amrex::MultiFab>& z_phys_nd,
13 std::unique_ptr<amrex::MultiFab>& z_phys_cc,
14 amrex::Geometry
const& geom)
override
16 const amrex::Real dz = geom.CellSize()[2];
18 const amrex::Real T_sfc = 300.;
19 const amrex::Real rho_sfc =
p_0 / (
R_d*T_sfc);
20 const amrex::Real Thetabar = T_sfc;
22 const int domlo_z = geom.Domain().smallEnd(2);
23 const int domhi_z = geom.Domain().bigEnd(2);
25 if (domhi_z > 255) amrex::Abort(
"1D Arrays are hard-wired to only 256 high");
27 bool use_terrain = (z_phys_nd !=
nullptr);
31 for ( amrex::MFIter mfi(rho_hse,
TileNoZ()); mfi.isValid(); ++mfi )
33 amrex::Array4<amrex::Real > rho_arr = rho_hse.array(mfi);
34 amrex::Array4<amrex::Real const> z_cc_arr = (use_terrain) ?
35 z_phys_cc->const_array(mfi) : amrex::Array4<amrex::Real const>{};
38 const amrex::Box& tbz = mfi.nodaltilebox(2);
40 b2d.grow(0,1); b2d.grow(1,1);
43 const int ilo = tbz.smallEnd(0);
44 const int jlo = tbz.smallEnd(1);
45 const int klo = tbz.smallEnd(2);
46 const int khi = tbz.bigEnd(2)-1;
48 amrex::Real rho_local_sfc;
50 rho_local_sfc = rho_sfc;
52 rho_local_sfc = rho_arr(ilo,jlo,klo-1);
55 amrex::ParallelFor(b2d, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
57 amrex::Array1D<amrex::Real,0,255> r;
58 amrex::Array1D<amrex::Real,0,255> p;
61 for (
int k = klo; k <= khi; k++) {
62 rho_arr(i,j,k) = r(k);
67 rho_arr(i,j,domlo_z-1) = rho_arr(i,j,domlo_z);
70 rho_arr(i,j,domhi_z+1) = rho_arr(i,j,domhi_z);
80 const int klo = geom.Domain().smallEnd(2);
81 const int khi = geom.Domain().bigEnd(2);
84 amrex::Vector<amrex::Real> h_r(khi+2);
85 amrex::Vector<amrex::Real> h_p(khi+2);
87 amrex::Gpu::DeviceVector<amrex::Real> d_r(khi+2);
88 amrex::Gpu::DeviceVector<amrex::Real> d_p(khi+2);
92 amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_r.begin(), h_r.end(), d_r.begin());
93 amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, h_p.begin(), h_p.end(), d_p.begin());
95 amrex::Real* r = d_r.data();
98 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
100 for ( amrex::MFIter mfi(rho_hse, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
102 const amrex::Box& bx = mfi.growntilebox(1);
103 const amrex::Array4<amrex::Real> rho_hse_arr = rho_hse[mfi].array();
104 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
106 int kk = std::max(k,0);
107 rho_hse_arr(i,j,k) = r[kk];
constexpr amrex::Real p_0
Definition: ERF_Constants.H:18
constexpr amrex::Real R_d
Definition: ERF_Constants.H:10
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
void erf_init_dens_hse(amrex::MultiFab &rho_hse, std::unique_ptr< amrex::MultiFab > &z_phys_nd, std::unique_ptr< amrex::MultiFab > &z_phys_cc, amrex::Geometry const &geom) override
Definition: ERF_init_density_hse_dry.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void init_isentropic_hse_terrain(int i, int j, const amrex::Real &r_sfc, const amrex::Real &theta, amrex::Real *r, amrex::Real *p, const amrex::Array4< amrex::Real const > z_cc, const int &klo, const int &khi)
Definition: ERF_HSE_utils.H:200
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void init_isentropic_hse(const amrex::Real &r_sfc, const amrex::Real &theta, amrex::Real *r, amrex::Real *p, const amrex::Real &dz, const int klo, const int khi)
Definition: ERF_HSE_utils.H:88