commit 715897c3ee81de7d30052a394ee497955acddb87
parent 36808aba7fdb95a4ccaebd041bce3fe65ef166ae
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 14 Aug 2025 12:02:28 +0200
stardis: implement the remaining plugin accessors
Diffstat:
2 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c
@@ -164,6 +164,108 @@ stardis_convection_coefficient
return bcond->lib_desc.smeteo_desc.entries[i].H;
}
+double /* [W/K/m^2] */
+stardis_max_convection_coefficient(void* data)
+{
+ struct boundary_condition* bcond = data;
+ ASSERT(data);
+ return bcond->lib_desc.max_convection_coef;
+}
+
+double /* [W/m^2] */
+stardis_boundary_flux
+ (const struct stardis_interface_fragment* frag,
+ void* data)
+{
+ struct boundary_condition* bcond = data;
+ double net_flux = 0; /* [W/m^2] */
+ double SWdn = 0; /* shortwave downward flux [W/m^2] */
+ size_t i = 0;
+ ASSERT(frag && data);
+
+ i = get_meteo_entry_id(bcond, frag->time);
+
+ SWdn = bcond->lib_desc.smeteo_desc.entries[i].SWdn_direct
+ + bcond->lib_desc.smeteo_desc.entries[i].SWdn_diffuse;
+
+ /* Net flux on the ground side, i.e. the downward flux - upward flux */
+ net_flux = SWdn - bcond->lib_desc.smeteo_desc.entries[i].SWup;
+ return net_flux;
+}
+
+double /* [K] */
+stardis_medium_temperature(const struct stardis_vertex* vtx, void* data)
+{
+ struct boundary_condition* bcond = data;
+ size_t i = 0;
+ ASSERT(vtx && data);
+
+ i = get_meteo_entry_id(bcond, vtx->time);
+ return bcond->lib_desc.smeteo_desc.entries[i].Tatm;
+}
+
+/* Ground emissivity */
+double
+stardis_emissivity
+ (const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
+ void* data)
+{
+ struct boundary_condition* bcond = data;
+ ASSERT(data);
+ (void)frag, (void)source_id; /* Avoid "unused variable" warning */
+
+ return 1 - bcond->lib_desc.smeteo_desc.albedo;
+}
+
+/* Specular part of the BRDF of the ground */
+double
+stardis_specular_fraction
+ (const struct stardis_interface_fragment* frag,
+ const unsigned source_id,
+ void* data)
+{
+ (void)data, (void)frag, (void)source_id; /* Avoid "unused variable" warning */
+ return 0; /* <=> The ground is purely diffuse */
+}
+
+/* The reference ground temperature is set here to the surface temperature
+ * obtained from meteorological data. */
+double /* [K] */
+stardis_reference_temperature
+ (const struct stardis_interface_fragment* frag,
+ void* data)
+{
+ return stardis_boundary_temperature(frag, data);
+}
+
+/* Range of reference temperature, i.e. range of ground temperature from the
+ * entire set of surface temperatures */
+double*
+stardis_t_range(void* data, double range[2] /* [K] */)
+{
+ struct boundary_condition* bcond = data;
+ ASSERT(data && range);
+
+ range[0] = bcond->lib_desc.surface_temperatue_range[0];
+ range[1] = bcond->lib_desc.surface_temperatue_range[1];
+ return range;
+}
+
+/* Ground temperature */
+double /* [K] */
+stardis_boundary_temperature
+ (const struct stardis_interface_fragment* frag,
+ void* data)
+{
+ struct boundary_condition* bcond = data;
+ size_t i = 0; /* Index of the meteo entry including fragment time */
+ ASSERT(frag && data);
+
+ i = get_meteo_entry_id(bcond, frag->time);
+ return bcond->lib_desc.smeteo_desc.entries[i].Tsrf;
+}
+
const char*
get_copyright_notice(void* data)
{
diff --git a/src/stardis_smeteo.h b/src/stardis_smeteo.h
@@ -76,7 +76,7 @@ STARDIS_API double /* >0 [W/K/m^2] */
stardis_max_convection_coefficient
(void* data);
-/* Net ground flux calculated from meteorological data */
+/* Net flux on the ground side, i.e. downward flux - upward flux */
STARDIS_API double /* [W/m^2] */
stardis_boundary_flux
(const struct stardis_interface_fragment* frag,
@@ -101,7 +101,8 @@ stardis_emissivity
const unsigned source_id,
void* data);
-/* Control the specularity of the ground BRDF */
+/* Controls the specular part of the BRDF of the ground. The ground is assumed
+ * to be purely diffuse, therefore its specular fraction is zero. */
STARDIS_API double
stardis_specular_fraction
(const struct stardis_interface_fragment* frag,