From a5d782819c56e6a6c8cc59a0ed62a47ed026029a Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Mon, 29 Jul 2024 14:56:02 -0700 Subject: [PATCH 1/4] don't limit in the bc routine when using WENOZ --- Godunov/hydro_godunov_ppm.H | 54 ++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/Godunov/hydro_godunov_ppm.H b/Godunov/hydro_godunov_ppm.H index 7089a88c4..85d7565bc 100644 --- a/Godunov/hydro_godunov_ppm.H +++ b/Godunov/hydro_godunov_ppm.H @@ -224,7 +224,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo,j, k, n) +amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n))); } @@ -236,7 +237,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo ,j,k,n) + amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n))); } @@ -244,7 +246,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if ( (sp - s(domlo+1,j,k,n))*(s(domlo+1,j,k,n) - sm) <= amrex::Real(0.0)) { sp = s(domlo+1,j,k,n); @@ -264,7 +267,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi,j,k, n) +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n))); } @@ -276,7 +280,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi ,j,k,n) +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n))); } @@ -284,7 +289,8 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if( (sp - s(domhi-1,j,k,n))*(s(domhi-1,j,k,n) - sm) <= amrex::Real(0.0)) { sp = s(domhi-1,j,k,n); @@ -316,7 +322,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n) +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n))); } @@ -328,7 +335,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n) +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n))); } @@ -336,7 +344,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if ( (sp - s(i,domlo+1,k,n))*(s(i,domlo+1,k,n) - sm) <= amrex::Real(0.0)) { sp = s(i,domlo+1,k,n); @@ -356,7 +365,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n) +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n))); } @@ -368,7 +378,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n) +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n))); } @@ -376,7 +387,8 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if( (sp - s(i,domhi-1,k,n))*(s(i,domhi-1,k,n) - sm) <= amrex::Real(0.0)){ sp = s(i,domhi-1,k,n); sm = s(i,domhi-1,k,n); @@ -408,7 +420,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n) +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n))); } @@ -420,7 +433,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n) +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n))); } @@ -428,7 +442,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if ( (sp - s(i,j,domlo+1,n))*(s(i,j,domlo+1,n) - sm) <= 0. ) { sp = s(i,j,domlo+1,n); @@ -448,7 +463,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n) +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n))); } @@ -460,7 +476,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n) +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n); - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n))); } @@ -468,7 +485,8 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr (! std::is_same_v) { + if constexpr ( (! std::is_same_v) && + (! std::is_same_v) ) { if ( (sp - s(i,j,domhi-1,n))*(s(i,j,domhi-1,n) - sm) <= 0. ) { sp = s(i,j,domhi-1,n); From 56d61f468768ae5e4313864b4121e6e0b09310b1 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Mon, 29 Jul 2024 15:18:08 -0700 Subject: [PATCH 2/4] generalize to allow for WENO_JS --- Godunov/hydro_godunov_edge_state_2D.cpp | 6 + Godunov/hydro_godunov_edge_state_3D.cpp | 6 + .../hydro_godunov_extrap_vel_to_faces_2D.cpp | 6 + .../hydro_godunov_extrap_vel_to_faces_3D.cpp | 6 + Godunov/hydro_godunov_ppm.H | 125 ++++++++++++------ Utils/hydro_utils.H | 4 +- 6 files changed, 114 insertions(+), 39 deletions(-) diff --git a/Godunov/hydro_godunov_edge_state_2D.cpp b/Godunov/hydro_godunov_edge_state_2D.cpp index 9c90dc77a..2c77a4e44 100644 --- a/Godunov/hydro_godunov_edge_state_2D.cpp +++ b/Godunov/hydro_godunov_edge_state_2D.cpp @@ -86,6 +86,12 @@ Godunov::ComputeEdgeState (Box const& bx, int ncomp, AMREX_D_DECL(Ipx,Ipy,Ipz), AMREX_D_DECL(umac,vmac,wmac), q,geom,l_dt,pbc,ncomp,limiter); + } else if ( limiter_type == PPM::WENO_JS) { + auto limiter = PPM::weno_js(); + PPM::PredictStateOnFaces(bxg1,AMREX_D_DECL(Imx,Imy,Imz), + AMREX_D_DECL(Ipx,Ipy,Ipz), + AMREX_D_DECL(umac,vmac,wmac), + q,geom,l_dt,pbc,ncomp,limiter); } else { auto limiter = PPM::nolimiter(); PPM::PredictStateOnFaces(bxg1,AMREX_D_DECL(Imx,Imy,Imz), diff --git a/Godunov/hydro_godunov_edge_state_3D.cpp b/Godunov/hydro_godunov_edge_state_3D.cpp index 78f08a1ef..af7d3c094 100644 --- a/Godunov/hydro_godunov_edge_state_3D.cpp +++ b/Godunov/hydro_godunov_edge_state_3D.cpp @@ -101,6 +101,12 @@ Godunov::ComputeEdgeState (Box const& bx, int ncomp, AMREX_D_DECL(Ipx,Ipy,Ipz), AMREX_D_DECL(umac,vmac,wmac), q,geom,l_dt,pbc,ncomp,limiter); + } else if ( limiter_type == PPM::WENO_JS) { + auto limiter = PPM::weno_js(); + PPM::PredictStateOnFaces(bxg1,AMREX_D_DECL(Imx,Imy,Imz), + AMREX_D_DECL(Ipx,Ipy,Ipz), + AMREX_D_DECL(umac,vmac,wmac), + q,geom,l_dt,pbc,ncomp,limiter); } else { auto limiter = PPM::nolimiter(); PPM::PredictStateOnFaces(bxg1,AMREX_D_DECL(Imx,Imy,Imz), diff --git a/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp b/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp index 343d15823..d4d6ef22f 100644 --- a/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp +++ b/Godunov/hydro_godunov_extrap_vel_to_faces_2D.cpp @@ -78,6 +78,12 @@ Godunov::ExtrapVelToFaces ( MultiFab const& a_vel, Imx, Imy, Ipx, Ipy, vel, vel, geom, l_dt, d_bcrec, limiter); + } else if (limiter_type == PPM::WENO_JS) { + auto limiter = PPM::weno_js(); + PPM::PredictVelOnFaces( bxg1, + Imx, Imy, Ipx, Ipy, + vel, vel, + geom, l_dt, d_bcrec, limiter); } else { auto limiter = PPM::nolimiter(); PPM::PredictVelOnFaces( bxg1, diff --git a/Godunov/hydro_godunov_extrap_vel_to_faces_3D.cpp b/Godunov/hydro_godunov_extrap_vel_to_faces_3D.cpp index 3835b3e91..920f19995 100644 --- a/Godunov/hydro_godunov_extrap_vel_to_faces_3D.cpp +++ b/Godunov/hydro_godunov_extrap_vel_to_faces_3D.cpp @@ -89,6 +89,12 @@ Godunov::ExtrapVelToFaces ( MultiFab const& a_vel, Imx, Imy, Imz, Ipx, Ipy, Ipz, vel, vel, geom, l_dt, d_bcrec, limiter); + } else if (limiter_type == PPM::WENO_JS) { + auto limiter = PPM::weno_js(); + PPM::PredictVelOnFaces( bxg1, + Imx, Imy, Imz, Ipx, Ipy, Ipz, + vel, vel, + geom, l_dt, d_bcrec, limiter); } else { auto limiter = PPM::nolimiter(); PPM::PredictVelOnFaces( bxg1, diff --git a/Godunov/hydro_godunov_ppm.H b/Godunov/hydro_godunov_ppm.H index 85d7565bc..6e71f1e06 100644 --- a/Godunov/hydro_godunov_ppm.H +++ b/Godunov/hydro_godunov_ppm.H @@ -14,12 +14,14 @@ namespace PPM { -enum limiters {VanLeer, WENOZ, NoLimiter}; +enum limiters {VanLeer, WENOZ, WENO_JS, NoLimiter}; static constexpr int default_limiter = VanLeer; struct nolimiter { + static constexpr bool do_limiting = false; + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real sedge1(const amrex::Real sm2, @@ -64,6 +66,8 @@ struct nolimiter { struct vanleer { + static constexpr bool do_limiting = true; + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real vanLeer(const amrex::Real a, const amrex::Real b, const amrex::Real c) { @@ -151,6 +155,8 @@ struct vanleer { struct wenoz { + static constexpr bool do_limiting = false; + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real sedge2(const amrex::Real sm2, @@ -206,6 +212,69 @@ struct wenoz { } }; +struct weno_js { + + static constexpr bool do_limiting = false; + + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real + sedge2(const amrex::Real sm2, + const amrex::Real sm1, + const amrex::Real s0, + const amrex::Real sp1, + const amrex::Real sp2) + { + constexpr auto eps = amrex::Real(1.0e-6); + + const amrex::Real beta1 = + amrex::Real(13.0) / amrex::Real(12.0) * (sm2 - amrex::Real(2.0) * sm1 + s0) * + (sm2 - amrex::Real(2.0) * sm1 + s0) + + amrex::Real(0.25) * (sm2 - amrex::Real(4.0) * sm1 + amrex::Real(3.0) * s0) * + (sm2 - amrex::Real(4.0) * sm1 + amrex::Real(3.0) * s0); + const amrex::Real beta2 = + amrex::Real(13.0) / amrex::Real(12.0) * (sm1 - amrex::Real(2.0) * s0 + sp1) * + (sm1 - amrex::Real(2.0) * s0 + sp1) + + amrex::Real(0.25) * (sm1 - sp1) * (sm1 - sp1); + const amrex::Real beta3 = + amrex::Real(13.0) / amrex::Real(12.0) * (s0 - amrex::Real(2.0) * sp1 + sp2) * + (s0 - amrex::Real(2.0) * sp1 + sp2) + + amrex::Real(0.25) * (amrex::Real(3.0) * s0 - amrex::Real(4.0) * sp1 + sp2) * + (amrex::Real(3.0) * s0 - amrex::Real(4.0) * sp1 + sp2); + + const amrex::Real t5 = amrex::Math::abs(beta3 - beta1); + const amrex::Real omega1 = amrex::Real(0.1) / (eps + beta1)); + const amrex::Real omega2 = amrex::Real(0.6) / (eps + beta2)); + const amrex::Real omega3 = amrex::Real(0.3) / (eps + beta3)); + + const amrex::Real omega = omega1 + omega2 + omega3; + + const amrex::Real v_1 = amrex::Real(2.0) * sm2 - amrex::Real(7.0) * sm1 + amrex::Real(11.0) * s0; + const amrex::Real v_2 = -sm1 + amrex::Real(5.0) * s0 + amrex::Real(2.0) * sp1; + const amrex::Real v_3 = amrex::Real(2.0) * s0 + amrex::Real(5.0) * sp1 - sp2; + + return (omega1 * v_1 + omega2 * v_2 + omega3 * v_3) / (amrex::Real(6.0) * omega); + } + + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::Real + sedge1(const amrex::Real sm2, + const amrex::Real sm1, + const amrex::Real s0, + const amrex::Real sp1, + const amrex::Real sp2) + { + return sedge2(sp2,sp1,s0,sm1,sm2); // NOLINT(readability-suspicious-call-argument) + } + + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + static amrex::GpuTuple + sm_sp(const amrex::Real /*s0*/, + const amrex::Real sedge1, + const amrex::Real sedge2) + { + return amrex::makeTuple(sedge1, sedge2); + } +}; template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE @@ -224,8 +293,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo,j, k, n) +amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n))); } @@ -237,8 +305,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(domlo-1,j,k,n) + amrex::Real(0.75)*s(domlo ,j,k,n) + amrex::Real(0.5)*s(domlo+1,j,k,n) - amrex::Real(0.05)*s(domlo+2,j,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(domlo+1,j,k,n), s(domlo,j,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(domlo+1,j,k,n), s(domlo,j,k,n))); } @@ -246,8 +313,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if ( (sp - s(domlo+1,j,k,n))*(s(domlo+1,j,k,n) - sm) <= amrex::Real(0.0)) { sp = s(domlo+1,j,k,n); @@ -267,8 +333,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi,j,k, n) +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n))); } @@ -280,8 +345,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(domhi+1,j,k,n) + amrex::Real(0.75)*s(domhi ,j,k,n) +amrex::Real(0.5)*s(domhi-1,j,k,n) - amrex::Real(0.05)*s(domhi-2,j,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(domhi-1,j,k,n), s(domhi,j,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(domhi-1,j,k,n), s(domhi,j,k,n))); } @@ -289,8 +353,7 @@ void SetXBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if( (sp - s(domhi-1,j,k,n))*(s(domhi-1,j,k,n) - sm) <= amrex::Real(0.0)) { sp = s(domhi-1,j,k,n); @@ -322,8 +385,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n) +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n))); } @@ -335,8 +397,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(i,domlo-1,k,n) + amrex::Real(0.75)*s(i,domlo ,k,n) +amrex::Real(0.5)*s(i,domlo+1,k,n) - amrex::Real(0.05)*s(i,domlo+2,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(i,domlo+1,k,n), s(i,domlo,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,domlo+1,k,n), s(i,domlo,k,n))); } @@ -344,8 +405,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if ( (sp - s(i,domlo+1,k,n))*(s(i,domlo+1,k,n) - sm) <= amrex::Real(0.0)) { sp = s(i,domlo+1,k,n); @@ -365,8 +425,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n) +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n))); } @@ -378,8 +437,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(i,domhi+1,k,n) + amrex::Real(0.75)*s(i,domhi ,k,n) +amrex::Real(0.5)*s(i,domhi-1,k,n) - amrex::Real(0.05)*s(i,domhi-2,k,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(i,domhi-1,k,n), s(i,domhi,k,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,domhi-1,k,n), s(i,domhi,k,n))); } @@ -387,8 +445,7 @@ void SetYBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if( (sp - s(i,domhi-1,k,n))*(s(i,domhi-1,k,n) - sm) <= amrex::Real(0.0)){ sp = s(i,domhi-1,k,n); sm = s(i,domhi-1,k,n); @@ -420,8 +477,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, { sedge2 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n) +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n))); } @@ -433,8 +489,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sedge1 = -amrex::Real(0.2)*s(i,j,domlo-1,n) + amrex::Real(0.75)*s(i,j,domlo ,n) +amrex::Real(0.5)*s(i,j,domlo+1,n) - amrex::Real(0.05)*s(i,j,domlo+2,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domlo+1,n), s(i,j,domlo,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domlo+1,n), s(i,j,domlo,n))); } @@ -442,8 +497,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if ( (sp - s(i,j,domlo+1,n))*(s(i,j,domlo+1,n) - sm) <= 0. ) { sp = s(i,j,domlo+1,n); @@ -463,8 +517,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, { sedge1 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n) +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge1 = amrex::max(sedge1, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n))); sedge1 = amrex::min(sedge1, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n))); } @@ -476,8 +529,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sedge2 = -amrex::Real(0.2)*s(i,j,domhi+1,n) + amrex::Real(0.75)*s(i,j,domhi ,n) +amrex::Real(0.5)*s(i,j,domhi-1,n) - amrex::Real(0.05)*s(i,j,domhi-2,n); - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { sedge2 = amrex::max(sedge2, amrex::min(s(i,j,domhi-1,n), s(i,j,domhi,n))); sedge2 = amrex::min(sedge2, amrex::max(s(i,j,domhi-1,n), s(i,j,domhi,n))); } @@ -485,8 +537,7 @@ void SetZBCs ( const int i, const int j, const int k, const int n, sp = sedge2; sm = sedge1; - if constexpr ( (! std::is_same_v) && - (! std::is_same_v) ) { + if constexpr (Limiter::do_limiting) { if ( (sp - s(i,j,domhi-1,n))*(s(i,j,domhi-1,n) - sm) <= 0. ) { sp = s(i,j,domhi-1,n); diff --git a/Utils/hydro_utils.H b/Utils/hydro_utils.H index ac3699bf0..af966dfb7 100644 --- a/Utils/hydro_utils.H +++ b/Utils/hydro_utils.H @@ -130,8 +130,8 @@ ComputeFluxesOnBoxFromState ( amrex::Box const& bx, int ncomp, amrex::MFIter& mf bool godunov_use_ppm, bool godunov_use_forces_in_trans, bool is_velocity, bool fluxes_are_area_weighted, std::string const& advection_type, - int limiter_type = PPM::default_limiter, - amrex::Array4 const& bc_arr = {}); + int limiter_type = PPM::default_limiter, + amrex::Array4 const& bc_arr = {}); #endif #ifdef AMREX_USE_EB From 0ac27a05191f673ef6eab6e544ce9f0d85698ab4 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Mon, 29 Jul 2024 15:20:15 -0700 Subject: [PATCH 3/4] fix typo --- Godunov/hydro_godunov_ppm.H | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Godunov/hydro_godunov_ppm.H b/Godunov/hydro_godunov_ppm.H index 6e71f1e06..fba71609b 100644 --- a/Godunov/hydro_godunov_ppm.H +++ b/Godunov/hydro_godunov_ppm.H @@ -242,9 +242,9 @@ struct weno_js { (amrex::Real(3.0) * s0 - amrex::Real(4.0) * sp1 + sp2); const amrex::Real t5 = amrex::Math::abs(beta3 - beta1); - const amrex::Real omega1 = amrex::Real(0.1) / (eps + beta1)); - const amrex::Real omega2 = amrex::Real(0.6) / (eps + beta2)); - const amrex::Real omega3 = amrex::Real(0.3) / (eps + beta3)); + const amrex::Real omega1 = amrex::Real(0.1) / (eps + beta1); + const amrex::Real omega2 = amrex::Real(0.6) / (eps + beta2); + const amrex::Real omega3 = amrex::Real(0.3) / (eps + beta3); const amrex::Real omega = omega1 + omega2 + omega3; From ca1ab2410866228038a6bc7ede7dc1ad738b05bc Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Mon, 29 Jul 2024 15:57:06 -0700 Subject: [PATCH 4/4] remove unused --- Godunov/hydro_godunov_ppm.H | 1 - 1 file changed, 1 deletion(-) diff --git a/Godunov/hydro_godunov_ppm.H b/Godunov/hydro_godunov_ppm.H index fba71609b..71ac154a8 100644 --- a/Godunov/hydro_godunov_ppm.H +++ b/Godunov/hydro_godunov_ppm.H @@ -241,7 +241,6 @@ struct weno_js { amrex::Real(0.25) * (amrex::Real(3.0) * s0 - amrex::Real(4.0) * sp1 + sp2) * (amrex::Real(3.0) * s0 - amrex::Real(4.0) * sp1 + sp2); - const amrex::Real t5 = amrex::Math::abs(beta3 - beta1); const amrex::Real omega1 = amrex::Real(0.1) / (eps + beta1); const amrex::Real omega2 = amrex::Real(0.6) / (eps + beta2); const amrex::Real omega3 = amrex::Real(0.3) / (eps + beta3);