Skip to content

Commit

Permalink
remove extra pressure scale in scale_flux for 1d cartesian (#2991)
Browse files Browse the repository at this point in the history
addresses #2803 . In #2468, we modified mom_flux_has_p to include pressure in momentum flux with 1d cartesian, so we don't need to scale pressure again scale_flux.
  • Loading branch information
zhichen3 authored Nov 17, 2024
1 parent aed0328 commit be78430
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 83 deletions.
52 changes: 26 additions & 26 deletions Exec/radiation_tests/Rad2Tshock/ci-benchmarks/Rad2TShock-1d.out
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
plotfile = plt_00025
time = 0.00026083835470476599
time = 0.00026084061812361401
variables minimum value maximum value
density 5.4596904436e-13 1.2720098871e-12
xmom 1.2327065163e-07 1.4587103381e-07
density 5.4596904436e-13 1.2717694091e-12
xmom 1.2328047524e-07 1.4591226172e-07
ymom 0 0
zmom 0 0
rho_E 0.021940622286 0.039199658391
rho_e 0.0068091599527 0.032333529333
Temp 100.00003116 217.3564598
rho_X 5.4596904436e-13 1.2720098871e-12
rad 7.5662679486e-07 1.4083425328e-05
pressure 0.0045394399687 0.021555686223
kineng 0.0064467244856 0.015131462333
soundspeed 117717.6283 173551.23637
rho_E 0.021940622285 0.039194728059
rho_e 0.0068091599514 0.032333527949
Temp 100.00003115 217.29660609
rho_X 5.4596904436e-13 1.2717694091e-12
rad 7.5662675907e-07 1.4083418723e-05
pressure 0.0045394399678 0.0215556853
kineng 0.0064473434191 0.015131462334
soundspeed 117717.62829 173527.33922
Gamma_1 1.6666666667 1.6666666667
MachNumber 0.60689740202 1.9999997205
uplusc 269483.97988 362284.15407
uminusc -66810.704217 117717.5954
entropy 2458725989.8 2507243428
MachNumber 0.6068973935 1.9999997207
uplusc 269518.17809 362247.33487
uminusc -66804.446805 117717.59541
entropy 2458725989.8 2507184972.2
magvort 0 0
divu -20286.061564 245.50876324
eint_E 12471696011 27108028479
eint_e 12471696011 27108028479
logden -12.26283198 -11.895509513
StateErr_0 5.4596904436e-13 1.2720098871e-12
StateErr_1 100.00003116 217.3564598
divu -20283.836079 245.94831837
eint_E 12471696009 27100563708
eint_e 12471696009 27100563708
logden -12.26283198 -11.895591626
StateErr_0 5.4596904436e-13 1.2717694091e-12
StateErr_1 100.00003115 217.29660609
StateErr_2 1 1
X(X) 1 1
abar 1 1
x_velocity 102258.95554 235435.2237
x_velocity 102299.57948 235435.22371
y_velocity 0 0
z_velocity 0 0
magvel 102258.95554 235435.2237
radvel -235435.2237 114038.34336
circvel 0 0.005524271728
magmom 1.2327065163e-07 1.4587103381e-07
magvel 102299.57948 235435.22371
radvel -235435.22371 114042.93363
circvel 0 0.0047841596539
magmom 1.2328047524e-07 1.4591226172e-07
angular_momentum_x 0 0
angular_momentum_y 0 0
angular_momentum_z -0 -0
Expand Down
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 be78430

Please sign in to comment.