From be7843093e870734e219dcf73df2094ab4abece7 Mon Sep 17 00:00:00 2001 From: Zhi Chen <62574124+zhichen3@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:40:02 -0500 Subject: [PATCH] remove extra pressure scale in scale_flux for 1d cartesian (#2991) 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. --- .../ci-benchmarks/Rad2TShock-1d.out | 52 +++++++++---------- Source/hydro/Castro_ctu_hydro.cpp | 29 ++++------- Source/hydro/Castro_hydro.H | 3 -- Source/hydro/Castro_mol_hydro.cpp | 31 ++++------- Source/hydro/advection_util.cpp | 14 ----- 5 files changed, 46 insertions(+), 83 deletions(-) diff --git a/Exec/radiation_tests/Rad2Tshock/ci-benchmarks/Rad2TShock-1d.out b/Exec/radiation_tests/Rad2Tshock/ci-benchmarks/Rad2TShock-1d.out index c4b21ef48f..0e1151359f 100644 --- a/Exec/radiation_tests/Rad2Tshock/ci-benchmarks/Rad2TShock-1d.out +++ b/Exec/radiation_tests/Rad2Tshock/ci-benchmarks/Rad2TShock-1d.out @@ -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 diff --git a/Source/hydro/Castro_ctu_hydro.cpp b/Source/hydro/Castro_ctu_hydro.cpp index d443bbe060..e982187f92 100644 --- a/Source/hydro/Castro_ctu_hydro.cpp +++ b/Source/hydro/Castro_ctu_hydro.cpp @@ -1259,35 +1259,26 @@ Castro::construct_ctu_hydro_source(Real time, Real dt) // NOLINT(readability-co Array4 const flux_arr = (flux[idir]).array(); Array4 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 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 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 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. diff --git a/Source/hydro/Castro_hydro.H b/Source/hydro/Castro_hydro.H index aa8c9582c5..cc7cd154cb 100644 --- a/Source/hydro/Castro_hydro.H +++ b/Source/hydro/Castro_hydro.H @@ -784,9 +784,6 @@ void scale_flux(const amrex::Box& bx, -#if AMREX_SPACEDIM == 1 - amrex::Array4 const& qint, -#endif amrex::Array4 const& flux, amrex::Array4 const& area, const amrex::Real dt); diff --git a/Source/hydro/Castro_mol_hydro.cpp b/Source/hydro/Castro_mol_hydro.cpp index 75899d67a1..8b00cd958b 100644 --- a/Source/hydro/Castro_mol_hydro.cpp +++ b/Source/hydro/Castro_mol_hydro.cpp @@ -657,9 +657,6 @@ Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update) Array4 pradial_fab = pradial.array(); #endif -#if AMREX_SPACEDIM == 1 - Array4 const qex_arr = qe[0].array(); -#endif for (int idir = 0; idir < AMREX_SPACEDIM; ++idir) { @@ -668,27 +665,19 @@ Castro::construct_mol_hydro_source(Real time, Real dt, MultiFab& A_update) Array4 const flux_arr = (flux[idir]).array(); Array4 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 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 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 } } diff --git a/Source/hydro/advection_util.cpp b/Source/hydro/advection_util.cpp index 515778c4d1..05ce02e699 100644 --- a/Source/hydro/advection_util.cpp +++ b/Source/hydro/advection_util.cpp @@ -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 const& qint, -#endif Array4 const& flux, Array4 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 }); }