stardis

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

commit c58e6d34fb67f63bb4ed510e3bcd10688a4a6273
parent 34fd967f17421c3cfe3c5340899ef6f3350aa16e
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 13 Feb 2020 15:12:52 +0100

Merge branch 'new_apis' into develop

Diffstat:
Mcmake/CMakeLists.txt | 37++++++++++++++++++++++---------------
Msrc/stardis-app.c | 11++++-------
Msrc/stardis-app.h | 48++++++++++++------------------------------------
Msrc/stardis-compute.c | 12++++--------
Msrc/stardis-fluid.c | 12++++++------
Msrc/stardis-intface.c | 24++++++------------------
Msrc/stardis-output.c | 21+++++++++------------
Msrc/stardis-solid.c | 11++++++-----
8 files changed, 69 insertions(+), 107 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -18,20 +18,23 @@ project(stardis-app C) set(SDIS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -################################################################################ +############################################################################### # Check dependencies -################################################################################ +############################################################################### find_package(RCMake 0.4 REQUIRED) find_package(RSys 0.8.1 REQUIRED) -find_package(StarEnc 0.3.1 REQUIRED) +find_package(StarGeom3D 0.1 REQUIRED) +find_package(StarEnc3D 0.3.1 REQUIRED) find_package(Stardis 0.7.1 REQUIRED) find_package(StarSTL 0.3 REQUIRED) -set(TINYEXPR_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../tinyexpr" CACHE PATH "Directory for TinyExpr source files") +set(TINYEXPR_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../tinyexpr" + CACHE PATH "Directory for TinyExpr source files") include_directories( ${RSys_INCLUDE_DIR} - ${StarEnc_INCLUDE_DIR} + ${StarGeom3D_INCLUDE_DIR} + ${StarEnc3D_INCLUDE_DIR} ${Stardis_INCLUDE_DIR} ${StarSTL_INCLUDE_DIR} ${TINYEXPR_SOURCE_DIR}) @@ -44,11 +47,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) include(rcmake) include(rcmake_runtime) -rcmake_append_runtime_dirs(_runtime_dirs RSys Stardis StarEnc StarSTL) +rcmake_append_runtime_dirs(_runtime_dirs RSys Stardis StarGeom3D StarEnc3D StarSTL) -################################################################################ +############################################################################### # Configure and define targets -################################################################################ +############################################################################### set(VERSION_MAJOR 0) set(VERSION_MINOR 4) set(VERSION_PATCH 0) @@ -81,10 +84,12 @@ rcmake_prepend_path(SDIS_FILES_INC ${SDIS_SOURCE_DIR}) rcmake_prepend_path(SDIS_FILES_DOC ${PROJECT_SOURCE_DIR}/../) # Default is right to left pow and log is natural log -# Build tinyExpr without closure support and with function_1 to function_3 support only -# (these ones cannot be disabled as predefined functions require them). +# Build tinyExpr without closure support and with function_1 to function_3 +# support only (these ones cannot be disabled as predefined functions require +# them). set(TE_DEFAULTS - "-DTE_POW_FROM_RIGHT -DTE_NAT_LOG -DTE_WITHOUT_CLOSURES -DTE_WITHOUT_FUNCTION_0 -DTE_MAX_FUNCTION_ARITY=3") + "-DTE_POW_FROM_RIGHT -DTE_NAT_LOG -DTE_WITHOUT_CLOSURES \ + -DTE_WITHOUT_FUNCTION_0 -DTE_MAX_FUNCTION_ARITY=3") ADD_LIBRARY(tinyexpr STATIC ${TINYEXPR_SOURCE_DIR}/tinyexpr.c ${TINYEXPR_SOURCE_DIR}/tinyexpr.h) @@ -105,19 +110,21 @@ if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(sdis-app PROPERTIES COMPILE_FLAGS "-std=c99 ${TE_DEFAULTS}" VERSION ${VERSION}) - target_link_libraries(sdis-app Stardis StarEnc StarSTL RSys tinyexpr m) + target_link_libraries(sdis-app + Stardis StarGeom3D StarEnc3D StarSTL RSys tinyexpr m) elseif(MSVC) set_target_properties(sdis-app PROPERTIES COMPILE_FLAGS "${TE_DEFAULTS}" VERSION ${VERSION}) - target_link_libraries(sdis-app Stardis StarEnc StarSTL RSys tinyexpr MuslGetopt) + target_link_libraries(sdis-app + Stardis StarGeom3D StarEnc3D StarSTL RSys tinyexpr MuslGetopt) endif() rcmake_copy_runtime_libraries(sdis-app) -################################################################################ +############################################################################### # Define output & install directories -################################################################################ +############################################################################### install(TARGETS sdis-app ARCHIVE DESTINATION bin LIBRARY DESTINATION lib diff --git a/src/stardis-app.c b/src/stardis-app.c @@ -213,12 +213,8 @@ read_triangles sa_push(boundary->sides, current_side); continue; /* Next triangle */ break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } if (*side_desc_ptr != UINT_MAX && *side_desc_ptr != desc_id) { /* Already described with a different description! */ @@ -227,7 +223,8 @@ read_triangles (file_type == CONTENT_CONNECTION ? "connection" : (current_side == SDIS_FRONT ? "front" : "back")), stl_filename); - print_trg_as_obj(stderr, (const struct vertex*)stl_desc->vertices, stl_desc->indices + (3 * tri_index)); + print_trg_as_obj(stderr, (const struct vertex*)stl_desc->vertices, + stl_desc->indices + (3 * tri_index)); return RES_BAD_ARG; } /* Everithing is OK: store description */ diff --git a/src/stardis-app.h b/src/stardis-app.h @@ -884,12 +884,8 @@ print_description case DESC_BOUND_F_FOR_SOLID: print_f_boundary(stream, &desc->d.f_boundary, desc->type); break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } @@ -912,12 +908,8 @@ eq_description(const struct description* a, const struct description* b) return eq_f_boundary(&a->d.f_boundary, &b->d.f_boundary); case DESC_SOLID_FLUID_CONNECT: return eq_sf_connect(&a->d.sf_connect, &b->d.sf_connect); - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } @@ -949,12 +941,8 @@ cp_description(struct description* dst, const struct description* src) return cp_f_boundary(&dst->d.f_boundary, &src->d.f_boundary); case DESC_SOLID_FLUID_CONNECT: return cp_sf_connect(&dst->d.sf_connect, &src->d.sf_connect); - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } @@ -980,12 +968,8 @@ cp_release_description(struct description* dst, struct description* src) return cp_release_sf_connect(&dst->d.sf_connect, &src->d.sf_connect); case DESCRIPTION_TYPE_COUNT__: return RES_OK; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } @@ -1010,12 +994,8 @@ release_description(struct description* a) return release_sf_connect(&a->d.sf_connect); case DESCRIPTION_TYPE_COUNT__: return RES_OK; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } @@ -1037,12 +1017,8 @@ hash_description(const struct description* key) return hash_f_boundary(&key->d.f_boundary); case DESC_SOLID_FLUID_CONNECT: return hash_sf_connect(&key->d.sf_connect); - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } diff --git a/src/stardis-compute.c b/src/stardis-compute.c @@ -319,12 +319,8 @@ create_holder if (res != RES_OK) goto error; break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } end: @@ -832,7 +828,7 @@ stardis_compute sa_size(stardis->geometry.vertex), geometry_get_position, &stardis->geometry, &scn); if(res != RES_OK) { - fprintf(stderr, "%s: could not setup the scene!\n", __FUNCTION__); + fprintf(stderr, "%s: could not setup the scene!\n", FUNC_NAME); goto error; } @@ -857,7 +853,7 @@ stardis_compute res = compute_map(scn, stardis, mode); else FATAL("Unknown mode.\n"); if(res != RES_OK) { - fprintf(stderr, "%s: computation failed!\n", __FUNCTION__); + fprintf(stderr, "%s: computation failed!\n", FUNC_NAME); goto error; } diff --git a/src/stardis-fluid.c b/src/stardis-fluid.c @@ -37,7 +37,6 @@ fluid_get_temperature struct sdis_data* data) { const struct fluid* fluid_props = sdis_data_cget(data); - char msg[128]; ASSERT(fluid_props->t_init || fluid_props->temp); if (fluid_props->is_green || vtx->time > fluid_props->t0) { /* Always use temp for Green mode, regardless of time */ @@ -49,13 +48,14 @@ fluid_get_temperature if (fluid_props->t_init) return te_eval(fluid_props->t_init, vtx); /* Must have had t_init defined: error! */ - if (fluid_props->name[0]) - snprintf(msg, sizeof(msg), + if (fluid_props->name[0]) { + fprintf(stderr, "fluid_get_temperature: getting undefined Tinit (fluid '%s')\n", fluid_props->name); - else - snprintf(msg, sizeof(msg), "fluid_get_temperature: getting undefined Tinit\n"); - FATAL(msg); + ASSERT(0); + abort(); + } else + FATAL("fluid_get_temperature: getting undefined Tinit\n"); } static void diff --git a/src/stardis-intface.c b/src/stardis-intface.c @@ -147,12 +147,8 @@ create_intface front_med = media[id]; fluid_side_shader = &interface_shader.front; break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } if (back_defined) { @@ -168,12 +164,8 @@ create_intface back_med = media[id]; fluid_side_shader = &interface_shader.back; break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } if (connect_defined) { @@ -321,12 +313,8 @@ create_intface interface_props->alpha = connect->d.sf_connect.specular_fraction; } break; - default: { - char msg[1024]; - snprintf(msg, sizeof(msg), "%s (%s: %d): Invalid type.\n", - __FUNCTION__, __FILE__, __LINE__); - FATAL(msg); - } + default: + FATAL("error:" STR(__FILE__) ":" STR(__LINE__)": Invalid type.\n"); } } diff --git a/src/stardis-output.c b/src/stardis-output.c @@ -7,7 +7,7 @@ #include <sdis.h> -#include<star/senc.h> +#include<star/senc3d.h> #include <rsys/math.h> #include <rsys/mem_allocator.h> @@ -537,20 +537,17 @@ create_edge_file_if FILE* obj = NULL; struct htable_vrtx_rank ranks; char structs_initialized = 0; - struct senc_descriptor* analyze = NULL; + struct senc3d_scene* senc3d_scn = NULL; struct darray_uint comps; struct darray_uint edges; unsigned cc_count = 0; unsigned *cc, *ee, uimax = UINT_MAX; - res = sdis_scene_get_analysis(scn, &analyze); - if (res != RES_OK) goto error; - res = sdis_scene_release_analysis(scn); - if (res != RES_OK) goto error; - ASSERT(scn && allocator); - res = senc_descriptor_get_frontier_segments_count(analyze, &scount); + res = sdis_scene_get_senc3d_scene(scn, &senc3d_scn); + if (res != RES_OK) goto error; + res = senc3d_scene_get_frontier_segments_count(senc3d_scn, &scount); if (res != RES_OK) goto error; if (scount == 0) @@ -568,7 +565,7 @@ create_edge_file_if vcount = 0; FOR_EACH(i, 0, scount) { unsigned v, edge[2], rk[2]; - res = senc_descriptor_get_frontier_segment(analyze, i, edge); + res = senc3d_scene_get_frontier_segment(senc3d_scn, i, edge); if (res != RES_OK) goto error; FOR_EACH(v, 0, 2) { unsigned* p_rank; @@ -617,13 +614,13 @@ create_edge_file_if * (same numbering scheme for all components) */ FOR_EACH(v, 0, vcount) { double coord[3]; - res = senc_descriptor_get_global_vertex(analyze, ee[v], coord); + res = senc3d_scene_get_vertex(senc3d_scn, ee[v], coord); if (res != RES_OK) goto error; fprintf(obj, "v %f %f %f\n", SPLIT3(coord)); } FOR_EACH(i, 0, scount) { unsigned edge[2], new_ranks[2]; - res = senc_descriptor_get_frontier_segment(analyze, i, edge); + res = senc3d_scene_get_frontier_segment(senc3d_scn, i, edge); if (res != RES_OK) goto error; ASSERT(cc[edge[0]] == cc[edge[1]]); if (cc[edge[0]] != comp) @@ -644,7 +641,7 @@ create_edge_file_if end: if (obj) fclose(obj); - if (analyze) senc_descriptor_ref_put(analyze); + if (senc3d_scn) senc3d_scene_ref_put(senc3d_scn); if (structs_initialized) { htable_vrtx_rank_release(&ranks); darray_uint_release(&comps); diff --git a/src/stardis-solid.c b/src/stardis-solid.c @@ -83,13 +83,14 @@ solid_get_temperature if (solid_props->t_init) return te_eval(solid_props->t_init, vtx); /* Must have had t_init defined: error! */ - if (solid_props->name[0]) - snprintf(msg, sizeof(msg), + if (solid_props->name[0]) { + fprintf(stderr, "solid_get_temperature: getting undefined Tinit (solid '%s')\n", solid_props->name); - else - snprintf(msg, sizeof(msg), "solid_get_temperature: getting undefined Tinit\n"); - FATAL(msg); + ASSERT(0); + abort(); + } else + FATAL("solid_get_temperature: getting undefined Tinit\n"); } static double