stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit f5aa4e47225bbb7af28ab44dfc4a30bc7984b1eb
parent b5eb97e48dc6cde6b2e8c0b54d8ef55a3fb2e786
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 16 Jan 2024 15:21:24 +0100

Add and test the API function sdis_source_get_power

It will be used to manually resolve the green function on scenes with an
external source.

Diffstat:
Msrc/sdis.h | 5+++++
Msrc/sdis_source.c | 15+++++++++++++++
Msrc/sdis_source_c.h | 4++++
Msrc/test_sdis_source.c | 6++++++
4 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -978,6 +978,11 @@ SDIS_API res_T sdis_source_ref_put (struct sdis_source* source); +SDIS_API res_T +sdis_source_get_power + (const struct sdis_source* src, + double* power);/* [W] */ + /******************************************************************************* * A scene is a collection of primitives. Each primitive is the geometric * support of the interface between 2 media. diff --git a/src/sdis_source.c b/src/sdis_source.c @@ -126,6 +126,14 @@ sdis_source_ref_put(struct sdis_source* src) return RES_OK; } +res_T +sdis_source_get_power(const struct sdis_source* src, double* power) +{ + if(!src || !power) return RES_BAD_ARG; + *power = source_get_power(src); + return RES_OK; +} + /******************************************************************************* * Local functions ******************************************************************************/ @@ -272,3 +280,10 @@ error: *sample = SOURCE_SAMPLE_NULL; goto exit; } + +double +source_get_power(const struct sdis_source* src) +{ + ASSERT(src); + return src->spherical.power; +} diff --git a/src/sdis_source_c.h b/src/sdis_source_c.h @@ -52,4 +52,8 @@ source_trace_to const double time, /* Time at which ray is traced */ struct source_sample* sample); /* pdf == 0 if no source is reached */ +extern LOCAL_SYM double /* [W] */ +source_get_power + (const struct sdis_source* source); + #endif /* SDIS_SOURCE_C_H */ diff --git a/src/test_sdis_source.c b/src/test_sdis_source.c @@ -36,6 +36,7 @@ check_spherical_source(struct sdis_device* dev) SDIS_SPHERICAL_SOURCE_CREATE_ARGS_NULL; struct sdis_source* src = NULL; struct sdis_data* data = NULL; + double power = 0; /* Create a data to check its memory management */ OK(sdis_data_create(dev, sizeof(double[3]), ALIGNOF(double[3]), NULL, &data)); @@ -50,6 +51,11 @@ check_spherical_source(struct sdis_device* dev) BA(sdis_spherical_source_create(dev, &args, NULL)); OK(sdis_spherical_source_create(dev, &args, &src)); + BA(sdis_source_get_power(NULL, &power)); + BA(sdis_source_get_power(src, NULL)); + OK(sdis_source_get_power(src, &power)); + CHK(power == args.power); + BA(sdis_source_ref_get(NULL)); OK(sdis_source_ref_get(src)); BA(sdis_source_ref_put(NULL));