stardis-solver

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

commit 4ebfc0ae8f35a4b57ba0e0efbd8b673f049da7fa
parent b00590b567dba3ad4269a3dc2db9db2a57bc5188
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 12 May 2023 11:12:42 +0200

Small improvments to error reporting

Display an error message when a path is rejected with the realization
and branch ID. This makes debugging easier.

The compute_temperature_<2|3>d functions are also renamed to
sample_coupled_path_<2|3>d, which is more accurate and explicit.

Diffstat:
Msrc/sdis_Xd_begin.h | 4++++
Msrc/sdis_heat_path_boundary_Xd_c.h | 2+-
Msrc/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h | 2+-
Msrc/sdis_realisation.c | 3++-
Msrc/sdis_realisation.h | 19+++++++++++--------
Msrc/sdis_realisation_Xd.h | 23++++++++++++++++-------
Msrc/sdis_solve_boundary_Xd.h | 2++
Msrc/sdis_solve_camera.c | 1+
Msrc/sdis_solve_probe_boundary_Xd.h | 2++
9 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -43,6 +43,9 @@ struct rwalk_context { /* Number of heat path branchings */ size_t nbranchings; + + /* Id of the realisation (for debug) */ + size_t irealisation; }; #define RWALK_CONTEXT_NULL__ { \ NULL, /* Green path */ \ @@ -55,6 +58,7 @@ struct rwalk_context { 0, /* That^3 */ \ 0, /* Max #branchings */ \ SIZE_MAX, /* #branchings */ \ + SIZE_MAX /* realisation id */ \ } static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__; diff --git a/src/sdis_heat_path_boundary_Xd_c.h b/src/sdis_heat_path_boundary_Xd_c.h @@ -419,7 +419,7 @@ XD(find_reinjection_ray) log_err(scn->dev, "%s: no valid reinjection direction at {%g, %g}.\n", FUNC_NAME, SPLIT2(ray->org)); #else - log_err(scn->dev, "%s: no valid reinjection direction at {%g, %g, %g}.\n", + log_err(scn->dev, "%s: no valid reinjection direction at {%g, %g, %g}.\n", FUNC_NAME, SPLIT3(ray->org)); #endif res = RES_BAD_OP_IRRECOVERABLE; diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h @@ -102,7 +102,7 @@ XD(sample_path) } /* Sample the path */ - res = XD(compute_temperature)(scn, ctx, &rwalk, rng, T); + res = XD(sample_coupled_path)(scn, ctx, &rwalk, rng, T); if(res != RES_OK) goto error; /* Check the returned temperature */ diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c @@ -66,6 +66,7 @@ ray_realisation_3d ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; + ctx.irealisation = args->irealisation; f3_set_d3(dir, args->direction); @@ -78,7 +79,7 @@ ray_realisation_3d if(res != RES_OK) goto error; if(!T.done) { - res = compute_temperature_3d(scn, &ctx, &rwalk, args->rng, &T); + res = sample_coupled_path_3d(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) goto error; } diff --git a/src/sdis_realisation.h b/src/sdis_realisation.h @@ -35,10 +35,10 @@ enum flux_flag { }; /******************************************************************************* - * Helper function used to compute a temperature + * Helper function used to sample a coupled path ******************************************************************************/ extern LOCAL_SYM res_T -compute_temperature_2d +sample_coupled_path_2d (struct sdis_scene* scn, struct rwalk_context* ctx, struct rwalk_2d* rwalk, @@ -46,7 +46,7 @@ compute_temperature_2d struct temperature_2d* T); extern LOCAL_SYM res_T -compute_temperature_3d +sample_coupled_path_3d (struct sdis_scene* scn, struct rwalk_context* ctx, struct rwalk_3d* rwalk, @@ -67,7 +67,7 @@ struct probe_realisation_args { size_t irealisation; /* Id of the realisation (for debug) */ }; #define PROBE_REALISATION_ARGS_NULL__ { \ - NULL, NULL, {0,0,0}, -1, 0, NULL, NULL, 0 \ + NULL, NULL, {0,0,0}, -1, 0, NULL, NULL, SIZE_MAX \ } static const struct probe_realisation_args PROBE_REALISATION_ARGS_NULL = PROBE_REALISATION_ARGS_NULL__; @@ -96,9 +96,10 @@ struct boundary_realisation_args { enum sdis_side side; /* Side of the geometric primitive */ struct green_path_handle* green_path; /* May be NULL */ struct sdis_heat_path* heat_path; /* May be NULL */ + size_t irealisation; /* Id of the realisation (for debug) */ }; #define BOUNDARY_REALISATION_ARGS_NULL__ { \ - NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, NULL, NULL \ + NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, NULL, NULL, SIZE_MAX \ } static const struct boundary_realisation_args BOUNDARY_REALISATION_ARGS_NULL = BOUNDARY_REALISATION_ARGS_NULL__; @@ -126,9 +127,10 @@ struct boundary_flux_realisation_args { size_t picard_order; /* Picard order to estimate radiative temperature */ enum sdis_side solid_side; /* Side of the geometric primitive */ int flux_mask; /* Combination of enum flux_flag */ + size_t irealisation; /* Id of the realisation (for debug) */ }; #define BOUNDARY_FLUX_REALISATION_ARGS_NULL__ { \ - NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, 0 \ + NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, 0, SIZE_MAX \ } static const struct boundary_flux_realisation_args BOUNDARY_FLUX_REALISATION_ARGS_NULL = BOUNDARY_FLUX_REALISATION_ARGS_NULL__; @@ -146,7 +148,7 @@ boundary_flux_realisation_3d struct bound_flux_result* result); /******************************************************************************* - * Realisation along a given ray at a given time. Available only in 3D. + * Realisation along a given ray at a given time. Available only in 3D ******************************************************************************/ struct ray_realisation_args { struct ssp_rng* rng; @@ -156,9 +158,10 @@ struct ray_realisation_args { double time; /* Observation time */ size_t picard_order; /* Picard order to estimate radiative temperature */ struct sdis_heat_path* heat_path; /* May be NULL */ + size_t irealisation; /* Id of the realisation (for debug) */ }; #define RAY_REALISATION_ARGS_NULL__ { \ - NULL, NULL, {0,0,0}, {0,0,0}, -1, 0, NULL \ + NULL, NULL, {0,0,0}, {0,0,0}, -1, 0, NULL, SIZE_MAX \ } static const struct ray_realisation_args RAY_REALISATION_ARGS_NULL = RAY_REALISATION_ARGS_NULL__; diff --git a/src/sdis_realisation_Xd.h b/src/sdis_realisation_Xd.h @@ -76,7 +76,7 @@ check_boundary_flux_realisation_args * Local functions ******************************************************************************/ res_T -XD(compute_temperature) +XD(sample_coupled_path) (struct sdis_scene* scn, struct rwalk_context* ctx, struct XD(rwalk)* rwalk, @@ -123,7 +123,13 @@ XD(compute_temperature) res = T->func(scn, ctx, rwalk, rng, T); if(res == RES_BAD_OP) { *rwalk = rwalk_bkp; *T = T_bkp; } } while(res == RES_BAD_OP && ++nfails < MAX_FAILS); - if(res != RES_OK) goto error; + if(res != RES_OK) { + log_err(scn->dev, "%s: reject path (realisation: %lu; branch: %lu)\n", + FUNC_NAME, + (unsigned long)ctx->irealisation, + (unsigned long)ctx->nbranchings); + goto error; + } /* Update the type of the first vertex of the random walks that begin on a * boundary. Indeed, one knows the "right" type of the first vertex only @@ -227,8 +233,9 @@ XD(probe_realisation) ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; + ctx.irealisation = args->irealisation; - res = XD(compute_temperature)(scn, &ctx, &rwalk, args->rng, &T); + res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) goto error; ASSERT(T.value >= 0); @@ -301,8 +308,9 @@ XD(boundary_realisation) ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; + ctx.irealisation = args->irealisation; - res = XD(compute_temperature)(scn, &ctx, &rwalk, args->rng, &T); + res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) goto error; *weight = T.value; @@ -387,6 +395,7 @@ XD(boundary_flux_realisation) ctx.That2 = That2; \ ctx.That3 = That3; \ ctx.max_branchings = args->picard_order - 1; \ + ctx.irealisation = args->irealisation; \ dX(set)(rwalk.vtx.P, P); \ fX(set)(rwalk.hit.normal, N); \ T = XD(TEMPERATURE_NULL); \ @@ -395,7 +404,7 @@ XD(boundary_flux_realisation) /* Compute boundary temperature */ RESET_WALK(args->solid_side, NULL); T.func = XD(boundary_path); - res = XD(compute_temperature)(scn, &ctx, &rwalk, args->rng, &T); + res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) return res; result->Tboundary = T.value; @@ -407,7 +416,7 @@ XD(boundary_flux_realisation) if(compute_radiative) { RESET_WALK(fluid_side, fluid_mdm); T.func = XD(radiative_path); - res = XD(compute_temperature)(scn, &ctx, &rwalk, args->rng, &T); + res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) return res; ASSERT(T.value >= 0); result->Tradiative = T.value; @@ -417,7 +426,7 @@ XD(boundary_flux_realisation) if(compute_convective) { RESET_WALK(fluid_side, fluid_mdm); T.func = XD(convective_path); - res = XD(compute_temperature)(scn, &ctx, &rwalk, args->rng, &T); + res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) return res; result->Tfluid = T.value; } diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -404,6 +404,7 @@ XD(solve_boundary) realis_args.side = side; realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; + realis_args.irealisation = (size_t)irealisation; realis_args.uv[0] = uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = uv[1]; @@ -803,6 +804,7 @@ XD(solve_boundary_flux) realis_args.picard_order = args->picard_order; realis_args.solid_side = solid_side; realis_args.flux_mask = flux_mask; + realis_args.irealisation = (size_t)irealisation; realis_args.uv[0] = uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = uv[1]; diff --git a/src/sdis_solve_camera.c b/src/sdis_solve_camera.c @@ -134,6 +134,7 @@ solve_pixel realis_args.time = time; realis_args.picard_order = picard_order; realis_args.heat_path = pheat_path; + realis_args.irealisation = (size_t)irealisation; d3_set(realis_args.position, ray_pos); d3_set(realis_args.direction, ray_dir); res_simul = ray_realisation_3d(scn, &realis_args, &w); diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -268,6 +268,7 @@ XD(solve_probe_boundary) realis_args.side = args->side; realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; + realis_args.irealisation = (size_t)irealisation; realis_args.uv[0] = args->uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = args->uv[1]; @@ -597,6 +598,7 @@ XD(solve_probe_boundary_flux) realis_args.picard_order = args->picard_order; realis_args.solid_side = solid_side; realis_args.flux_mask = flux_mask; + realis_args.irealisation = (size_t)irealisation; realis_args.uv[0] = args->uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = args->uv[1];