htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 7181b736ff06133a790052e8f6b9a2c2f1fa985d
parent 354c2c5bc88b5d836f01a3c55a4e2d65cbef6b35
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 24 Jan 2019 13:35:57 +0100

Fix a possible invalid memory access to cloud data

The mapping from a spatial coordinate to a voxel might exceed the cloud
definition for clouds whose voxel size is irregular along the Z
dimension.

Diffstat:
Msrc/htrdr_sky.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/htrdr_sky.c b/src/htrdr_sky.c @@ -622,6 +622,10 @@ cloud_vox_get_particle ivox[0] = xyz[0]; ivox[1] = xyz[1]; ivox[2] = pos_z <= split->height ? split->index : split->index + 1; + if(ivox[2] >= ctx->sky->htcp_desc.spatial_definition[2] + && eq_eps(pos_z, split->height, 1.e-6)) { /* Handle numerical inaccuracy */ + ivox[2] = split->index; + } /* Compute the upper bound of the *next* LUT cell clamped to the voxel * upper bound. Note that the upper bound of the current LUT cell is @@ -740,6 +744,10 @@ cloud_vox_get_gas ivox[0] = xyz[0]; ivox[1] = xyz[1]; ivox[2] = pos_z <= split->height ? split->index : split->index + 1; + if(ivox[2] >= ctx->sky->htcp_desc.spatial_definition[2] + && eq_eps(pos_z, split->height, 1.e-6)) { /* Handle numerical inaccuracy */ + ivox[2] = split->index; + } /* Compute the upper bound of the *next* LUT cell clamped to the voxel * upper bound. Note that the upper bound of the current LUT cell is