stardis

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

commit 8f69fae0174effa1964bab21a472bcf80d2a45c5
parent 6d8d23fc537a0608dfd4cd37f7c4289d837c25f7
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue,  2 Jun 2020 15:33:02 +0200

Change scaling management (from command args to model file)

Diffstat:
Mdoc/stardis-input.5.txt | 28++++++++++++++++++----------
Mdoc/stardis-output.5.txt | 3++-
Mdoc/stardis.1.txt.in | 20+++-----------------
Msrc/stardis-app.c | 4+++-
Msrc/stardis-parsing.c | 56++++++++++++++++++++++++++++++++++++++------------------
Msrc/stardis-parsing.h | 1-
6 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/doc/stardis-input.5.txt b/doc/stardis-input.5.txt @@ -28,10 +28,13 @@ DESCRIPTION thermal system. It relies on a line-based ad-hoc syntax. A thermal system is composed of lines of text, each one describing either a -medium (solid or fluid) frontier or a boundary (limit condition or -connection between two media). In either case, a description line includes a -list of file names that constitute the limit or boundary. The current version -of *stardis* only accepts triangle mesh geometry files in *VTK* format. +medium (solid or fluid) frontier, a boundary (limit condition or connection +between two media), or the scale of the geometry. In the medium or boundary +cases, description lines include a list of file names that constitute the +limit or boundary. The current version of *stardis* only accepts triangle +mesh geometry files in *STL* format. If a scale is specified, it defines the +scaling factor to apply to the geometry to have it expressed in meters (e.g. +1e-3 if the geometry is in mm). A medium limit or a boundary description can be split accross files and a single file or description line can describe more than one frontier (more than @@ -50,9 +53,7 @@ International System of Units (second, metre, kilogram, kelvin, watt, joule); 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, with the scaling factor provided through option -*-f*. The constraint this feature sets to stardis input is that the product -delta*scaling_factor must be in meters. +multiple of meters or not, as long as the scaling factor is provided. GRAMMAR ------- @@ -66,13 +67,18 @@ description. [verse] _______ -<thermal-system> ::= <description-line> - [ <thermal-system> ] +<thermal-system> ::= <description-lines> + [ <scaling-factor> ] + +<description-lines> ::= <description-line> + [ <description-lines> ] <description-line> ::= [ <medium-frontier> ] [ <comment> ] | [ <medium-boundary> ] [ <comment> ] | [ <media-connection> ] [ <comment> ] +<scaling-factor> ::= "SCALE" <scaling_factor> [ <comment> ] + ------------------------------------- <medium-frontier> ::= <solid-frontier> @@ -88,6 +94,8 @@ _______ <comment> ::= "#" Any text introduced by the # character +<scaling_factor> ::= REAL # scaling factor to apply to the geometry ; in ]0 INF) + <solid-frontier> ::= "SOLID" <medium-name> <lambda> <rho> <cp> <delta> \ <initial-temp> <imposed-temperature> <volumic-power> \ <triangle-sides> @@ -123,7 +131,7 @@ _______ <delta> ::= "AUTO" # delta is automatically set to V/6A (V and A being # respectively the solid volume and its boundary area) - | REAL # delta*scale_factor in m; in [0, INF) + | REAL # delta*scaling_factor in m; in [0, INF) <initial-temp> ::= REAL # in K; in [0, INF) diff --git a/doc/stardis-output.5.txt b/doc/stardis-output.5.txt @@ -43,7 +43,8 @@ computation produce output including information on the *stardis*(1) software == UNITS As with the values in *stardis-input*(5), any physical quantity in output is in -the International System of Units (second, metre, kilogram, kelvin). +the International System of Units (second, metre, kilogram, kelvin) except the +coordinates that are in same system as the geometry. == OPTIONS diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in @@ -92,13 +92,14 @@ EXCLUSIVE OPTIONS *-p* _x,y,z[,time]_:: Compute the temperature at the given probe at a given time. By default compute time is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The probe must be in a - medium. + medium. The probe coordinates must be in the same system as the geometry. *-P* _x,y,z[,time]_:: Compute the temperature at the given probe on an interface at a given time. By default compute time is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The probe is supposed to be on an interface and is moved to the closest point of the - closest interface before the computation start. + closest interface before the computation start. The probe coordinates must + be in the same system as the geometry. *-m* _medium_name[,time]_:: Compute the mean temperature in a given medium at a given time. The medium @@ -199,15 +200,6 @@ options -g or -G. conjunction with options that compute a single Monte-Carlo (-F, -m, -P, -p, or -s without options -g or -G). -**-f** _factor_:: - Define the scaling factor to apply to the geometry to have it expressed - in meters (e.g. 1e-3 if the geometry is in mm). Default scaling *factor* is - @STARDIS_ARGS_DEFAULT_SCALE_FACTOR@. -+ -If this option is used, any input data provided to stardis must be scaled -accordingly (see *stardis-input*(5)). Also, if option *-p* or *-P* is used to -provide a probe point, this point must be in the same unit as the geometry. - *-g*:: Compute the Green function at steady state and write in ASCII to _standard output_. @@ -281,12 +273,6 @@ named error_path_00000000.vtk, error_path_00000001.vtk, ... $ stardis -M scene.txt -R t=10000:spp=2:img=800x600 -D error,error_path_ -Compute the temperature at the probe point *0, 0.5, 0* at steady state, in a -model whose dimensions are in mm, including the coordinates of the probe point. -The system is read from the file *model.txt*: - - $ stardis -M model.txt -p 0,0.5,0 -f 0.001 - COPYRIGHT --------- Copyright &copy; 2018-2020 |Meso|Star>. License GPLv3+: GNU GPL diff --git a/src/stardis-app.c b/src/stardis-app.c @@ -111,6 +111,8 @@ read_model txtrdr = NULL; fclose(f); f = NULL; + if(stardis->scale_factor <= 0) + stardis->scale_factor = STARDIS_DEFAULT_SCALE_FACTOR; } ASSERT(!f && !txtrdr); @@ -528,7 +530,7 @@ stardis_init darray_uint_init(stardis->allocator, &stardis->compute_surface.err_triangles); stardis->samples = args->samples; stardis->nthreads = args->nthreads; - stardis->scale_factor = args->scale_factor; + 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; diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c @@ -310,7 +310,6 @@ init_args args->samples = STARDIS_DEFAULT_SAMPLES_COUNT; args->nthreads = DEFAULT_NTHREADS; args->probe[3] = STARDIS_DEFAULT_COMPUTE_TIME; - args->scale_factor = STARDIS_DEFAULT_SCALE_FACTOR; args->ambient_temp = STARDIS_DEFAULT_AMBIENT_TEMP; args->ref_temp = STARDIS_DEFAULT_REFERENCE_TEMP; args->verbose = STARDIS_DEFAULT_VERBOSE_LEVEL; @@ -449,9 +448,6 @@ short_help fprintf(stream, "\n -e\n"); fprintf(stream, " Use extended format to output Monte-Carlo results.\n"); - fprintf(stream, "\n -f SCALE_FACTOR\n"); - fprintf(stream, " Rescale the geometry before sending it to the solver.\n"); - fprintf(stream, "\n -g\n"); fprintf(stream, " Change the computation to produce the green function.\n"); @@ -485,7 +481,7 @@ parse_args { int opt = 0, n_used = 0; size_t len = 0; - const char option_list[] = "a:dD:ef:F:gG:hm:M:n:p:P:r:R:s:S:t:vV:"; + const char option_list[] = "a:dD:eF:gG:hm:M:n:p:P:r:R:s:S:t:vV:"; char buf[128]; res_T res = RES_OK; @@ -568,19 +564,6 @@ parse_args break; } - case 'f': - res = cstr_to_double(optarg, &args->scale_factor); - if(res != RES_OK - || args->scale_factor <= 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 'F': see 's' */ case 'g': @@ -1532,6 +1515,40 @@ error: goto end; } +/* SCALE scale_factor */ +static res_T +process_scale + (struct stardis* stardis, + char** tok_ctx) +{ + char* tk = NULL; + res_T res = RES_OK; + + ASSERT(stardis && tok_ctx); + + if(stardis->scale_factor > 0) { + logger_print(stardis->logger, LOG_ERROR, + "SCALE cannot be specified twice\n"); + res = RES_BAD_ARG; + goto end; + } + CHK_TOK(strtok_r(NULL, " \t", tok_ctx), "scale factor"); + res = cstr_to_double(tk, &stardis->scale_factor); + if(res != RES_OK + || stardis->scale_factor <= 0) + { + logger_print(stardis->logger, LOG_ERROR, + "Invalid scale factor: %s\n", tk); + if(res == RES_OK) res = RES_BAD_ARG; + goto end; + } + +end: + return res; +error: + goto end; +} + /* 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 @@ -1541,6 +1558,7 @@ error: * T_BOUNDARY_FOR_FLUID Name T hc STL_filenames * F_BOUNDARY_FOR_SOLID Name F STL_filenames * SOLID_FLUID_CONNECTION Name emissivity specular_fraction hc STL_filenames + * SCALE scale_factor * * STL_filenames = { { FRONT | BACK | BOTH } STL_filename }+ */ @@ -1577,6 +1595,8 @@ process_model_line ERR(process_solid(stardis, &tok_ctx)); else if(0 == strcmp(tk, "FLUID")) ERR(process_fluid(stardis, &tok_ctx)); + else if(0 == strcmp(tk, "SCALE")) + ERR(process_scale(stardis, &tok_ctx)); else { logger_print(stardis->logger, LOG_ERROR, "Unknown description type: %s\n", tk); diff --git a/src/stardis-parsing.h b/src/stardis-parsing.h @@ -102,7 +102,6 @@ struct args { unsigned nthreads; double probe[4]; enum stardis_mode mode; - double scale_factor; double ambient_temp, ref_temp; char* camera; enum dump_path_type dump_paths;