commit 87d5bdc07c3aa08e2887a05826bd9a396ec4629f
parent 706c02ea4116e351750e834930ae0b5e86c2672a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 10 Sep 2025 08:24:59 +0200
Fix for radiative path bounces
When sampling the radiative path, its position on a triangle may be
slightly offset from its edges in order to avoid numerical problems.
This can happen when the position is close to an angle and the sampled
direction is oriented towards one of the faces of this angle: the ray
may miss the intersection with the boundary (too close to the origin of
the ray) and be traced inside the solid.
The find_next_fragment subroutine therefore adjusts the current position
to avoid this problem and returns the next position on the surface along
the sampled direction, as well as the impact distance used to construct
it. But not the updated original position (i.e. the actual origin of the
ray).
The caller must therefore use the new position returned directly instead
of trying to recalculate it from the ray origin (which it does not have,
since it may be an update of the current position), the sampled
direction, and the collision distance returned. However, it was this
recalculation that was performed by the radiative path sampling
procedure that led to numerical errors.
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/sdis_heat_path_radiative_Xd.h b/src/sdis_heat_path_radiative_Xd.h
@@ -231,7 +231,6 @@ XD(trace_radiative_path)
struct sdis_interface* interf = NULL;
struct sdis_medium* chk_mdm = NULL;
double wi[3] = {0,0,0};
- float dirf[3] = {0,0,0};
d3_set(pos, rwalk->vtx.P);
d3_minus(wi, dir);
@@ -249,8 +248,9 @@ XD(trace_radiative_path)
break; /* Stop the radiative path */
}
- /* Move the random walk to the hit position */
- XD(move_pos)(rwalk->vtx.P, fX_set_dX(dirf, dir), rwalk->XD(hit).distance);
+ /* Move the random walk to the hit position, i.e. the next position on the
+ * interface returned as a fragment by the previous function */
+ d3_set(rwalk->vtx.P, frag.P);
rwalk->hit_side = frag.side;
/* Verify that the intersection, although in the same enclosure, touches the