35 , density(fields_in.repo.get_field(
"density"))
36 , u_mac(fields_in.repo.get_field(
"u_mac"))
37 , v_mac(fields_in.repo.get_field(
"v_mac"))
38 , w_mac(fields_in.repo.get_field(
"w_mac"))
40 amrex::ParmParse pp(
"incflo");
41 pp.query(
"godunov_type", godunov_type);
42 pp.query(
"godunov_use_forces_in_trans", godunov_use_forces_in_trans);
43 if (pp.contains(
"use_ppm") || pp.contains(
"use_limiter")) {
45 "Godunov: use_ppm and use_limiter are deprecated. Please "
49 if (amrex::toLower(godunov_type) ==
"plm") {
51 }
else if (amrex::toLower(godunov_type) ==
"ppm") {
53 }
else if (amrex::toLower(godunov_type) ==
"ppm_nolim") {
55 amrex::Print() <<
"WARNING: Using advection type ppm_nolim is not "
56 "recommended. Prefer using weno_z."
58 }
else if (amrex::toLower(godunov_type) ==
"bds") {
60 advection_type =
"BDS";
62 amrex::toLower(godunov_type) ==
"weno" ||
63 amrex::toLower(godunov_type) ==
"weno_js") {
65 }
else if (amrex::toLower(godunov_type) ==
"weno_z") {
69 "Invalid godunov_type specified. For godunov_type select "
70 "between plm, ppm, ppm_nolim, bds, weno_js, and weno_z. If no "
71 "godunov_type is specified, the default weno_z is used.");
76 "allow_inflow_at_pressure_outflow", m_allow_inflow_on_outflow);
79 iconserv.resize(PDE::ndim, 1);
91 PDE::ndim == 1,
"Invalid number of components for scalar");
92 auto& repo = fields.repo;
93 const auto& geom = repo.mesh().Geom();
95 const auto& src_term = fields.src_term;
97 auto& conv_term = fields.conv_term;
98 const auto& dof_field = fields.field.state(fstate);
115 const auto& den = density.state(fstate);
118 for (
int lev = 0; lev < repo.num_active_levels(); ++lev) {
119 amrex::MFItInfo mfi_info;
120 if (amrex::Gpu::notInLaunchRegion()) {
121 mfi_info.EnableTiling(amrex::IntVect(1024, 1024, 1024))
125#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
127 for (amrex::MFIter mfi(dof_field(lev), mfi_info); mfi.isValid();
129 const auto& bx = mfi.tilebox();
130 auto rho_arr = den(lev).array(mfi);
131 auto rho_nph_arr = den_nph(lev).array(mfi);
132 auto tra_arr = dof_field(lev).array(mfi);
133 auto tra_nph_arr = dof_nph(lev).array(mfi);
134 amrex::FArrayBox rhotracfab;
135 amrex::Array4<amrex::Real> rhotrac;
136 amrex::FArrayBox rhotrac_nph_fab;
137 amrex::Array4<amrex::Real> rhotrac_nph;
139 if (PDE::multiply_rho) {
142 rhotracfab.resize(rhotrac_box, PDE::ndim);
143 rhotrac = rhotracfab.array();
144 rhotrac_nph_fab.resize(rhotrac_box, PDE::ndim);
145 rhotrac_nph = rhotrac_nph_fab.array();
148 rhotrac_box, PDE::ndim,
149 [=] AMREX_GPU_DEVICE(
150 int i,
int j,
int k,
int n)
noexcept {
151 rhotrac(i, j, k, n) =
152 rho_arr(i, j, k) * tra_arr(i, j, k, n);
153 rhotrac_nph(i, j, k, n) =
154 rho_nph_arr(i, j, k) * tra_nph_arr(i, j, k, n);
164 amrex::FArrayBox tmpfab(amrex::grow(bx, 1), 1);
165 tmpfab.setVal<amrex::RunOn::Device>(0.0);
166 const auto& divu = tmpfab.array();
167 const bool is_velocity =
false;
168 const bool known_edge_state =
false;
169 const bool godunov_use_ppm =
174 limiter_type = PPM::NoLimiter;
176 limiter_type = PPM::WENOZ;
178 limiter_type = PPM::WENO_JS;
180 limiter_type = PPM::default_limiter;
185 const amrex::Real dt_extrap =
188 HydroUtils::ComputeFluxesOnBoxFromState(
190 (PDE::multiply_rho ? rhotrac : tra_arr),
191 (PDE::multiply_rho ? rhotrac_nph : tra_nph_arr),
192 (*flux_x)(lev).array(mfi), (*flux_y)(lev).array(mfi),
193 (*flux_z)(lev).array(mfi), (*face_x)(lev).array(mfi),
194 (*face_y)(lev).array(mfi), (*face_z)(lev).array(mfi),
195 known_edge_state, u_mac(lev).const_array(mfi),
196 v_mac(lev).const_array(mfi),
197 w_mac(lev).const_array(mfi), divu,
198 src_term(lev).const_array(mfi), geom[lev], dt_extrap,
199 dof_field.bcrec(), dof_field.bcrec_device().data(),
200 iconserv.data(), godunov_use_ppm,
201 godunov_use_forces_in_trans, is_velocity,
202 fluxes_are_area_weighted, advection_type, limiter_type,
203 m_allow_inflow_on_outflow);
205 amrex::Abort(
"Invalid godunov scheme");
207 amrex::Gpu::streamSynchronize();
211 amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
212 repo.num_active_levels());
213 for (
int lev = 0; lev < repo.num_active_levels(); ++lev) {
214 fluxes[lev][0] = &(*flux_x)(lev);
215 fluxes[lev][1] = &(*flux_y)(lev);
216 fluxes[lev][2] = &(*flux_z)(lev);
221 for (
int lev = repo.num_active_levels() - 1; lev > 0; --lev) {
223 geom[lev].Domain().size() / geom[lev - 1].Domain().size();
224 amrex::average_down_faces(
225 GetArrOfConstPtrs(fluxes[lev]), fluxes[lev - 1], rr,
229 for (
int lev = 0; lev < repo.num_active_levels(); ++lev) {
231#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
233 for (amrex::MFIter mfi(dof_field(lev), amrex::TilingIfNotGPU());
234 mfi.isValid(); ++mfi) {
235 const auto& bx = mfi.tilebox();
237 HydroUtils::ComputeDivergence(
238 bx, conv_term(lev).array(mfi), (*flux_x)(lev).array(mfi),
239 (*flux_y)(lev).array(mfi), (*flux_z)(lev).array(mfi),
240 PDE::ndim, geom[lev], amrex::Real(-1.0),
241 fluxes_are_area_weighted);