Skip to content

Commit

Permalink
prevent out-of-bounds access to grav_phi_zface
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWibking committed Mar 4, 2024
1 parent ed367d1 commit 7b5684b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pgen/precipitator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,10 @@ void UserMeshWorkBeforeOutput(Mesh *mesh, ParameterInput *pin,

// compute potential at center and faces
const Real phi_zminus = grav_phi_zface(0, k, j, i);
const Real phi_zplus = grav_phi_zface(0, k + 1, j, i);
Real phi_zplus = NAN;
if (k < kb.e) {
phi_zplus = grav_phi_zface(0, k + 1, j, i);
}
const Real g_z = -(phi_zplus - phi_zminus) / dx3;

// compute local t_ff
Expand Down

0 comments on commit 7b5684b

Please sign in to comment.