stardis-solver

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

commit c9f7092d6d4e77afb2f7ed7df999edc2c4ef3d01
parent 69071685d679ff19a44b1b4a472691444d56765f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 18 Jan 2024 14:56:23 +0100

The diffusion algorithm can be selected by the caller

The caller can define the algorithm to be used to sample the conductive
paths. This is a new input parameter for the solve functions which, by
default, is set to the delta sphere algorithm, i.e. the historical
Stardis algorithm. It can be set to the Walk on Sphere algorithm, and
this is in fact the purpose of this commit, which offers both a way of
activating WoS via the Stardis API and a way of testing the early
implementation of this algorithm in current tests.

Note that this commit move the rwalk_context data structure from the
sdis_Xd_begin header to the sdis_heat_path header because this structure
must now be defined in a regular file, in this case the
sdis_heat_path_conductive.c file, whereas the sdis_Xd_begin.h file was
designed to be included only in generic dimension files.

Diffstat:
Msrc/sdis.h | 34+++++++++++++++++++++++++++++++---
Msrc/sdis_Xd_begin.h | 56+-------------------------------------------------------
Msrc/sdis_heat_path.h | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Msrc/sdis_heat_path_conductive.c | 28++++++++++++++++++++++++++--
Msrc/sdis_realisation.c | 8+++++---
Msrc/sdis_realisation.h | 45+++++++++++++++++++++++++++++++++++++++++----
Msrc/sdis_realisation_Xd.h | 12+++++++++---
Msrc/sdis_solve_boundary_Xd.h | 7+++++++
Msrc/sdis_solve_camera.c | 13+++++++++++--
Msrc/sdis_solve_medium_Xd.h | 6++++++
Msrc/sdis_solve_probe_Xd.h | 7+++++++
Msrc/sdis_solve_probe_boundary_Xd.h | 12++++++++++++
12 files changed, 215 insertions(+), 77 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -89,6 +89,13 @@ enum sdis_scene_dimension { SDIS_SCENE_3D }; +enum sdis_diffusion_algorithm { + SDIS_DIFFUSION_DELTA_SPHERE, + SDIS_DIFFUSION_WOS, /* Walk on Sphere */ + SDIS_DIFFUSION_ALGORITHMS_COUNT__, + SDIS_DIFFUSION_NONE = SDIS_DIFFUSION_ALGORITHMS_COUNT__ +}; + /* Random walk vertex, i.e. a spatiotemporal position at a given step of the * random walk. */ struct sdis_rwalk_vertex { @@ -477,6 +484,8 @@ struct sdis_solve_probe_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ + /* Signature of the estimated green function. The signature is ignored in an * ordinary probe estimation. The signature of the green function can be * queried to verify that it is the expected one with respect to the caller's @@ -491,6 +500,7 @@ struct sdis_solve_probe_args { SDIS_HEAT_PATH_NONE, /* Register paths mask */ \ NULL, /* RNG state */ \ SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */ \ {0} /* Signature */ \ } static const struct sdis_solve_probe_args SDIS_SOLVE_PROBE_ARGS_DEFAULT = @@ -531,6 +541,8 @@ struct sdis_solve_probe_boundary_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ + /* Signature of the estimated green function. The signature is ignored in an * ordinary probe estimation. The signature of the green function can be * queried to verify that it is the expected one with respect to the caller's @@ -547,6 +559,7 @@ struct sdis_solve_probe_boundary_args { SDIS_HEAT_PATH_NONE, \ NULL, /* RNG state */ \ SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */ \ {0} /* Signature */ \ } static const struct sdis_solve_probe_boundary_args @@ -569,6 +582,8 @@ struct sdis_solve_boundary_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ + /* Signature of the estimated green function. The signature is ignored in an * ordinary probe estimation. The signature of the green function can be * queried to verify that it is the expected one with respect to the caller's @@ -585,6 +600,7 @@ struct sdis_solve_boundary_args { SDIS_HEAT_PATH_NONE, \ NULL, /* RNG state */ \ SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */ \ {0} /* Signature */ \ } static const struct sdis_solve_boundary_args SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT = @@ -604,6 +620,8 @@ struct sdis_solve_medium_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ + /* Signature of the estimated green function. The signature is ignored in an * ordinary probe estimation. The signature of the green function can be * queried to verify that it is the expected one with respect to the caller's @@ -618,6 +636,7 @@ struct sdis_solve_medium_args { SDIS_HEAT_PATH_NONE, \ NULL, /* RNG state */ \ SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */ \ {0} /* Signature */ \ } static const struct sdis_solve_medium_args SDIS_SOLVE_MEDIUM_ARGS_DEFAULT = @@ -636,6 +655,8 @@ struct sdis_solve_probe_boundary_flux_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -644,7 +665,8 @@ struct sdis_solve_probe_boundary_flux_args { {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ NULL, /* RNG state */ \ - SSP_RNG_THREEFRY /* RNG type */ \ + SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */ \ } static const struct sdis_solve_probe_boundary_flux_args SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT = @@ -663,6 +685,8 @@ struct sdis_solve_boundary_flux_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ + + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -671,7 +695,8 @@ struct sdis_solve_boundary_flux_args { {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ NULL, /* RNG state */ \ - SSP_RNG_THREEFRY /* RNG type */ \ + SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */ \ } static const struct sdis_solve_boundary_flux_args SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT = @@ -692,6 +717,8 @@ struct sdis_solve_camera_args { struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ enum ssp_rng_type rng_type; /* RNG type to use */ + + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define SDIS_SOLVE_CAMERA_ARGS_DEFAULT__ { \ NULL, /* Camera */ \ @@ -701,7 +728,8 @@ struct sdis_solve_camera_args { 256, /* #realisations per pixel */ \ SDIS_HEAT_PATH_NONE, \ NULL, /* RNG state */ \ - SSP_RNG_THREEFRY /* RNG type */ \ + SSP_RNG_THREEFRY, /* RNG type */ \ + SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */ \ } static const struct sdis_solve_camera_args SDIS_SOLVE_CAMERA_ARGS_DEFAULT = SDIS_SOLVE_CAMERA_ARGS_DEFAULT__; diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -13,63 +13,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SDIS_XD_BEGIN_H -#define SDIS_XD_BEGIN_H - +#include "sdis.h" #include <rsys/rsys.h> -/* Forward declaration */ -struct green_path_handle; -struct sdis_heat_path; - -struct rwalk_context { - struct green_path_handle* green_path; - struct sdis_heat_path* heat_path; - - double Tmin; /* Lower bound temperature */ - double Tmin2; /* Tmin^2 */ - double Tmin3; /* Tmin^3 */ - - double That; /* Upper bound temperature */ - double That2; /* That^2 */ - double That3; /* That^3 */ - - /* Maximum branchings i.e. the maximum number of times XD(sample_coupled_path) - * can be called. It controls the number of ramifications of the heat path and - * currently is correlated to the Picard order used to estimate the radiative - * temperature. max_branchings == picard_order-1 */ - size_t max_branchings; - - /* Number of heat path branchings */ - size_t nbranchings; - - /* Id of the realisation (for debug) */ - size_t irealisation; -}; -#define RWALK_CONTEXT_NULL__ { \ - NULL, /* Green path */ \ - NULL, /* Heat path */ \ - 0, /* Tmin */ \ - 0, /* Tmin^2 */ \ - 0, /* Tmin^3 */ \ - 0, /* That */ \ - 0, /* That^2 */ \ - 0, /* That^3 */ \ - 0, /* Max #branchings */ \ - SIZE_MAX, /* #branchings */ \ - SIZE_MAX /* realisation id */ \ -} -static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__; - -static INLINE size_t -get_picard_order(const struct rwalk_context* ctx) -{ - ASSERT(ctx); - return ctx->max_branchings + 1; -} - -#endif /* SDIS_XD_BEGIN_H */ - #ifdef SDIS_XD_BEGIN_H__ #error "This header is already included without its associated sdis_Xd_end.h file." #endif diff --git a/src/sdis_heat_path.h b/src/sdis_heat_path.h @@ -23,22 +23,77 @@ #include <rsys/rsys.h> /* Forward declarations */ +struct green_path_handle; struct rwalk_2d; struct rwalk_3d; -struct rwalk_context; struct sdis_scene; struct ssp_rng; struct temperature_2d; struct temperature_3d; +/******************************************************************************* + * Context of a random walk, i.e. its data concerning the current system and the + * solve parameters. + ******************************************************************************/ + struct rwalk_context { + struct green_path_handle* green_path; + struct sdis_heat_path* heat_path; + + double Tmin; /* Lower bound temperature */ + double Tmin2; /* Tmin^2 */ + double Tmin3; /* Tmin^3 */ + + double That; /* Upper bound temperature */ + double That2; /* That^2 */ + double That3; /* That^3 */ + + /* Maximum branchings i.e. the maximum number of times XD(sample_coupled_path) + * can be called. It controls the number of ramifications of the heat path and + * currently is correlated to the Picard order used to estimate the radiative + * temperature. max_branchings == picard_order-1 */ + size_t max_branchings; + + /* Number of heat path branchings */ + size_t nbranchings; + + /* Id of the realisation (for debug) */ + size_t irealisation; + + /* Algorithm used for the diffusive random walks, + * i.e. for sampling conductive paths */ + enum sdis_diffusion_algorithm diff_algo; +}; +#define RWALK_CONTEXT_NULL__ { \ + NULL, /* Green path */ \ + NULL, /* Heat path */ \ + 0, /* Tmin */ \ + 0, /* Tmin^2 */ \ + 0, /* Tmin^3 */ \ + 0, /* That */ \ + 0, /* That^2 */ \ + 0, /* That^3 */ \ + 0, /* Max #branchings */ \ + SIZE_MAX, /* #branchings */ \ + SIZE_MAX, /* realisation id */ \ + SDIS_DIFFUSION_NONE /* Diffusion algorithm */ \ +} +static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__; + +static INLINE size_t +get_picard_order(const struct rwalk_context* ctx) +{ + ASSERT(ctx); + return ctx->max_branchings + 1; +} + +/******************************************************************************* + * Heat path data structure used to record the geometry of sampled paths + ******************************************************************************/ /* Generate the dynamic array of heat vertices */ #define DARRAY_NAME heat_vertex #define DARRAY_DATA struct sdis_heat_vertex #include <rsys/dynamic_array.h> -/******************************************************************************* - * Heat path data structure - ******************************************************************************/ struct sdis_heat_path { /* List of the path vertices */ struct darray_heat_vertex vertices; @@ -293,4 +348,3 @@ boundary_path_3d struct temperature_3d* temperature); #endif /* SDIS_HEAT_PATH_H */ - diff --git a/src/sdis_heat_path_conductive.c b/src/sdis_heat_path_conductive.c @@ -78,7 +78,19 @@ conductive_path_2d struct ssp_rng* rng, struct temperature_2d* T) { - return conductive_path_delta_sphere_2d(scn, ctx, rwalk, rng, T); + res_T res = RES_OK; + ASSERT(ctx); + + switch(ctx->diff_algo) { + case SDIS_DIFFUSION_DELTA_SPHERE: + res = conductive_path_delta_sphere_2d(scn, ctx, rwalk, rng, T); + break; + case SDIS_DIFFUSION_WOS: + res = conductive_path_wos_2d(scn, ctx, rwalk, rng, T); + break; + default: FATAL("Unreachable code.\n"); break; + } + return res; } res_T @@ -89,7 +101,19 @@ conductive_path_3d struct ssp_rng* rng, struct temperature_3d* T) { - return conductive_path_delta_sphere_3d(scn, ctx, rwalk, rng, T); + res_T res = RES_OK; + ASSERT(ctx); + + switch(ctx->diff_algo) { + case SDIS_DIFFUSION_DELTA_SPHERE: + res = conductive_path_delta_sphere_3d(scn, ctx, rwalk, rng, T); + break; + case SDIS_DIFFUSION_WOS: + res = conductive_path_wos_3d(scn, ctx, rwalk, rng, T); + break; + default: FATAL("Unreachable code.\n"); break; + } + return res; } /* Generate the conductive path functions */ diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c @@ -20,14 +20,15 @@ * Helper functions ******************************************************************************/ static INLINE int -check_ray_realisatio_args(const struct ray_realisation_args* args) +check_ray_realisation_args(const struct ray_realisation_args* args) { return args && args->rng && args->medium && args->medium->type == SDIS_FLUID && args->time >= 0 - && args->picard_order > 0; + && args->picard_order > 0 + && (unsigned)args->diff_algo < SDIS_DIFFUSION_ALGORITHMS_COUNT__; } /******************************************************************************* @@ -50,7 +51,7 @@ ray_realisation_3d struct temperature_3d T = TEMPERATURE_NULL_3d; float dir[3]; res_T res = RES_OK; - ASSERT(scn && weight && check_ray_realisatio_args(args)); + ASSERT(scn && weight && check_ray_realisation_args(args)); d3_set(rwalk.vtx.P, args->position); rwalk.vtx.time = args->time; @@ -67,6 +68,7 @@ ray_realisation_3d ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; ctx.irealisation = args->irealisation; + ctx.diff_algo = args->diff_algo; f3_set_d3(dir, args->direction); diff --git a/src/sdis_realisation.h b/src/sdis_realisation.h @@ -65,9 +65,18 @@ struct probe_realisation_args { 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) */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define PROBE_REALISATION_ARGS_NULL__ { \ - NULL, NULL, {0,0,0}, -1, 0, NULL, NULL, SIZE_MAX \ + NULL, /* RNG */ \ + NULL, /* Medium */ \ + {0,0,0}, /* Position */ \ + -1, /* Observation time */ \ + 0, /* Picard order */ \ + NULL, /* Green path */ \ + NULL, /* Heat path */ \ + SIZE_MAX, /* Realisation ID */ \ + SDIS_DIFFUSION_NONE /* Diffusion algorithm */ \ } static const struct probe_realisation_args PROBE_REALISATION_ARGS_NULL = PROBE_REALISATION_ARGS_NULL__; @@ -97,9 +106,19 @@ struct boundary_realisation_args { 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) */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define BOUNDARY_REALISATION_ARGS_NULL__ { \ - NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, NULL, NULL, SIZE_MAX \ + NULL, /* RNG */ \ + SIZE_MAX, /* Primitive ID */ \ + {0,0}, /* Parametric coordinates */ \ + -1, /* Observation time */ \ + 0, /* Picard order */ \ + SDIS_SIDE_NULL__, /* Interface side */ \ + NULL, /* Green path */ \ + NULL, /* Heat path */ \ + SIZE_MAX, /* Realisation ID */ \ + SDIS_DIFFUSION_NONE /* Diffusion algorithm */ \ } static const struct boundary_realisation_args BOUNDARY_REALISATION_ARGS_NULL = BOUNDARY_REALISATION_ARGS_NULL__; @@ -128,9 +147,18 @@ struct boundary_flux_realisation_args { 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) */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define BOUNDARY_FLUX_REALISATION_ARGS_NULL__ { \ - NULL, SIZE_MAX, {0,0}, -1, 0, SDIS_SIDE_NULL__, 0, SIZE_MAX \ + NULL, /* RNG */ \ + SIZE_MAX, /* Primitive ID */ \ + {0,0}, /* Parametric coordinates */ \ + -1, /* Observation time */ \ + 0, /* Picard order */ \ + SDIS_SIDE_NULL__, /* Interface side */ \ + 0, /* Flux mask */ \ + SIZE_MAX, /* Realisation ID */ \ + SDIS_DIFFUSION_NONE /* Diffusion algorithm */ \ } static const struct boundary_flux_realisation_args BOUNDARY_FLUX_REALISATION_ARGS_NULL = BOUNDARY_FLUX_REALISATION_ARGS_NULL__; @@ -159,9 +187,18 @@ struct ray_realisation_args { 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) */ + enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */ }; #define RAY_REALISATION_ARGS_NULL__ { \ - NULL, NULL, {0,0,0}, {0,0,0}, -1, 0, NULL, SIZE_MAX \ + NULL, /* RNG */ \ + NULL, /* Medium */ \ + {0,0,0}, /* Position */ \ + {0,0,0}, /* Direction */ \ + -1, /* Observation time */ \ + 0, /* Picard order */ \ + NULL, /* Heat path */ \ + SIZE_MAX, /* Realisation ID */ \ + SDIS_DIFFUSION_NONE /* Diffusion algorithm */ \ } 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 @@ -39,7 +39,8 @@ check_probe_realisation_args(const struct probe_realisation_args* args) && args->rng && args->medium && args->time >= 0 - && args->picard_order > 0; + && args->picard_order > 0 + && (unsigned)args->diff_algo < SDIS_DIFFUSION_ALGORITHMS_COUNT__; } static INLINE int @@ -53,7 +54,8 @@ check_boundary_realisation_args(const struct boundary_realisation_args* args) && args->uv[1] <= 1 && args->time >= 0 && args->picard_order > 0 - && (args->side == SDIS_FRONT || args->side == SDIS_BACK); + && (args->side == SDIS_FRONT || args->side == SDIS_BACK) + && (unsigned)args->diff_algo < SDIS_DIFFUSION_ALGORITHMS_COUNT__; } static INLINE int @@ -68,7 +70,8 @@ check_boundary_flux_realisation_args && args->uv[1] <= 1 && args->time >= 0 && args->picard_order > 0 - && (args->solid_side == SDIS_FRONT || args->solid_side == SDIS_BACK); + && (args->solid_side == SDIS_FRONT || args->solid_side == SDIS_BACK) + && (unsigned)args->diff_algo < SDIS_DIFFUSION_ALGORITHMS_COUNT__; } #endif /* SDIS_REALISATION_XD_H */ @@ -234,6 +237,7 @@ XD(probe_realisation) ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; ctx.irealisation = args->irealisation; + ctx.diff_algo = args->diff_algo; res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) goto error; @@ -309,6 +313,7 @@ XD(boundary_realisation) ctx.That3 = ctx.That * ctx.That2; ctx.max_branchings = args->picard_order - 1; ctx.irealisation = args->irealisation; + ctx.diff_algo = args->diff_algo; res = XD(sample_coupled_path)(scn, &ctx, &rwalk, args->rng, &T); if(res != RES_OK) goto error; @@ -396,6 +401,7 @@ XD(boundary_flux_realisation) ctx.That3 = That3; \ ctx.max_branchings = args->picard_order - 1; \ ctx.irealisation = args->irealisation; \ + ctx.diff_algo = args->diff_algo; \ dX(set)(rwalk.vtx.P, P); \ fX(set)(rwalk.hit.normal, N); \ T = XD(TEMPERATURE_NULL); \ diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -78,6 +78,11 @@ check_solve_boundary_args(const struct sdis_solve_boundary_args* args) return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -405,6 +410,7 @@ XD(solve_boundary) realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; realis_args.uv[0] = uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = uv[1]; @@ -805,6 +811,7 @@ XD(solve_boundary_flux) realis_args.solid_side = solid_side; realis_args.flux_mask = flux_mask; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; 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 @@ -72,6 +72,11 @@ check_solve_camera_args(const struct sdis_solve_camera_args* args) return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -87,6 +92,7 @@ solve_pixel const int register_paths, /* Combination of enum sdis_heat_path_flag */ const double pix_sz[2], /* Pixel size in the normalized image plane */ const size_t picard_order, + const enum sdis_diffusion_algorithm diff_algo, struct sdis_estimator* estimator, struct pixel* pixel) { @@ -135,6 +141,7 @@ solve_pixel realis_args.picard_order = picard_order; realis_args.heat_path = pheat_path; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = diff_algo; d3_set(realis_args.position, ray_pos); d3_set(realis_args.direction, ray_dir); res_simul = ray_realisation_3d(scn, &realis_args, &w); @@ -197,6 +204,7 @@ solve_tile const int register_paths, /* Combination of enum sdis_heat_path_flag */ const double pix_sz[2], /* Pixel size in the normalized image plane */ const size_t picard_order, + const enum sdis_diffusion_algorithm diff_algo, struct sdis_estimator_buffer* buf, struct tile* tile) { @@ -234,7 +242,7 @@ solve_tile } res = solve_pixel (scn, rng, mdm, cam, time_range, ipix_image, spp, register_paths, pix_sz, - picard_order, estimator, pixel); + picard_order, diff_algo, estimator, pixel); if(res != RES_OK) goto error; } @@ -651,7 +659,8 @@ sdis_solve_camera /* Draw the tile */ res_local = solve_tile (scn, rng, medium, args->cam, args->time_range, tile_org, tile_sz, - args->spp, register_paths, pix_sz, args->picard_order, buf, tile); + args->spp, register_paths, pix_sz, args->picard_order, args->diff_algo, + buf, tile); if(res_local != RES_OK) { ATOMIC_SET(&res, res_local); continue; diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -172,6 +172,11 @@ check_solve_medium_args(const struct sdis_solve_medium_args* args) return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -436,6 +441,7 @@ XD(solve_medium) realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; dX(set)(realis_args.position, pos); res_simul = XD(probe_realisation)(scn, &realis_args, &weight); if(res_simul != RES_OK && res_simul != RES_BAD_OP) { diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h @@ -64,6 +64,11 @@ check_solve_probe_args(const struct sdis_solve_probe_args* args) return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -221,6 +226,7 @@ XD(solve_one_probe) realis_args.time = time; realis_args.picard_order = args->picard_order; realis_args.irealisation = irealisation; + realis_args.diff_algo = args->diff_algo; dX(set)(realis_args.position, args->position); res = XD(probe_realisation)(scn, &realis_args, &w); if(res != RES_OK) goto error; @@ -405,6 +411,7 @@ XD(solve_probe) realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; dX(set)(realis_args.position, args->position); res_simul = XD(probe_realisation)(scn, &realis_args, &w); diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -71,6 +71,11 @@ check_solve_probe_boundary_args return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -104,6 +109,11 @@ check_solve_probe_boundary_flux_args return RES_BAD_ARG; } + /* Check the diffusion algorithm */ + if((unsigned)args->diff_algo >= SDIS_DIFFUSION_ALGORITHMS_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -269,6 +279,7 @@ XD(solve_probe_boundary) realis_args.green_path = pgreen_path; realis_args.heat_path = pheat_path; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; realis_args.uv[0] = args->uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = args->uv[1]; @@ -599,6 +610,7 @@ XD(solve_probe_boundary_flux) realis_args.solid_side = solid_side; realis_args.flux_mask = flux_mask; realis_args.irealisation = (size_t)irealisation; + realis_args.diff_algo = args->diff_algo; realis_args.uv[0] = args->uv[0]; #if SDIS_XD_DIMENSION == 3 realis_args.uv[1] = args->uv[1];