Skip to content

Commit

Permalink
don't access sm2/sp2 if we don't need them (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Aug 20, 2024
1 parent 8fa618b commit 71b6684
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Godunov/hydro_godunov_ppm.H
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,9 @@ void PredictStateOnXFace ( const int i, const int j, const int k, const int n,
const Limiter& /*limiter*/,
int limiter_type)
{
amrex::Real sm2 = S(i-2,j,k,n);
amrex::Real sm1 = S(i-1,j,k,n);
amrex::Real s0 = S(i ,j,k,n);
amrex::Real sp1 = S(i+1,j,k,n);
amrex::Real sp2 = S(i+2,j,k,n);

constexpr auto half{amrex::Real(0.5)};
constexpr auto one{amrex::Real(1.0)};
Expand Down Expand Up @@ -896,6 +894,9 @@ void PredictStateOnXFace ( const int i, const int j, const int k, const int n,
} else {
constexpr auto two3rds{amrex::Real(2.0/3.0)};

amrex::Real sm2 = S(i-2,j,k,n);
amrex::Real sp2 = S(i+2,j,k,n);

amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);

Expand Down Expand Up @@ -933,11 +934,9 @@ void PredictStateOnYFace ( const int i, const int j, const int k, const int n,
const Limiter& /*limiter*/,
int limiter_type)
{
amrex::Real sm2 = S(i,j-2,k,n);
amrex::Real sm1 = S(i,j-1,k,n);
amrex::Real s0 = S(i,j ,k,n);
amrex::Real sp1 = S(i,j+1,k,n);
amrex::Real sp2 = S(i,j+2,k,n);

constexpr auto half{amrex::Real(0.5)};
constexpr auto one{amrex::Real(1.0)};
Expand Down Expand Up @@ -974,6 +973,9 @@ void PredictStateOnYFace ( const int i, const int j, const int k, const int n,

constexpr auto two3rds{amrex::Real(2.0/3.0)};

amrex::Real sm2 = S(i,j-2,k,n);
amrex::Real sp2 = S(i,j+2,k,n);

amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);

Expand Down Expand Up @@ -1013,11 +1015,9 @@ void PredictStateOnZFace ( const int i, const int j, const int k, const int n,
const Limiter& /*limiter*/,
int limiter_type)
{
amrex::Real sm2 = S(i,j,k-2,n);
amrex::Real sm1 = S(i,j,k-1,n);
amrex::Real s0 = S(i,j,k ,n);
amrex::Real sp1 = S(i,j,k+1,n);
amrex::Real sp2 = S(i,j,k+2,n);

constexpr auto half{amrex::Real(0.5)};
constexpr auto one{amrex::Real(1.0)};
Expand Down Expand Up @@ -1052,6 +1052,9 @@ void PredictStateOnZFace ( const int i, const int j, const int k, const int n,
} else {
constexpr auto two3rds{amrex::Real(2.0/3.0)};

amrex::Real sm2 = S(i,j,k-2,n);
amrex::Real sp2 = S(i,j,k+2,n);

amrex::Real sedge1 = Limiter::sedge1(sm2,sm1,s0,sp1,sp2);
amrex::Real sedge2 = Limiter::sedge2(sm2,sm1,s0,sp1,sp2);

Expand Down

0 comments on commit 71b6684

Please sign in to comment.