stardis

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

commit 71702a3911f79cd5aad5788096553020a5a6f23f
parent eb90b002988c8d03f7c568a386d604eb0cf56ff8
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue, 17 Nov 2020 12:03:05 +0100

Add a new output format to infrared rendering

The new format is htrdr-image, from the high-tune project and can be post-processed using the htpp utility

Diffstat:
Mcmake/CMakeLists.txt | 1+
Mdoc/stardis-output.5.txt | 39++++++++++++++++++++++++++++++++++++---
Mdoc/stardis.1.txt.in | 29+++++++++++++++++++----------
Msrc/stardis-app.h | 7+++++++
Msrc/stardis-compute.c | 6+++++-
Msrc/stardis-default.h.in | 2++
Msrc/stardis-output.c | 34+++++++++++++++++++++++++++++++++-
Msrc/stardis-output.h | 7++++++-
Msrc/stardis-parsing.c | 14++++++++++++++
9 files changed, 123 insertions(+), 16 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -40,6 +40,7 @@ set(STARDIS_ARGS_DEFAULT_COMPUTE_TIME "INF, INF") set(STARDIS_ARGS_DEFAULT_RENDERING_FOV "70") # degrees set(STARDIS_ARGS_DEFAULT_RENDERING_IMG_HEIGHT "480") set(STARDIS_ARGS_DEFAULT_RENDERING_IMG_WIDTH "640") +set(STARDIS_ARGS_DEFAULT_RENDERING_OUTPUT_FILE_FMT "HT") # VTK or HT set(STARDIS_ARGS_DEFAULT_RENDERING_POS "1, 1, 1") set(STARDIS_ARGS_DEFAULT_RENDERING_SPP "4") set(STARDIS_ARGS_DEFAULT_RENDERING_TGT "0, 0, 0") diff --git a/doc/stardis-output.5.txt b/doc/stardis-output.5.txt @@ -779,9 +779,42 @@ _______ == INFRARED IMAGE When invoked with option *-R*, *stardis*(1) generates an infrared image of -the system and write it to _standard output_ in VTK [1] file format. The image -is on an XY plane with coordinates in the [0 pixel_count[ range. By convention, -the origine (0,0) pixel is at the top-left corner of the image. +the system and write it to _standard output_. Depending on the *fmt* +sub-option, this file can be either in VTK [1] format on in *htrdr-image*(5) +format. + +=== HTRDR-IMAGE INFRARED IMAGE +If the output image is in htrdr-image format, it comply with the *lw* section +of the format, with only the temperature fields being informed. The resulting +format is as follows: + +[verse] +_______ +<htrdr-image> ::= <definition> + <pixel> + [ <pixel> ... ] + +<definition> ::= <width> <height> +<width> ::= INTEGER +<height> ::= INTEGER + +<pixel> ::= <temperature> 0 0 0 0 <time> + +<temperature> ::= <estimate> +<time> ::= <estimate> + +<estimate> ::= <expected-value> <standard-error> +<expected-value> ::= REAL +<standard-error> ::= REAL +_______ + +These files can be post-processed using the *htpp*(1) tool, that is part of +the high-tune project. + +=== VTK INFRARED IMAGE +If the output image is in VTK format, it is on an XY plane with coordinates in +the [0 pixel_count[ range. By convention, the origine (0,0) pixel is at the +top-left corner of the image. The result not only includes the computed temperature image, but also includes a per-pixel computation time image as well as a per-pixel path error count diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in @@ -137,11 +137,15 @@ EXCLUSIVE OPTIONS *-R* [__sub-option__:...]:: Render an infrared image of the system through a pinhole camera and write it - to _standard output_ in VTK format. One can use all-default sub-options by + to _standard output_. One can use all-default sub-options by simply providing the colon character (*:*) alone as an argument. Please note that the camera position must be outside the geometry or in a fluid. Available sub-options are: + **fmt=**_image_file_format_;; + Format of the image file in output. Can be *VTK* or *HT*. Default + _image_file_format_ is @STARDIS_ARGS_DEFAULT_RENDERING_OUTPUT_FILE_FMT@. + **fov=**_angle_;; Horizontal field of view of the camera in [30, 120] degrees. By default _angle_ is @STARDIS_ARGS_DEFAULT_RENDERING_FOV@ degrees. @@ -177,8 +181,8 @@ EXCLUSIVE OPTIONS OTHER OPTIONS ------------- *-a* _ambient_:: - Set the ambient radiative temperature for the whole system. By default - *ambient* is @STARDIS_ARGS_DEFAULT_AMBIENT_TEMP@. + Set the ambient radiative temperature for the whole system, in Kelvin. By + default *ambient* is @STARDIS_ARGS_DEFAULT_AMBIENT_TEMP@. *-d*:: Write the geometry to _standard output_ in VTK format along with various @@ -234,7 +238,8 @@ different temperature, flux or volumic power values. *-r* _reference_:: Set the reference temperature used for the linearization of the radiative - transfer. By default *reference* is @STARDIS_ARGS_DEFAULT_REFERENCE_TEMP@. + 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 @@ -283,12 +288,15 @@ Render the system as described in *scene.txt* with default settings: $ stardis -M scene.txt -R : -Render the system as described in *scene.txt* at *t=10000*, *spp=2*, -*img=800x600* and all other settings set to their default values. It the +Render the system as described in *scn.txt* at *t=100*, *spp=2*, +*img=800x600*, with output format *fmt=ht* and all other settings set to their +default values. The output is redirected to the *img.ht* file. If the computation encounters erroneous heat paths, they will be dumped to VTK files -named error_path_00000000.vtk, error_path_00000001.vtk, ... +named err_path_00000000.vtk, err_path_00000001.vtk, etc. The image file is then +post-processed using *htpp*(1) with default settings to obtain a png file. - $ stardis -M scene.txt -R t=10000:spp=2:img=800x600 -D error,error_path_ + $ stardis -M scn.txt -R t=100:spp=2:img=800x600:fmt=ht -D error,err_path_ > img.ht + $ htpp -o img.pgn -v -m default img.ht Compute the Green fonction that computes the temperature at the probe point *0, 0, 0* at steady state. The system is read from the file *model.txt* and @@ -296,7 +304,7 @@ the Green function is written to the *probe.green file* and the heat paths' ends are written to the *probe_ends.csv* file: $ stardis -M model.txt -p 0,0,0 -G probe.green,probe_ends.csv - + COPYRIGHT --------- Copyright &copy; 2018-2020 |Meso|Star>. License GPLv3+: GNU GPL @@ -308,4 +316,5 @@ SEE ALSO -------- *stardis-input*(5), *stardis-output*(5), -*sgreen*(1) +*sgreen*(1), +*htpp*(1) diff --git a/src/stardis-app.h b/src/stardis-app.h @@ -611,10 +611,16 @@ description_get_medium_id } } +enum stardis_output_fmt { + STARDIS_RENDERING_OUTPUT_FILE_FMT_VTK, + STARDIS_RENDERING_OUTPUT_FILE_FMT_HT +}; + struct camera { double pos[3]; double tgt[3]; double up[3]; + enum stardis_output_fmt fmt; double fov; double time_range[2]; unsigned spp; @@ -627,6 +633,7 @@ init_camera(struct camera* cam) { d3(cam->pos, STARDIS_DEFAULT_RENDERING_POS); d3(cam->tgt, STARDIS_DEFAULT_RENDERING_TGT); d3(cam->up, STARDIS_DEFAULT_RENDERING_UP); + cam->fmt = STARDIS_DEFAULT_RENDERING_OUTPUT_FILE_FMT; cam->fov = STARDIS_DEFAULT_RENDERING_FOV; cam->spp = STARDIS_DEFAULT_RENDERING_SPP; cam->img_width = STARDIS_DEFAULT_RENDERING_IMG_WIDTH; diff --git a/src/stardis-compute.c b/src/stardis-compute.c @@ -624,7 +624,11 @@ compute_camera(struct stardis* stardis) ERR(sdis_solve_camera(stardis->sdis_scn, &args, &buf)); /* Write the image */ - ERR(dump_image(buf, stdout)); + ASSERT(stardis->camera.fmt == STARDIS_RENDERING_OUTPUT_FILE_FMT_VTK + || stardis->camera.fmt == STARDIS_RENDERING_OUTPUT_FILE_FMT_HT); + if(stardis->camera.fmt == STARDIS_RENDERING_OUTPUT_FILE_FMT_VTK) + ERR(dump_vtk_image(buf, stdout)); + else ERR(dump_ht_image(buf, stdout)); /* Dump paths recorded according to user settings */ dump_ctx.stardis = stardis; diff --git a/src/stardis-default.h.in b/src/stardis-default.h.in @@ -15,12 +15,14 @@ #ifndef STARDIS_DEFAULT_H #define STARDIS_DEFAULT_H +#define STARDIS_RENDERING_FMT(Fmt) STARDIS_RENDERING_OUTPUT_FILE_FMT_ ## Fmt #define STARDIS_DEFAULT_AMBIENT_TEMP @STARDIS_ARGS_DEFAULT_AMBIENT_TEMP@ #define STARDIS_DEFAULT_COMPUTE_TIME @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@ #define STARDIS_DEFAULT_RENDERING_FOV @STARDIS_ARGS_DEFAULT_RENDERING_FOV@ #define STARDIS_DEFAULT_RENDERING_IMG_HEIGHT @STARDIS_ARGS_DEFAULT_RENDERING_IMG_HEIGHT@ #define STARDIS_DEFAULT_RENDERING_IMG_WIDTH @STARDIS_ARGS_DEFAULT_RENDERING_IMG_WIDTH@ +#define STARDIS_DEFAULT_RENDERING_OUTPUT_FILE_FMT STARDIS_RENDERING_FMT( @STARDIS_ARGS_DEFAULT_RENDERING_OUTPUT_FILE_FMT@ ) #define STARDIS_DEFAULT_RENDERING_POS @STARDIS_ARGS_DEFAULT_RENDERING_POS@ #define STARDIS_DEFAULT_RENDERING_SPP @STARDIS_ARGS_DEFAULT_RENDERING_SPP@ #define STARDIS_DEFAULT_RENDERING_TGT @STARDIS_ARGS_DEFAULT_RENDERING_TGT@ diff --git a/src/stardis-output.c b/src/stardis-output.c @@ -256,7 +256,7 @@ error: } res_T -dump_image +dump_vtk_image (const struct sdis_estimator_buffer* buf, FILE* stream) { @@ -346,6 +346,38 @@ error: goto end; } +res_T +dump_ht_image + (const struct sdis_estimator_buffer* buf, + FILE* stream) +{ + res_T res = RES_OK; + size_t definition[2]; + size_t ix, iy; + + ASSERT(buf && stream); + ERR(sdis_estimator_buffer_get_definition(buf, definition)); + + fprintf(stream, "%zu %zu\n", definition[0], definition[1]); + FOR_EACH(iy, 0, definition[1]) { + FOR_EACH(ix, 0, definition[0]) { + const struct sdis_estimator* estimator; + struct sdis_mc T; + struct sdis_mc time; + ERR(sdis_estimator_buffer_at(buf, ix, iy, &estimator)); + ERR(sdis_estimator_get_realisation_time(estimator, &time)); + ERR(sdis_estimator_get_temperature(estimator, &T)); + fprintf(stream, "%f %f 0 0 0 0 %f %f\n", + T.E, T.SE, time.E, time.SE); + } + }; + +end: + return res; +error: + goto end; +} + #define FW(Ptr, Count) \ if((Count) != fwrite((Ptr), sizeof(*(Ptr)), (Count), stream)) { \ res = RES_IO_ERR; \ diff --git a/src/stardis-output.h b/src/stardis-output.h @@ -48,7 +48,12 @@ print_sample void* ctx); extern res_T -dump_image +dump_vtk_image + (const struct sdis_estimator_buffer* buf, + FILE* stream); + +extern res_T +dump_ht_image (const struct sdis_estimator_buffer* buf, FILE* stream); diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c @@ -984,6 +984,20 @@ parse_camera GET_OPTIONAL_TIME_RANGE(opt[1], 0, cam->time_range, logger, "%s", str_cget(&keep)); } + else if(strcmp(opt[0], "FMT") == 0) { + _strupr(opt[1]); + if(strcmp(opt[1], "VTK") == 0) + cam->fmt = STARDIS_RENDERING_OUTPUT_FILE_FMT_VTK; + else if(strcmp(opt[1], "HT") == 0) + cam->fmt = STARDIS_RENDERING_OUTPUT_FILE_FMT_HT; + else { + logger_print(logger, LOG_ERROR, + "Unexpected value for rendering option %s: %s.\n", + opt[0], opt[1]); + res = RES_BAD_ARG; + goto error; + } + } else if(strcmp(opt[0], "FOV") == 0) { ERR(cstr_to_double(opt[1], &cam->fov)); }