commit a121eed1481ee719302aea5edf089f3471fedb35
parent 3727ca344e06d9a333a83410ae29e7d9e19c7e32
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 15 Oct 2020 15:12:47 +0200
Merge branch 'develop' into feature_unsteady_green
Diffstat:
9 files changed, 224 insertions(+), 15 deletions(-)
diff --git a/doc/stardis-output.5.txt b/doc/stardis-output.5.txt
@@ -32,9 +32,9 @@ The type of the data that are generated depends on the options used when
(*-p*, *-P*, *-m*, *-s* or *-F*), *stardis*(1) outputs a single Monte-Carlo
result. On the opposite, *stardis*(1) ouputs compound results when invoked with
option *-S* or *-R*. Additionally, options *-g* and *-G* make *stardis*(1)
-compute and output a Green function. Most if not all complex data output are in
-VTK [1] format that can be displayed and manipulated by the open-source
-software Paraview [2].
+compute and output a Green function and possibly information on heat paths'
+ends. Most of the complex data output is in VTK [1] format that can be
+displayed and manipulated by the open-source software Paraview [2].
Finaly, some special options (*-v*, *-h* or *-d*) that does not involve any
computation produce output including information on the *stardis*(1) software
@@ -61,7 +61,7 @@ correspondance:
*-F*: produces <mean-flux>
*-p*, *-P*, *-m* or *-s* with *-g* or *-G*: produce <ascii-green> or
-<binary-green> respectively.
+<binary-green> and possibly <heat-paths-ends> respectively.
*-D*: produces <heat-path> files in addition to the simulation output
@@ -89,6 +89,7 @@ _______
<output> ::= <single-MC-result>
| <binary-green>
+ | <heat-paths-ends>
| <ascii-green>
| <geometry-dump>
| <infrared-image>
@@ -190,7 +191,7 @@ _______
The Green function is generated, either in binary or ascii format, when a
green-compatible *stardis*(1) simulation option is used in conjuction with
-option *-G* for a binary outpur, or option *-g* for an ascii output. For
+option *-G* for a binary output, or option *-g* for an ascii output. For
every successful heat path sampled carrying out the simulation, the solver
records all the elements of the path history relevant to link the various
imposed temperature, fluxe and volumic power values to the simulation result.
@@ -202,7 +203,8 @@ ambient temperature.
The output in green mode is made of tables containing the different media and
boundaries and their imposed temperature, flux and volumic power values,
-followed by the paths' history.
+followed by the heat paths' history. Also, option *-G* make it possible to
+output heat paths' end information on an ascii, csv formated file.
The Monte-Carlo estimate and standard deviation for a given set of settings can
be computed as the mean and standard deviation of the samples of the *Green
@@ -499,8 +501,44 @@ _______
<flux-factor> ::= REAL # in ]0, INF)
# the temperature gain is flux-factor * Flux(green-id)
+_______
+
+== HEAT PATHS' ENDS
+When computing the Green function in binary mode, stardis can output partial
+information ot the sampled heat paths. Opposed to what the *-D* option outputs,
+that is the complete history of selected heat paths, here the information
+output is restricted to paths' ends to allow the inclusion of all the sampled
+heat paths, allowing statistical analysis.
+Note that in wath follows, the meaning of external quotes is as usual: what is
+inside is verbatim, including quotes.
+
+[verse]
+_______
+<heat-paths-ends> ::= ""End", "End ID", "X", "Y", "Z", "Elapsed time""
+ <heat-path-end-list>
+
+<heat-path-end-list> ::= <end-name> ", " <endid> ", " <x> ", " <y> ", " \
+ <z> ", " <elapsed-time>
+ <heat-path-end-list> # #samples heat path ends
+
+-------------------------------------
+
+<end-name> ::= STRING # the name of the boundary at the end of the
+ # heat path, or AMBIANT for radiative ending
+
+<end-id> ::= INTEGER # in [0 #boundaries]
+ # order is the order in the description file,
+ # AMBIANT's id being #boundaries
+
+<x> ::= REAL
+
+<y> ::= REAL
+
+<z> ::= REAL
+
+<elapsed-time> ::= REAL # in [0, INF)
_______
== GEOMETRY DUMP
@@ -736,7 +774,6 @@ _______
| "3" # invalid enclosure: more than 1 medium
| "5" # invalid enclosure: some triangles with no defined medium
| "7" # invalid enclosure: more than 1 "medium", including undefined
-
_______
== INFRARED IMAGE
diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in
@@ -214,9 +214,10 @@ options -g or -G.
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.
-*-G* _file_name_::
+*-G* _file_name_[,__file_name__]::
Compute the Green function at the specified time and write it to a binary
- file.
+ 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.
@@ -289,6 +290,13 @@ 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 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
+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 © 2018-2020 |Meso|Star>. License GPLv3+: GNU GPL
diff --git a/src/stardis-app.c b/src/stardis-app.c
@@ -224,6 +224,7 @@ stardis_init
str_init(stardis->allocator, &stardis->solve_name);
str_init(stardis->allocator, &stardis->paths_filename);
str_init(stardis->allocator, &stardis->bin_green_filename);
+ str_init(stardis->allocator, &stardis->end_paths_filename);
str_init(stardis->allocator, &stardis->chunks_prefix);
darray_size_t_init(stardis->allocator, &stardis->compute_surface.primitives);
darray_sides_init(stardis->allocator, &stardis->compute_surface.sides);
@@ -352,6 +353,9 @@ stardis_init
if(args->bin_green_filename) {
ERR(str_set(&stardis->bin_green_filename, args->bin_green_filename));
}
+ if(args->end_paths_filename) {
+ ERR(str_set(&stardis->end_paths_filename, args->end_paths_filename));
+ }
}
/* If computation is on a volume, check medium is known */
@@ -405,6 +409,7 @@ stardis_release
str_release(&stardis->solve_name);
str_release(&stardis->paths_filename);
str_release(&stardis->bin_green_filename);
+ str_release(&stardis->end_paths_filename);
str_release(&stardis->chunks_prefix);
darray_descriptions_release(&stardis->descriptions);
release_geometry(&stardis->geometry);
diff --git a/src/stardis-app.h b/src/stardis-app.h
@@ -716,6 +716,7 @@ struct stardis {
or MAP_COMPUTE */
struct str paths_filename;
struct str bin_green_filename;
+ struct str end_paths_filename;
struct str chunks_prefix;
int mode;
size_t samples;
diff --git a/src/stardis-compute.c b/src/stardis-compute.c
@@ -399,6 +399,17 @@ compute_probe(struct stardis* stardis)
}
ERR(dump_green_bin(green, stardis, stream));
fclose(stream); stream = NULL;
+ if(str_cget(&stardis->end_paths_filename)
+ && strlen(str_cget(&stardis->end_paths_filename)))
+ {
+ stream = fopen(str_cget(&stardis->end_paths_filename), "w");
+ if(!stream) {
+ res = RES_IO_ERR;
+ goto error;
+ }
+ ERR(dump_paths_end(green, stardis, stream));
+ fclose(stream); stream = NULL;
+ }
}
if(stardis->mode & MODE_GREEN) {
ERR(dump_green_ascii(green, stardis, stdout));
@@ -460,6 +471,17 @@ compute_probe_on_interface(struct stardis* stardis)
}
ERR(dump_green_bin(green, stardis, stream));
fclose(stream); stream = NULL;
+ if(str_cget(&stardis->end_paths_filename)
+ && strlen(str_cget(&stardis->end_paths_filename)))
+ {
+ stream = fopen(str_cget(&stardis->end_paths_filename), "w");
+ if(!stream) {
+ res = RES_IO_ERR;
+ goto error;
+ }
+ ERR(dump_paths_end(green, stardis, stream));
+ fclose(stream); stream = NULL;
+ }
}
if(stardis->mode & MODE_GREEN) {
ERR(dump_green_ascii(green, stardis, stdout));
@@ -674,6 +696,17 @@ compute_medium(struct stardis* stardis)
}
ERR(dump_green_bin(green, stardis, stream));
fclose(stream); stream = NULL;
+ if(str_cget(&stardis->end_paths_filename)
+ && strlen(str_cget(&stardis->end_paths_filename)))
+ {
+ stream = fopen(str_cget(&stardis->end_paths_filename), "w");
+ if(!stream) {
+ res = RES_IO_ERR;
+ goto error;
+ }
+ ERR(dump_paths_end(green, stardis, stream));
+ fclose(stream); stream = NULL;
+ }
}
if(stardis->mode & MODE_GREEN) {
ERR(dump_green_ascii(green, stardis, stdout));
@@ -779,6 +812,17 @@ compute_boundary(struct stardis* stardis)
}
ERR(dump_green_bin(green, stardis, stream));
fclose(stream); stream = NULL;
+ if(str_cget(&stardis->end_paths_filename)
+ && strlen(str_cget(&stardis->end_paths_filename)))
+ {
+ stream = fopen(str_cget(&stardis->end_paths_filename), "w");
+ if(!stream) {
+ res = RES_IO_ERR;
+ goto error;
+ }
+ ERR(dump_paths_end(green, stardis, stream));
+ fclose(stream); stream = NULL;
+ }
}
if(stardis->mode & MODE_GREEN) {
ERR(dump_green_ascii(green, stardis, stdout));
diff --git a/src/stardis-output.c b/src/stardis-output.c
@@ -49,6 +49,11 @@ struct w_ctx {
FILE* stream;
};
+struct e_ctx {
+ const struct darray_descriptions* desc;
+ FILE* stream;
+};
+
/*******************************************************************************
* Local Type; for documentation purpose
* These values are used in dumps
@@ -373,6 +378,77 @@ medium_get_t0
}
static res_T
+dump_sample_end
+ (struct sdis_green_path* path,
+ void* ctx)
+{
+ res_T res = RES_OK;
+ struct sdis_point pt = SDIS_POINT_NULL;
+ struct sdis_data* data = NULL;
+ enum sdis_medium_type type;
+ struct e_ctx* e_ctx = ctx;
+ const struct description* descs;
+ FILE* stream;
+ double elapsed;
+ double* pos;
+ unsigned id;
+
+ CHK(path && ctx);
+
+ stream = e_ctx->stream;
+ ERR(sdis_green_path_get_limit_point(path, &pt));
+ ERR(sdis_green_path_get_elapsed_time(path, &elapsed));
+
+ descs = darray_descriptions_cdata_get(e_ctx->desc);
+ switch (pt.type) {
+ case SDIS_FRAGMENT: {
+ struct intface* d__;
+ data = sdis_interface_get_data(pt.data.itfrag.intface);
+ pos = pt.data.itfrag.fragment.P;
+ d__ = sdis_data_get(data);
+ id = d__->desc_id;
+ CHK(DESC_IS_T(descs[id].type) || DESC_IS_H(descs[id].type));
+ break;
+ }
+ case SDIS_VERTEX:
+ type = sdis_medium_get_type(pt.data.mdmvert.medium);
+ data = sdis_medium_get_data(pt.data.mdmvert.medium);
+ pos = pt.data.mdmvert.vertex.P;
+ if(pt.data.mdmvert.vertex.P[0] == INF) {
+ /* Radiative output (ambient temperature) */
+ size_t sz = darray_descriptions_size_get(e_ctx->desc);
+ ASSERT(sz <= UINT_MAX);
+ id = (unsigned)sz; /* Ambient ID */
+ }
+ else if(type == SDIS_FLUID) {
+ struct fluid* d__ = sdis_data_get(data);
+ id = d__->desc_id;
+ } else {
+ struct solid* d__ = sdis_data_get(data);
+ ASSERT(type == SDIS_SOLID);
+ ASSERT(!d__->is_outside); /* FIXME: what if in external solid? */
+ id = d__->desc_id;
+ }
+ break;
+ default: FATAL("Unreachable code.\n"); break;
+ }
+
+ /* End, End ID, X, Y, Z, Elapsed time */
+ if(pt.data.mdmvert.vertex.P[0] == INF) {
+ fprintf(stream, "AMBIANT, %u, 0, 0, 0, %g\n",
+ id, elapsed);
+ } else {
+ fprintf(stream, "%s, %u, %g, %g, %g, %g\n",
+ str_cget(get_description_name(descs + id)), id, SPLIT3(pos), elapsed);
+ }
+
+end:
+ return res;
+error:
+ goto end;
+}
+
+static res_T
dump_sample
(struct sdis_green_path* path,
void* ctx)
@@ -397,7 +473,8 @@ dump_sample
ERR(sdis_green_path_get_limit_point(path, &pt));
/* For each path, dump:
- * # end_id #power_terms #flux_terms power_id_1 ... power_id_n flux_id_1 ... flux_id_n
+ * # end_id #power_terms #flux_terms
+ * power_id_1 ... power_id_n flux_id_1 ... flux_id_n
* power_factor_1 ... power_factor_n flux_factor_1 ... flux_factor_n
*/
@@ -420,7 +497,7 @@ dump_sample
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)*/
+ /* Radiative output (ambient temperature) */
sz = darray_descriptions_size_get(w_ctx->desc);
ASSERT(sz <= UINT_MAX);
header.id = (unsigned)sz; /* Ambient ID */
@@ -491,7 +568,6 @@ dump_sample
FW(ids, sz);
FW(weights, sz);
-
end:
MEM_RM(w_ctx->alloc, ids);
MEM_RM(w_ctx->alloc, weights);
@@ -592,6 +668,29 @@ error:
}
res_T
+dump_paths_end
+ (struct sdis_green_function* green,
+ const struct stardis* stardis,
+ FILE* stream)
+{
+ res_T res = RES_OK;
+ struct e_ctx e_ctx = { 0 };
+
+ ASSERT(green && stardis && stream);
+
+ e_ctx.desc = &stardis->descriptions;
+ e_ctx.stream = stream;
+
+ fprintf(stream, "\"End\", \"End ID\", \"X\", \"Y\", \"Z\", \"Elapsed time\"\n");
+ ERR(sdis_green_function_for_each_path(green, dump_sample_end, &e_ctx));
+
+end:
+ return res;
+error:
+ goto end;
+}
+
+res_T
print_sample
(struct sdis_green_path* path,
void* ctx)
diff --git a/src/stardis-output.h b/src/stardis-output.h
@@ -65,6 +65,12 @@ dump_green_bin
FILE* stream);
extern res_T
+dump_paths_end
+ (struct sdis_green_function* green,
+ const struct stardis* stardis,
+ FILE* stream);
+
+extern res_T
dump_enclosure_related_stuff_at_the_end_of_vtk
(struct stardis* stardis,
FILE* stream);
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -490,8 +490,8 @@ short_help
fprintf(stream, "\n -g\n");
fprintf(stream, " Change the computation to produce the green function.\n");
- fprintf(stream, "\n -G BIN_FILE_NAME\n");
- fprintf(stream, " Change the computation to produce the green function.\n");
+ fprintf(stream, "\n -G BIN_FILE_NAME[,CSV_FILE_NAME]\n");
+ fprintf(stream, " Change the computation to produce the green function and possibly end of paths information.\n");
fprintf(stream, "\n -h\n");
fprintf(stream, " Print this help and exit.\n");
@@ -662,7 +662,10 @@ parse_args
args->mode |= MODE_GREEN;
break;
- case 'G':
+ case 'G': {
+ char* ptr = strrchr(optarg, ',');
+ if(ptr && ptr != strchr(optarg, ','))
+ res = RES_BAD_ARG; /* Expecting 1 or 0 ',' */
if(args->mode & (MODE_BIN_GREEN | MODE_GREEN)) {
res = RES_BAD_ARG;
if(args->mode & MODE_BIN_GREEN)
@@ -676,8 +679,13 @@ parse_args
goto error;
}
args->mode |= MODE_BIN_GREEN;
+ if(ptr) {
+ args->end_paths_filename = ptr + 1;
+ *ptr = '\0';
+ }
args->bin_green_filename = optarg;
break;
+ }
case 'h':
if(args->mode & USE_STDOUT_MODES) {
diff --git a/src/stardis-parsing.h b/src/stardis-parsing.h
@@ -101,6 +101,7 @@ struct args {
char* medium_name;
char* solve_filename;
char* bin_green_filename;
+ char* end_paths_filename;
char* paths_filename;
char* chunks_prefix;
size_t samples;