stardis

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

commit 40d1905154cd7687d949b66f76b44b53f9b47bde
parent d46f4cdd3507afb8b2168af4df52fa2a8361eb9b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Mon,  4 May 2020 16:06:29 +0200

Make it possible to impose temperature on media

Diffstat:
Mdoc/stardis-input.5.txt | 18++++++++++++------
Msrc/stardis-parsing.c | 52++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/doc/stardis-input.5.txt b/doc/stardis-input.5.txt @@ -84,9 +84,11 @@ _______ <comment> ::= "#" Any text introduced by the # character <solid-frontier> ::= "SOLID" <medium-name> <lambda> <rho> <cp> <delta> \ - <initial-temp> <volumic-power> <triangle-sides> + <initial-temp> <imposed-temperature> <volumic-power> \ + <triangle-sides> -<fluid-frontier> ::= "FLUID" <medium-name> <rho> <cp> <initial-temp> <triangle-sides> +<fluid-frontier> ::= "FLUID" <medium-name> <rho> <cp> <initial-temp> \ + <imposed-temperature> <triangle-sides> <t-bound-for-solid> ::= "T_BOUNDARY_FOR_SOLID" <bound-name> <temperature> <triangles> @@ -118,6 +120,11 @@ _______ <initial-temp> ::= REAL # in [0, INF) +<imposed-temperature> ::= "UNKNOWN" # temperature has to be solved + | REAL # in [0, INF) + +<outside-temperature> ::= REAL # in [0, INF) + <volumic-power> ::= REAL # in (-INF , INF) <triangle-sides> ::= <side-specifier> <file-name> [ <triangle-sides> ] @@ -130,8 +137,6 @@ _______ <hc> ::= REAL # in [0, INF) -<outside-temperature> ::= REAL # in [0, INF) - <flux> ::= REAL # in (-INF , INF) <triangles> ::= <file-name> [ <triangles> ] @@ -157,8 +162,9 @@ NAMES Names, either file names, medium names or boundary names, are a sequence of one or ore ASCII characters, including numbers and special characters like *.* *_* *-* as one may consider using in standard file names, *without any -spacing* either escaped or not. Two different description lines cannot use -the same name. +spacing* either escaped or not. Names are case-sensitive anf two different +description lines, either in the same description file or from different +description files, cannot use the same name. EXAMPLES -------- diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c @@ -1278,7 +1278,46 @@ error: goto end; } -/* SOLID Name lambda rho cp delta Tinit volumic_power STL_filenames */ +static res_T +read_imposed_temperature + (struct stardis* stardis, + double* imposed_temperature, + char** tok_ctx) +{ + char* tk = NULL; + struct str keep; + res_T res = RES_OK; + + str_init(stardis->allocator, &keep); + CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "imposed temperature"); + ERR(str_set(&keep, tk)); + if(RES_OK == cstr_to_double(tk, imposed_temperature)) { + /* Was a number */ + if(imposed_temperature < 0) { + res = RES_BAD_ARG; + goto error; + } + } else { + /* Could be 'unknown' */ + _strupr(tk); + if(0 == strcmp(tk, "UNKNOWN")) { + /* Unknown for stadis solver is -1 */ + *imposed_temperature = -1; + } else { + res = RES_BAD_ARG; + goto error; + } + } +end: + str_release(&keep); + return res; +error: + logger_print(stardis->logger, LOG_ERROR, "Invalid imposed temperature: %s\n", + str_cget(&keep)); + goto end; +} + +/* SOLID Name lambda rho cp delta Tinit Timposed volumic_power STL_filenames */ static res_T process_solid (struct stardis* stardis, @@ -1356,6 +1395,8 @@ process_solid if(res == RES_OK) res = RES_BAD_ARG; goto end; } + ERR(read_imposed_temperature(stardis, &desc->d.solid.imposed_temperature, + tok_ctx)); CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "volumic power"); res = cstr_to_double(tk, &desc->d.solid.vpower); if(res != RES_OK) { @@ -1372,7 +1413,7 @@ error: goto end; } -/* FLUID Name rho cp Tinit STL_filenames */ +/* FLUID Name rho cp Tinit Timposed STL_filenames */ static res_T process_fluid (struct stardis* stardis, @@ -1433,6 +1474,9 @@ process_fluid goto end; } + ERR(read_imposed_temperature(stardis, &desc->d.fluid.imposed_temperature, + tok_ctx)); + ERR(read_sides_and_files(stardis, 0, desc->d.fluid.fluid_id, tok_ctx)); end: @@ -1442,8 +1486,8 @@ error: } /* Read medium or boundary line; should be one of: - * SOLID Name lambda rho cp delta Tinit volumic_power STL_filenames - * FLUID Name rho cp Tinit STL_filenames + * SOLID Name lambda rho cp delta Tinit Timposed volumic_power STL_filenames + * FLUID Name rho cp Tinit Timposed STL_filenames * H_BOUNDARY_FOR_SOLID Name emissivity specular_fraction hc T_env STL_filenames * H_BOUNDARY_FOR_FLUID Name emissivity specular_fraction hc T_env STL_filenames * T_BOUNDARY_FOR_SOLID Name T STL_filenames