commit b341a4f429199be36aefd8757e98ab15751a7bf4 parent ab6b651549100f912b4a7c4d1bdf41c613559cf5 Author: Christophe Coustet <christophe.coustet@meso-star.com> Date: Thu, 30 Apr 2020 16:34:04 +0200 Merge branch 'new_senc_api' into develop Diffstat:
24 files changed, 256 insertions(+), 301 deletions(-)
diff --git a/README.md b/README.md @@ -17,7 +17,7 @@ It also depends on the [OpenMP](http://www.openmp.org) 2.0 specification to parallelize its computations. -First ensure that CMake and a compiler that implements the OpenMP 1.2 +First ensure that CMake and a C compiler that implements the OpenMP 2.0 specification are installed on your system. Then install the RCMake package as well as all the aforementioned prerequisites. Finally generate the project from the `cmake/CMakeLists.txt` file by appending to the `CMAKE_PREFIX_PATH` diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -25,15 +25,15 @@ option(NO_TEST "Do not build tests" OFF) CMAKE_DEPENDENT_OPTION(ALL_TESTS "Perform basic and advanced tests" OFF "NOT NO_TEST" OFF) -################################################################################ +############################################################################### # Check dependencies -################################################################################ +############################################################################### find_package(RCMake 0.4 REQUIRED) find_package(Star2D 0.3.1 REQUIRED) find_package(Star3D 0.6.2 REQUIRED) find_package(StarSP 0.8 REQUIRED) -find_package(StarEnc 0.4.2 REQUIRED) find_package(StarEnc2D 0.4.2 REQUIRED) +find_package(StarEnc3D 0.4.2 REQUIRED) find_package(RSys 0.8.1 REQUIRED) find_package(OpenMP 2.0 REQUIRED) @@ -45,15 +45,16 @@ include_directories( ${Star2D_INCLUDE_DIR} ${Star3D_INCLUDE_DIR} ${StarSP_INCLUDE_DIR} - ${StarEnc_INCLUDE_DIR} ${StarEnc2D_INCLUDE_DIR} + ${StarEnc3D_INCLUDE_DIR} ${RSys_INCLUDE_DIR}) -rcmake_append_runtime_dirs(_runtime_dirs RSys Star3D StarSP StarEnc StarEnc2D) +rcmake_append_runtime_dirs(_runtime_dirs + RSys Star2D Star3D StarSP StarEnc2D StarEnc3D) -################################################################################ +############################################################################### # Configure and define targets -################################################################################ +############################################################################### set(VERSION_MAJOR 0) set(VERSION_MINOR 8) set(VERSION_PATCH 2) @@ -115,7 +116,8 @@ if(MSVC) ### disable verbose warnings: # warning C4127: conditional expression is constant set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127") - # warning C4204: nonstandard extension used : non-constant aggregate initializer + # warning C4204: + # nonstandard extension used : non-constant aggregate initializer set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4204") # warning C4938: Floating point reduction variable may cause inconsistent # results under /fp:strict or #pragma fenv_access @@ -126,7 +128,8 @@ add_library(sdis SHARED ${SDIS_FILES_SRC} ${SDIS_FILES_INC} ${SDIS_FILES_INC_API}) -target_link_libraries(sdis RSys Star2D Star3D StarSP StarEnc StarEnc2D ${MATH_LIB}) +target_link_libraries(sdis + RSys Star2D Star3D StarSP StarEnc2D StarEnc3D ${MATH_LIB}) set_target_properties(sdis PROPERTIES DEFINE_SYMBOL SDIS_SHARED_BUILD @@ -141,9 +144,9 @@ endif() rcmake_setup_devel(sdis Stardis ${VERSION} sdis_version.h) -################################################################################ +############################################################################### # Add tests -################################################################################ +############################################################################### if(NOT NO_TEST) find_package(Star3DUT REQUIRED 0.2.0) @@ -209,11 +212,14 @@ if(NOT NO_TEST) target_link_libraries(test_sdis_solve_probe3_2d ${MATH_LIB}) target_link_libraries(test_sdis_solve_camera Star3DUT) + + rcmake_copy_runtime_libraries(test_sdis_solid_random_walk_robustness) + endif() -################################################################################ +############################################################################### # Define output & install directories -################################################################################ +############################################################################### install(TARGETS sdis ARCHIVE DESTINATION bin LIBRARY DESTINATION lib diff --git a/src/sdis.h b/src/sdis.h @@ -47,8 +47,8 @@ /* Forward declaration of external opaque data types */ struct logger; struct mem_allocator; -struct senc2d_descriptor; -struct senc_descriptor; +struct senc2d_scene; +struct senc3d_scene; /* Forward declaration of the Stardis opaque data types. These data types are * ref counted. Once created the caller implicitly owns the created data, i.e. @@ -106,9 +106,9 @@ enum sdis_heat_vertex_type { }; enum sdis_heat_path_flag { - SDIS_HEAT_PATH_SUCCEED = BIT(0), - SDIS_HEAT_PATH_FAILED = BIT(1), - SDIS_HEAT_PATH_ALL = SDIS_HEAT_PATH_SUCCEED | SDIS_HEAT_PATH_FAILED, + SDIS_HEAT_PATH_SUCCESS = BIT(0), + SDIS_HEAT_PATH_FAILURE = BIT(1), + SDIS_HEAT_PATH_ALL = SDIS_HEAT_PATH_SUCCESS | SDIS_HEAT_PATH_FAILURE, SDIS_HEAT_PATH_NONE = 0 }; @@ -525,6 +525,9 @@ sdis_interface_get_id * references an absolute 3D position. The physical properties of an interface * is defined by the interface of the triangle. * + * No duplicate is allowed, either vertex or triangle. No degenerated triangle + * is allowed. + * * Note that each triangle has 2 sides: a front and a back side. By convention, * the front side of a triangle is the side where its vertices are clock wise * ordered. The back side of a triangle is the exact opposite: it is the side @@ -537,9 +540,9 @@ sdis_scene_create (struct sdis_device* dev, const size_t ntris, /* #triangles */ void (*indices) /* Retrieve the indices toward the vertices of `itri' */ - (const size_t itri, size_t ids[3], void*), + (const size_t itri, size_t ids[3], void* ctx), void (*interf) /* Get the interface of the triangle `itri' */ - (const size_t itri, struct sdis_interface** bound, void*), + (const size_t itri, struct sdis_interface** bound, void* ctx), const size_t nverts, /* #vertices */ void (*position) /* Retrieve the position of the vertex `ivert' */ (const size_t ivert, double pos[3], void* ctx), @@ -551,6 +554,9 @@ sdis_scene_create * references an absolute 2D position. The physical properties of an interface * is defined by the interface of the segment. * + * No duplicate is allowed, either vertex or segment. No degenerated segment is + * allowed. + * * Note that each segment has 2 sides: a front and a back side. By convention, * the front side of a segment is the side where its vertices are clock wise * ordered. The back side of a segment is the exact opposite: it is the side @@ -563,9 +569,9 @@ sdis_scene_2d_create (struct sdis_device* dev, const size_t nsegs, /* #segments */ void (*indices) /* Retrieve the indices toward the vertices of `iseg' */ - (const size_t iseg, size_t ids[2], void*), + (const size_t iseg, size_t ids[2], void* ctx), void (*interf) /* Get the interface of the segment `iseg' */ - (const size_t iseg, struct sdis_interface** bound, void*), + (const size_t iseg, struct sdis_interface** bound, void* ctx), const size_t nverts, /* #vertices */ void (*position) /* Retrieve the position of the vertex `ivert' */ (const size_t ivert, double pos[2], void* ctx), @@ -630,23 +636,17 @@ sdis_scene_boundary_project_position const double pos[3], double uv[]); -/* Get the descriptor of the 3D scene's enclosures */ +/* Get the 2D scene's enclosures. Only defined for a 2D scene. */ SDIS_API res_T -sdis_scene_get_analysis +sdis_scene_get_senc2d_scene (struct sdis_scene* scn, - struct senc_descriptor** descriptor); + struct senc2d_scene** senc2d_scn); -/* Get the descriptor of the 2D scene's enclosures */ +/* Get the 3D scene's enclosures. Only defined for a 3D scene. */ SDIS_API res_T -sdis_scene_2d_get_analysis +sdis_scene_get_senc3d_scene (struct sdis_scene* scn, - struct senc2d_descriptor** descriptor); - -/* Release the descriptor of the scene's enclosures; subsequent attempts to get - * it will fail. */ -SDIS_API res_T -sdis_scene_release_analysis - (struct sdis_scene* scn); + struct senc3d_scene** senc3d_scn); SDIS_API res_T sdis_scene_get_dimension diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -60,7 +60,6 @@ static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__; /* Star-XD macros generic to SDIS_XD_DIMENSION */ #define sXd(Name) CONCAT(CONCAT(CONCAT(s, DIM), d_), Name) -#define sXd_dev CONCAT(CONCAT(s, DIM), d) #define SXD_HIT_NONE CONCAT(CONCAT(S,DIM), D_HIT_NONE) #define SXD_HIT_NULL CONCAT(CONCAT(S,DIM), D_HIT_NULL) #define SXD_HIT_NULL__ CONCAT(CONCAT(S, DIM), D_HIT_NULL__) @@ -70,6 +69,7 @@ static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__; #define SXD CONCAT(CONCAT(S, DIM), D) #define SXD_FLOAT2 CONCAT(CONCAT(S, DIM), D_FLOAT2) #define SXD_FLOAT3 CONCAT(CONCAT(S, DIM), D_FLOAT3) +#define SXD_FLOATX CONCAT(CONCAT(CONCAT(S,DIM), D_FLOAT), DIM) #define SXD_SAMPLE CONCAT(CONCAT(S, DIM), D_SAMPLE) /* Vector macros generic to SDIS_XD_DIMENSION */ diff --git a/src/sdis_Xd_end.h b/src/sdis_Xd_end.h @@ -21,7 +21,6 @@ #undef DIM #undef sXd -#undef sXd_dev #undef SXD_HIT_NONE #undef SXD_HIT_NULL #undef SXD_HIT_NULL__ @@ -31,6 +30,7 @@ #undef SXD #undef SXD_FLOAT2 #undef SXD_FLOAT3 +#undef SXD_FLOATX #undef SXD_SAMPLE #undef dX diff --git a/src/sdis_device.c b/src/sdis_device.c @@ -48,8 +48,8 @@ device_release(ref_T* ref) struct sdis_device* dev; ASSERT(ref); dev = CONTAINER_OF(ref, struct sdis_device, ref); - if(dev->s2d) S2D(device_ref_put(dev->s2d)); - if(dev->s3d) S3D(device_ref_put(dev->s3d)); + if(dev->s2d_dev) S2D(device_ref_put(dev->s2d_dev)); + if(dev->s3d_dev) S3D(device_ref_put(dev->s3d_dev)); ASSERT(flist_name_is_empty(&dev->interfaces_names)); ASSERT(flist_name_is_empty(&dev->media_names)); flist_name_release(&dev->interfaces_names); @@ -98,13 +98,13 @@ sdis_device_create flist_name_init(allocator, &dev->interfaces_names); flist_name_init(allocator, &dev->media_names); - res = s2d_device_create(log, allocator, 0, &dev->s2d); + res = s2d_device_create(log, allocator, 0, &dev->s2d_dev); if(res != RES_OK) { log_err(dev, "%s: could not create the Star-2D device on Stardis.\n", FUNC_NAME); } - res = s3d_device_create(log, allocator, 0, &dev->s3d); + res = s3d_device_create(log, allocator, 0, &dev->s3d_dev); if(res != RES_OK) { log_err(dev, "%s: could not create the Star-3D device on Stardis.\n", FUNC_NAME); diff --git a/src/sdis_device_c.h b/src/sdis_device_c.h @@ -35,8 +35,8 @@ struct sdis_device { struct flist_name interfaces_names; struct flist_name media_names; - struct s2d_device* s2d; - struct s3d_device* s3d; + struct s2d_device* s2d_dev; + struct s3d_device* s3d_dev; ref_T ref; }; diff --git a/src/sdis_heat_path_boundary_Xd.h b/src/sdis_heat_path_boundary_Xd.h @@ -114,9 +114,9 @@ XD(move_away_primitive_boundaries) float min_dst, max_dst; float cos_a1, cos_a2; float len; - int imax; - int imin; - int imid; + int imax = 0; + int imin = 0; + int imid = 0; int i; ASSERT(rwalk && delta > 0 && !S3D_HIT_NONE(&rwalk->hit)); @@ -300,7 +300,7 @@ XD(select_reinjection_dir) } while(dst0 == -1 && dst1 == -1 && ++iattempt < MAX_ATTEMPTS); if(dst0 == -1 && dst1 == -1) { /* No valid reinjection */ - log_err(scn->dev, "%s: no valid reinjection direction at {%g, %g, %g}.\n", + log_warn(scn->dev, "%s: no valid reinjection direction at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP_IRRECOVERABLE; goto error; @@ -482,7 +482,7 @@ XD(solid_solid_boundary_path) float dir0[DIM], dir1[DIM], dir2[DIM], dir3[DIM]; float dir_front[DIM], dir_back[DIM]; float* dir; - float reinject_dst_front, reinject_dst_back; + float reinject_dst_front = 0, reinject_dst_back = 0; float reinject_dst; /* In 2D it is useless to try to resample a reinjection direction since there * is only one possible direction */ @@ -554,8 +554,8 @@ XD(solid_solid_boundary_path) /* Could not find a valid reinjection */ if(iattempt >= MAX_ATTEMPTS) { *rwalk = rwalk_saved; - log_err(scn->dev, - "%s: could not find a valid soid/solid reinjection at {%g, %g, %g}.\n", + log_warn(scn->dev, + "%s: could not find a valid solid/solid reinjection at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP_IRRECOVERABLE; goto error; @@ -718,7 +718,7 @@ XD(solid_fluid_boundary_path) /* Could not find a valid reinjecton */ if(iattempt >= MAX_ATTEMPTS) { *rwalk = rwalk_saved; - log_err(scn->dev, + log_warn(scn->dev, "%s: could not find a valid solid/fluid reinjection at {%g, %g %g}.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP_IRRECOVERABLE; @@ -867,7 +867,7 @@ XD(solid_boundary_with_flux_path) /* Could not find a valid reinjecton */ if(iattempt >= MAX_ATTEMPTS) { *rwalk = rwalk_saved; - log_err(scn->dev, + log_warn(scn->dev, "%s: could not find a valid solid/fluid with flux reinjection " "at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP_IRRECOVERABLE; diff --git a/src/sdis_heat_path_conductive_Xd.h b/src/sdis_heat_path_conductive_Xd.h @@ -158,11 +158,11 @@ XD(sample_next_step_robust) if(current_mdm != mdm) { #if 0 #if DIM == 2 - log_err(scn->dev, + log_warn(scn->dev, "%s: inconsistent medium during the solid random walk at {%g, %g}.\n", FUNC_NAME, SPLIT2(pos)); #else - log_err(scn->dev, + log_warn(scn->dev, "%s: inconsistent medium during the solid random walk at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(pos)); #endif @@ -173,11 +173,11 @@ XD(sample_next_step_robust) /* Handle error */ if(iattempt >= MAX_ATTEMPTS) { #if DIM == 2 - log_err(scn->dev, + log_warn(scn->dev, "%s: could not find a next valid conductive step at {%g, %g}.\n", FUNC_NAME, SPLIT2(pos)); #else - log_err(scn->dev, + log_warn(scn->dev, "%s: could not find a next valid conductive step at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(pos)); #endif @@ -218,7 +218,7 @@ XD(conductive_path) /* Check the random walk consistency */ res = scene_get_medium_in_closed_boundaries(scn, rwalk->vtx.P, &mdm); if(res != RES_OK || mdm != rwalk->mdm) { - log_err(scn->dev, "%s: invalid solid random walk. " + log_warn(scn->dev, "%s: invalid solid random walk. " "Unexpected medium at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP_IRRECOVERABLE; goto error; @@ -370,7 +370,7 @@ XD(conductive_path) /* The initial condition should have been reached */ log_err(scn->dev, "%s: undefined initial condition. " - "The time is %f but the temperature remains unknown.\n", + "The time is %g but the temperature remains unknown.\n", FUNC_NAME, t0); res = RES_BAD_OP; goto error; diff --git a/src/sdis_heat_path_convective_Xd.h b/src/sdis_heat_path_convective_Xd.h @@ -86,6 +86,7 @@ XD(convective_path) double cp; /* Calorific capacity */ double tmp; double r; + int path_started_in_fluid; #if SDIS_XD_DIMENSION == 2 float st; #else @@ -112,7 +113,8 @@ XD(convective_path) goto exit; } - if(SXD_HIT_NONE(&rwalk->hit)) { /* The path begins in the fluid */ + path_started_in_fluid = SXD_HIT_NONE(&rwalk->hit); + if(path_started_in_fluid) { /* The path begins in the fluid */ const float range[2] = {0, FLT_MAX}; float dir[DIM] = {0}; float org[DIM]; @@ -123,7 +125,6 @@ XD(convective_path) /* Init the path hit field required to define the current enclosure and * fetch the interface data */ SXD(scene_view_trace_ray(scn->sXd(view), org, dir, range, NULL, &rwalk->hit)); - rwalk->hit_side = fX(dot)(rwalk->hit.normal, dir) < 0 ? SDIS_FRONT : SDIS_BACK; if(SXD_HIT_NONE(&rwalk->hit)) { log_err(scn->dev, @@ -132,6 +133,8 @@ XD(convective_path) res = RES_BAD_OP; goto error; } + + rwalk->hit_side = fX(dot)(rwalk->hit.normal, dir) < 0 ? SDIS_FRONT : SDIS_BACK; } /* Fetch the current interface and its associated enclosures */ @@ -166,7 +169,7 @@ XD(convective_path) * is the initial condition. */ if(enc->hc_upper_bound == 0) { /* Cannot be in the fluid without starting there. */ - ASSERT(SXD_HIT_NONE(&rwalk->hit)); + ASSERT(path_started_in_fluid); if(ctx->green_path) { log_err(scn->dev, @@ -185,11 +188,11 @@ XD(convective_path) goto exit; } - /* At t=0, the initial condition should have been reached. */ + /* At t=t0, the initial condition should have been reached. */ log_err(scn->dev, "%s: undefined initial condition. " - "Time is 0 but the temperature remains unknown.\n", - FUNC_NAME); + "Time is %g but the temperature remains unknown.\n", + FUNC_NAME, rwalk->vtx.time); res = RES_BAD_OP; goto error; } diff --git a/src/sdis_heat_path_radiative_Xd.h b/src/sdis_heat_path_radiative_Xd.h @@ -167,7 +167,7 @@ XD(trace_radiative_path) if(outside && chk_mdm->type == SDIS_FLUID) { rwalk->mdm = chk_mdm; } else { - log_err(scn->dev, "%s: inconsistent medium definition at `%g %g %g'.\n", + log_warn(scn->dev, "%s: inconsistent medium definition at `%g %g %g'.\n", FUNC_NAME, SPLIT3(rwalk->vtx.P)); res = RES_BAD_OP; goto error; diff --git a/src/sdis_realisation_Xd.h b/src/sdis_realisation_Xd.h @@ -174,7 +174,7 @@ XD(probe_realisation) /* The initial condition should have been reached */ log_err(scn->dev, "%s: undefined initial condition. " - "The time is %f but the temperature remains unknown.\n", + "The time is %g but the temperature remains unknown.\n", FUNC_NAME, t0); res = RES_BAD_OP; goto error; diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -104,8 +104,8 @@ scene_release(ref_T * ref) htable_d_release(&scn->tmp_hc_ub); if(scn->s2d_view) S2D(scene_view_ref_put(scn->s2d_view)); if(scn->s3d_view) S3D(scene_view_ref_put(scn->s3d_view)); - if(scn->senc_descriptor) SENC(descriptor_ref_put(scn->senc_descriptor)); - if(scn->senc2d_descriptor) SENC2D(descriptor_ref_put(scn->senc2d_descriptor)); + if(scn->senc2d_scn) SENC2D(scene_ref_put(scn->senc2d_scn)); + if(scn->senc3d_scn) SENC3D(scene_ref_put(scn->senc3d_scn)); MEM_RM(dev->allocator, scn); SDIS(device_ref_put(dev)); } @@ -132,8 +132,8 @@ res_T sdis_scene_2d_create (struct sdis_device* dev, const size_t nsegs, /* #segments */ - void (*indices)(const size_t itri, size_t ids[2], void*), - void (*interf)(const size_t itri, struct sdis_interface** bound, void*), + void (*indices)(const size_t iseg, size_t ids[2], void*), + void (*interf)(const size_t iseg, struct sdis_interface** bound, void*), const size_t nverts, /* #vertices */ void (*position)(const size_t ivert, double pos[2], void* ctx), void* ctx, @@ -276,37 +276,26 @@ sdis_scene_boundary_project_position } res_T -sdis_scene_2d_get_analysis +sdis_scene_get_senc2d_scene (struct sdis_scene* scn, - struct senc2d_descriptor** descriptor) + struct senc2d_scene** senc2d_scn) { - if(!scn || !descriptor) return RES_BAD_ARG; - if(!scn->senc2d_descriptor) return RES_BAD_ARG; /* Scene is 3D */ - SENC2D(descriptor_ref_get(scn->senc2d_descriptor)); - *descriptor = scn->senc2d_descriptor; + if(!scn || !senc2d_scn) return RES_BAD_ARG; + if(!scn->senc2d_scn) return RES_BAD_ARG; /* Scene is 3D */ + SENC2D(scene_ref_get(scn->senc2d_scn)); + *senc2d_scn = scn->senc2d_scn; return RES_OK; } res_T -sdis_scene_get_analysis +sdis_scene_get_senc3d_scene (struct sdis_scene* scn, - struct senc_descriptor** descriptor) + struct senc3d_scene** senc3d_scn) { - if(!scn || !descriptor) return RES_BAD_ARG; - if(!scn->senc_descriptor) return RES_BAD_ARG; /* Scene is 2D */ - SENC(descriptor_ref_get(scn->senc_descriptor)); - *descriptor = scn->senc_descriptor; - return RES_OK; -} - -res_T -sdis_scene_release_analysis(struct sdis_scene* scn) -{ - if(!scn) return RES_BAD_ARG; - if(scn->senc2d_descriptor) SENC2D(descriptor_ref_put(scn->senc2d_descriptor)); - if(scn->senc_descriptor) SENC(descriptor_ref_put(scn->senc_descriptor)); - scn->senc_descriptor = NULL; - scn->senc2d_descriptor = NULL; + if(!scn || !senc3d_scn) return RES_BAD_ARG; + if(!scn->senc3d_scn) return RES_BAD_ARG; /* Scene is 2D */ + SENC3D(scene_ref_get(scn->senc3d_scn)); + *senc3d_scn = scn->senc3d_scn; return RES_OK; } diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -118,11 +118,12 @@ clear_properties(struct sdis_scene* scn) #include <limits.h> /* Check the submitted dimension and include its specific headers */ +#define SENCXD_DIM SDIS_SCENE_DIMENSION #if (SDIS_SCENE_DIMENSION == 2) - #include <star/senc2d.h> + #include <star/sencX2d.h> #include <star/s2d.h> #elif (SDIS_SCENE_DIMENSION == 3) - #include <star/senc.h> + #include <star/sencX3d.h> #include <star/s3d.h> #else #error "Invalid SDIS_SCENE_DIMENSION value." @@ -131,15 +132,6 @@ clear_properties(struct sdis_scene* scn) /* Syntactic sugar */ #define DIM SDIS_SCENE_DIMENSION -/* Star-Enc macros generic to the SDIS_SCENE_DIMENSION */ -#if DIM == 2 - #define sencXd(Name) CONCAT(senc2d_, Name) - #define SENCXD SENC2D -#else - #define sencXd(Name) CONCAT(senc_, Name) - #define SENCXD SENC -#endif - /* Star-XD macros generic to SDIS_SCENE_DIMENSION */ #define sXd(Name) CONCAT(CONCAT(CONCAT(s, DIM), d_), Name) #define SXD CONCAT(CONCAT(S, DIM), D) @@ -150,6 +142,7 @@ clear_properties(struct sdis_scene* scn) #define SXD_GET_PRIMITIVE CONCAT(CONCAT(S,DIM), D_GET_PRIMITIVE) #define SXD_HIT_NONE CONCAT(CONCAT(S,DIM), D_HIT_NONE) #define SXD_PRIMITIVE_EQ CONCAT(CONCAT(S,DIM), D_PRIMITIVE_EQ) +#define SXD_FLOATX CONCAT(CONCAT(CONCAT(S,DIM), D_FLOAT), DIM) /* Vector macros generic to SDIS_SCENE_DIMENSION */ #define fX(Func) CONCAT(CONCAT(CONCAT(f, DIM), _), Func) @@ -484,24 +477,20 @@ XD(geometry_position)(const unsigned ivert, double out_pos[DIM], void* data) /* Retrieve the indices of a primitive of a Star-EncXD descriptor */ static void -XD(descriptor_indices)(const unsigned iprim, unsigned ids[DIM], void* data) +XD(scene_indices)(const unsigned iprim, unsigned ids[DIM], void* data) { - struct sencXd(descriptor)* desc = data; -#if DIM == 2 - SENCXD(descriptor_get_global_segment(desc, iprim, ids)); -#else - SENCXD(descriptor_get_global_triangle(desc, iprim, ids)); -#endif + struct sencXd(scene)* scn = data; + SENCXD(scene_get_primitive(scn, iprim, ids)); } /* Retrieve the coordinates of a vertex of a Star-EncXD descriptor */ static void -XD(descriptor_position)(const unsigned ivert, float out_pos[DIM], void* data) +XD(scene_position)(const unsigned ivert, float out_pos[DIM], void* data) { - struct sencXd(descriptor)* desc = data; + struct sencXd(scene)* scn = data; double pos[3]; int i; - SENCXD(descriptor_get_global_vertex(desc, ivert, pos)); + SENCXD(scene_get_vertex(scn, ivert, pos)); FOR_EACH(i, 0, DIM) out_pos[i] = (float)pos[i]; } @@ -510,11 +499,7 @@ static void XD(enclosure_indices)(const unsigned iprim, unsigned ids[DIM], void* data) { struct sencXd(enclosure)* enc = data; -#if DIM == 2 - SENCXD(enclosure_get_segment(enc, iprim, ids)); -#else - SENCXD(enclosure_get_triangle(enc, iprim, ids)); -#endif + SENCXD(enclosure_get_primitive(enc, iprim, ids)); } /* Retrieve the coordinates of a vertex of a Star-EncXD encolsure */ @@ -542,51 +527,37 @@ XD(run_analyze) const size_t nverts, /* #vertices */ void (*position)(const size_t ivert, double pos[], void*), void* ctx, - struct sencXd(descriptor)** out_desc) + struct sencXd(scene)** out_scn) { struct geometry geom; struct sencXd(device)* senc = NULL; - struct sencXd(scene)* senc_scn = NULL; - struct sencXd(descriptor)* desc = NULL; + struct sencXd(scene)* senc3d_scn = NULL; res_T res = RES_OK; - ASSERT(scn && nprims && indices && interf && nverts && position && out_desc); + ASSERT(scn && nprims && indices && interf && nverts && position && out_scn); res = sencXd(device_create)(scn->dev->logger, scn->dev->allocator, scn->dev->nthreads, scn->dev->verbose, &senc); if(res != RES_OK) goto error; - res = sencXd(scene_create)(senc, -#if DIM == 2 - SENC2D_CONVENTION_NORMAL_BACK | SENC2D_CONVENTION_NORMAL_OUTSIDE, -#else - SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_OUTSIDE, -#endif - &senc_scn); - if(res != RES_OK) goto error; - /* Setup the geometry data */ geom.indices = indices; geom.interf = interf; geom.position = position; geom.data = ctx; - res = sencXd(scene_add_geometry) - (senc_scn, (unsigned)nprims, XD(geometry_indices), geometry_media, - (unsigned)nverts, XD(geometry_position), NULL, NULL, &geom); - if(res != RES_OK) goto error; - - /* Launch the scene analyze */ - res = sencXd(scene_analyze)(senc_scn, &desc); + res = sencXd(scene_create)(senc, + SENCXD_(CONVENTION_NORMAL_BACK) | SENCXD_(CONVENTION_NORMAL_OUTSIDE), + (unsigned)nprims, XD(geometry_indices), geometry_media, + (unsigned)nverts, XD(geometry_position), &geom, &senc3d_scn); if(res != RES_OK) goto error; exit: if(senc) SENCXD(device_ref_put(senc)); - if(senc_scn) SENCXD(scene_ref_put(senc_scn)); - if(out_desc) *out_desc = desc; + if(out_scn) *out_scn = senc3d_scn; return res; error: - if(desc) { - SENCXD(descriptor_ref_put(desc)); - desc = NULL; + if(senc3d_scn) { + SENCXD(scene_ref_put(senc3d_scn)); + senc3d_scn = NULL; } goto exit; @@ -598,45 +569,31 @@ error: static res_T XD(setup_properties) (struct sdis_scene* scn, - struct sencXd(descriptor)* desc, + struct sencXd(scene)* senc3d_scn, void (*interf)(const size_t itri, struct sdis_interface**, void*), void* ctx) { unsigned iprim, nprims; res_T res = RES_OK; - ASSERT(scn && interf); + ASSERT(scn && senc3d_scn && interf); clear_properties(scn); -#if DIM == 2 - SENCXD(descriptor_get_global_segments_count(desc, &nprims)); -#else - SENCXD(descriptor_get_global_triangles_count(desc, &nprims)); -#endif + SENCXD(scene_get_primitives_count(senc3d_scn, &nprims)); FOR_EACH(iprim, 0, nprims) { struct prim_prop* prim_prop; struct sdis_interface* itface; unsigned enclosures[2]; - unsigned iprim_adjusted; /* Primitive id in user space */ unsigned id; int i; double* enc_upper_bound; size_t ninterfaces; -#if DIM == 2 - /* Retrieve the segment id in user space */ - SENCXD(descriptor_get_global_segment_global_id(desc, iprim, &iprim_adjusted)); - /* Fetch the enclosures that the segment splits */ - SENCXD(descriptor_get_global_segment_enclosures(desc, iprim, enclosures)); -#else - /* Retrieve the triangle id in user space */ - SENCXD(descriptor_get_global_triangle_global_id(desc, iprim, &iprim_adjusted)); - /* Fetch the enclosures that the triangle splits */ - SENCXD(descriptor_get_global_triangle_enclosures(desc, iprim, enclosures)); -#endif + /* Fetch the enclosures that the segment/triangle splits */ + SENCXD(scene_get_primitive_enclosures(senc3d_scn, iprim, enclosures)); /* Fetch the interface of the primitive */ - interf(iprim_adjusted, &itface, ctx); + interf(iprim, &itface, ctx); /* Check that the interface is already registered against the scene */ id = interface_get_id(itface); @@ -689,7 +646,7 @@ error: /* Build the Star-XD scene view of the whole scene */ static res_T -XD(setup_scene_geometry)(struct sdis_scene* scn, struct sencXd(descriptor)* desc) +XD(setup_scene_geometry)(struct sdis_scene* scn, struct sencXd(scene)* senc3d_scn) { struct sXd(device)* sXd_dev = NULL; struct sXd(shape)* sXd_shape = NULL; @@ -697,36 +654,30 @@ XD(setup_scene_geometry)(struct sdis_scene* scn, struct sencXd(descriptor)* desc struct sXd(vertex_data) vdata = SXD_VERTEX_DATA_NULL; unsigned nprims, nverts; res_T res = RES_OK; - ASSERT(scn && desc); + ASSERT(scn && senc3d_scn); - SENCXD(descriptor_get_global_vertices_count(desc, &nverts)); + SENCXD(scene_get_vertices_count(senc3d_scn, &nverts)); /* Setup the vertex data */ vdata.usage = SXD_POSITION; -#if DIM == 2 - vdata.type = S2D_FLOAT2; -#else - vdata.type = S3D_FLOAT3; -#endif - vdata.get = XD(descriptor_position); + vdata.type = SXD_FLOATX; + vdata.get = XD(scene_position); /* Create the Star-XD geometry of the whole scene */ #define CALL(Func) { if(RES_OK != (res = Func)) goto error; } (void)0 + sXd_dev = scn->dev->sXd(dev); + SENCXD(scene_get_primitives_count(senc3d_scn, &nprims)); #if DIM == 2 - sXd_dev = scn->dev->s2d; - SENCXD(descriptor_get_global_segments_count(desc, &nprims)); CALL(sXd(shape_create_line_segments)(sXd_dev, &sXd_shape)); CALL(sXd(line_segments_set_hit_filter_function)(sXd_shape, XD(hit_filter_function), NULL)); CALL(sXd(line_segments_setup_indexed_vertices)(sXd_shape, nprims, - XD(descriptor_indices), nverts, &vdata, 1, desc)); + XD(scene_indices), nverts, &vdata, 1, senc3d_scn)); #else - sXd_dev = scn->dev->s3d; - SENCXD(descriptor_get_global_triangles_count(desc, &nprims)); CALL(sXd(shape_create_mesh)(sXd_dev, &sXd_shape)); CALL(sXd(mesh_set_hit_filter_function)(sXd_shape, XD(hit_filter_function), NULL)); - CALL(sXd(mesh_setup_indexed_vertices)(sXd_shape, nprims, XD(descriptor_indices), - nverts, &vdata, 1, desc)); + CALL(sXd(mesh_setup_indexed_vertices)(sXd_shape, nprims, XD(scene_indices), + nverts, &vdata, 1, senc3d_scn)); #endif CALL(sXd(scene_create)(sXd_dev, &sXd_scn)); CALL(sXd(scene_attach_shape)(sXd_scn, sXd_shape)); @@ -757,24 +708,15 @@ XD(setup_enclosure_geometry)(struct sdis_scene* scn, struct sencXd(enclosure)* e float S, V; double* p_ub; unsigned iprim, nprims, nverts; -#if DIM == 2 - struct senc2d_enclosure_header header; -#else - struct senc_enclosure_header header; -#endif + struct sencXd(enclosure_header) header; res_T res = RES_OK; ASSERT(scn && enc); enclosure_init(scn->dev->allocator, &enc_dummy); SENCXD(enclosure_get_header(enc, &header)); -#if DIM == 2 - sXd_dev = scn->dev->s2d; - nprims = header.segment_count; -#else - sXd_dev = scn->dev->s3d; - nprims = header.triangle_count; -#endif + sXd_dev = scn->dev->sXd(dev); + nprims = header.primitives_count; nverts = header.vertices_count; /* Register the enclosure into the scene. Use a dummy data on their @@ -791,11 +733,7 @@ XD(setup_enclosure_geometry)(struct sdis_scene* scn, struct sencXd(enclosure)* e /* Setup the vertex data */ vdata.usage = SXD_POSITION; -#if DIM == 2 - vdata.type = S2D_FLOAT2; -#else - vdata.type = S3D_FLOAT3; -#endif + vdata.type = SXD_FLOATX; vdata.get = XD(enclosure_position); /* Create the Star-XD geometry */ @@ -836,13 +774,8 @@ XD(setup_enclosure_geometry)(struct sdis_scene* scn, struct sencXd(enclosure)* e if(res != RES_OK) goto error; FOR_EACH(iprim, 0, nprims) { enum sencXd(side) side; -#if DIM == 2 - senc2d_enclosure_get_segment_global_id - (enc, iprim, darray_uint_data_get(&enc_data->local2global)+iprim, &side); -#else - senc_enclosure_get_triangle_global_id - (enc, iprim, darray_uint_data_get(&enc_data->local2global)+iprim, &side); -#endif + SENCXD(enclosure_get_primitive_id + (enc, iprim, darray_uint_data_get(&enc_data->local2global)+iprim, &side)); } /* Setup the medium id of the enclosure */ @@ -861,25 +794,21 @@ error: /* Build the Star-XD scene view and define its associated data of the finite * fluid enclosures */ static res_T -XD(setup_enclosures)(struct sdis_scene* scn, struct sencXd(descriptor)* desc) +XD(setup_enclosures)(struct sdis_scene* scn, struct sencXd(scene)* senc3d_scn) { struct sencXd(enclosure)* enc = NULL; unsigned ienc, nencs; unsigned enclosed_medium; int outer_found = 0; res_T res = RES_OK; - ASSERT(scn && desc); + ASSERT(scn && senc3d_scn); (void)outer_found; - SENCXD(descriptor_get_enclosure_count(desc, &nencs)); + SENCXD(scene_get_enclosure_count(senc3d_scn, &nencs)); FOR_EACH(ienc, 0, nencs) { -#if DIM == 2 - struct senc2d_enclosure_header header; -#else - struct senc_enclosure_header header; -#endif + struct sencXd(enclosure_header) header; - SENCXD(descriptor_get_enclosure(desc, ienc, &enc)); + SENCXD(scene_get_enclosure(senc3d_scn, ienc, &enc)); SENCXD(enclosure_get_header(enc, &header)); if(header.is_infinite) { @@ -891,37 +820,37 @@ XD(setup_enclosures)(struct sdis_scene* scn, struct sencXd(descriptor)* desc) /* As paths don't go in infinite enclosures we can accept models are broken * there. But nowhere else. */ if(header.enclosed_media_count != 1 && !header.is_infinite) { -#ifndef NDEBUG /* Dump the problematic enclosure. */ double tmp[DIM]; unsigned indices[DIM]; unsigned i; log_warn(scn->dev, "# Found internal enclosure with %u materials:\n", header.enclosed_media_count); - #if DIM == 2 + FOR_EACH(i, 0, header.enclosed_media_count) { + unsigned imed; + const struct sdis_medium* med; + SENCXD(enclosure_get_medium(enc, i, &imed)); + med = darray_medium_cdata_get(&scn->media)[imed]; + log_warn(scn->dev, "# %u (%s)\n", + imed, (med->type == SDIS_SOLID ? "solid" : "fluid")); + } FOR_EACH(i, 0, header.vertices_count) { SENCXD(enclosure_get_vertex(enc, i, tmp)); + #if DIM == 2 log_warn(scn->dev, "v %g %g\n", SPLIT2(tmp)); - } - FOR_EACH(i, 0, header.segment_count) { - ASSERT(senc2d_enclosure_get_segment(enc, i, indices) == RES_OK); - log_warn(scn->dev, "f %u %u\n", indices[0]+1, indices[1]+1); - } #else - FOR_EACH(i, 0, header.vertices_count) { - SENCXD(enclosure_get_vertex(enc, i, tmp)); log_warn(scn->dev, "v %g %g %g\n", SPLIT3(tmp)); + #endif } - FOR_EACH(i, 0, header.triangle_count) { - ASSERT(senc_enclosure_get_triangle(enc, i, indices) == RES_OK); + FOR_EACH(i, 0, header.primitives_count) { + SENCXD(enclosure_get_primitive(enc, i, indices)); + #if DIM == 2 + log_warn(scn->dev, "f %u %u\n", indices[0]+1, indices[1]+1); + #else log_warn(scn->dev, "f %u %u %u\n", indices[0]+1, indices[1]+1, indices[2]+1); - } #endif -#else - log_warn(scn->dev, "Found internal enclosure with %u materials.\n", - header.enclosed_media_count); -#endif + } SENCXD(enclosure_ref_put(enc)); enc = NULL; res = RES_BAD_ARG; @@ -961,7 +890,7 @@ XD(scene_create) void* ctx, struct sdis_scene** out_scn) { - struct sencXd(descriptor)* desc = NULL; + struct sencXd(scene)* senc3d_scn = NULL; struct sdis_scene* scn = NULL; res_T res = RES_OK; @@ -988,38 +917,34 @@ XD(scene_create) htable_enclosure_init(dev->allocator, &scn->enclosures); htable_d_init(dev->allocator, &scn->tmp_hc_ub); - res = XD(run_analyze)(scn, nprims, indices, interf, nverts, position, ctx, &desc); + res = XD(run_analyze)(scn, nprims, indices, interf, nverts, position, ctx, &senc3d_scn); if(res != RES_OK) { log_err(dev, "%s: error during the scene analysis.\n", FUNC_NAME); goto error; } - res = XD(setup_properties)(scn, desc, interf, ctx); + res = XD(setup_properties)(scn, senc3d_scn, interf, ctx); if(res != RES_OK) { log_err(dev, "%s: could not setup the scene interfaces and their media.\n", FUNC_NAME); goto error; } - res = XD(setup_scene_geometry)(scn, desc); + res = XD(setup_scene_geometry)(scn, senc3d_scn); if(res != RES_OK) { log_err(dev, "%s: could not setup the scene geometry.\n", FUNC_NAME); goto error; } - res = XD(setup_enclosures)(scn, desc); + res = XD(setup_enclosures)(scn, senc3d_scn); if(res != RES_OK) { log_err(dev, "%s: could not setup the enclosures.\n", FUNC_NAME); goto error; } -#if DIM==2 - scn->senc2d_descriptor = desc; -#else - scn->senc_descriptor = desc; -#endif + scn->sencXd(scn) = senc3d_scn; exit: if(out_scn) *out_scn = scn; return res; error: - if(desc) SENCXD(descriptor_ref_put(desc)); + if(senc3d_scn) SENCXD(scene_ref_put(senc3d_scn)); if(scn) { SDIS(scene_ref_put(scn)); scn = NULL; @@ -1237,10 +1162,14 @@ error: goto exit; } +#if (SDIS_SCENE_DIMENSION == 2) +#include <star/sencX2d_undefs.h> +#else /* SDIS_SCENE_DIMENSION == 3 */ +#include <star/sencX3d_undefs.h> +#endif + #undef SDIS_SCENE_DIMENSION #undef DIM -#undef sencXd -#undef SENCXD #undef sXd #undef SXD #undef SXD_VERTEX_DATA_NULL @@ -1251,6 +1180,7 @@ error: #undef SXD_GET_PRIMITIVE #undef SXD_HIT_NONE #undef SXD_PRIMITIVE_EQ +#undef SXD_FLOATX #undef fX #undef fX_set_dX #undef fXX_mulfX diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h @@ -200,8 +200,8 @@ struct sdis_scene { struct darray_prim_prop prim_props; /* Per primitive properties */ struct s2d_scene_view* s2d_view; struct s3d_scene_view* s3d_view; - struct senc_descriptor* senc_descriptor; - struct senc2d_descriptor* senc2d_descriptor; + struct senc2d_scene* senc2d_scn; + struct senc3d_scene* senc3d_scn; struct htable_d tmp_hc_ub; /* Map an enclosure id to its hc upper bound */ struct htable_enclosure enclosures; /* Map an enclosure id to its data */ diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -125,8 +125,8 @@ solve_pixel if(pheat_path) { pheat_path->status = res_simul == RES_OK - ? SDIS_HEAT_PATH_SUCCEED - : SDIS_HEAT_PATH_FAILED; + ? SDIS_HEAT_PATH_SUCCESS + : SDIS_HEAT_PATH_FAILURE; /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -62,12 +62,11 @@ XD(boundary_get_position)(const unsigned ivert, float pos[DIM], void* context) iprim = (unsigned)ctx->primitives[iprim_id]; SXD(scene_view_get_primitive(ctx->view, iprim, &prim)); #if DIM == 2 - s2d_segment_get_vertex_attrib(&prim, iprim_vert, S2D_POSITION, &attr); - ASSERT(attr.type == S2D_FLOAT2); + s2d_segment_get_vertex_attrib(&prim, iprim_vert, SXD_POSITION, &attr); #else - s3d_triangle_get_vertex_attrib(&prim, iprim_vert, S3D_POSITION, &attr); - ASSERT(attr.type == S3D_FLOAT3); + s3d_triangle_get_vertex_attrib(&prim, iprim_vert, SXD_POSITION, &attr); #endif + ASSERT(attr.type == SXD_FLOATX); fX(set)(pos, attr.value); } @@ -144,9 +143,9 @@ XD(solve_boundary) /* Create the Star-XD shape of the boundary */ #if SDIS_XD_DIMENSION == 2 - res = s2d_shape_create_line_segments(scn->dev->sXd_dev, &shape); + res = s2d_shape_create_line_segments(scn->dev->sXd(dev), &shape); #else - res = s3d_shape_create_mesh(scn->dev->sXd_dev, &shape); + res = s3d_shape_create_mesh(scn->dev->sXd(dev), &shape); #endif if(res != RES_OK) goto error; @@ -168,7 +167,7 @@ XD(solve_boundary) if(res != RES_OK) goto error; /* Create and setup the boundary Star-XD scene */ - res = sXd(scene_create)(scn->dev->sXd_dev, &scene); + res = sXd(scene_create)(scn->dev->sXd(dev), &scene); if(res != RES_OK) goto error; res = sXd(scene_attach_shape)(scene, shape); if(res != RES_OK) goto error; @@ -291,8 +290,8 @@ XD(solve_boundary) /* Register heat path */ if(pheat_path) { pheat_path->status = res_simul == RES_OK - ? SDIS_HEAT_PATH_SUCCEED - : SDIS_HEAT_PATH_FAILED; + ? SDIS_HEAT_PATH_SUCCESS + : SDIS_HEAT_PATH_FAILURE; /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { @@ -438,9 +437,9 @@ XD(solve_boundary_flux) /* Create the Star-XD shape of the boundary */ #if SDIS_XD_DIMENSION == 2 - res = s2d_shape_create_line_segments(scn->dev->s2d, &shape); + res = s2d_shape_create_line_segments(scn->dev->sXd(dev), &shape); #else - res = s3d_shape_create_mesh(scn->dev->s3d, &shape); + res = s3d_shape_create_mesh(scn->dev->sXd(dev), &shape); #endif if(res != RES_OK) goto error; @@ -463,7 +462,7 @@ XD(solve_boundary_flux) if(res != RES_OK) goto error; /* Create and setup the boundary Star-XD scene */ - res = sXd(scene_create)(scn->dev->sXd_dev, &scene); + res = sXd(scene_create)(scn->dev->sXd(dev), &scene); if(res != RES_OK) goto error; res = sXd(scene_attach_shape)(scene, shape); if(res != RES_OK) goto error; diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -353,8 +353,8 @@ XD(solve_medium) /* Finalize the registered path */ if(pheat_path) { pheat_path->status = res_simul == RES_OK - ? SDIS_HEAT_PATH_SUCCEED - : SDIS_HEAT_PATH_FAILED; + ? SDIS_HEAT_PATH_SUCCESS + : SDIS_HEAT_PATH_FAILURE; /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h @@ -168,8 +168,8 @@ XD(solve_probe) if(pheat_path) { pheat_path->status = res_simul == RES_OK - ? SDIS_HEAT_PATH_SUCCEED - : SDIS_HEAT_PATH_FAILED; + ? SDIS_HEAT_PATH_SUCCESS + : SDIS_HEAT_PATH_FAILURE; /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -205,8 +205,8 @@ XD(solve_probe_boundary) if(pheat_path) { pheat_path->status = res_simul == RES_OK - ? SDIS_HEAT_PATH_SUCCEED - : SDIS_HEAT_PATH_FAILED; + ? SDIS_HEAT_PATH_SUCCESS + : SDIS_HEAT_PATH_FAILURE; /* Check if the path must be saved regarding the register_paths mask */ if(!(register_paths & (int)pheat_path->status)) { diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -19,8 +19,8 @@ #include <rsys/double2.h> #include <rsys/double3.h> #include <rsys/math.h> -#include<star/senc.h> #include<star/senc2d.h> +#include<star/senc3d.h> struct context { const double* positions; @@ -93,10 +93,14 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) double lower[3], upper[3]; double uv0[2], uv1[2], pos[3], pos1[3]; struct context ctx; - struct senc_descriptor* descriptor; - struct senc2d_descriptor* descriptor2d; + struct senc2d_scene* scn2d; + struct senc3d_scene* scn3d; size_t ntris, npos; size_t i; + size_t duplicated_indices[] = { 0, 1, 2, 0, 2, 1 }; + size_t degenerated_indices[] = { 0, 1, 1 }; + double duplicated_vertices[] = { 0, 0, 0, 1, 1, 1, 0, 0, 0 }; + size_t dup_vrtx_indices[] = { 0, 1, 2 }; enum sdis_scene_dimension dim; ctx.positions = box_vertices; @@ -116,6 +120,20 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) BA(CREATE(dev, ntris, IDS, NULL, npos, POS, &ctx, &scn)); BA(CREATE(dev, ntris, IDS, IFA, 0, POS, &ctx, &scn)); BA(CREATE(dev, ntris, IDS, IFA, npos, NULL, &ctx, &scn)); + /* Duplicated vertex */ + ctx.positions = duplicated_vertices; + ctx.indices = dup_vrtx_indices; + BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + /* Duplicated triangle */ + ctx.positions = box_vertices; + ctx.indices = duplicated_indices; + BA(CREATE(dev, 2, IDS, IFA, npos, POS, &ctx, &scn)); + /* Degenerated triangle */ + ctx.indices = degenerated_indices; + BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + + ctx.positions = box_vertices; + ctx.indices = box_indices; OK(CREATE(dev, ntris, IDS, IFA, npos, POS, &ctx, &scn)); #undef CREATE @@ -172,19 +190,13 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_get_boundary_position(scn, 6, uv1, pos1)); CHK(!d3_eq_eps(pos1, pos, 1.e-6)); - BA(sdis_scene_get_analysis(NULL, NULL)); - BA(sdis_scene_get_analysis(scn, NULL)); - BA(sdis_scene_get_analysis(NULL, &descriptor)); - OK(sdis_scene_get_analysis(scn, &descriptor)); - OK(senc_descriptor_ref_put(descriptor)); + BA(sdis_scene_get_senc3d_scene(NULL, NULL)); + BA(sdis_scene_get_senc3d_scene(scn, NULL)); + BA(sdis_scene_get_senc3d_scene(NULL, &scn3d)); + OK(sdis_scene_get_senc3d_scene(scn, &scn3d)); + OK(senc3d_scene_ref_put(scn3d)); /* No 2D available */ - BA(sdis_scene_2d_get_analysis(scn, &descriptor2d)); - BA(sdis_scene_release_analysis(NULL)); - OK(sdis_scene_release_analysis(scn)); - /* Already released */ - OK(sdis_scene_release_analysis(scn)); - /* Descriptor released: cannot get it anymore */ - BA(sdis_scene_get_analysis(scn, &descriptor)); + BA(sdis_scene_get_senc2d_scene(scn, &scn2d)); BA(sdis_scene_ref_get(NULL)); OK(sdis_scene_ref_get(scn)); @@ -200,10 +212,14 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) double lower[2], upper[2]; double u0, u1, pos[2]; struct context ctx; - struct senc2d_descriptor* descriptor; - struct senc_descriptor* descriptor3d; + struct senc2d_scene* scn2d; + struct senc3d_scene* scn3d; size_t nsegs, npos; size_t i; + size_t duplicated_indices[] = { 0, 1, 1, 0 }; + size_t degenerated_indices[] = { 0, 0 }; + double duplicated_vertices[] = { 0, 0, 0, 0 }; + size_t dup_vrtx_indices[] = { 0, 1 }; enum sdis_scene_dimension dim; ctx.positions = square_vertices; @@ -223,6 +239,20 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) BA(CREATE(dev, nsegs, IDS, NULL, npos, POS, &ctx, &scn)); BA(CREATE(dev, nsegs, IDS, IFA, 0, POS, &ctx, &scn)); BA(CREATE(dev, nsegs, IDS, IFA, npos, NULL, &ctx, &scn)); + /* Duplicated vertex */ + ctx.positions = duplicated_vertices; + ctx.indices = dup_vrtx_indices; + BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + /* Duplicated segment */ + ctx.positions = square_vertices; + ctx.indices = duplicated_indices; + BA(CREATE(dev, 2, IDS, IFA, npos, POS, &ctx, &scn)); + /* Degenerated segment */ + ctx.indices = degenerated_indices; + BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + + ctx.positions = square_vertices; + ctx.indices = square_indices; OK(CREATE(dev, nsegs, IDS, IFA, npos, POS, &ctx, &scn)); #undef CREATE @@ -280,20 +310,18 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_boundary_project_position(scn, 3, pos, &u0)); CHK(eq_eps(u0, 1, 1.e-6)); - BA(sdis_scene_2d_get_analysis(NULL, NULL)); - BA(sdis_scene_2d_get_analysis(scn, NULL)); - BA(sdis_scene_2d_get_analysis(NULL, &descriptor)); - OK(sdis_scene_2d_get_analysis(scn, &descriptor)); - OK(senc2d_descriptor_ref_put(descriptor)); + BA(sdis_scene_get_senc2d_scene(NULL, NULL)); + BA(sdis_scene_get_senc2d_scene(scn, NULL)); + BA(sdis_scene_get_senc2d_scene(NULL, &scn2d)); + OK(sdis_scene_get_senc2d_scene(scn, &scn2d)); + OK(senc2d_scene_ref_put(scn2d)); /* No 3D available */ - BA(sdis_scene_get_analysis(scn, &descriptor3d)); - BA(sdis_scene_release_analysis(NULL)); - OK(sdis_scene_release_analysis(scn)); - /* Already released */ - OK(sdis_scene_release_analysis(scn)); - /* Descriptor released: cannot get it anymore */ - BA(sdis_scene_2d_get_analysis(scn, &descriptor)); + BA(sdis_scene_get_senc3d_scene(scn, &scn3d)); + BA(sdis_scene_ref_get(NULL)); + OK(sdis_scene_ref_get(scn)); + BA(sdis_scene_ref_put(NULL)); + OK(sdis_scene_ref_put(scn)); OK(sdis_scene_ref_put(scn)); } diff --git a/src/test_sdis_solid_random_walk_robustness.c b/src/test_sdis_solid_random_walk_robustness.c @@ -354,7 +354,7 @@ main(int argc, char** argv) /* Launch probe estimation with trilinear profile set at interfaces */ interf_param->profile = PROFILE_TRILINEAR; OK(sdis_solve_probe(scn, Nreals, probe, time, 1.0, -1, 0, - SDIS_HEAT_PATH_FAILED, &estimator)); + SDIS_HEAT_PATH_FAILURE, &estimator)); print_estimation_result(estimator, trilinear_temperature(probe)); OK(sdis_estimator_ref_put(estimator)); @@ -362,7 +362,7 @@ main(int argc, char** argv) interf_param->profile = PROFILE_VOLUMETRIC_POWER; solid_param->power = Pw; OK(sdis_solve_probe(scn, Nreals, probe, time, 1.0, -1, 0, - SDIS_HEAT_PATH_FAILED, &estimator)); + SDIS_HEAT_PATH_FAILURE, &estimator)); print_estimation_result(estimator, volumetric_temperature(probe, upper)); solid_param->power = SDIS_VOLUMIC_POWER_NONE; OK(sdis_estimator_ref_put(estimator)); @@ -370,7 +370,7 @@ main(int argc, char** argv) /* Launch medium integration */ interf_param->profile = PROFILE_UNKNOWN; OK(sdis_solve_medium(scn, Nreals, solid, time, 1.0, -1, 0, - SDIS_HEAT_PATH_FAILED, &estimator)); + SDIS_HEAT_PATH_FAILURE, &estimator)); print_estimation_result(estimator, Tfluid); /*dump_heat_paths(stdout, estimator);*/ OK(sdis_estimator_ref_put(estimator)); diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c @@ -206,11 +206,11 @@ process_heat_path(const struct sdis_heat_path* path, void* context) BA(sdis_heat_path_get_status(NULL, &status)); BA(sdis_heat_path_get_status(path, NULL)); OK(sdis_heat_path_get_status(path, &status)); - CHK(status == SDIS_HEAT_PATH_SUCCEED || status == SDIS_HEAT_PATH_FAILED); + CHK(status == SDIS_HEAT_PATH_SUCCESS || status == SDIS_HEAT_PATH_FAILURE); switch(status) { - case SDIS_HEAT_PATH_FAILED: ++ctx->nfailures; break; - case SDIS_HEAT_PATH_SUCCEED: ++ctx->nsuccesses; break; + case SDIS_HEAT_PATH_FAILURE: ++ctx->nfailures; break; + case SDIS_HEAT_PATH_SUCCESS: ++ctx->nsuccesses; break; default: FATAL("Unreachable code.\n"); break; } diff --git a/src/test_sdis_utils.c b/src/test_sdis_utils.c @@ -354,8 +354,8 @@ dump_heat_paths(FILE* stream, const struct sdis_estimator* estimator) OK(sdis_estimator_get_path(estimator, ipath, &path)); OK(sdis_heat_path_get_status(path, &status)); switch(status) { - case SDIS_HEAT_PATH_SUCCEED: fprintf(stream, "0.0\n"); break; - case SDIS_HEAT_PATH_FAILED: fprintf(stream, "1.0\n"); break; + case SDIS_HEAT_PATH_SUCCESS: fprintf(stream, "0.0\n"); break; + case SDIS_HEAT_PATH_FAILURE: fprintf(stream, "1.0\n"); break; default: FATAL("Unreachable code.\n"); break; } }