commit 21cbf052694441408f10480ae68508cf0a2da64a
parent fbe60e6000694c1cf95afed6521719449e74736f
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Thu, 31 Jul 2025 19:51:55 +0200
Add source to test case for discrete distribution setup
The test case lacked a source, causing ssp_ranst_discrete_setup to
return RES_BAD_ARG due to an empty powers array. This is unintended
behavior, as sphor should handle systems with no sources independently
of ssp. A source has been temporarily added to the test case. The
underlying physics issue requires further discussion and a proper error
handling policy in sphor.
Diffstat:
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/sphor_sources.c b/src/sphor_sources.c
@@ -266,6 +266,14 @@ setup_source_distrib_power
(sphor->allocator, &sphor->source_distrib_power);
if (RES_OK != res) { goto error; }
+ /* TODO ssp does not allow an empty list as an argument to this function.
+ * Currently, if an input file does not contain a source, the next function
+ * call will return RES_BAD_ARG and the program will stop. In other words,
+ * input files without sources are not allowed in star-phor, although they are
+ * allowed in star-phor-input. The behavior of the function
+ * `setup_source_distrib_power`, which is currently the same as
+ * `ssp_ranst_discret_setup`, should be discussed, as we may want to be more
+ * tolerant of input files with no sources. */
res = ssp_ranst_discrete_setup
(sphor->source_distrib_power,
darray_double_cdata_get(&powers),
diff --git a/src/test_sphor_lib.c b/src/test_sphor_lib.c
@@ -90,6 +90,9 @@ write_input_file(FILE* fp)
fprintf(fp, "surface: \"test surface\"\n");
fprintf(fp, "\tgeometry: BACK %s\n", geom_filename);
+ fprintf(fp, "\tsource:\t #commentaire\n");
+ fprintf(fp, "\tflux_density: 1e3 umol/m^2/s\t\n");
+ fprintf(fp, "\tdirection: COLLIM NORMAL\n");
CHK(fflush(fp) == 0);
}