mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Prevent divide-by-zero in bins_crossed methods
This commit is contained in:
parent
f813c45810
commit
e584b9c918
1 changed files with 2 additions and 0 deletions
|
|
@ -594,6 +594,7 @@ void StructuredMesh::bins_crossed(const Particle& p, std::vector<int>& bins,
|
|||
|
||||
// Compute the length of the entire track.
|
||||
double total_distance = (r - last_r).norm();
|
||||
if (total_distance == 0.0) return;
|
||||
|
||||
// While determining if this track intersects the mesh, offset the starting
|
||||
// and ending coords by a bit. This avoid finite-precision errors that can
|
||||
|
|
@ -1713,6 +1714,7 @@ MOABMesh::bins_crossed(const Particle& p,
|
|||
moab::CartVect dir(u.x, u.y, u.z);
|
||||
|
||||
double track_len = (r1 - r0).length();
|
||||
if (track_len == 0.0) return;
|
||||
|
||||
r0 -= TINY_BIT * dir;
|
||||
r1 += TINY_BIT * dir;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue