commit 8d8a57eff6197c11637d33f3703f1e2bda5a2649
parent 9ffbc52c3b470f8473240c7285c3d88aaac86658
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 29 Oct 2020 14:59:28 +0100
Fix initial VS imposed temperature incoherency
Diffstat:
4 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/doc/stardis-input.5.txt b/doc/stardis-input.5.txt
@@ -55,6 +55,14 @@ the same applies to *stardis(1)* outputs as described in *stardis-output(5)*.
However, the geometry provided to *stardis*(1) can be described in any unit,
multiple of meters or not, as long as the scaling factor is provided.
+TINIT VS TIMPOSED
+-----------------
+Media's descriptions, either solids or fluids, include two possible
+temperatures: initial and imposed. If imposed temperature is set (that is not
+"UNKNOWN"), initial temperature must be defined at the same value. As a
+consequence, one cannot define a medium with an imposed temperature that
+changes at t=0.
+
GRAMMAR
-------
In what follows, some lines end in *\*. This is used as a convenience to
diff --git a/src/stardis-fluid.c b/src/stardis-fluid.c
@@ -51,20 +51,22 @@ fluid_get_temperature
struct sdis_data* data)
{
const struct fluid* fluid_props = sdis_data_cget(data);
- if(vtx->time > fluid_props->t0)
+ if(fluid_props->imposed_temperature >= 0)
+ /* If there is an imposed temp, it is imposed regardless of time */
return fluid_props->imposed_temperature;
- /* Time is <= 0: use tinit */
- if(fluid_props->tinit >= 0) return fluid_props->tinit;
- /* Must have had tinit defined: error! */
- if(str_is_empty(&fluid_props->name)) {
- FATAL("fluid_get_temperature: getting undefined Tinit\n");
- } else {
- fprintf(stderr,
- "fluid_get_temperature: getting undefined Tinit (fluid '%s')\n",
- str_cget(&fluid_props->name));
- ASSERT(0);
- abort();
+ if(vtx->time <= fluid_props->t0) {
+ /* If time is <= t0: use tinit */
+ if(fluid_props->tinit < 0) {
+ if(str_is_empty(&fluid_props->name)) {
+ FATAL("fluid_get_temperature: getting undefined Tinit\n");
+ } else {
+ VFATAL("fluid_get_temperature: getting undefined Tinit (fluid '%s')\n",
+ ARG1(str_cget(&fluid_props->name)));
+ }
+ }
+ return fluid_props->tinit;
}
+ return -1; /* Unknown temperature */
}
/*******************************************************************************
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -1541,6 +1541,15 @@ process_solid
}
ERR(read_imposed_temperature(stardis, &desc->d.solid.imposed_temperature,
tok_ctx));
+ if(desc->d.solid.imposed_temperature >= 0
+ && desc->d.solid.imposed_temperature != desc->d.solid.tinit)
+ {
+ logger_print(stardis->logger, LOG_ERROR,
+ "Imposed temperature, if defined, must match initial temperature "
+ "(initial: %g; imposed: %g)\n",
+ desc->d.solid.tinit, desc->d.solid.imposed_temperature); res = RES_BAD_ARG;
+ goto end;
+ }
CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "volumic power");
res = cstr_to_double(tk, &desc->d.solid.vpower);
if(res != RES_OK) {
@@ -1629,6 +1638,15 @@ process_fluid
ERR(read_imposed_temperature(stardis, &desc->d.fluid.imposed_temperature,
tok_ctx));
+ if(desc->d.fluid.imposed_temperature >= 0
+ && desc->d.fluid.imposed_temperature != desc->d.fluid.tinit)
+ {
+ logger_print(stardis->logger, LOG_ERROR,
+ "Imposed temperature, if defined, must match initial temperature "
+ "(initial: %g; imposed: %g)\n",
+ desc->d.fluid.tinit, desc->d.fluid.imposed_temperature); res = RES_BAD_ARG;
+ goto end;
+ }
ERR(create_solver_fluid(stardis, &desc->d.fluid));
diff --git a/src/stardis-solid.c b/src/stardis-solid.c
@@ -82,20 +82,22 @@ solid_get_temperature
struct sdis_data* data)
{
const struct solid* solid_props = sdis_data_cget(data);
- if(vtx->time > solid_props->t0)
+ if(solid_props->imposed_temperature >= 0)
+ /* If there is an imposed temp, it is imposed regardless of time */
return solid_props->imposed_temperature;
- /* Time is <= 0: use tinit */
- if(solid_props->tinit >= 0) return solid_props->tinit;
- /* Must have had t_init defined: error! */
- if(str_is_empty(&solid_props->name)) {
- FATAL("solid_get_temperature: getting undefined Tinit\n");
- } else {
- fprintf(stderr,
- "solid_get_temperature: getting undefined Tinit (solid '%s')\n",
- str_cget(&solid_props->name));
- ASSERT(0);
- abort();
+ if(vtx->time <= solid_props->t0) {
+ /* If time is <= t0: use tinit */
+ if(solid_props->tinit < 0) {
+ if(str_is_empty(&solid_props->name)) {
+ FATAL("solid_get_temperature: getting undefined Tinit\n");
+ } else {
+ VFATAL("solid_get_temperature: getting undefined Tinit (solid '%s')\n",
+ ARG1(str_cget(&solid_props->name)));
+ }
+ }
+ return solid_props->tinit;
}
+ return -1; /* Unknown temperature */
}
static double