stardis

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

commit 1579c93b7d1eb1ef40d75e7294a0d3f6f0190ad5
parent 0e0eed88f0e4137dbda82847c5076fe791e9e03e
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 22 Oct 2020 18:52:22 +0200

Merge branch 'feature_unsteady_green' into develop

Diffstat:
Mdoc/stardis-output.5.txt | 32+++++++++++++++++++++++++-------
Mdoc/stardis.1.txt.in | 16+++++++---------
Msrc/stardis-compute.c | 12++++--------
Msrc/stardis-fluid.c | 4+---
Msrc/stardis-output.c | 67++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Msrc/stardis-parsing.c | 5++++-
Msrc/stardis-solid.c | 8++------
7 files changed, 99 insertions(+), 45 deletions(-)

diff --git a/doc/stardis-output.5.txt b/doc/stardis-output.5.txt @@ -238,6 +238,7 @@ _______ <concatenated-names> # char[names-pool-size] ambient-temperature # double reference-temperature # double + time-range # double[2] <samples> <descriptions> ::= description # struct description @@ -268,16 +269,19 @@ _______ struct mat_fluid { struct str name; - unsigned fluid_id; double rho; double cp; double tinit; double imposed_temperature; + double t0; + int is_outside; + int is_green; + unsigned desc_id; + unsigned fluid_id; }; struct mat_solid { struct str name; - unsigned solid_id; double lambda; double rho; double cp; @@ -285,24 +289,29 @@ _______ double tinit; double imposed_temperature; double vpower; + double t0; + int is_outside; + int is_green; + unsigned desc_id; + unsigned solid_id; }; struct t_boundary { struct str name; - unsigned mat_id; double emissivity; double specular_fraction; double hc; double imposed_temperature; + unsigned mat_id; }; struct h_boundary { struct str name; - unsigned mat_id; double emissivity; double specular_fraction; double hc; double imposed_temperature; + unsigned mat_id; }; struct solid_fluid_connect { @@ -310,6 +319,7 @@ _______ double emissivity; double specular_fraction; double hc; + unsigned connection_id; }; enum description_type { @@ -327,8 +337,8 @@ _______ struct f_boundary { struct str name; - unsigned mat_id; double imposed_flux; + unsigned mat_id; }; struct description { @@ -346,6 +356,7 @@ _______ struct path_header { unsigned id; unsigned pcount, fcount; + char at_initial; }; === ASCII GREEN @@ -355,6 +366,8 @@ Thereafter is the format of ascii Green outputs. [verse] _______ <ascii-green> ::= "---BEGIN GREEN---" + "# time range" + <time-range> "# #solids #fluids #t_boundaries #h_boundaries #f_boundaries \ #ok #failures" #solids #fluids #t_boundaries #h_boundaries #f_boundaries \ @@ -386,6 +399,8 @@ _______ <samples> "---END GREEN---" +<time-range> ::= <REAL> <REAL> # in [0, INF) x [first REAL, INF) + <solids> ::= <solid> <solids> # #solids solid descriptions @@ -410,9 +425,9 @@ _______ <sample> ::= <end-spec> <power-count> <flux-count> <power-terms> <flux-terms> -<solid> ::= <green-id> <name> <lambda> <rho> <cp> <power> <imposed-temp> +<solid> ::= <green-id> <name> <lambda> <rho> <cp> <power> <initial-temp> <imposed-temp> -<fluid> ::= <green-id> <name> <rho> <cp> <imposed-temp> +<fluid> ::= <green-id> <name> <rho> <cp> <initial-temp> <imposed-temp> <t-bound> ::= <green-id> <name> <temperature> @@ -433,6 +448,9 @@ _______ <power> ::= REAL # in (-INF , INF) +<initial-temp> ::= REAL # in [0 , INF) + | "NONE" if not imposed + <imposed-temp> ::= REAL # in [0 , INF) | "NONE" if not imposed diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in @@ -208,21 +208,19 @@ options -g or -G. or -s without options -g or -G). *-g*:: - Compute the Green function at steady state and write in ASCII to _standard - output_. + Compute the Green function at the specified time and write it in ASCII to + _standard output_. + This option can only be used in conjunction with one these options: -p, -P, --m, -s and cannot be used in conjunction with option -D. Any compute time -range provided through one of these options is silently ignored. +-m, -s and cannot be used in conjunction with option -D. *-G* _file_name_[,__file_name__]:: - Compute the Green function at steady state and write it to an binary file. - If a second file name is provided, information on heat paths' ends is also - written in this second file in ascii csv format. + Compute the Green function at the specified time and write it to a binary + file. If a second file name is provided, information on heat paths' ends + is also written in this second file in ascii csv format. + This option can only be used in conjunction with one these options: -p, -P, --m, -s and cannot be used in conjunction with option -D. Any compute time -range provided through one of these options is silently ignored. +-m, -s and cannot be used in conjunction with option -D. + The resulting file can be further used through the *sgreen*(1) command to apply different temperature, flux or volumic power values. diff --git a/src/stardis-compute.c b/src/stardis-compute.c @@ -383,12 +383,12 @@ compute_probe(struct stardis* stardis) args.nrealisations = stardis->samples; d3_set(args.position, stardis->probe); + d2_splat(args.time_range, stardis->probe[3]); args.fp_to_meter = stardis->scale_factor; args.ambient_radiative_temperature = stardis->ambient_temp; args.reference_temperature = stardis->ref_temp; if(stardis->mode & (MODE_BIN_GREEN | MODE_GREEN)) { - d2_splat(args.time_range, INF); ERR(sdis_solve_probe_green_function(stardis->sdis_scn, &args, &green)); if(stardis->mode & MODE_BIN_GREEN) { ASSERT(!str_is_empty(&stardis->bin_green_filename)); @@ -415,7 +415,6 @@ compute_probe(struct stardis* stardis) ERR(dump_green_ascii(green, stardis, stdout)); } } else { - d2_set(args.time_range, stardis->time_range); args.register_paths = stardis->dump_paths; ERR(sdis_solve_probe(stardis->sdis_scn, &args, &estimator)); ERR(print_single_MC_result(estimator, stardis, stdout)); @@ -455,12 +454,12 @@ compute_probe_on_interface(struct stardis* stardis) args.iprim = iprim; d3_set(args.uv, uv); args.side = SDIS_FRONT; + d2_splat(args.time_range, stardis->probe[3]); args.fp_to_meter = stardis->scale_factor; args.ambient_radiative_temperature = stardis->ambient_temp; args.reference_temperature = stardis->ref_temp; if(stardis->mode & (MODE_BIN_GREEN | MODE_GREEN)) { - d2_splat(args.time_range, INF); ERR(sdis_solve_probe_boundary_green_function(stardis->sdis_scn, &args, &green)); if(stardis->mode & MODE_BIN_GREEN) { @@ -488,7 +487,6 @@ compute_probe_on_interface(struct stardis* stardis) ERR(dump_green_ascii(green, stardis, stdout)); } } else { - d2_set(args.time_range, stardis->time_range); args.register_paths = stardis->dump_paths; ERR(sdis_solve_probe_boundary(stardis->sdis_scn, &args, &estimator)); ERR(print_single_MC_result(estimator, stardis, stdout)); @@ -682,12 +680,12 @@ compute_medium(struct stardis* stardis) args.nrealisations = stardis->samples; args.medium = medium; + d2_splat(args.time_range, stardis->probe[3]); args.fp_to_meter = stardis->scale_factor; args.ambient_radiative_temperature = stardis->ambient_temp; args.reference_temperature = stardis->ref_temp; if(stardis->mode & (MODE_BIN_GREEN | MODE_GREEN)) { - d2_splat(args.time_range, INF); ERR(sdis_solve_medium_green_function(stardis->sdis_scn, &args, &green)); if(stardis->mode & MODE_BIN_GREEN) { ASSERT(!str_is_empty(&stardis->bin_green_filename)); @@ -714,7 +712,6 @@ compute_medium(struct stardis* stardis) ERR(dump_green_ascii(green, stardis, stdout)); } } else { - d2_set(args.time_range, stardis->time_range); args.register_paths = stardis->dump_paths; ERR(sdis_solve_medium(stardis->sdis_scn, &args, &estimator)); ERR(print_single_MC_result(estimator, stardis, stdout)); @@ -799,12 +796,12 @@ compute_boundary(struct stardis* stardis) args.sides = darray_sides_cdata_get(&stardis->compute_surface.sides); args.nprimitives = darray_size_t_size_get(&stardis->compute_surface.primitives); + d2_splat(args.time_range, stardis->probe[3]); args.fp_to_meter = stardis->scale_factor; args.ambient_radiative_temperature = stardis->ambient_temp; args.reference_temperature = stardis->ref_temp; if(stardis->mode & (MODE_BIN_GREEN | MODE_GREEN)) { - d2_splat(args.time_range, INF); ERR(sdis_solve_boundary_green_function(stardis->sdis_scn, &args, &green)); if(stardis->mode & MODE_BIN_GREEN) { ASSERT(!str_is_empty(&stardis->bin_green_filename)); @@ -831,7 +828,6 @@ compute_boundary(struct stardis* stardis) ERR(dump_green_ascii(green, stardis, stdout)); } } else { - d2_set(args.time_range, stardis->time_range); args.register_paths = stardis->dump_paths; ERR(sdis_solve_boundary(stardis->sdis_scn, &args, &estimator)); ERR(print_single_MC_result(estimator, stardis, stdout)); diff --git a/src/stardis-fluid.c b/src/stardis-fluid.c @@ -51,10 +51,8 @@ fluid_get_temperature struct sdis_data* data) { const struct fluid* fluid_props = sdis_data_cget(data); - if(fluid_props->is_green || vtx->time > fluid_props->t0) { - /* Always use temp for Green mode, regardless of time */ + if(vtx->time > fluid_props->t0) 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! */ diff --git a/src/stardis-output.c b/src/stardis-output.c @@ -355,8 +355,28 @@ error: struct path_header { unsigned id; unsigned pcount, fcount; + char at_initial; }; +static FINLINE double +medium_get_t0 + (struct sdis_medium* medium) +{ + struct sdis_data* data = NULL; + enum sdis_medium_type type; + ASSERT(medium); + type = sdis_medium_get_type(medium); + data = sdis_medium_get_data(medium); + if(type == SDIS_FLUID) { + const struct fluid* fluid_props = sdis_data_cget(data); + return fluid_props->t0; + } else { + ASSERT(type == SDIS_SOLID); + const struct solid* solid_props = sdis_data_cget(data); + return solid_props->t0; + } +} + static res_T dump_sample_end (struct sdis_green_path* path, @@ -445,6 +465,7 @@ dump_sample unsigned* ids = NULL; double* weights = NULL; size_t sz, i; + double t0; CHK(path && ctx); @@ -467,11 +488,14 @@ dump_sample desc_id = d__->desc_id; CHK(DESC_IS_T(descs[desc_id].type) || DESC_IS_H(descs[desc_id].type)); header.id = desc_id; + header.at_initial = 0; break; } case SDIS_VERTEX: type = sdis_medium_get_type(pt.data.mdmvert.medium); data = sdis_medium_get_data(pt.data.mdmvert.medium); + t0 = medium_get_t0(pt.data.mdmvert.medium); + header.at_initial = (pt.data.mdmvert.vertex.time <= t0); if(pt.data.mdmvert.vertex.P[0] == INF) { /* Radiative output (ambient temperature) */ sz = darray_descriptions_size_get(w_ctx->desc); @@ -579,7 +603,7 @@ dump_green_bin szd = (unsigned)sz; descs = darray_descriptions_cdata_get(&stardis->descriptions); - /* Save names that donot fit inplace */ + /* Save names that do not fit inplace */ FOR_EACH(i, 0, szd) { const struct description* desc = descs + i; const struct str* name = get_description_name(desc); @@ -617,9 +641,13 @@ dump_green_bin if(name_pool_sz) FW(name_pool, name_pool_sz); + /* Write radiative temperatures */ FW(&stardis->ambient_temp, 1); FW(&stardis->ref_temp, 1); + /* Write time range */ + FW(&stardis->time_range, 2); + w_ctx.alloc = stardis->allocator; w_ctx.desc = &stardis->descriptions; htable_weigth_init(NULL, &w_ctx.pw); @@ -804,6 +832,9 @@ dump_green_ascii /* Output counts */ fprintf(stream, "---BEGIN GREEN---\n"); + fprintf(stream, "# time range\n"); + fprintf(stream, "%g %g\n", + SPLIT2(stardis->time_range)); fprintf(stream, "# #solids #fluids #t_boundaries #h_boundaries #f_boundaries #ok #failures\n"); fprintf(stream, "%u %u %u %u %u %u %u\n", @@ -814,37 +845,51 @@ dump_green_ascii /* List Media */ if(stardis->counts.smed_count) { fprintf(stream, "# Solids\n"); - fprintf(stream, "# ID Name lambda rho cp power Temp\n"); + fprintf(stream, "# ID Name lambda rho cp power initial_temp imposed_temp\n"); FOR_EACH(i, 0, szd) { const struct description* desc = descs + i; const struct solid* sl; if(desc->type != DESC_MAT_SOLID) continue; sl = &desc->d.solid; + fprintf(stream, "%u\t%s\t%g\t%g\t%g\t%g", + i, str_cget(&sl->name), sl->lambda, sl->rho, sl->cp, sl->vpower); + if(sl->tinit >= 0) { + fprintf(stream, "\t%g", sl->tinit); + } else { + fprintf(stream, "\tNONE"); + } if(sl->imposed_temperature >= 0) { - fprintf(stream, "%u\t%s\t%g\t%g\t%g\t%g\t%g\n", - i, str_cget(&sl->name), sl->lambda, sl->rho, sl->cp, sl->vpower, - sl->imposed_temperature); + fprintf(stream, "\t%g\n", sl->imposed_temperature); } else { - fprintf(stream, "%u\t%s\t%g\t%g\t%g\t%g\tNONE\n", - i, str_cget(&sl->name), sl->lambda, sl->rho, sl->cp, sl->vpower); + fprintf(stream, "\tNONE\n"); } } } if(stardis->counts.fmed_count) { fprintf(stream, "# Fluids\n"); - fprintf(stream, "# ID Name rho cp Temp\n"); + fprintf(stream, "# ID Name rho cp initial_temp imposed_temp\n"); FOR_EACH(i, 0, szd) { const struct description* desc = descs + i; const struct fluid* fl; if(desc->type != DESC_MAT_FLUID) continue; fl = &desc->d.fluid; if(fl->imposed_temperature >= 0) { - fprintf(stream, "%u\t%s\t%g\t%g\t%g\n", - i, str_cget(&fl->name), fl->rho, fl->cp, fl->imposed_temperature); + fprintf(stream, "%u\t%s\t%g\t%g", + i, str_cget(&fl->name), fl->rho, fl->cp); } else { - fprintf(stream, "%u\t%s\t%g\t%g\tNONE\n", + fprintf(stream, "%u\t%s\t%g\t%g", i, str_cget(&fl->name), fl->rho, fl->cp); } + if(fl->tinit >= 0) { + fprintf(stream, "\t%g", fl->tinit); + } else { + fprintf(stream, "\tNONE"); + } + if(fl->imposed_temperature >= 0) { + fprintf(stream, "\t%g\n", fl->imposed_temperature); + } else { + fprintf(stream, "\tNONE\n"); + } } } diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c @@ -512,13 +512,16 @@ short_help fprintf(stream, " Set the verbosity level.\n"); } +/* Workaround for a gcc warning when GET_OPTIONAL_TIME_RANGE used with Rank=0 */ +FINLINE int is_less(size_t a, size_t b) { return a < b; } + /* Get a time range from a coma-separated list of doubles * The first Rank values are mandatory, followed by an optional time range * that can be a single time */ #define GET_OPTIONAL_TIME_RANGE(Src, Rank, Dst, Logger, OptionString, Option) \ res = cstr_to_list_double((Src), ',', (Dst), &len, (Rank)+2); \ if(res != RES_OK \ - || (len < (Rank)) \ + || is_less(len, (Rank)) \ || (len == (Rank)+1 && (Dst)[(Rank)] < 0) \ || (len == (Rank)+2 && ((Dst)[0] < 0 || (Dst)[(Rank)] > (Dst)[(Rank)+1])) \ || len > (Rank)+2) \ diff --git a/src/stardis-solid.c b/src/stardis-solid.c @@ -82,12 +82,8 @@ solid_get_temperature struct sdis_data* data) { const struct solid* solid_props = sdis_data_cget(data); - if(solid_props->is_green || vtx->time > solid_props->t0) { - /* Always use temp for Green mode, regardless of time */ - if(solid_props->imposed_temperature >= 0) - return solid_props->imposed_temperature; - else return -1; - } + if(vtx->time > solid_props->t0) + 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! */