commit 6abd454ead439407f704ccd4870d0592812f1317
parent 310dd9271b28781a1f0f87ddc9cb2484fbcd601e
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 12 Feb 2021 17:18:40 +0100
Merge remote-tracking branch 'origin/develop' into feature_thermal_contact_resistance
Diffstat:
5 files changed, 137 insertions(+), 125 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -36,7 +36,7 @@ set_property(CACHE STARDIS_DOC PROPERTY STRINGS
# Generate files
###############################################################################
set(STARDIS_ARGS_DEFAULT_AMBIENT_TEMP "300")
-set(STARDIS_ARGS_DEFAULT_COMPUTE_TIME "INF, INF")
+set(STARDIS_ARGS_DEFAULT_COMPUTE_TIME "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")
diff --git a/doc/stardis-input.5.txt b/doc/stardis-input.5.txt
@@ -199,9 +199,14 @@ NAMES
Names, either file names, medium names or boundary names, are a sequence of
one or ore ASCII characters, including numbers and special characters like
*.* *_* *-* as one may consider using in standard file names, *without any
-spacing* either escaped or not. Names are case-sensitive anf two different
+spacing* either escaped or not. Names are case-sensitive and two different
description lines, either in the same description file or from different
-description files, cannot use the same name.
+description files, cannot use the same name. Additionaly, medium and boundary
+names cannot be parsable as a number, nor be one of the few keywords defined
+by the present grammar (AUTO, BACK, BOTH, FLUID, FRONT, F_BOUNDARY_FOR_SOLID,
+H_BOUNDARY_FOR_FLUID, H_BOUNDARY_FOR_SOLID, SCALE, SOLID,
+SOLID_FLUID_CONNECTION, T_BOUNDARY_FOR_FLUID, T_BOUNDARY_FOR_SOLID, UNKNOWN) or
+their lowercase counterparts.
EXAMPLES
--------
diff --git a/doc/stardis.1.txt.in b/doc/stardis.1.txt.in
@@ -89,48 +89,48 @@ MANDATORY OPTIONS
EXCLUSIVE OPTIONS
-----------------
-*-p* _x,y,z[,time-range]_::
+*-p* _x,y,z[,time[,time]]_::
Compute the temperature at the given probe at a given time. By default the
- compute time range is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The probe must
+ compute time is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The probe must
be in a medium. The probe coordinates must be in the same system as the
geometry.
-*-P* _x,y,z[,time-range][,medium_name]_::
+*-P* _x,y,z[,time[,time]][,medium_name]_::
Compute the temperature at the given probe on an interface at a given time.
If the probe is on an interface where a thermal contact resistance is
defined it is mandatory to provide a medium name, as the temperature differs
between the two sides.
- By default the compute time range is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The
+ By default the 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 starts. The probe coordinates
must be in the same system as the geometry.
-*-m* _medium_name[,time-range]_::
+*-m* _medium_name[,time[,time]]_::
Compute the mean temperature in a given medium at a given time. The medium
name must be part of the system description. By default the compute time
- range is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The medium does not need to be
- connex.
+ is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The medium region does not need
+ to be connex.
-*-s* _file[,time-range][,FRONT|BACK]_::
+*-s* _file[,time[,time]][,FRONT|BACK]_::
Compute the mean temperature on a given 2D region at a given time, the region
being defined as the front sides of the triangles in the provided *STL* file.
- By default the compute time range is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@.
+ By default the compute time is @STARDIS_ARGS_DEFAULT_COMPUTE_TIME@.
These triangles are not added to the geometry, but must be part of it. The
region does not need to be connex.
-*-S* _file[,time-range][,FRONT|BACK]_::
+*-S* _file[,time[,time]][,FRONT|BACK]_::
Compute the by-triangle mean temperature on a given 2D region at a given
time, the region being defined as the front sides of the triangles in the
provided *STL* file. These triangles are not added to the geometry, but must
- be part of it. By default the compute time range is
+ be part of it. By default the compute time is
@STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The region does not need to be connex.
-*-F* _file[,time-range]_::
+*-F* _file[,time[,time]]_::
Compute the mean flux on a given 2D region at a given time, the region
being defined as the front sides of the triangles in the provided *STL* file.
These triangles are not added to the geometry, but must be part of it. Flux
is accounted positive when going from the front side to the back side, at a
- single-triangle level. By default the compute time range is
+ single-triangle level. By default the compute time is
@STARDIS_ARGS_DEFAULT_COMPUTE_TIME@. The region does not need to be connex,
but it can currently only include geometry appearing in description lines
starting with H_BOUNDARY_FOR_SOLID, H_BOUNDARY_FOR_FLUID,
@@ -169,8 +169,8 @@ EXCLUSIVE OPTIONS
Number of samples per pixel.
By default, use @STARDIS_ARGS_DEFAULT_RENDERING_SPP@ samples per pixel.
- **t=**_time-range_;;
- Rendering time range. By default _time-range_ is
+ **t=**_time[,time]_;;
+ Rendering time. By default the rendering time is
@STARDIS_ARGS_DEFAULT_RENDERING_TIME@.
**tgt=**_x_**,**_y_**,**_z_;;
diff --git a/src/stardis-compute.c b/src/stardis-compute.c
@@ -174,7 +174,7 @@ check_probe_conform_to_type
(const struct stardis* stardis,
const int move2boundary,
double pos[3],
- size_t* iprim,
+ unsigned* iprim,
double uv[2])
{
res_T res = RES_OK;
@@ -371,7 +371,7 @@ compute_probe(struct stardis* stardis, struct time* start)
{
res_T res = RES_OK;
double uv[2] = { 0,0 };
- size_t iprim = SIZE_MAX;
+ unsigned iprim = UINT_MAX;
struct sdis_green_function* green = NULL;
struct sdis_estimator* estimator = NULL;
struct dump_path_context dump_ctx;
@@ -448,7 +448,7 @@ compute_probe_on_interface(struct stardis* stardis, struct time* start)
{
res_T res = RES_OK;
double uv[2] = { 0,0 };
- size_t iprim = SIZE_MAX;
+ unsigned iprim = UINT_MAX;
struct sdis_estimator* estimator = NULL;
struct sdis_green_function* green = NULL;
struct dump_path_context dump_ctx;
@@ -459,7 +459,7 @@ compute_probe_on_interface(struct stardis* stardis, struct time* start)
ASSERT(stardis && start && (stardis->mode & MODE_PROBE_COMPUTE_ON_INTERFACE));
ERR(check_probe_conform_to_type(stardis, 1, stardis->probe, &iprim, uv));
- ASSERT(iprim != SIZE_MAX);
+ ASSERT(iprim != UINT_MAX);
/* Find medium */
medium = find_medium_by_name(stardis, &stardis->solve_name, NULL);
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -30,24 +30,16 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#ifdef COMPILER_GCC
+#include <strings.h>
+#endif
/*******************************************************************************
* Local Functions
******************************************************************************/
-#ifdef COMPILER_GCC
-static char*
-_strupr
- (char* s)
-{
- char* ptr;
- for(ptr = s; *ptr; ++ptr) {
- int tmp = toupper(*ptr);
- ASSERT(tmp == (char)tmp);
- *ptr = (char)tmp;
- }
- return s;
-}
+#ifdef COMPILER_CL
+#define strcasecmp(s1, s2) _stricmp((s1), (s2))
#endif
static char**
@@ -225,17 +217,16 @@ read_sides_and_files
}
else break;
}
- _strupr(tk);
add_geom_ctx.properties[SG3D_INTFACE] = SG3D_UNSPECIFIED_PROPERTY;
- if(0 == strcmp(tk, "FRONT")) {
+ if(0 == strcasecmp(tk, "FRONT")) {
add_geom_ctx.properties[SG3D_FRONT] = description_id;
add_geom_ctx.properties[SG3D_BACK] = SG3D_UNSPECIFIED_PROPERTY;
}
- else if(0 == strcmp(tk, "BACK")) {
+ else if(0 == strcasecmp(tk, "BACK")) {
add_geom_ctx.properties[SG3D_FRONT] = SG3D_UNSPECIFIED_PROPERTY;
add_geom_ctx.properties[SG3D_BACK] = description_id;
}
- else if(0 == strcmp(tk, "BOTH")) {
+ else if(0 == strcasecmp(tk, "BOTH")) {
add_geom_ctx.properties[SG3D_FRONT] = description_id;
add_geom_ctx.properties[SG3D_BACK] = description_id;
}
@@ -629,13 +620,13 @@ parse_args
*ptr = '\0';
}
if(res == RES_OK) {
- if(0 == strcmp(optarg, "all")) {
+ if(0 == strcasecmp(optarg, "all")) {
args->dump_paths = DUMP_ALL;
}
- else if(0 == strcmp(optarg, "error")) {
+ else if(0 == strcasecmp(optarg, "error")) {
args->dump_paths = DUMP_ERROR;
}
- else if(0 == strcmp(optarg, "success")) {
+ else if(0 == strcasecmp(optarg, "success")) {
args->dump_paths = DUMP_SUCCESS;
}
}
@@ -964,88 +955,91 @@ parse_camera
char** opt = NULL;
struct camera* cam;
struct str keep;
+ int i = 0;
res_T res = RES_OK;
ASSERT(cam_param && stardis);
cam = &stardis->camera;
line = split_line(cam_param, ':');
- str_init(stardis->allocator, &keep);
+ if(!line) {
+ res = RES_MEM_ERR;
+ goto error;
+ }
- if(line) {
- int i = 0;
- for(i = 0; *(line + i); i++) {
- size_t len = 0;
- ERR(str_set(&keep, line[i]));
- opt = split_line(line[i], '=');
- if(!opt[0] || ! opt[1] || opt[2]) {
- if(res == RES_OK) res = RES_BAD_ARG;
- logger_print((logger), LOG_ERROR,
- "Invalid option syntax: %s\n", str_cget(&keep));
- goto error;
- }
- ERR(str_set(&keep, opt[0]));
- _strupr(opt[0]);
- if(strcmp(opt[0], "T") == 0) {
- GET_OPTIONAL_TIME_RANGE(opt[1], 0, cam->time_range, logger, "%s",
- str_cget(&keep));
- }
- else if(strcmp(opt[0], "FILE") == 0) {
- ERR(str_set(&cam->file_name, opt[1]));
- }
- 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));
- }
- else if(strcmp(opt[0], "UP") == 0) {
- ERR(cstr_to_list_double(opt[1], ',', cam->up, &len, 3));
- }
- else if(strcmp(opt[0], "TGT") == 0) {
- ERR(cstr_to_list_double(opt[1], ',', cam->tgt, &len, 3));
- cam->auto_look_at = 0;
- }
- else if(strcmp(opt[0], "POS") == 0) {
- ERR(cstr_to_list_double(opt[1], ',', cam->pos, &len, 3));
- cam->auto_look_at = 0;
- }
- else if(strcmp(opt[0], "IMG") == 0) {
- unsigned img_sz[2];
- ERR(cstr_to_list_uint(opt[1], 'x', img_sz, &len, 2));
- cam->img_width = img_sz[0];
- cam->img_height = img_sz[1];
- }
- else if(strcmp(opt[0], "SPP") == 0) {
- ERR(cstr_to_uint(opt[1], &cam->spp));
- } else {
+ str_init(stardis->allocator, &keep);
+ for(i = 0; *(line + i); i++) {
+ size_t len = 0;
+ ERR(str_set(&keep, line[i]));
+ opt = split_line(line[i], '=');
+ if(!opt[0] || !opt[1] || opt[2]) { /* We expect 2 parts */
+ if(res == RES_OK) res = RES_BAD_ARG;
+ logger_print((logger), LOG_ERROR,
+ "Invalid option syntax: %s\n", str_cget(&keep));
+ goto error;
+ }
+ if(strcasecmp(opt[0], "T") == 0) {
+ GET_OPTIONAL_TIME_RANGE(opt[1], 0, cam->time_range, logger, "%s", opt[0]);
+ }
+ else if(strcasecmp(opt[0], "FILE") == 0) {
+ ERR(str_set(&cam->file_name, opt[1]));
+ }
+ else if(strcasecmp(opt[0], "FMT") == 0) {
+ if(strcasecmp(opt[1], "VTK") == 0)
+ cam->fmt = STARDIS_RENDERING_OUTPUT_FILE_FMT_VTK;
+ else if(strcasecmp(opt[1], "HT") == 0)
+ cam->fmt = STARDIS_RENDERING_OUTPUT_FILE_FMT_HT;
+ else {
logger_print(logger, LOG_ERROR,
- "Unexpected option for rendering mode: %s.\n",
- opt[0]);
+ "Unexpected value for rendering option %s: %s.\n",
+ opt[0], opt[1]);
res = RES_BAD_ARG;
goto error;
}
}
- }
+ else if(strcasecmp(opt[0], "FOV") == 0) {
+ ERR(cstr_to_double(opt[1], &cam->fov));
+ }
+ else if(strcasecmp(opt[0], "UP") == 0) {
+ ERR(cstr_to_list_double(opt[1], ',', cam->up, &len, 3));
+ }
+ else if(strcasecmp(opt[0], "TGT") == 0) {
+ ERR(cstr_to_list_double(opt[1], ',', cam->tgt, &len, 3));
+ cam->auto_look_at = 0;
+ }
+ else if(strcasecmp(opt[0], "POS") == 0) {
+ ERR(cstr_to_list_double(opt[1], ',', cam->pos, &len, 3));
+ cam->auto_look_at = 0;
+ }
+ else if(strcasecmp(opt[0], "IMG") == 0) {
+ unsigned img_sz[2];
+ ERR(cstr_to_list_uint(opt[1], 'x', img_sz, &len, 2));
+ cam->img_width = img_sz[0];
+ cam->img_height = img_sz[1];
+ }
+ else if(strcasecmp(opt[0], "SPP") == 0) {
+ ERR(cstr_to_uint(opt[1], &cam->spp));
+ } else {
+ logger_print(logger, LOG_ERROR,
+ "Unexpected option for rendering mode: %s.\n",
+ opt[0]);
+ res = RES_BAD_ARG;
+ goto error;
+ }
-end:
-#define FREE_AARRAY(ARRAY) if(ARRAY) {\
- int i = 0; \
- for(i=0; *(ARRAY+i);i++){\
- free(ARRAY[i]);\
+#define FREE_AARRAY(ARRAY) \
+if(ARRAY) {\
+ int i__ = 0; \
+ for(i__=0; *((ARRAY)+i__);i__++){\
+ free((ARRAY)[i__]);\
}\
free(ARRAY);\
+ (ARRAY) = NULL;\
}
+
+ FREE_AARRAY(opt)
+ }
+
+end:
FREE_AARRAY(line)
FREE_AARRAY(opt)
#undef FREE_AARRAY
@@ -1070,14 +1064,30 @@ description_set_name
{
res_T res = RES_OK;
double foo;
+ const char* keywords[] = {
+ "AUTO", "BACK", "BOTH", "FLUID", "FRONT", "F_BOUNDARY_FOR_SOLID",
+ "H_BOUNDARY_FOR_FLUID", "H_BOUNDARY_FOR_SOLID", "SCALE", "SOLID",
+ "SOLID_FLUID_CONNECTION", "T_BOUNDARY_FOR_FLUID", "T_BOUNDARY_FOR_SOLID",
+ "UNKNOWN" };
+ int i;
ASSERT(name && tk);
+ /* Use name before uppercasing it */
+ ERR(str_set(name, tk));
+
if(RES_OK == cstr_to_double(tk, &foo)) {
/* A number is not a sensible choice for a name! */
res = RES_BAD_ARG;
goto error;
}
- ERR(str_set(name, tk));
+ FOR_EACH(i, 0, sizeof(keywords) / sizeof(*keywords)) {
+ if(0 == strcasecmp(tk, keywords[i])) {
+ /* A keyword is not a sensible choice for a name! */
+ res = RES_BAD_ARG;
+ goto error;
+ }
+ }
+ /* Name is OK */
end:
return res;
@@ -1509,8 +1519,7 @@ read_imposed_temperature
}
} else {
/* Could be 'unknown' */
- _strupr(tk);
- if(0 == strcmp(tk, "UNKNOWN")) {
+ if(0 == strcasecmp(tk, "UNKNOWN")) {
*imposed_temperature = UNKNOWN_MEDIUM_TEMPERATURE;
} else {
res = RES_BAD_ARG;
@@ -1548,8 +1557,7 @@ read_delta
}
} else {
/* Could be 'auto' */
- _strupr(tk);
- if(0 == strcmp(tk, "AUTO")) {
+ if(0 == strcasecmp(tk, "AUTO")) {
/* Set to DELTA_AUTO until actual value is substituted */
*delta = DELTA_AUTO;
} else {
@@ -1824,27 +1832,26 @@ process_model_line
str_init(stardis->allocator, &keep);
ERR(str_set(&keep, line));
CHK_TOK(strtok_r(line, " \t", &tok_ctx), "model line type");
- _strupr(tk);
- if(0 == strcmp(tk, "H_BOUNDARY_FOR_SOLID"))
+ if(0 == strcasecmp(tk, "H_BOUNDARY_FOR_SOLID"))
ERR(process_h(stardis, dummies, DESC_BOUND_H_FOR_SOLID, &tok_ctx));
- else if(0 == strcmp(tk, "H_BOUNDARY_FOR_FLUID"))
+ else if(0 == strcasecmp(tk, "H_BOUNDARY_FOR_FLUID"))
ERR(process_h(stardis, dummies, DESC_BOUND_H_FOR_FLUID, &tok_ctx));
- else if(0 == strcmp(tk, "T_BOUNDARY_FOR_SOLID"))
+ else if(0 == strcasecmp(tk, "T_BOUNDARY_FOR_SOLID"))
ERR(process_t(stardis, dummies, DESC_BOUND_T_FOR_SOLID, &tok_ctx));
- else if(0 == strcmp(tk, "T_BOUNDARY_FOR_FLUID"))
+ else if(0 == strcasecmp(tk, "T_BOUNDARY_FOR_FLUID"))
ERR(process_t(stardis, dummies, DESC_BOUND_T_FOR_FLUID, &tok_ctx));
- else if(0 == strcmp(tk, "F_BOUNDARY_FOR_SOLID"))
+ else if(0 == strcasecmp(tk, "F_BOUNDARY_FOR_SOLID"))
ERR(process_flx(stardis, dummies, &tok_ctx));
- else if(0 == strcmp(tk, "SOLID_FLUID_CONNECTION"))
+ else if(0 == strcasecmp(tk, "SOLID_FLUID_CONNECTION"))
ERR(process_sfc(stardis, &tok_ctx));
- else if(0 == strcmp(tk, "SOLID_SOLID_CONNECTION"))
+ else if(0 == strcasecmp(tk, "SOLID_SOLID_CONNECTION"))
ERR(process_ssc(stardis, &tok_ctx));
- else if(0 == strcmp(tk, "SOLID"))
+ else if(0 == strcasecmp(tk, "SOLID"))
ERR(process_solid(stardis, &tok_ctx));
- else if(0 == strcmp(tk, "FLUID"))
+ else if(0 == strcasecmp(tk, "FLUID"))
ERR(process_fluid(stardis, &tok_ctx));
- else if(0 == strcmp(tk, "SCALE"))
+ else if(0 == strcasecmp(tk, "SCALE"))
ERR(process_scale(stardis, &tok_ctx));
else {
logger_print(stardis->logger, LOG_ERROR,