commit 637cbcf608ea2c6c610a4efe3dc4bf12a30f5973
parent 024fa89fa859231efc7a2a41afea63cf1d2cb686
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 28 Oct 2021 09:32:12 +0200
Merge branch 'feature_local_Tref' into develop
Diffstat:
11 files changed, 88 insertions(+), 68 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -46,7 +46,6 @@ set(STARDIS_ARGS_DEFAULT_RENDERING_SPP "4")
set(STARDIS_ARGS_DEFAULT_RENDERING_TGT "0, 0, 0")
set(STARDIS_ARGS_DEFAULT_RENDERING_TIME "INF, INF")
set(STARDIS_ARGS_DEFAULT_RENDERING_UP "0, 0, 1")
-set(STARDIS_ARGS_DEFAULT_REFERENCE_TEMP "300")
set(STARDIS_ARGS_DEFAULT_SAMPLES_COUNT "10000")
set(STARDIS_ARGS_DEFAULT_SCALE_FACTOR "1")
set(STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL "1")
diff --git a/doc/stardis-input.5.txt b/doc/stardis-input.5.txt
@@ -117,17 +117,17 @@ _______
<triangles>
-<h-bound-for-solid> ::= "H_BOUNDARY_FOR_SOLID" <bound-name> <emissivity> \
+<h-bound-for-solid> ::= "H_BOUNDARY_FOR_SOLID" <bound-name> <Tref> <emissivity> \
<specular-fraction> <hc> <outside-temperature> \
<triangles>
-<h-bound-for-fluid> ::= "H_BOUNDARY_FOR_FLUID" <bound-name> <emissivity> \
+<h-bound-for-fluid> ::= "H_BOUNDARY_FOR_FLUID" <bound-name> <Tref> <emissivity> \
<specular-fraction> <hc> <outside-temperature> \
<triangles>
<f-bound-for-solid> ::= "F_BOUNDARY_FOR_SOLID" <bound-name> <flux> <triangles>
-<solid-fluid-connect> ::= "SOLID_FLUID_CONNECTION" <bound-name> <emissivity> \
+<solid-fluid-connect> ::= "SOLID_FLUID_CONNECTION" <bound-name> <Tref> <emissivity> \
<specular-fraction> <hc> <triangles>
<solid-solid-connect> ::= "SOLID_SOLID_CONNECTION" <bound-name> \
@@ -163,6 +163,8 @@ _______
<bound-name> ::= STRING # no space allowed
+<Tref> ::= REAL # in [0, inf)
+
<emissivity> ::= REAL # in [0, 1]
<specular-fraction> ::= REAL # in [0, 1]
diff --git a/doc/stardis-output.5.txt b/doc/stardis-output.5.txt
@@ -249,7 +249,6 @@ _______
<descriptions>
<concatenated-names> # char[names-pool-size]
ambient-temperature # double
- reference-temperature # double
time-range # double[2]
<samples>
@@ -316,6 +315,7 @@ _______
struct h_boundary {
struct str name;
+ double ref_temperature;
double emissivity;
double specular_fraction;
double hc;
@@ -325,6 +325,7 @@ _______
struct solid_fluid_connect {
struct str name;
+ double ref_temperature;
double emissivity;
double specular_fraction;
double hc;
@@ -390,14 +391,14 @@ _______
"# ID Name temperature"
<t-bounds>
"# H Boundaries"
- "# ID Name emissivity specular_fraction hc T_env"
+ "# ID Name ref_temperature emissivity specular_fraction hc T_env"
<h-bounds>
"# F Boundaries"
"# ID Name flux"
<f-bounds>
- "# Radiative Temperatures"
- "# ID Rad_Temp Lin_Temp"
- <rad-temps>
+ "# Radiative Temperature"
+ "# ID Rad_Temp"
+ <rad-temp>
"# Samples"
"# end #power_terms #flux_terms power_term_1 ... \
power_term_n flux_term_1 ... flux_term_n"
@@ -425,7 +426,7 @@ _______
<f-bounds> ::= <f-bound>
<f-bounds> # #f-bounds f-bound descriptions
-<rad-temps> ::= <green-id> <rad-temp> <lin-temp>
+<rad-temp> ::= <green-id> <ambient-temp>
<samples> ::= <sample>
<samples> # #samples sample descriptions
@@ -443,12 +444,11 @@ _______
<t-bound> ::= <green-id> <name> <temperature>
-<h-bound> ::= <green-id> <name> <emissivity> <specular_fraction> \
- <hc> <temperature>
+<h-bound> ::= <green-id> <name> <ref_temperature> <emissivity> \
+ <specular_fraction> <hc> <temperature>
<f-bound> ::= <green-id> <name> <flux>
-<rad-temps> ::= <green-id> <ambient-temp> <lin-temp>
<name> ::= STRING # no space allowed
@@ -468,6 +468,8 @@ _______
<temperature> ::= REAL # in [0, INF)
+<ref-temperature> ::= REAL # in [0, INF)
+
<emissivity> ::= REAL # in [0, 1]
<specular-fraction> ::= REAL # in [0, 1]
diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in
@@ -242,11 +242,6 @@ different temperature, flux or volumic power values.
Number of Monte-Carlo samples. By default *samples-count* is set to
@STARDIS_ARGS_DEFAULT_SAMPLES_COUNT@.
-*-r* _reference_::
- Set the reference temperature used for the linearization of the radiative
- transfer, in Kelvin. By default *reference*
- is @STARDIS_ARGS_DEFAULT_REFERENCE_TEMP@.
-
*-t* _threads-count_::
Hint on the number of threads to use. By default use as many threads as CPU
cores.
diff --git a/src/stardis-app.c b/src/stardis-app.c
@@ -236,7 +236,6 @@ stardis_init
stardis->nthreads = args->nthreads;
stardis->scale_factor = -1; /* invalid value */
stardis->ambient_temp = args->ambient_temp;
- stardis->ref_temp = args->ref_temp;
stardis->dump_paths = SDIS_HEAT_PATH_NONE;
if(args->dump_paths & DUMP_ERROR)
stardis->dump_paths |= SDIS_HEAT_PATH_FAILURE;
@@ -395,7 +394,6 @@ stardis_init
scn_args.nvertices = vcount;
scn_args.fp_to_meter = stardis->scale_factor;
scn_args.trad = stardis->ambient_temp;
- scn_args.tref = stardis->ref_temp;
scn_args.context = &create_context;
res = sdis_scene_create(stardis->dev, &scn_args, &stardis->sdis_scn);
if(res != RES_OK) {
diff --git a/src/stardis-app.h b/src/stardis-app.h
@@ -195,6 +195,7 @@ error:
struct h_boundary {
struct str name;
+ double ref_temperature;
double emissivity;
double specular_fraction;
double hc;
@@ -206,6 +207,7 @@ static FINLINE void
init_h(struct mem_allocator* allocator, struct h_boundary* dst)
{
str_init(allocator, &dst->name);
+ dst->ref_temperature = 0;
dst->emissivity = 0;
dst->specular_fraction = 0;
dst->hc = 0;
@@ -228,10 +230,11 @@ str_print_h_boundary
res_T res = RES_OK;
ASSERT(str && b && DESC_IS_H(type));
STR_APPEND_PRINTF(str,
- "H boundary for %s '%s': emissivity=%g specular_fraction=%g hc=%g T=%g "
- "(using medium %u as external medium)",
- ARG7( (type == DESC_BOUND_H_FOR_SOLID ? "solid" : "fluid"), str_cget(&b->name),
- b->emissivity, b->specular_fraction, b->hc, b->imposed_temperature, b->mat_id ) );
+ "H boundary for %s '%s': ref_temperature=%g emissivity=%g specular_fraction=%g "
+ "hc=%g T=%g (using medium %u as external medium)",
+ ARG8( (type == DESC_BOUND_H_FOR_SOLID ? "solid" : "fluid"), str_cget(&b->name),
+ b->ref_temperature, b->emissivity, b->specular_fraction, b->hc,
+ b->imposed_temperature, b->mat_id ) );
end:
return res;
error:
@@ -241,10 +244,11 @@ error:
static FINLINE res_T
cp_h_boundary(struct h_boundary* dst, const struct h_boundary* src)
{
- dst->specular_fraction = src->specular_fraction;
- dst->imposed_temperature = src->imposed_temperature;
+ dst->ref_temperature = src->ref_temperature;
dst->emissivity = src->emissivity;
+ dst->specular_fraction = src->specular_fraction;
dst->hc = src->hc;
+ dst->imposed_temperature = src->imposed_temperature;
dst->mat_id = src->mat_id;
return str_copy(&dst->name, &src->name);
}
@@ -341,6 +345,7 @@ cp_f_boundary(struct f_boundary* dst, const struct f_boundary* src)
struct solid_fluid_connect {
struct str name;
+ double ref_temperature;
double emissivity;
double specular_fraction;
double hc;
@@ -357,6 +362,7 @@ static FINLINE void
init_sf(struct mem_allocator* allocator, struct solid_fluid_connect* dst)
{
str_init(allocator, &dst->name);
+ dst->ref_temperature = 0;
dst->emissivity = 0;
dst->specular_fraction = 0;
dst->hc = 0;
@@ -370,9 +376,9 @@ str_print_sf_connect
{
res_T res = RES_OK;
ASSERT(str && c);
- STR_APPEND_PRINTF(str, "Solid-Fluid connection '%s':", ARG1( str_cget(&c->name) ) );
- STR_APPEND_PRINTF(str, " emissivity=%g, specular_fraction=%g hc=%g",
- ARG3( c->emissivity, c->specular_fraction, c->hc ) );
+ STR_APPEND_PRINTF(str, "Solid-Fluid connection '%s': ", ARG1( str_cget(&c->name) ) );
+ STR_APPEND_PRINTF(str, "ref_temperature=%g emissivity=%g, specular_fraction=%g hc=%g",
+ ARG4( c->ref_temperature, c->emissivity, c->specular_fraction, c->hc ) );
end:
return res;
error:
@@ -383,10 +389,11 @@ static FINLINE res_T
cp_sf_connect
(struct solid_fluid_connect* dst, const struct solid_fluid_connect* src)
{
- dst->connection_id = src->connection_id;
- dst->specular_fraction = src->specular_fraction;
+ dst->ref_temperature = src->ref_temperature;
dst->emissivity = src->emissivity;
+ dst->specular_fraction = src->specular_fraction;
dst->hc = src->hc;
+ dst->connection_id = src->connection_id;
return str_copy(&dst->name, &src->name);
}
@@ -424,8 +431,8 @@ str_print_ss_connect
{
res_T res = RES_OK;
ASSERT(str && c);
- STR_APPEND_PRINTF(str, "Solid-Solid connection '%s':", ARG1( str_cget(&c->name) ) );
- STR_APPEND_PRINTF(str, " contact resistance=%g", ARG1( c->tcr ) );
+ STR_APPEND_PRINTF(str, "Solid-Solid connection '%s': ", ARG1( str_cget(&c->name) ) );
+ STR_APPEND_PRINTF(str, "contact resistance=%g", ARG1( c->tcr ) );
end:
return res;
error:
diff --git a/src/stardis-intface.c b/src/stardis-intface.c
@@ -56,6 +56,16 @@ interface_get_flux
}
static double
+interface_get_ref_temperature
+ (const struct sdis_interface_fragment* frag,
+ struct sdis_data* data)
+{
+ const struct intface* interface_props = sdis_data_cget(data);
+ (void)frag;
+ return interface_props->ref_temperature;
+}
+
+static double
interface_get_emissivity
(const struct sdis_interface_fragment* frag,
struct sdis_data* data)
@@ -249,8 +259,9 @@ create_intface
if(connect->d.h_boundary.hc > 0) {
interface_shader.convection_coef = interface_get_convection_coef;
}
+ ASSERT(fluid_side_shader);
+ fluid_side_shader->reference_temperature = interface_get_ref_temperature;
if(connect->d.h_boundary.emissivity > 0) {
- ASSERT(fluid_side_shader);
fluid_side_shader->emissivity = interface_get_emissivity;
fluid_side_shader->specular_fraction = interface_get_alpha;
}
@@ -278,6 +289,7 @@ create_intface
/* Set emissivity to 1 to allow radiative paths comming from
* a possible external fluid to 'see' the imposed T */
ASSERT(fluid_side_shader);
+ fluid_side_shader->reference_temperature = interface_get_ref_temperature;
fluid_side_shader->emissivity = interface_get_emissivity;
interface_props->emissivity = 1;
ASSERT(connect->d.t_boundary.imposed_temperature >= 0);
@@ -317,8 +329,9 @@ create_intface
if(connect->d.sf_connect.hc > 0) {
interface_shader.convection_coef = interface_get_convection_coef;
}
+ ASSERT(fluid_side_shader);
+ fluid_side_shader->reference_temperature = interface_get_ref_temperature;
if(connect->d.sf_connect.emissivity > 0) {
- ASSERT(fluid_side_shader);
fluid_side_shader->emissivity = interface_get_emissivity;
fluid_side_shader->specular_fraction = interface_get_alpha;
}
diff --git a/src/stardis-intface.h b/src/stardis-intface.h
@@ -29,6 +29,7 @@ struct dummies;
struct intface {
/* fluid - solid */
double hc;
+ double ref_temperature;
double emissivity;
double alpha;
/* solid - solid */
diff --git a/src/stardis-output.c b/src/stardis-output.c
@@ -722,9 +722,8 @@ dump_green_bin
if(name_pool_sz)
FW(name_pool, name_pool_sz);
- /* Write radiative temperatures */
+ /* Write ambient temperatures */
FW(&stardis->ambient_temp, 1);
- FW(&stardis->ref_temp, 1);
/* Write time range */
FW(&stardis->time_range, 2);
@@ -989,16 +988,16 @@ dump_green_ascii
}
if(stardis->counts.hbound_count) {
fprintf(stream, "# H Boundaries\n");
- fprintf(stream, "# ID Name emissivity specular_fraction hc T_env\n");
+ fprintf(stream, "# ID Name ref_temperature emissivity specular_fraction hc T_env\n");
FOR_EACH(i, 0, szd) {
const struct description* desc = descs + i;
const struct h_boundary* bd;
if(desc->type != DESC_BOUND_H_FOR_SOLID
&& desc->type != DESC_BOUND_H_FOR_FLUID) continue;
bd = &desc->d.h_boundary;
- fprintf(stream, "%u\t%s\t%g\t%g\t%g\t%g\n",
- i, str_cget(&bd->name), bd->emissivity, bd->specular_fraction,
- bd->hc, bd->imposed_temperature);
+ fprintf(stream, "%u\t%s\t%g\t%g\t%g\t%g\t%g\n",
+ i, str_cget(&bd->name), bd->ref_temperature, bd->emissivity,
+ bd->specular_fraction, bd->hc, bd->imposed_temperature);
}
}
if(stardis->counts.fbound_count) {
@@ -1014,11 +1013,11 @@ dump_green_ascii
}
}
- /* Radiative Temperatures */
- fprintf(stream, "# Radiative Temperatures\n");
- fprintf(stream, "# ID Amb_Temp Lin_Temp\n");
- fprintf(stream, "%u\t%g\t%g\n",
- szd, stardis->ambient_temp, stardis->ref_temp);
+ /* Radiative Temperature */
+ fprintf(stream, "# Radiative Temperature\n");
+ fprintf(stream, "# ID Amb_Temp\n");
+ fprintf(stream, "%u\t%g\n",
+ szd, stardis->ambient_temp);
fprintf(stream, "# Samples\n");
fprintf(stream,
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -338,7 +338,6 @@ init_args
d2(args->pos_and_time+3,
STARDIS_DEFAULT_COMPUTE_TIME, STARDIS_DEFAULT_COMPUTE_TIME);
args->ambient_temp = STARDIS_DEFAULT_AMBIENT_TEMP;
- args->ref_temp = STARDIS_DEFAULT_REFERENCE_TEMP;
args->verbose = STARDIS_DEFAULT_VERBOSE_LEVEL;
end:
@@ -572,7 +571,7 @@ parse_args
{
int opt = 0, n_used = 0;
size_t len = 0;
- const char option_list[] = "a:c:dD:eF:gG:hm:M:n:p:P:r:R:s:S:t:vV:x:X:";
+ const char option_list[] = "a:c:dD:eF:gG:hm:M:n:p:P:R:s:S:t:vV:x:X:";
char buf[128];
struct str keep;
char** line = NULL;
@@ -809,19 +808,6 @@ parse_args
break;
- case 'r':
- res = cstr_to_double(optarg, &args->ref_temp);
- if(res != RES_OK
- || args->ref_temp < 0)
- {
- if(res == RES_OK) res = RES_BAD_ARG;
- logger_print(args->logger, LOG_ERROR,
- "Invalid argument for option -%c: %s\n",
- opt, optarg);
- goto error;
- }
- break;
-
case 'R':
if(args->mode & EXCLUSIVE_MODES) {
res = RES_BAD_ARG;
@@ -1200,8 +1186,8 @@ find_description_by_name
return NULL;
}
-/* 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 */
+/* H_BOUNDARY_FOR_SOLID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames
+ * H_BOUNDARY_FOR_FLUID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames */
static res_T
process_h
(struct stardis* stardis,
@@ -1236,6 +1222,15 @@ process_h
goto end;
}
+ CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "ref_temperature");
+ res = cstr_to_double(tk, &desc->d.h_boundary.ref_temperature);
+ if(res != RES_OK
+ || desc->d.h_boundary.ref_temperature < 0)
+ {
+ logger_print(stardis->logger, LOG_ERROR, "Invalid reference temperature: %s\n", tk);
+ if(res == RES_OK) res = RES_BAD_ARG;
+ goto end;
+ }
CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "emissivity");
res = cstr_to_double(tk, &desc->d.h_boundary.emissivity);
if(res != RES_OK
@@ -1413,7 +1408,7 @@ error:
goto end;
}
-/* SOLID_FLUID_CONNECTION Name emissivity specular_fraction hc STL_filenames */
+/* SOLID_FLUID_CONNECTION Name ref_temperature emissivity specular_fraction hc STL_filenames */
static res_T
process_sfc
(struct stardis* stardis,
@@ -1450,6 +1445,15 @@ process_sfc
goto end;
}
+ CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "ref_temperature");
+ res = cstr_to_double(tk, &desc->d.h_boundary.ref_temperature);
+ if(res != RES_OK
+ || desc->d.h_boundary.ref_temperature < 0)
+ {
+ logger_print(stardis->logger, LOG_ERROR, "Invalid reference temperature: %s\n", tk);
+ if(res == RES_OK) res = RES_BAD_ARG;
+ goto end;
+ }
CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "emissivity");
res = cstr_to_double(tk, &desc->d.sf_connect.emissivity);
if(res != RES_OK
@@ -1861,11 +1865,11 @@ error:
/* Read medium or boundary line; should be one of:
* 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
+ * H_BOUNDARY_FOR_SOLID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames
+ * H_BOUNDARY_FOR_FLUID Name ref_temperature emissivity specular_fraction hc T_env STL_filenames
* T_BOUNDARY_FOR_SOLID Name T STL_filenames
* F_BOUNDARY_FOR_SOLID Name F STL_filenames
- * SOLID_FLUID_CONNECTION Name emissivity specular_fraction hc STL_filenames
+ * SOLID_FLUID_CONNECTION Name ref_temperature emissivity specular_fraction hc STL_filenames
* SCALE scale_factor
*
* STL_filenames = { { FRONT | BACK | BOTH } STL_filename }+
diff --git a/src/stardis-parsing.h b/src/stardis-parsing.h
@@ -114,7 +114,7 @@ struct args {
unsigned nthreads;
double pos_and_time[5];
enum stardis_mode mode;
- double ambient_temp, ref_temp;
+ double ambient_temp;
char* camera;
enum dump_path_type dump_paths;
int verbose;