commit a23dc171dc565a7c2ec28eb8246fd5e3a77f0b92
parent cf24c2bb68478e17b329006d514692e3022a571e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 10 Sep 2024 09:20:45 +0200
Avoid external flux calculation with 0 emissivity
Returns the function that calculates the net external flux if the
emissivity of the surface from which it is to be calculated is zero.
Until now, the path was sampled before its contribution was inhibited by
multiplying it by an emissivity of zero. The result was the same, but
the calculation time was not.
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/sdis_heat_path_boundary_Xd_handle_external_net_flux.h b/src/sdis_heat_path_boundary_Xd_handle_external_net_flux.h
@@ -503,6 +503,13 @@ XD(handle_external_net_flux)
handle_flux = handle_flux && (scn->source != NULL);
if(!handle_flux) goto exit;
+ /* Emissivity is null <=> external flux is null. Nothing to do */
+ src_id = sdis_source_get_id(scn->source);
+ emissivity = interface_side_get_emissivity(args->interf, src_id, &frag);
+ res = interface_side_check_emissivity(scn->dev, emissivity, frag.P, frag.time);
+ if(res != RES_OK) goto error;
+ if(emissivity == 0) goto exit;
+
/* Sample the external source */
res = source_sample
(scn->source, rng, frag.P, frag.time, &src_sample);
@@ -536,10 +543,6 @@ XD(handle_external_net_flux)
incident_flux_direct + incident_flux_diffuse.reflected;
/* Calculate the net flux [W/m^2] */
- src_id = sdis_source_get_id(scn->source);
- emissivity = interface_side_get_emissivity(args->interf, src_id, &frag);
- res = interface_side_check_emissivity(scn->dev, emissivity, frag.P, frag.time);
- if(res != RES_OK) goto error;
net_flux = incident_flux * emissivity; /* [W/m^2] */
/* Calculate the net flux from the radiance source scattered at least once by