stardis-solver

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

commit 53e7eabf94cd5c083a1f9d444ad8e971fe90888c
parent e1eefd1803609894d778553f65b508eb87ed06e9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 10 Apr 2024 10:28:30 +0200

Update reference temperature checks

Improve the log message if an error is detected on the Tref or
temperature range. In addition, when sampling a radiative path, make
sure that these temperatures are known _and_ positive. While negative
temperatures make sense for boundary or initial conditions, reference
temperatures and temperature ranges are used to evaluate a radiative H
when linearizing radiative transfer. They cannot therefore be negative,
i.e. relative to another temperature.

Diffstat:
Msrc/sdis_heat_path_boundary_Xd_c.h | 51+++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/src/sdis_heat_path_boundary_Xd_c.h b/src/sdis_heat_path_boundary_Xd_c.h @@ -1001,27 +1001,58 @@ XD(check_Tref) { ASSERT(scn && pos && func_name); + #define CHECK_TBOUND(Bound, Name) { \ + if(SDIS_TEMPERATURE_IS_UNKNOWN(Bound)) { \ + log_err(scn->dev, \ + "%s: the "Name" temperature cannot be unknown " \ + "to sampling a radiative path.\n", \ + func_name); \ + return RES_BAD_OP_IRRECOVERABLE; \ + } \ + \ + if((Bound) < 0) { \ + log_err(scn->dev, \ + "%s: the "Name" temperature cannot be negative " \ + "to sample a radiative path (T"Name" = %g K).\n", \ + func_name, (Bound)); \ + return RES_BAD_OP_IRRECOVERABLE; \ + } \ + } (void) 0 + CHECK_TBOUND(scn->tmin, "min"); + CHECK_TBOUND(scn->tmax, "max"); + #undef CHECK_TBOUND + + if(scn->tmin > scn->tmax) { + log_err(scn->dev, + "%s: the temperature range cannot be degenerated to sample a radiative " + "path (Tmin = %g K; Tmax = %g K).\n", + func_name, scn->tmin, scn->tmax); + return RES_BAD_OP_IRRECOVERABLE; + } + if(SDIS_TEMPERATURE_IS_UNKNOWN(Tref)) { log_err(scn->dev, - "%s: invalid reference temperature at the position `"FORMAT_VECX"'.\n", + "%s: the reference temperature is unknown at `"FORMAT_VECX". " + "Sampling a radiative path requires a valid reference temperature field.\n", func_name, SPLITX(pos)); return RES_BAD_OP_IRRECOVERABLE; } - if(SDIS_TEMPERATURE_IS_UNKNOWN(scn->tmin) - || SDIS_TEMPERATURE_IS_UNKNOWN(scn->tmax)) { + if(Tref < 0) { log_err(scn->dev, - "%s: invalid scene temperature range. " - "At least one boundary is unknown.\n", - func_name); + "%s: the reference temperature is negative at `"FORMAT_VECX" (Tref = %g K). " + "Sampling a radiative path requires a known, positive reference " + "temperature field.\n", + func_name, SPLITX(pos), Tref); return RES_BAD_OP_IRRECOVERABLE; } - if(Tref > scn->tmax) { + if(Tref < scn->tmin || scn->tmax < Tref) { log_err(scn->dev, - "%s: invalid maximum temperature `%gK'. The reference temperature `%gK' " - "at the position `"FORMAT_VECX"' is greater than this temperature.\n", - func_name, scn->tmax, Tref, SPLITX(pos)); + "%s: invalid reference temperature at `"FORMAT_VECX"' (Tref = %g K). " + "It must be included in the provided temperature range " + "(Tmin = %g K; Tmax = %g K)\n", + func_name, SPLITX(pos), Tref, scn->tmin, scn->tmax); return RES_BAD_OP_IRRECOVERABLE; }