stardis

Perform coupled heat transfer calculations
git clone git://git.meso-star.fr/stardis.git
Log | Files | Refs | README | LICENSE

commit a31951d88d142573aa23ea7d6dad0d8ed140b61b
parent 9919cf4853f1d1cbaefda6dfe367f0a6e2fa31eb
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 29 May 2024 09:35:30 +0200

Constants added to the public API

Several solver constants were not exposed in the API provided to the
user for programming physical properties. Missing was the constant used
to set an unknown temperature and its helper macros used to check it.
Also missing were the constants for setting a null flux/power density,
which although they have no influence on the actual calculation activate
the use of a flux/power density for the interface/solid under
consideration and are therefore recorded as potential source in the
green function. Finally, the constant defining the internal source
identifier was also missing

Functions that wrap user functions in the corresponding solver function
are updated to associate Stardis constants with their solver matches.
Note that we do not directly expose solver constants in the Stardis API
due to licensing issues. The Stardis header API has been released under
the LGPLv3+ license, while the solver and all other Stardis sources are
licensed under the GPLv3+ license. The use of the LGPLv3+ license for
the Stardis API is intended to enable users to provide programmable
properties based on non-free licenses, as is already the case for
ordinary data, i.e. data that is not programmable. Free software can be
used to process closed data. But to enable this for programmable
properties, we need to provide a programming interface that can be used
on both sides (free and non-free). Hence the use of the LGPLv3+ license
for the Stardis API.

Diffstat:
Msrc/stardis-app.h | 2+-
Msrc/stardis-fluid-prog.c | 5+++--
Msrc/stardis-intface.c | 28+++++++++++++++++-----------
Msrc/stardis-prog-properties.h.in | 113+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/stardis-solid-prog.c | 8++++++--
5 files changed, 86 insertions(+), 70 deletions(-)

