stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit 22441dbce8822c2123ad4d30620caf2987311732
parent 4c159e942201e107b30ab330feb2769dc5f3c24d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 24 Aug 2021 14:29:13 +0200

Merge branch 'release_0.12.1'

Diffstat:
MREADME.md | 6++++++
Mcmake/CMakeLists.txt | 2+-
Msrc/sdis_heat_path_conductive_Xd.h | 2+-
Msrc/sdis_heat_path_convective_Xd.h | 2+-
Msrc/sdis_scene_Xd.h | 52++++++++++++++++++++--------------------------------
Msrc/sdis_solve_medium_Xd.h | 2+-
6 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/README.md b/README.md @@ -111,6 +111,12 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.12.1 + +Updates the way numerical issues are handled during a conductive random walk. +Previously, a zealous test would report a numerical error and stop the +calculations when that error could be handled. + ### Version 0.12 Add the support of thermal contact resistance between two solids: the new diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -57,7 +57,7 @@ rcmake_append_runtime_dirs(_runtime_dirs ############################################################################### set(VERSION_MAJOR 0) set(VERSION_MINOR 12) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(SDIS_FILES_SRC diff --git a/src/sdis_heat_path_conductive_Xd.h b/src/sdis_heat_path_conductive_Xd.h @@ -65,7 +65,7 @@ XD(sample_next_step) /* Use the previously sampled direction to estimate the minimum distance from * `pos' to the scene boundary */ - f2(range, 0.f, delta_solid*RAY_RANGE_MAX_SCALE); + f2(range, FLT_MIN, delta_solid*RAY_RANGE_MAX_SCALE); SXD(scene_view_trace_ray(scn->sXd(view), pos, dirs[0], range, NULL, &hits[0])); SXD(scene_view_trace_ray(scn->sXd(view), pos, dirs[1], range, NULL, &hits[1])); if(SXD_HIT_NONE(&hits[0]) && SXD_HIT_NONE(&hits[1])) { diff --git a/src/sdis_heat_path_convective_Xd.h b/src/sdis_heat_path_convective_Xd.h @@ -115,7 +115,7 @@ XD(convective_path) 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}; + const float range[2] = {FLT_MIN, FLT_MAX}; float dir[DIM] = {0}; float org[DIM]; diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -453,11 +453,12 @@ XD(hit_filter_function) const struct sXd(hit)* hit_from = &filter_data->XD(hit); (void)org, (void)dir, (void)global_data, (void)range; - if(!ray_data || SXD_HIT_NONE(hit_from)) return 0; /* No filtering */ + /* No user defined data. Do not filter */ + if(!ray_data || SXD_HIT_NONE(hit_from)) return 0; if(SXD_PRIMITIVE_EQ(&hit_from->prim, &hit->prim)) return 1; - /* No displacement => assume self intersection */ + /* No displacement => assume self intersection in all situations */ if(hit->distance <= 0) return 1; if(eq_epsf(hit->distance, 0, (float)filter_data->epsilon)) { @@ -1033,8 +1034,6 @@ XD(scene_get_medium) { struct sdis_medium* medium = NULL; size_t iprim, nprims; - size_t nfailures = 0; - const size_t max_failures = 10; float P[DIM]; /* Range of the parametric coordinate into which positions are challenged */ #if DIM == 2 @@ -1064,7 +1063,7 @@ XD(scene_get_medium) struct sXd(attrib) attr; struct sXd(primitive) prim; size_t iprim2; - const float range[2] = {0.f, FLT_MAX}; + const float range[2] = {FLT_MIN, FLT_MAX}; float N[DIM], dir[DIM], cos_N_dir; size_t istep = 0; @@ -1089,23 +1088,13 @@ XD(scene_get_medium) fX(normalize)(dir, fX(sub)(dir, attr.value, P)); SXD(scene_view_trace_ray(scn->sXd(view), P, dir, range, NULL, &hit)); - /* Unforeseen error. One has to intersect a primitive ! */ - if(SXD_HIT_NONE(&hit)) { - ++nfailures; - if(nfailures < max_failures) { - continue; - } else { - res = RES_BAD_ARG; - goto error; - } - } - /* Discard the hit if it is on a vertex/edge, and target a new position - * onto the current primitive */ + /* Try another position onto the current primitive if there is no + * intersection or if it is on a vertex/edge */ } while((SXD_HIT_NONE(&hit) || HIT_ON_BOUNDARY(&hit, P, dir)) && ++istep < nsteps); - /* The hits of all targeted positions on the current primitive are on - * vertices. Challenge positions on another primitive. */ + /* No valid intersection is found on the current primitive. Challenge + * another. */ if(istep >= nsteps) continue; fX(normalize)(N, hit.normal); @@ -1133,7 +1122,7 @@ XD(scene_get_medium) res = RES_BAD_OP; goto error; } - + #if DIM == 2 if(iprim > 10 && iprim > (size_t)((double)nprims * 0.05)) { log_warn(scn->dev, @@ -1154,13 +1143,19 @@ exit: *out_medium = medium; return res; error: + { + /* RES_BAD_OP means that this is a recoverable issue. In such case, print a + * warning rather than an error. */ + void (*log_func)(const struct sdis_device*, const char*, ...) = + (res == RES_BAD_OP ? log_warn : log_err); #if DIM == 2 - log_err(scn->dev, "%s: could not retrieve the medium at {%g, %g}.\n", - FUNC_NAME, SPLIT2(pos)); + log_func(scn->dev, "%s: could not retrieve the medium at {%g, %g}.\n", + FUNC_NAME, SPLIT2(pos)); #else - log_err(scn->dev, "%s: could not retrieve the medium at {%g, %g, %g}.\n", - FUNC_NAME, SPLIT3(pos)); + log_func(scn->dev, "%s: could not retrieve the medium at {%g, %g, %g}.\n", + FUNC_NAME, SPLIT3(pos)); #endif + } goto exit; } @@ -1193,7 +1188,7 @@ XD(scene_get_medium_in_closed_boundaries) FOR_EACH(idir, 0, 2*DIM) { struct sXd(hit) hit; float N[DIM]; - const float range[2] = {0.f, FLT_MAX}; + const float range[2] = {FLT_MIN, FLT_MAX}; float cos_N_dir; /* Transform the directions to avoid to be aligned with the axis */ @@ -1230,13 +1225,6 @@ exit: *out_medium = medium; return res; error: -#if DIM == 2 - log_err(scn->dev, "%s: could not retrieve the medium at {%g, %g}.\n", - FUNC_NAME, SPLIT2(pos)); -#else - log_err(scn->dev, "%s: could not retrieve the medium at {%g, %g, %g}.\n", - FUNC_NAME, SPLIT3(pos)); -#endif goto exit; } diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -165,7 +165,7 @@ XD(sample_enclosure_position) FOR_EACH(ichallenge, 0, MAX_NCHALLENGES) { struct sXd(hit) hit = SXD_HIT_NULL; const float dir[3] = {1,0,0}; - const float range[2] = {0, FLT_MAX}; + const float range[2] = {FLT_MIN, FLT_MAX}; float org[DIM]; /* Generate an uniform position into the enclosure AABB */