star-phor-input

File format for describing photoreactor configurations
git clone https://www.edstar.cnrs.fr/git/star-phor-input.git
Log | Files | Refs | README | LICENSE

commit 9b3e3f96d582de39e6e838f32f43cca37618efb2
parent 92bb5e1198a0cc0e65d4e68e421117046782305b
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date:   Tue, 13 Jan 2026 16:14:53 +0100

Rename exposed function

Rename sphin_volume_compute_total_volume to
sphin_volume_compute_total_size. This change makes the function name
more semantic, since the word "volume" was previously used both to
describe the physical volume of an object and the total extent of a
volume.

Diffstat:
Msrc/sphin.h | 4++--
Msrc/sphin_geometry.c | 2+-
Msrc/sphin_volume.c | 79++++---------------------------------------------------------------------------
3 files changed, 7 insertions(+), 78 deletions(-)

diff --git a/src/sphin.h b/src/sphin.h @@ -317,9 +317,9 @@ sphin_volume_get_name char** name); SPHIN_API res_T -sphin_volume_compute_total_volume +sphin_volume_compute_total_size (struct sphin_volume* volume, - double* total_volume); + double* total_size); SPHIN_API res_T sphin_volume_get_ka diff --git a/src/sphin_geometry.c b/src/sphin_geometry.c @@ -166,7 +166,7 @@ geometry_compute_volume volume += (h*b); } - return volume / 3.0; + return volume / 6.0; } diff --git a/src/sphin_volume.c b/src/sphin_volume.c @@ -162,61 +162,6 @@ error: goto exit; } -static res_T -parse_ka - (struct sphin_volume* volume, - struct txtrdr* txtrdr, - char* value) /* ka: 1.2 */ -{ - char* ka_val = NULL; - char* ka_unit = NULL; - char* token = NULL; - char* token_ptr = NULL; - res_T res = RES_OK; - double ka; - - ASSERT(NULL != volume); - ASSERT(NULL != txtrdr); - - if (NULL == value){ res = RES_BAD_ARG; goto error; } - - /* Parse ka value */ - ka_val = strtok_r(value, " \t", &token_ptr); - res = cstr_to_double(ka_val, &ka); - if (RES_OK != res) { goto error; } - if (ka < 0) { res = RES_BAD_ARG; goto error; } - - /* Parse ka unit and convert its value to m^-1 accordingly */ - ka_unit = strtok_r(NULL, " \t", &token_ptr); - - if (0 == strcmp(ka_unit, "cm^-1") - || 0 == strcmp(ka_unit, "1/cm")) { - volume->ka = ka * 100; - } - else if (0 == strcmp(ka_unit, "mm^-1") - || 0 == strcmp(ka_unit, "1/mm")) { - volume->ka = ka * 1000; - } - else if (0 == strcmp(ka_unit, "m^-1") - || 0 == strcmp(ka_unit, "1/m")) { - volume->ka = ka * 1; /* No conversion */ - } - else { res = RES_BAD_ARG; goto error; } - - /* Assert that there isnt anything but the ka - * value and its unit in the line */ - token = strtok_r(NULL, " \t", &token_ptr); - if (NULL != token) { res = RES_BAD_ARG; goto error; } - - res = txtrdr_read_line(txtrdr); - if (RES_OK != res) { goto error; } - -exit: - return res; -error: - goto exit; -} - /******************************************************************************* * Local functions ******************************************************************************/ @@ -260,10 +205,6 @@ parse_volume if (0 == strcmp(keyword, "geometry")){ res = parse_geometry(volume, txtrdr, token); } - /* TODO Remove ka from volumes */ - else if (0 == strcmp(keyword, "ka")){ - res = parse_ka(volume, txtrdr, token); - } else if (0 == strcmp(keyword, "prop_rad")){ res = parse_prop_rad(volume, txtrdr, token); } @@ -348,9 +289,9 @@ sphin_volume_get_name } res_T -sphin_volume_compute_total_volume +sphin_volume_compute_total_size (struct sphin_volume* volume, - double* total_volume) + double* total_size) { double total_vol = 0.; size_t geometry_count = 0; @@ -358,7 +299,7 @@ sphin_volume_compute_total_volume struct sphin_geometry* geometry = NULL; if (NULL == volume) { return RES_BAD_ARG; } - if (NULL == total_volume ) { return RES_BAD_ARG; } + if (NULL == total_size) { return RES_BAD_ARG; } geometry_count = darray_sphin_geometry_ptr_size_get(&volume->geometries); @@ -366,19 +307,7 @@ sphin_volume_compute_total_volume geometry = darray_sphin_geometry_ptr_data_get(&volume->geometries)[i]; total_vol += geometry_compute_volume(geometry, geometry->side); } - *total_volume = total_vol; - return RES_OK; -} - -res_T -sphin_volume_get_ka - (struct sphin_volume* volume, - double* ka) -{ - if (NULL == volume || NULL == ka) { - return RES_BAD_ARG; - } - *ka = volume->ka; + *total_size = total_vol; return RES_OK; }