star-line

Structure for accelerating line importance sampling
git clone git://git.meso-star.fr/star-line.git
Log | Files | Refs | README | LICENSE

commit 8fe6ed7249c6ae9691099de1f2efb753867d2847
parent 49633440660e91d1b125a53e745e9d053777b61a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 19 Mar 2026 11:44:17 +0100

sln-get: checking a sampling criterion by importance

Once used to evaluate the value of a node (option -w), sln-get now
checks, for acceleration structures designed to be upper bounds of the
lines they partition, that the value of the node is greater than or equal
to the sum of the values of its children. If this is not the case,
sln-get returns an error.

This criterion is a requirement of the importance based sampling
algorithm for which this acceleration structure is built. If it is not
met, the probability of being absorbed by a sampled line, calculated
from the node values, could be invalid, i.e. greater than 1.

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

diff --git a/src/sln_get.c b/src/sln_get.c @@ -452,6 +452,7 @@ error: static res_T print_node_value(const struct cmd* cmd) { + struct sln_tree_desc tree_desc = SLN_TREE_DESC_NULL; struct sln_mesh mesh = SLN_MESH_NULL; const struct sln_node* node = NULL; double val_mesh = 0; @@ -469,6 +470,35 @@ print_node_value(const struct cmd* cmd) printf("ka(%e) = %e ~ %e\n", cmd->args.wavenumber, val_node, val_mesh); + res = sln_tree_get_desc(cmd->tree, &tree_desc); + if(res != RES_OK) goto error; + + if(tree_desc.mesh_type == SLN_MESH_UPPER && !sln_node_is_leaf(node)) { + /* Check that the value of the node is greater than or equal to the sum of + * the values of its children */ + struct sln_mesh mesh0 = SLN_MESH_NULL; + struct sln_mesh mesh1 = SLN_MESH_NULL; + const struct sln_node* child0 = NULL; + const struct sln_node* child1 = NULL; + double val_mesh0 = 0; + double val_mesh1 = 0; + + child0 = sln_node_get_child(node, 0); + child1 = sln_node_get_child(node, 1); + if((res = sln_node_get_mesh(cmd->tree, child0, &mesh0)) != RES_OK) goto error; + if((res = sln_node_get_mesh(cmd->tree, child1, &mesh1)) != RES_OK) goto error; + + val_mesh0 = sln_mesh_eval(&mesh0, cmd->args.wavenumber); + val_mesh1= sln_mesh_eval(&mesh1, cmd->args.wavenumber); + + if(val_mesh < val_mesh0 + val_mesh1) { + fprintf(stderr, "error: ka < ka0 + ka1 (ka0=%e; ka1=%e)\n", + val_mesh0, val_mesh1); + res = RES_BAD_OP; + goto error; + } + } + exit: return res; error: