commit 764ad811e8784e1a8fe21098f1008585f7f1b007
parent 1f7adff34fd73615c167ac37b3bf60a3418f09e7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sat, 13 Apr 2024 16:51:59 +0200
Make emissivity and alpha dependent on radiation source
Update the profile of their associated getter to add the ID of the
radiation source in question.
This introduces an API break on programmable properties that the user
must take into account with care. This is because programmable property
functions are dynamically loaded and therefore casted into the function
profile expected at runtime. And there's no easy way to check that the
loaded function profile is the right one. Without updating programmable
properties, the user will use a function with an incorrect profile
which, once called, will lead to memory corruption.
To alleviate this problem, and because it was designed for this very
purpose, the programmable properties version has been updated.
Diffstat:
7 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/config.mk b/config.mk
@@ -5,7 +5,7 @@ VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
PREFIX = /usr/local
GREEN_TYPES_VERSION = 4
-PROG_PROPERTIES_VERSION = 1
+PROG_PROPERTIES_VERSION = 2
LIB_TYPE = SHARED
#LIB_TYPE = STATIC
diff --git a/src/stardis-hbound-prog.h b/src/stardis-hbound-prog.h
@@ -41,8 +41,10 @@ struct h_boundary_prog {
(const struct stardis_description_create_context*, void*, size_t, char**);
void (*release)(void*);
double (*ref_temp)(const struct stardis_interface_fragment*, void*);
- double (*emissivity)(const struct stardis_interface_fragment*, void*);
- double (*alpha)(const struct stardis_interface_fragment*, void*);
+ double (*emissivity)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
+ double (*alpha)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
double (*hc)(const struct stardis_interface_fragment*, void*);
double (*hmax)(void*);
double* (*t_range)(void*, double trange[2]);
diff --git a/src/stardis-hfbound-prog.h b/src/stardis-hfbound-prog.h
@@ -41,8 +41,10 @@ struct hf_boundary_prog {
(const struct stardis_description_create_context*, void*, size_t, char**);
void (*release)(void*);
double (*ref_temp)(const struct stardis_interface_fragment*, void*);
- double (*emissivity)(const struct stardis_interface_fragment*, void*);
- double (*alpha)(const struct stardis_interface_fragment*, void*);
+ double (*emissivity)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
+ double (*alpha)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
double (*hc)(const struct stardis_interface_fragment*, void*);
double (*hmax)(void*);
double* (*t_range)(void*, double trange[2]);
diff --git a/src/stardis-intface.c b/src/stardis-intface.c
@@ -112,9 +112,10 @@ interface_get_tcr
static double
emissivity_1
(const struct stardis_interface_fragment* frag,
+ const unsigned src_id,
void* data)
{
- (void)frag, (void)data;
+ (void)frag, (void)src_id, (void)data;
return 1;
}
@@ -181,7 +182,8 @@ intface_prog_get_emissivity
f.time = frag->time;
ASSERT(frag->side == SDIS_FRONT || frag->side == SDIS_BACK);
f.side = (frag->side == SDIS_FRONT) ? FRONT : BACK;
- return interface_props->get_emissivity(&f, interface_props->prog_data);
+ return interface_props->get_emissivity
+ (&f, source_id, interface_props->prog_data);
}
static double
@@ -199,7 +201,8 @@ intface_prog_get_alpha
f.time = frag->time;
ASSERT(frag->side == SDIS_FRONT || frag->side == SDIS_BACK);
f.side = (frag->side == SDIS_FRONT) ? FRONT : BACK;
- return interface_props->get_alpha(&f, interface_props->prog_data);
+ return interface_props->get_alpha
+ (&f, source_id, interface_props->prog_data);
}
static double
diff --git a/src/stardis-intface.h b/src/stardis-intface.h
@@ -31,10 +31,13 @@ struct intface {
double (*get_temp)(const struct stardis_interface_fragment*, void*);
double (*get_flux)(const struct stardis_interface_fragment*, void*);
double (*get_hc)(const struct stardis_interface_fragment*, void*);
- double (*get_emissivity)(const struct stardis_interface_fragment*, void*);
- double (*get_alpha)(const struct stardis_interface_fragment*, void*);
double (*get_ref_temp)(const struct stardis_interface_fragment*, void*);
double (*get_tcr)(const struct stardis_interface_fragment*, void*);
+ double (*get_emissivity)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
+ double (*get_alpha)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
+
void* prog_data;
/* fluid - solid */
double hc;
diff --git a/src/stardis-prog-properties.h.in b/src/stardis-prog-properties.h.in
@@ -303,6 +303,7 @@ stardis_boundary_temperature
STARDIS_API double
stardis_emissivity
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the specular fraction at a given fragment.
@@ -312,6 +313,7 @@ stardis_emissivity
STARDIS_API double
stardis_specular_fraction
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the convection coefficient at a given fragment.
@@ -361,6 +363,7 @@ stardis_t_range
STARDIS_API double
stardis_emissivity
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the specular fraction at a given fragment.
@@ -370,6 +373,7 @@ stardis_emissivity
STARDIS_API double
stardis_specular_fraction
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the convection coefficient at a given fragment.
@@ -452,6 +456,7 @@ stardis_t_range
STARDIS_API double
stardis_emissivity
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the specular fraction at a given fragment.
@@ -461,6 +466,7 @@ stardis_emissivity
STARDIS_API double
stardis_specular_fraction
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the convection coefficient at a given fragment.
@@ -556,6 +562,7 @@ stardis_thermal_contact_resistance
STARDIS_API double
stardis_emissivity
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the specular fraction at a given fragment.
@@ -565,6 +572,7 @@ stardis_emissivity
STARDIS_API double
stardis_specular_fraction
(const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
void* data);
/* Returns the convection coefficient at a given fragment.
diff --git a/src/stardis-sfconnect-prog.h b/src/stardis-sfconnect-prog.h
@@ -43,8 +43,10 @@ struct solid_fluid_connect_prog {
(const struct stardis_description_create_context*, void*, size_t, char**);
void (*release)(void*);
double (*ref_temp)(const struct stardis_interface_fragment*, void*);
- double (*emissivity)(const struct stardis_interface_fragment*, void*);
- double (*alpha)(const struct stardis_interface_fragment*, void*);
+ double (*emissivity)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
+ double (*alpha)
+ (const struct stardis_interface_fragment*, const unsigned src_id, void*);
double (*hc)(const struct stardis_interface_fragment*, void*);
double (*hmax)(void*);
double* (*t_range)(void*, double trange[2]);