htrdr

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

commit 391f53c90760f3c7225ea75ae0f6c1690c41f969
parent 9963c5519944c3b311006febb675ab2d87d4c087
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 29 Jun 2018 10:18:23 +0200

Add the htrdr_sky_fetch_svx_[voxel_]_property functions

Diffstat:
Msrc/htrdr_sky.c | 44++++++++++++++++++++++++++++++++++++++++++++
Msrc/htrdr_sky.h | 35++++++++++++++++++++++++++++-------
Msrc/htrdr_transmission.c | 13++++++++-----
3 files changed, 80 insertions(+), 12 deletions(-)

diff --git a/src/htrdr_sky.c b/src/htrdr_sky.c @@ -484,3 +484,47 @@ htrdr_sky_dump_clouds_vtk(const struct htrdr_sky* sky, FILE* stream) return RES_OK; } +double +htrdr_sky_fetch_svx_property + (const struct htrdr_sky* sky, + const enum htrdr_sky_svx_property prop, + const int components_mask, /* Combination of htrdr_sky_component_flag */ + const double wavelength, + const double pos[3]) +{ + struct svx_voxel voxel = SVX_VOXEL_NULL; + ASSERT(sky && pos); +#ifndef NDEBUG + { + struct svx_tree_desc tree_desc = SVX_TREE_DESC_NULL; + SVX(tree_get_desc(sky->clouds, &tree_desc)); + ASSERT(tree_desc.lower[0] <= pos[0] && tree_desc.upper[0] >= pos[0]); + ASSERT(tree_desc.lower[1] <= pos[1] && tree_desc.upper[1] >= pos[1]); + ASSERT(tree_desc.lower[2] <= pos[2] && tree_desc.upper[2] >= pos[2]); + } +#endif + SVX(tree_at(sky->clouds, pos, NULL, NULL, &voxel)); + return htrdr_sky_fetch_svx_voxel_property + (sky, prop, components_mask, wavelength, &voxel); +} + +double +htrdr_sky_fetch_svx_voxel_property + (const struct htrdr_sky* sky, + const enum htrdr_sky_svx_property prop, + const int components_mask, /* Combination of htrdr_sky_component_flag */ + const double wavelength, + const struct svx_voxel* voxel) +{ + const double* pdbl = NULL; + ASSERT(sky && prop && components_mask && wavelength>=0 && voxel); + ASSERT((unsigned)prop < HTRDR_SKY_SVX_PROPS_COUNT__); + (void)sky, (void)wavelength; + + if(components_mask != (HTRDR_SKY_GAZ|HTRDR_SKY_PARTICLE)) { + FATAL("Unsupported sky component\n"); + } + pdbl = voxel->data; + return pdbl[prop]; +} + diff --git a/src/htrdr_sky.h b/src/htrdr_sky.h @@ -18,25 +18,30 @@ #include <rsys/rsys.h> +/* Raw sky properties */ enum htrdr_sky_property { HTRDR_SKY_Ks, /* Scattering coefficient */ HTRDR_SKY_Ka /* Absorption coefficient */ }; -enum htrdr_sky_component_flag { - HTRDR_GAZ = BIT(0), - HTRDR_PARTICLE = BIT(1) -}; - +/* Property of the sky computed by region and managed by Star-VoXel */ enum htrdr_sky_svx_property { HTRDR_SKY_SVX_Kext_MIN, HTRDR_SKY_SVX_Kext_MAX, HTRDR_SKY_SVX_PROPS_COUNT__ }; +/* Component of the sky for which the properties are queried */ +enum htrdr_sky_component_flag { + HTRDR_SKY_GAZ = BIT(0), + HTRDR_SKY_PARTICLE = BIT(1) +}; + /* Forward declaration */ struct htrdr; struct htrdr_sky; +struct svx_tree; +struct svx_voxel; extern LOCAL_SYM res_T htrdr_sky_create @@ -53,10 +58,10 @@ htrdr_sky_ref_put (struct htrdr_sky* sky); extern LOCAL_SYM double -htrdr_sky_fetch_property +htrdr_sky_fetch_raw_property (const struct htrdr_sky* sky, const enum htrdr_sky_property prop, - const int components, /* Combination of htrdr_sky_component_flag */ + const int components_mask, /* Combination of htrdr_sky_component_flag */ const double wavelength, const double pos[3]); @@ -64,6 +69,22 @@ extern LOCAL_SYM struct svx_tree* htrdr_sky_get_svx_tree (struct htrdr_sky* sky); +extern LOCAL_SYM double +htrdr_sky_fetch_svx_property + (const struct htrdr_sky* sky, + const enum htrdr_sky_svx_property prop, + const int components_mask, /* Combination of htrdr_sky_component_flag */ + const double wavelength, + const double pos[3]); + +extern LOCAL_SYM double +htrdr_sky_fetch_svx_voxel_property + (const struct htrdr_sky* sky, + const enum htrdr_sky_svx_property prop, + const int components_mask, /* Combination of htrdr_sky_component_flag */ + const double wavelength, + const struct svx_voxel* voxel); + extern LOCAL_SYM res_T htrdr_sky_dump_clouds_vtk (const struct htrdr_sky* sky, diff --git a/src/htrdr_transmission.c b/src/htrdr_transmission.c @@ -26,11 +26,12 @@ #include <omp.h> struct transmit_context { + const struct htrdr_sky* sky; double tau_sampled; double tau_max_min; double tau_min; }; -static const struct transmit_context TRANSMIT_CONTEXT_NULL = {0,0,0}; +static const struct transmit_context TRANSMIT_CONTEXT_NULL = {NULL,0,0,0}; /******************************************************************************* * Helper functions @@ -54,7 +55,7 @@ discard_hit const double range[2], void* context) { - const double* vox_data = NULL; + const int comp = HTRDR_SKY_GAZ | HTRDR_SKY_PARTICLE; struct transmit_context* ctx = context; double dst; double k_ext_min; @@ -62,9 +63,10 @@ discard_hit ASSERT(hit && ctx && !SVX_HIT_NONE(hit)); (void)org, (void)dir, (void)range; - vox_data = hit->voxel.data; - k_ext_min = vox_data[HTRDR_SKY_SVX_Kext_MIN]; - k_ext_max = vox_data[HTRDR_SKY_SVX_Kext_MAX]; + k_ext_min = htrdr_sky_fetch_svx_voxel_property + (ctx->sky, HTRDR_SKY_SVX_Kext_MIN, comp, -1/*FIXME*/, &hit->voxel); + k_ext_max = htrdr_sky_fetch_svx_voxel_property + (ctx->sky, HTRDR_SKY_SVX_Kext_MAX, comp, -1/*FIXME*/, &hit->voxel); dst = hit->distance[1] - hit->distance[0]; ASSERT(dst >= 0); @@ -89,6 +91,7 @@ transmission_realisation ASSERT(htrdr && pos && dir && val); ctx.tau_sampled = ssp_ran_exp(rng, 1.0); + ctx.sky = htrdr->sky; svx_tree = htrdr_sky_get_svx_tree(htrdr->sky); res = svx_octree_trace_ray(svx_tree, pos, dir, range, NULL, discard_hit, &ctx, &hit);