Skip to content

Commit

Permalink
remove additional pressure update in 1d cartesian
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichen3 committed Nov 12, 2024
1 parent b38a018 commit 401ee1f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
29 changes: 10 additions & 19 deletions Source/hydro/Castro_ctu_hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,35 +1259,26 @@ Castro::construct_ctu_hydro_source(Real time, Real dt) // NOLINT(readability-co
Array4<Real> const flux_arr = (flux[idir]).array();
Array4<Real const> const area_arr = (area[idir]).array(mfi);

scale_flux(nbx,
#if AMREX_SPACEDIM == 1
qex_arr,
#endif
flux_arr, area_arr, dt);
scale_flux(nbx, flux_arr, area_arr, dt);

#ifdef RADIATION
Array4<Real> const rad_flux_arr = (rad_flux[idir]).array();
scale_rad_flux(nbx, rad_flux_arr, area_arr, dt);
#endif

if (idir == 0) {
#if AMREX_SPACEDIM <= 2
Array4<Real> pradial_fab = pradial.array();
#endif
// get the scaled radial pressure -- we need to treat this specially

// get the scaled radial pressure -- we need to treat this specially
#if AMREX_SPACEDIM <= 2
if (!mom_flux_has_p(0, 0, coord)) {
amrex::ParallelFor(nbx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
pradial_fab(i,j,k) = qex_arr(i,j,k,GDPRES) * dt;
});
}
if (idir == 0 && !mom_flux_has_p(0, 0, coord)) {
Array4<Real> pradial_fab = pradial.array();

#endif
amrex::ParallelFor(nbx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
pradial_fab(i,j,k) = qex_arr(i,j,k,GDPRES) * dt;
});
}

#endif
// Store the fluxes from this advance. For simplified SDC integration we
// only need to do this on the last iteration.

Expand Down
3 changes: 0 additions & 3 deletions Source/hydro/Castro_hydro.H
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,6 @@


void scale_flux(const amrex::Box& bx,
#if AMREX_SPACEDIM == 1
amrex::Array4<amrex::Real const> const& qint,
#endif
amrex::Array4<amrex::Real> const& flux,
amrex::Array4<amrex::Real const> const& area,
const amrex::Real dt);
Expand Down
31 changes: 10 additions & 21 deletions Source/hydro/Castro_mol_hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,6 @@ Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update)

Array4<Real> pradial_fab = pradial.array();
#endif
#if AMREX_SPACEDIM == 1
Array4<Real> const qex_arr = qe[0].array();
#endif

for (int idir = 0; idir < AMREX_SPACEDIM; ++idir) {

Expand All @@ -668,27 +665,19 @@ Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update)
Array4<Real> const flux_arr = (flux[idir]).array();
Array4<Real const> const area_arr = (area[idir]).array(mfi);

scale_flux(nbx,
#if AMREX_SPACEDIM == 1
qex_arr,
#endif
flux_arr, area_arr, dt);

scale_flux(nbx, flux_arr, area_arr, dt);

if (idir == 0) {
// get the scaled radial pressure -- we need to treat this specially
Array4<Real> const qex_fab = qe[idir].array();
const int prescomp = GDPRES;
#if AMREX_SPACEDIM <= 2
// get the scaled radial pressure -- we need to treat this specially

if (idir == 0 && !mom_flux_has_p(0, 0, coord)) {
Array4<Real> const qex_arr = qe[idir].array();

#if AMREX_SPACEDIM <= 2
if (!mom_flux_has_p(0, 0, coord)) {
amrex::ParallelFor(nbx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
pradial_fab(i,j,k) = qex_fab(i,j,k,prescomp) * dt;
});
}
amrex::ParallelFor(nbx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
pradial_fab(i,j,k) = qex_arr(i,j,k,GDPRES) * dt;
});
#endif
}
}
Expand Down
14 changes: 0 additions & 14 deletions Source/hydro/advection_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,28 +503,14 @@ Castro::normalize_species_fluxes(const Box& bx,

void // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
Castro::scale_flux(const Box& bx,
#if AMREX_SPACEDIM == 1
Array4<Real const> const& qint,
#endif
Array4<Real> const& flux,
Array4<Real const> const& area_arr,
const Real dt) {

#if AMREX_SPACEDIM == 1
const int coord_type = geom.Coord();
#endif

amrex::ParallelFor(bx, NUM_STATE,
[=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{

flux(i,j,k,n) = dt * flux(i,j,k,n) * area_arr(i,j,k);
#if AMREX_SPACEDIM == 1
// Correct the momentum flux with the grad p part.
if (coord_type == 0 && n == UMX) {
flux(i,j,k,n) += dt * area_arr(i,j,k) * qint(i,j,k,GDPRES);
}
#endif
});
}

Expand Down

0 comments on commit 401ee1f

Please sign in to comment.