diff --git a/src/stardis-app.h b/src/stardis-app.h @@ -34,7 +34,7 @@ #include <sdis.h> #ifdef STARDIS_ENABLE_MPI -#include <mpi.h> + #include <mpi.h> #endif /* Forward declarations */ diff --git a/src/stardis-fluid-prog.c b/src/stardis-fluid-prog.c @@ -24,7 +24,6 @@ #include <limits.h> - /******************************************************************************* * Local Functions ******************************************************************************/ @@ -59,9 +58,11 @@ fluid_prog_get_temperature { const struct fluid_prog* const* fluid_props = sdis_data_cget(data); struct stardis_vertex v; + double temp = 0; d3_set(v.P, vtx->P); v.time = vtx->time; - return (*fluid_props)->temp(&v, (*fluid_props)->prog_data); + temp = (*fluid_props)->temp(&v, (*fluid_props)->prog_data); + return STARDIS_TEMPERATURE_IS_KNOWN(temp) ? temp : SDIS_TEMPERATURE_NONE;; } /******************************************************************************* diff --git a/src/stardis-intface.c b/src/stardis-intface.c @@ -126,13 +126,15 @@ intface_prog_get_temp { const struct intface* interface_props = sdis_data_cget(data); struct stardis_interface_fragment f; + double temp; d3_set(f.P, frag->P); d3_set(f.Ng, frag->Ng); d3_set(f.uv, frag->uv); 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_temp(&f, interface_props->prog_data); + temp = interface_props->get_temp(&f, interface_props->prog_data); + return STARDIS_TEMPERATURE_IS_KNOWN(temp) ? temp : SDIS_TEMPERATURE_NONE; } static double @@ -142,13 +144,15 @@ intface_prog_get_flux { const struct intface* interface_props = sdis_data_cget(data); struct stardis_interface_fragment f; + double flux; d3_set(f.P, frag->P); d3_set(f.Ng, frag->Ng); d3_set(f.uv, frag->uv); 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_flux(&f, interface_props->prog_data); + flux = interface_props->get_flux(&f, interface_props->prog_data); + return flux != STARDIS_FLUX_NONE ? flux : SDIS_FLUX_NONE; } static double @@ -170,39 +174,39 @@ intface_prog_get_hc static double intface_prog_get_emissivity (const struct sdis_interface_fragment* frag, - const unsigned source_id, + const unsigned src_id, struct sdis_data* data) { const struct intface* interface_props = sdis_data_cget(data); struct stardis_interface_fragment f; - (void)source_id; + unsigned id; d3_set(f.P, frag->P); d3_set(f.Ng, frag->Ng); d3_set(f.uv, frag->uv); 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, source_id, interface_props->prog_data); + id = src_id != SDIS_INTERN_SOURCE_ID ? src_id : STARDIS_INTERN_SOURCE_ID; + return interface_props->get_emissivity(&f, id, interface_props->prog_data); } static double intface_prog_get_alpha (const struct sdis_interface_fragment* frag, - const unsigned source_id, + const unsigned src_id, struct sdis_data* data) { const struct intface* interface_props = sdis_data_cget(data); struct stardis_interface_fragment f; - (void)source_id; + unsigned id; d3_set(f.P, frag->P); d3_set(f.Ng, frag->Ng); d3_set(f.uv, frag->uv); 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, source_id, interface_props->prog_data); + id = src_id != SDIS_INTERN_SOURCE_ID ? src_id : STARDIS_INTERN_SOURCE_ID; + return interface_props->get_alpha(&f, id, interface_props->prog_data); } static double @@ -212,13 +216,15 @@ intface_prog_get_ref_temp { const struct intface* interface_props = sdis_data_cget(data); struct stardis_interface_fragment f; + double temp; d3_set(f.P, frag->P); d3_set(f.Ng, frag->Ng); d3_set(f.uv, frag->uv); 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_ref_temp(&f, interface_props->prog_data); + temp = interface_props->get_ref_temp(&f, interface_props->prog_data); + return STARDIS_TEMPERATURE_IS_KNOWN(temp) ? temp : SDIS_TEMPERATURE_NONE; } static double diff --git a/src/stardis-prog-properties.h.in b/src/stardis-prog-properties.h.in @@ -32,12 +32,23 @@ #define STARDIS_API extern #endif -/*****************************************************************************/ -/* API types. */ -/* The various functions defining programmed descriptions receive arguments */ -/* of the following types when called from the stardis simulation. */ -/*****************************************************************************/ - +/* Constants defining that no power density/imposed flux is defined */ +#define STARDIS_VOLUMIC_POWER_NONE DBL_MAX +#define STARDIS_FLUX_NONE DBL_MAX + +/* Syntactic sugar used to define whether a temperature is known or not */ +#define STARDIS_TEMPERATURE_NONE (-(DBL_MAX+DBL_MAX)*0) /* NAN */ +#define STARDIS_TEMPERATURE_IS_KNOWN(Temp) (Temp==Temp) +#define STARDIS_TEMPERATURE_IS_UNKNOWN(Temp) (Temp!=Temp) + +/* Indentifier of the internal source of radiation */ +#define STARDIS_INTERN_SOURCE_ID UINT_MAX + +/******************************************************************************* + * API types. + * The various functions defining programmed descriptions receive arguments + * of the following types when called from the stardis simulation. + ******************************************************************************/ struct stardis_vertex { double P[3]; /* World space position */ double time; /* "Time" of the vertex */ @@ -83,11 +94,11 @@ struct stardis_description_create_context { extern "C" { #endif -/******************************************************************************/ -/* Optional functions for any programmed library. */ -/* Either all 3 or none of the 3 following functions must be defined. */ -/* If a libray doesn't need its own data, just let these functions undefined. */ -/******************************************************************************/ +/******************************************************************************* + * Optional functions for any programmed library. + * Either all 3 or none of the 3 following functions must be defined. + * If a libray doesn't need its own data, just let these functions undefined. + ******************************************************************************/ /* Create the data attached to a given libray. * A NULL result is interpreted as an error and ends the program. @@ -121,9 +132,9 @@ STARDIS_API void stardis_release_library_data (void* lib_data); -/******************************************************************************/ -/* Mandatory functions for any programmed description regardless of its type. */ -/******************************************************************************/ +/******************************************************************************* + * Mandatory functions for any programmed description regardless of its type. + ******************************************************************************/ /* Create the data attached to a given description. * A NULL result is interpreted as an error and ends the program. @@ -168,15 +179,9 @@ STARDIS_API const char* get_license_text (void* data); -/*****************************************************************************/ -/* Additional mandatory function declarations (sorted by description type). */ -/* Some functions appear multiple times as they are part of more than one */ -/* description requirement. */ -/*****************************************************************************/ - -/*********************************************************/ -/* Additional mandatory functions for a programmed solid */ -/*********************************************************/ +/******************************************************************************* + * Mandatory functions for a solid + ******************************************************************************/ /* Returns the calorific capacity at a given vertex. * This functions is called at every vertex of every path of the computation @@ -242,9 +247,9 @@ stardis_t_range (void* data, double range[2]); -/*********************************************************/ -/* Additional mandatory functions for a programmed fluid */ -/*********************************************************/ +/******************************************************************************* + * Mandatory functions for a fluid + ******************************************************************************/ /* Returns the calorific capacity at a given vertex. * This functions is called at every vertex of every path of the computation @@ -283,9 +288,9 @@ stardis_t_range (void* data, double range[2]); -/**************************************************************************/ -/* Additional mandatory functions for a programmed H boundary for a fluid */ -/**************************************************************************/ +/******************************************************************************* + * Mandatory functions for a H boundary for a fluid + ******************************************************************************/ /* Returns the boundary temperature at a given fragment. * This functions is called every time a path of the computation reaches @@ -352,9 +357,9 @@ stardis_t_range (void* data, double range[2]); -/**************************************************************************/ -/* Additional mandatory functions for a programmed H boundary for a solid */ -/**************************************************************************/ +/******************************************************************************* + * Mandatory functions for a H boundary for a solid + ******************************************************************************/ /* Returns the emissivity at a given fragment. * This functions is called every time a path of the computation reaches @@ -423,9 +428,9 @@ stardis_t_range (void* data, double range[2]); -/**************************************************************/ -/* Additional mandatory functions for a programmed T boundary */ -/**************************************************************/ +/******************************************************************************* + * Mandatory functions for a T boundary + ******************************************************************************/ /* Returns the boundary temperature at a given fragment. * This functions is called every time a path of the computation reaches @@ -445,9 +450,9 @@ stardis_t_range (void* data, double range[2]); -/****************************************************************/ -/* Additional mandatory functions for a programmed F+H boundary */ -/****************************************************************/ +/******************************************************************************* + * Mandatory functions for a F+H boundary + ******************************************************************************/ /* Returns the emissivity at a given fragment. * This functions is called every time a path of the computation reaches @@ -525,9 +530,9 @@ stardis_t_range (void* data, double range[2]); -/**************************************************************/ -/* Additional mandatory functions for a programmed F boundary */ -/**************************************************************/ +/******************************************************************************* + * Mandatory functions for a F boundary + ******************************************************************************/ /* Returns the flux at the boundary at a given fragment. * This functions is called every time a path of the computation reaches @@ -538,9 +543,9 @@ stardis_boundary_flux (const struct stardis_interface_fragment* frag, void* data); -/**************************************************************************/ -/* Additional mandatory functions for a programmed Solid-Solid connection */ -/**************************************************************************/ +/******************************************************************************* + * Mandatory functions for a solid-solid connection + ******************************************************************************/ /* Returns the thermal contact resistance at a given fragment. * This functions is called every time a path of the computation reaches @@ -551,9 +556,9 @@ stardis_thermal_contact_resistance (const struct stardis_interface_fragment* frag, void* data); -/**************************************************************************/ -/* Additional mandatory functions for a programmed Solid-Fluid connection */ -/**************************************************************************/ +/******************************************************************************* + * Mandatory functions for a solid-fluid connection + ******************************************************************************/ /* Returns the emissivity at a given fragment. * This functions is called every time a path of the computation reaches @@ -611,10 +616,10 @@ stardis_t_range (void* data, double range[2]); -/******************************************************************************/ -/* Additional mandatory functions for a programmed spherical source */ -/* These functions are used to calculate the external flux at the boundaries. */ -/******************************************************************************/ +/******************************************************************************* + * Mandatory functions for a spherical source. + * These functions are used to calculate the external flux at the boundaries + ******************************************************************************/ /* Retrieve the position of the spherical source center. * This function is used to calculate the external flux at the boundaries. @@ -642,9 +647,9 @@ stardis_spherical_source_diffuse_radiance const double dir[3], void* data); -/******************************************************************************/ -/* Additional mandatory functions for a programmed radiative environment */ -/******************************************************************************/ +/******************************************************************************* + * Mandatory functions for a radiative environment + ******************************************************************************/ /* Retrieve the temperature of radiative paths that reach infinity */ STARDIS_API double diff --git a/src/stardis-solid-prog.c b/src/stardis-solid-prog.c @@ -82,9 +82,11 @@ solid_prog_get_volumic_power { const struct solid_prog* const* solid_props = sdis_data_cget(data); struct stardis_vertex v; + double power; d3_set(v.P, vtx->P); v.time = vtx->time; - return (*solid_props)->vpower(&v, (*solid_props)->prog_data); + power = (*solid_props)->vpower(&v, (*solid_props)->prog_data); + return power != STARDIS_VOLUMIC_POWER_NONE ? power : SDIS_VOLUMIC_POWER_NONE; } static double @@ -94,9 +96,11 @@ solid_prog_get_temperature { const struct solid_prog* const* solid_props = sdis_data_cget(data); struct stardis_vertex v; + double temp; d3_set(v.P, vtx->P); v.time = vtx->time; - return (*solid_props)->temp(&v, (*solid_props)->prog_data); + temp = (*solid_props)->temp(&v, (*solid_props)->prog_data); + return STARDIS_TEMPERATURE_IS_KNOWN(temp) ? temp : SDIS_TEMPERATURE_NONE; } /*******************************************************************************