star-schiff

Library for estimating radiative properties
git clone git://git.meso-star.com/star-schiff.git
Log | Files | Refs | README | LICENSE

commit e22a1821b16b63a81a32d4b1c33b30d9da6eee71
parent f383438b2f5de3c9e2fe98be37ed691c6fe452eb
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 13 Oct 2015 22:29:03 +0200

Minor refactoring of the Schiff estimator

Diffstat:
Msrc/sschiff_estimator.c | 52++++++++++++++++++++++++----------------------------
Msrc/test_sschiff_estimator_sphere.c | 6++----
2 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c @@ -122,6 +122,7 @@ build_transform transform[11] = -f3_dot(basis+6, pos); } +/* Compute the length of radiative path that traverses the scene */ static res_T compute_path_length (struct sschiff_device* dev, @@ -194,7 +195,7 @@ compute_monte_carlo_weight ASSERT(scn && rng && mtl && basis && pos && lower && upper && accum); f2_sub(plane_size, upper, lower); - rcp_pdf = plane_size[0] * 1.e-6f * plane_size[1] * 1.e-6f; + rcp_pdf = plane_size[0] * plane_size[1] * 1.e-12f/*Metter^2 to micron^2*/; /* Define the projection axis */ f3_mulf(axis_x, basis + 0, plane_size[0] * 0.5f); @@ -213,6 +214,7 @@ compute_monte_carlo_weight f3_add(ray_org, f3_add(ray_org, x, y), org); S3D(scene_trace_ray(scn, ray_org, axis_z, range, &hit)); + if(!S3D_HIT_NONE(&hit)) { struct sschiff_material_properties props; double n_r, k_r; @@ -327,25 +329,16 @@ radiative_properties struct sschiff_integrator_desc* desc, const int istep, struct s3d_scene* scene, - struct s3d_shape* shape, + struct sschiff_material* material, struct accum* accum) { - struct sschiff_material material = SSCHIFF_NULL_MATERIAL; float lower[3], upper[3]; float aabb_pt[8][3]; float centroid[3]; size_t idir; - int mask; - res_T res = RES_OK; - ASSERT(dev && rng && desc && accum); + ASSERT(dev && rng && desc && material && accum); + (void)istep; - res = desc->sample_geometry(rng, &material, shape, desc->sampler_context); - if(res != RES_OK) { - log_error(dev, "Error in sampling a Schiff geometry.\n"); - goto error; - } - - S3D(scene_begin_session(scene, S3D_TRACE)); S3D(scene_get_aabb(scene, lower, upper)); /* AABB vertex layout @@ -392,28 +385,19 @@ radiative_properties f3_max(upper, upper, pt[i]); } -#if 1 - (void)istep; - res = compute_monte_carlo_weight(dev, scene, rng, &material, + compute_monte_carlo_weight(dev, scene, rng, material, desc->wavelength, basis, centroid, lower, upper, accum); - /*if(res != RES_OK) goto error;*/ -#else +#if 0 /* Compute an image of the shape transformed in the footprint space */ { char thumb_name[64]; - sprintf(thumb_name, "%d_%d.ppm", istep, idir); + (void)accum; + sprintf(thumb_name, "%d_%lu.ppm", istep, idir); draw_thumbnail(scene, basis, centroid, lower, upper, thumb_name); } #endif } - S3D(scene_end_session(scene)); - -exit: - S3D(scene_get_session_mask(scene, &mask)); - if(mask) S3D(scene_end_session(scene)); - return res; -error: - goto exit; + return RES_OK; } static char @@ -513,9 +497,21 @@ sschiff_integrate memset(&estimator->extinction_cross_section, 0, sizeof(struct accum)); FOR_EACH(i, 0, desc->sampled_geometries_count) { - res = radiative_properties(dev, rng, desc, (int)i, scene, shape, + struct sschiff_material material = SSCHIFF_NULL_MATERIAL; + + res = desc->sample_geometry(rng, &material, shape, desc->sampler_context); + if(res != RES_OK) { + log_error(dev, "Error in sampling a Schiff geometry.\n"); + goto error; + } + + S3D(scene_begin_session(scene, S3D_TRACE)); + + res = radiative_properties(dev, rng, desc, (int)i, scene, &material, &estimator->extinction_cross_section); if(res != RES_OK) goto error; + + S3D(scene_end_session(scene)); } exit: diff --git a/src/test_sschiff_estimator_sphere.c b/src/test_sschiff_estimator_sphere.c @@ -250,8 +250,8 @@ check_schiff_estimation desc.sample_geometry = sample_sphere; desc.scattering_angles_count = 1; desc.sampler_context = sampler_ctx; - desc.sampled_geometries_count = 500; - desc.sampled_directions_count = 5; + desc.sampled_geometries_count = 1000; + desc.sampled_directions_count = 1; desc.wavelength = 6.e-7; printf("Schiff sphere estimation - m: %g; n_r: %g; kappa_r: %g; n_e: %g\n", @@ -269,8 +269,6 @@ check_schiff_estimation CHECK(sschiff_estimator_get_extinction_cross_section(estimator, &status), RES_OK); - - time_sub(&t0, &t1, &t0); time_dump(&t0, TIME_MIN|TIME_SEC|TIME_MSEC, NULL, buf, sizeof(buf)); printf(