commit 3761303e2a40eb356f85cf37a4ee463e9f87f45b parent 54a69d046b28c2ec48ae23e850ac7874fcc81eab Author: Christophe Coustet <christophe.coustet@meso-star.com> Date: Wed, 4 Nov 2020 10:56:02 +0100 Allow Trad changes for green computations Trad, Tref and fp_to_meter are moved from solver args to scene Diffstat:
49 files changed, 537 insertions(+), 368 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h @@ -69,6 +69,7 @@ struct sdis_medium; struct sdis_scene; /* Forward declaration of non ref counted types */ +struct sdis_green_path; struct sdis_heat_path; /******************************************************************************* @@ -270,6 +271,14 @@ typedef res_T /******************************************************************************* * Green function data types ******************************************************************************/ +enum sdis_green_path_end_type { + SDIS_GREEN_PATH_END_AT_INTERFACE, + SDIS_GREEN_PATH_END_IN_VOLUME, + SDIS_GREEN_PATH_END_RADIATIVE, + SDIS_GREEN_PATH_END_TYPES_COUNT__, + SDIS_GREEN_PATH_END_ERROR = SDIS_GREEN_PATH_END_TYPES_COUNT__ +}; + enum sdis_point_type { SDIS_FRAGMENT, SDIS_VERTEX, @@ -277,16 +286,6 @@ enum sdis_point_type { SDIS_POINT_NONE = SDIS_POINT_TYPES_COUNT__ }; -/* Path used to estimate the green function */ -struct sdis_green_path { - /* Internal data. Should not be accessed */ - void* green__; - size_t id__; -}; -#define SDIS_GREEN_PATH_NULL__ {NULL, 0} -static const struct sdis_green_path SDIS_GREEN_PATH_NULL = - SDIS_GREEN_PATH_NULL__; - /* Spatio temporal point */ struct sdis_point { union { @@ -334,9 +333,6 @@ struct sdis_solve_probe_args { size_t nrealisations; /* #realisations */ double position[3]; /* Probe position */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; @@ -344,9 +340,6 @@ struct sdis_solve_probe_args { 10000, /* #realisations */ \ {0,0,0}, /* Position */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1.0, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ SDIS_HEAT_PATH_NONE, /* Register paths mask */ \ NULL /* RNG state */ \ } @@ -360,9 +353,6 @@ struct sdis_solve_probe_boundary_args { double uv[2]; /* Parametric coordinates of the probe onto the primitve */ double time_range[2]; /* Observation time */ enum sdis_side side; /* Side of iprim on which the probe lies */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; @@ -372,9 +362,6 @@ struct sdis_solve_probe_boundary_args { {0,0}, /* UV */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ SDIS_SIDE_NULL__, \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ SDIS_HEAT_PATH_NONE, \ NULL /* RNG state */ \ } @@ -388,9 +375,6 @@ struct sdis_solve_boundary_args { const enum sdis_side* sides; /* Per primitive side to consider */ size_t nprimitives; /* #primitives */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; @@ -400,9 +384,6 @@ struct sdis_solve_boundary_args { NULL, /* Per primitive side */ \ 0, /* #primitives */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ SDIS_HEAT_PATH_NONE, \ NULL /* RNG state */ \ } @@ -413,9 +394,6 @@ struct sdis_solve_medium_args { size_t nrealisations; /* #realisations */ struct sdis_medium* medium; /* Medium to solve */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; @@ -423,9 +401,6 @@ struct sdis_solve_medium_args { 10000, /* #realisations */ \ NULL, /* Medium */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ SDIS_HEAT_PATH_NONE, \ NULL /* RNG state */ \ } @@ -437,9 +412,6 @@ struct sdis_solve_probe_boundary_flux_args { size_t iprim; /* Identifier of the primitive on which the probe lies */ double uv[2]; /* Parametric coordinates of the probe onto the primitve */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; #define SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ @@ -447,9 +419,6 @@ struct sdis_solve_probe_boundary_flux_args { 0, /* Primitive identifier */ \ {0,0}, /* UV */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ NULL /* RNG state */ \ } static const struct sdis_solve_probe_boundary_flux_args @@ -461,9 +430,6 @@ struct sdis_solve_boundary_flux_args { const size_t* primitives; /* List of boundary primitives to handle */ size_t nprimitives; /* #primitives */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; #define SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ @@ -471,9 +437,6 @@ struct sdis_solve_boundary_flux_args { NULL, /* List or primitive ids */ \ 0, /* #primitives */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ NULL /* RNG state */ \ } static const struct sdis_solve_boundary_flux_args @@ -483,9 +446,6 @@ SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT = struct sdis_solve_camera_args { struct sdis_camera* cam; /* Point of view */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ - double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ size_t image_resolution[2]; /* Image resolution */ size_t spp; /* #samples per pixel */ int register_paths; /* Combination of enum sdis_heat_path_flag */ @@ -493,9 +453,6 @@ struct sdis_solve_camera_args { #define SDIS_SOLVE_CAMERA_ARGS_DEFAULT__ { \ NULL, /* Camera */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ - -1, /* Ambient radiative temperature */ \ - -1, /* Reference temperature */ \ {512,512}, /* Image resolution */ \ 256, /* #realisations per pixel */ \ SDIS_HEAT_PATH_NONE \ @@ -507,14 +464,12 @@ struct sdis_compute_power_args { size_t nrealisations; struct sdis_medium* medium; /* Medium to solve */ double time_range[2]; /* Observation time */ - double fp_to_meter; /* Scale from floating point units to meters */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; #define SDIS_COMPUTE_POWER_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ NULL, /* Medium */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - 1, /* FP to meter */ \ NULL /* RNG state */ \ } static const struct sdis_compute_power_args @@ -763,6 +718,9 @@ sdis_scene_create const size_t nverts, /* #vertices */ void (*position) /* Retrieve the position of the vertex `ivert' */ (const size_t ivert, double pos[3], void* ctx), + const double fp_to_meter, + const double trad, + const double tref, void* ctx, /* Client side data sent as input of the previous callbacks */ struct sdis_scene** scn); @@ -792,6 +750,9 @@ sdis_scene_2d_create const size_t nverts, /* #vertices */ void (*position) /* Retrieve the position of the vertex `ivert' */ (const size_t ivert, double pos[2], void* ctx), + const double fp_to_meter, + const double trad, + const double tref, void* ctx, /* Client side data sent as input of the previous callbacks */ struct sdis_scene** scn); @@ -810,6 +771,44 @@ sdis_scene_get_aabb double lower[3], double upper[3]); +/* Get scene's fp_to_meter */ +SDIS_API res_T +sdis_scene_get_fp_to_meter + (const struct sdis_scene* scn, + double* fp_to_meter); + +/* Set scene's fp_to_meter */ +SDIS_API res_T +sdis_scene_set_fp_to_meter + (struct sdis_scene* scn, + const double fp_to_meter); + +/* Get scene's ambient radiative temperature */ +SDIS_API res_T +sdis_scene_get_ambient_radiative_temperature + (const struct sdis_scene* scn, + double* trad); + +/* Set scene's ambient radiative temperature. If set negative, any sample + * ending in ambient radiative temperature will fail */ +SDIS_API res_T +sdis_scene_set_ambient_radiative_temperature + (struct sdis_scene* scn, + const double trad); + +/* Get scene's reference temperature */ +SDIS_API res_T +sdis_scene_get_reference_temperature + (const struct sdis_scene* scn, + double* tref); + +/* Set scene's reference temperature. If set to 0, there is no radiative + * transfert in the whole system */ +SDIS_API res_T +sdis_scene_set_reference_temperature + (struct sdis_scene* scn, + const double tref); + /* Search the point onto the scene geometry that is the closest of `pos'. The * `radius' parameter controls the maximum search distance around `pos'. The * returned closest point is expressed locally to the geometric primitive onto @@ -1006,6 +1005,12 @@ sdis_green_function_create_from_stream FILE* stream, /* Stream into which the green was serialized */ struct sdis_green_function** green); +/* Retrieve the scene used to compute the green function */ +SDIS_API res_T +sdis_green_function_get_scene + (const struct sdis_green_function* green, + struct sdis_scene** scn); + /* Retrieve the number of valid paths used to estimate the green function. It * is actually equal to the number of successful realisations. */ SDIS_API res_T @@ -1030,17 +1035,28 @@ sdis_green_function_for_each_path /* Retrieve the path's elapsed time */ SDIS_API res_T sdis_green_path_get_elapsed_time - (struct sdis_green_path* path_handle, double* elapsed); + (struct sdis_green_path* path_handle, + double* elapsed); + +/* Retrieve the path's end type. */ +SDIS_API res_T +sdis_green_path_get_end_type + (struct sdis_green_path* path, + enum sdis_green_path_end_type* type); /* Retrieve the spatio-temporal end point of a path used to estimate the green - * function. Note that this point went back in time from the relative - * observation time 0. Its time is thus negative; its absolute value - * represents the time spent by the path into the system. */ + * function. Return RES_BAD_OP for paths ending radiative. */ SDIS_API res_T sdis_green_path_get_limit_point (struct sdis_green_path* path, struct sdis_point* pt); +/* Retrieve the green function the path belongs to */ +SDIS_API res_T +sdis_green_path_get_green_function + (struct sdis_green_path* path_handle, + struct sdis_green_function** green); + /* Retrieve the number of "power terms" associated to a path. */ SDIS_API res_T sdis_green_function_get_power_terms_count diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -105,7 +105,6 @@ static const struct XD(rwalk) XD(RWALK_NULL) = { struct XD(temperature) { res_T (*func)/* Next function to invoke in order to compute the temperature */ (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, diff --git a/src/sdis_green.c b/src/sdis_green.c @@ -28,12 +28,17 @@ #include <rsys/hash_table.h> #include <rsys/mem_allocator.h> #include <rsys/ref_count.h> - #include <rsys/dynamic_array.h> -#include <rsys/ref_count.h> #include <limits.h> +/* Path used to estimate the green function */ +struct sdis_green_path { + /* Internal data. Should not be accessed */ + void* green__; + size_t id__; +}; + struct power_term { double term; /* Power term computed during green estimation */ unsigned id; /* Identifier of the medium of the term */ @@ -85,7 +90,7 @@ struct green_path { struct sdis_interface_fragment fragment; } limit; unsigned limit_id; /* Identifier of the limit medium/interface */ - enum sdis_point_type limit_type; + enum sdis_green_path_end_type end_type; /* Indices of the last accessed medium/interface. Used to speed up the access * to the medium/interface. */ @@ -103,7 +108,7 @@ green_path_init(struct mem_allocator* allocator, struct green_path* path) path->limit.vertex = SDIS_RWALK_VERTEX_NULL; path->limit.fragment = SDIS_INTERFACE_FRAGMENT_NULL; path->limit_id = UINT_MAX; - path->limit_type = SDIS_POINT_NONE; + path->end_type = SDIS_GREEN_PATH_END_TYPES_COUNT__; path->ilast_medium = UINT16_MAX; path->ilast_interf = UINT16_MAX; } @@ -124,7 +129,7 @@ green_path_copy(struct green_path* dst, const struct green_path* src) dst->elapsed_time = src->elapsed_time; dst->limit = src->limit; dst->limit_id = src->limit_id; - dst->limit_type = src->limit_type; + dst->end_type = src->end_type; dst->ilast_medium = src->ilast_medium; dst->ilast_interf = src->ilast_interf; res = darray_flux_term_copy(&dst->flux_terms, &src->flux_terms); @@ -142,7 +147,7 @@ green_path_copy_and_clear(struct green_path* dst, struct green_path* src) dst->elapsed_time = src->elapsed_time; dst->limit = src->limit; dst->limit_id = src->limit_id; - dst->limit_type = src->limit_type; + dst->end_type = src->end_type; dst->ilast_medium = src->ilast_medium; dst->ilast_interf = src->ilast_interf; res = darray_flux_term_copy_and_clear(&dst->flux_terms, &src->flux_terms); @@ -161,7 +166,7 @@ green_path_copy_and_release(struct green_path* dst, struct green_path* src) dst->elapsed_time = src->elapsed_time; dst->limit = src->limit; dst->limit_id = src->limit_id; - dst->limit_type = src->limit_type; + dst->end_type = src->end_type; dst->ilast_medium = src->ilast_medium; dst->ilast_interf = src->ilast_interf; res = darray_flux_term_copy_and_release(&dst->flux_terms, &src->flux_terms); @@ -201,7 +206,7 @@ green_path_write(const struct green_path* path, FILE* stream) /* Write the limit point */ WRITE(&path->limit, 1); WRITE(&path->limit_id, 1); - WRITE(&path->limit_type, 1); + WRITE(&path->end_type, 1); /* Write miscellaneous data */ WRITE(&path->ilast_medium, 1); @@ -253,7 +258,7 @@ green_path_read(struct green_path* path, FILE* stream) /* Read the limit point */ READ(&path->limit, 1); READ(&path->limit_id, 1); - READ(&path->limit_type, 1); + READ(&path->end_type, 1); /* Read the miscellaneous data */ READ(&path->ilast_medium, 1); @@ -419,18 +424,18 @@ green_function_solve_path const struct green_path* path = NULL; const struct sdis_medium* medium = NULL; const struct sdis_interface* interf = NULL; + struct sdis_scene* scn = NULL; struct sdis_rwalk_vertex vtx = SDIS_RWALK_VERTEX_NULL; struct sdis_interface_fragment frag = SDIS_INTERFACE_FRAGMENT_NULL; double power; double flux; - double temperature; - double time_curr; + double end_temperature; size_t i, n; res_T res = RES_OK; ASSERT(green && ipath < darray_green_path_size_get(&green->paths) && weight); path = darray_green_path_cdata_get(&green->paths) + ipath; - if(path->limit_type == SDIS_POINT_NONE) { /* Rejected path */ + if(path->end_type == SDIS_GREEN_PATH_END_ERROR) { /* Rejected path */ res = RES_BAD_OP; goto error; } @@ -456,36 +461,31 @@ green_function_solve_path flux += flux_terms[i].term * interface_side_get_flux(interf, &frag); } - /* Setup time. */ - switch(path->limit_type) { - case SDIS_FRAGMENT: - time_curr = path->limit.fragment.time; + /* Compute path's end temperature */ + switch(path->end_type) { + case SDIS_GREEN_PATH_END_AT_INTERFACE: interf = green_function_fetch_interf(green, path->limit_id); - break; - case SDIS_VERTEX: - time_curr = path->limit.vertex.time; - medium = green_function_fetch_medium(green, path->limit_id); - break; - default: FATAL("Unreachable code.\n"); break; - } - - /* Compute limit condition */ - switch(path->limit_type) { - case SDIS_FRAGMENT: frag = path->limit.fragment; - frag.time = time_curr; - temperature = interface_side_get_temperature(interf, &frag); + end_temperature = interface_side_get_temperature(interf, &frag); break; - case SDIS_VERTEX: + case SDIS_GREEN_PATH_END_IN_VOLUME: + medium = green_function_fetch_medium(green, path->limit_id); vtx = path->limit.vertex; - vtx.time = time_curr; - temperature = medium_get_temperature(medium, &vtx); + end_temperature = medium_get_temperature(medium, &vtx); + break; + case SDIS_GREEN_PATH_END_RADIATIVE: + SDIS(green_function_get_scene(green, &scn)); + SDIS(scene_get_ambient_radiative_temperature(scn, &end_temperature)); + if(end_temperature < 0) { /* Cannot be negative if used */ + res = RES_BAD_ARG; + goto error; + } break; default: FATAL("Unreachable code.\n"); break; } /* Compute the path weight */ - *weight = power + flux + temperature; + *weight = power + flux + end_temperature; exit: return res; @@ -1046,6 +1046,17 @@ error: } res_T +sdis_green_function_get_scene + (const struct sdis_green_function* green, + struct sdis_scene** scn) +{ + if(!green || !scn) return RES_BAD_ARG; + ASSERT(green->npaths_valid != SIZE_MAX); + *scn = green->scn; + return RES_OK; +} + +res_T sdis_green_function_get_paths_count (const struct sdis_green_function* green, size_t* npaths) { @@ -1085,7 +1096,7 @@ sdis_green_function_for_each_path struct sdis_green_path path_handle; const struct green_path* path = darray_green_path_cdata_get(&green->paths)+ipath; - if(path->limit_type == SDIS_POINT_NONE) continue; + if(path->end_type == SDIS_GREEN_PATH_END_ERROR) continue; path_handle.green__ = green; path_handle.id__ = ipath; @@ -1126,6 +1137,31 @@ error: } res_T +sdis_green_path_get_end_type + (struct sdis_green_path* path_handle, enum sdis_green_path_end_type* type) +{ + const struct green_path* path = NULL; + struct sdis_green_function* green = NULL; + res_T res = RES_OK; + + if(!path_handle || !type) { + res = RES_BAD_ARG; + goto error; + } + + green = path_handle->green__; + ASSERT(path_handle->id__ < darray_green_path_size_get(&green->paths)); + + path = darray_green_path_cdata_get(&green->paths) + path_handle->id__; + *type = path->end_type; + +exit: + return res; +error: + goto exit; +} + +res_T sdis_green_path_get_limit_point (struct sdis_green_path* path_handle, struct sdis_point* pt) { @@ -1142,16 +1178,21 @@ sdis_green_path_get_limit_point ASSERT(path_handle->id__ < darray_green_path_size_get(&green->paths)); path = darray_green_path_cdata_get(&green->paths) + path_handle->id__; - pt->type = path->limit_type; - switch(path->limit_type) { - case SDIS_FRAGMENT: + switch(path->end_type) { + case SDIS_GREEN_PATH_END_AT_INTERFACE: pt->data.itfrag.intface = green_function_fetch_interf(green, path->limit_id); pt->data.itfrag.fragment = path->limit.fragment; + pt->type = SDIS_FRAGMENT; break; - case SDIS_VERTEX: + case SDIS_GREEN_PATH_END_IN_VOLUME: pt->data.mdmvert.medium = green_function_fetch_medium(green, path->limit_id); pt->data.mdmvert.vertex = path->limit.vertex; + pt->type = SDIS_VERTEX; + break; + case SDIS_GREEN_PATH_END_RADIATIVE: + res = RES_BAD_OP; + goto error; break; default: FATAL("Unreachable code.\n"); break; } @@ -1163,6 +1204,31 @@ error: } res_T +sdis_green_path_get_green_function + (struct sdis_green_path* path_handle, + struct sdis_green_function** out_green) + +{ + struct sdis_green_function* green = NULL; + res_T res = RES_OK; + + if(!path_handle || !out_green) { + res = RES_BAD_ARG; + goto error; + } + + green = path_handle->green__; + ASSERT(path_handle->id__ < darray_green_path_size_get(&green->paths)); + + *out_green = green; + +exit: + return res; +error: + goto exit; +} + +res_T sdis_green_function_get_power_terms_count (const struct sdis_green_path* path_handle, size_t* nterms) @@ -1437,7 +1503,7 @@ green_function_finalize n = darray_green_path_size_get(&green->paths); FOR_EACH(i, 0, n) { const struct green_path* path = darray_green_path_cdata_get(&green->paths)+i; - green->npaths_valid += path->limit_type != SDIS_POINT_NONE; + green->npaths_valid += (path->end_type != SDIS_GREEN_PATH_END_ERROR); } green->npaths_invalid = n - green->npaths_valid; @@ -1477,13 +1543,13 @@ green_path_set_limit_interface_fragment { res_T res = RES_OK; ASSERT(handle && interf && frag); - ASSERT(handle->path->limit_type == SDIS_POINT_NONE); + ASSERT(handle->path->end_type == SDIS_GREEN_PATH_END_TYPES_COUNT__); res = ensure_interface_registration(handle->green, interf); if(res != RES_OK) return res; handle->path->elapsed_time = elapsed_time; handle->path->limit.fragment = *frag; handle->path->limit_id = interface_get_id(interf); - handle->path->limit_type = SDIS_FRAGMENT; + handle->path->end_type = SDIS_GREEN_PATH_END_AT_INTERFACE; return RES_OK; } @@ -1496,13 +1562,25 @@ green_path_set_limit_vertex { res_T res = RES_OK; ASSERT(handle && mdm && vert); - ASSERT(handle->path->limit_type == SDIS_POINT_NONE); + ASSERT(handle->path->end_type == SDIS_GREEN_PATH_END_TYPES_COUNT__); res = ensure_medium_registration(handle->green, mdm); if(res != RES_OK) return res; handle->path->elapsed_time = elapsed_time; handle->path->limit.vertex = *vert; handle->path->limit_id = medium_get_id(mdm); - handle->path->limit_type = SDIS_VERTEX; + handle->path->end_type = SDIS_GREEN_PATH_END_IN_VOLUME; + return RES_OK; +} + +res_T +green_path_set_limit_radiative + (struct green_path_handle* handle, + const double elapsed_time) +{ + ASSERT(handle); + ASSERT(handle->path->end_type == SDIS_GREEN_PATH_END_TYPES_COUNT__); + handle->path->elapsed_time = elapsed_time; + handle->path->end_type = SDIS_GREEN_PATH_END_RADIATIVE; return RES_OK; } @@ -1622,4 +1700,3 @@ exit: error: goto exit; } - diff --git a/src/sdis_green.h b/src/sdis_green.h @@ -82,6 +82,11 @@ green_path_set_limit_vertex const double elapsed_time); extern LOCAL_SYM res_T +green_path_set_limit_radiative + (struct green_path_handle* handle, + const double elapsed_time); + +extern LOCAL_SYM res_T green_path_add_power_term (struct green_path_handle* path, struct sdis_medium* mdm, diff --git a/src/sdis_heat_path.h b/src/sdis_heat_path.h @@ -115,7 +115,6 @@ extern LOCAL_SYM res_T trace_radiative_path_2d (struct sdis_scene* scn, const float ray_dir[3], - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct ssp_rng* rng, @@ -125,7 +124,6 @@ extern LOCAL_SYM res_T trace_radiative_path_3d (struct sdis_scene* scn, const float ray_dir[3], - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct ssp_rng* rng, @@ -134,7 +132,6 @@ trace_radiative_path_3d extern LOCAL_SYM res_T radiative_path_2d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct ssp_rng* rng, @@ -143,7 +140,6 @@ radiative_path_2d extern LOCAL_SYM res_T radiative_path_3d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct ssp_rng* rng, @@ -155,7 +151,6 @@ radiative_path_3d extern LOCAL_SYM res_T convective_path_2d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct ssp_rng* rng, @@ -164,7 +159,6 @@ convective_path_2d extern LOCAL_SYM res_T convective_path_3d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct ssp_rng* rng, @@ -176,7 +170,6 @@ convective_path_3d extern LOCAL_SYM res_T conductive_path_2d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct ssp_rng* rng, @@ -185,7 +178,6 @@ conductive_path_2d extern LOCAL_SYM res_T conductive_path_3d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct ssp_rng* rng, @@ -197,7 +189,6 @@ conductive_path_3d extern LOCAL_SYM res_T boundary_path_2d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct ssp_rng* rng, @@ -206,7 +197,6 @@ boundary_path_2d extern LOCAL_SYM res_T boundary_path_3d (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct ssp_rng* rng, diff --git a/src/sdis_heat_path_boundary_Xd.h b/src/sdis_heat_path_boundary_Xd.h @@ -458,7 +458,6 @@ XD(check_rwalk_fragment_consistency) static res_T XD(solid_solid_boundary_path) (const struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, const struct sdis_interface_fragment* frag, struct XD(rwalk)* rwalk, @@ -491,7 +490,7 @@ XD(solid_solid_boundary_path) int move; int reinjection_is_valid; res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && ctx && frag && rwalk && rng && T); + ASSERT(scn && ctx && frag && rwalk && rng && T); ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag)); (void)frag, (void)ctx; @@ -589,7 +588,7 @@ XD(solid_solid_boundary_path) /* Handle the volumic power */ power = solid_get_volumic_power(mdm, &rwalk->vtx); if(power != SDIS_VOLUMIC_POWER_NONE) { - const double delta_in_meter = reinject_dst * fp_to_meter; + const double delta_in_meter = reinject_dst * scn->fp_to_meter; const double lambda = solid_get_thermal_conductivity(mdm, &rwalk->vtx); tmp = delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); T->value += power * tmp; @@ -601,7 +600,7 @@ XD(solid_solid_boundary_path) } /* Time rewind */ - res = XD(time_rewind)(mdm, rng, reinject_dst, fp_to_meter, ctx, rwalk, T); + res = XD(time_rewind)(mdm, rng, reinject_dst * scn->fp_to_meter, ctx, rwalk, T); if(res != RES_OK) goto error; if(T->done) goto exit; /* Limit condition was reached */ @@ -633,7 +632,6 @@ error: static res_T XD(solid_fluid_boundary_path) (const struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, const struct sdis_interface_fragment* frag, struct XD(rwalk)* rwalk, @@ -666,7 +664,7 @@ XD(solid_fluid_boundary_path) int iattempt; int reinjection_is_valid = 0; res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T && ctx); + ASSERT(scn && rwalk && rng && T && ctx); ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag)); /* Retrieve the solid and the fluid split by the boundary */ @@ -741,7 +739,7 @@ XD(solid_fluid_boundary_path) hr = 4.0 * BOLTZMANN_CONSTANT * ctx->Tref3 * epsilon; /* Compute the probas to switch in solid, fluid or radiative random walk */ - tmp = lambda / (delta*fp_to_meter); + tmp = lambda / (delta * scn->fp_to_meter); fluid_proba = hc / (tmp + hr + hc); radia_proba = hr / (tmp + hr + hc); /*solid_proba = tmp / (tmp + hr + hc);*/ @@ -759,7 +757,7 @@ XD(solid_fluid_boundary_path) /* Handle the volumic power */ const double power = solid_get_volumic_power(solid, &rwalk->vtx); if(power != SDIS_VOLUMIC_POWER_NONE) { - const double delta_in_meter = reinject_dst * fp_to_meter; + const double delta_in_meter = reinject_dst * scn->fp_to_meter; tmp = delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); T->value += power * tmp; @@ -770,7 +768,7 @@ XD(solid_fluid_boundary_path) } /* Time rewind */ - res = XD(time_rewind)(solid, rng, reinject_dst, fp_to_meter, ctx, rwalk, T); + res = XD(time_rewind)(solid, rng, reinject_dst * scn->fp_to_meter, ctx, rwalk, T); if(res != RES_OK) goto error; if(T->done) goto exit; /* Limit condition was reached */ @@ -803,7 +801,6 @@ error: static res_T XD(solid_boundary_with_flux_path) (const struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, const struct sdis_interface_fragment* frag, const double phi, @@ -888,7 +885,7 @@ XD(solid_boundary_with_flux_path) delta = reinject_dst / sqrt(DIM); /* Handle the flux */ - delta_in_meter = delta*fp_to_meter; + delta_in_meter = delta * scn->fp_to_meter; tmp = delta_in_meter / lambda; T->value += phi * tmp; if(ctx->green_path) { @@ -899,7 +896,7 @@ XD(solid_boundary_with_flux_path) /* Handle the volumic power */ power = solid_get_volumic_power(mdm, &rwalk->vtx); if(power != SDIS_VOLUMIC_POWER_NONE) { - delta_in_meter = reinject_dst * fp_to_meter; + delta_in_meter = reinject_dst * scn->fp_to_meter; tmp = delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); T->value += power * tmp; if(ctx->green_path) { @@ -909,7 +906,7 @@ XD(solid_boundary_with_flux_path) } /* Time rewind */ - res = XD(time_rewind)(mdm, rng, reinject_dst, fp_to_meter, ctx, rwalk, T); + res = XD(time_rewind)(mdm, rng, reinject_dst * scn->fp_to_meter, ctx, rwalk, T); if(res != RES_OK) goto error; if(T->done) goto exit; /* Limit condition was reached */ @@ -945,7 +942,6 @@ error: res_T XD(boundary_path) (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -958,7 +954,7 @@ XD(boundary_path) struct sdis_medium* mdm = NULL; double tmp; res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T); + ASSERT(scn && ctx && rwalk && rng && T); ASSERT(rwalk->mdm == NULL); ASSERT(!SXD_HIT_NONE(&rwalk->hit)); @@ -993,7 +989,7 @@ XD(boundary_path) const double phi = interface_side_get_flux(interf, &frag); if(phi != SDIS_FLUX_NONE) { res = XD(solid_boundary_with_flux_path) - (scn, fp_to_meter, ctx, &frag, phi, rwalk, rng, T); + (scn, ctx, &frag, phi, rwalk, rng, T); if(res != RES_OK) goto error; goto exit; @@ -1004,11 +1000,9 @@ XD(boundary_path) mdm_back = interface_get_medium(interf, SDIS_BACK); if(mdm_front->type == mdm_back->type) { - res = XD(solid_solid_boundary_path) - (scn, fp_to_meter, ctx, &frag, rwalk, rng, T); + res = XD(solid_solid_boundary_path)(scn, ctx, &frag, rwalk, rng, T); } else { - res = XD(solid_fluid_boundary_path) - (scn, fp_to_meter, ctx, &frag, rwalk, rng, T); + res = XD(solid_fluid_boundary_path)(scn, ctx, &frag, rwalk, rng, T); } if(res != RES_OK) goto error; diff --git a/src/sdis_heat_path_conductive_Xd.h b/src/sdis_heat_path_conductive_Xd.h @@ -199,7 +199,6 @@ error: res_T XD(conductive_path) (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -211,7 +210,7 @@ XD(conductive_path) struct sdis_medium* mdm; size_t istep = 0; /* Help for debug */ res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T); + ASSERT(scn && rwalk && rng && T); ASSERT(rwalk->mdm->type == SDIS_SOLID); (void)ctx, (void)istep; @@ -286,12 +285,12 @@ XD(conductive_path) /* Add the volumic power density to the measured temperature */ if(power != SDIS_VOLUMIC_POWER_NONE) { if((S3D_HIT_NONE(&hit0) && S3D_HIT_NONE(&hit1))) { /* Hit nothing */ - const double delta_in_meter = delta * fp_to_meter; + const double delta_in_meter = delta * scn->fp_to_meter; power_factor = delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); T->value += power * power_factor; } else { const double delta_s_adjusted = delta_solid * RAY_RANGE_MAX_SCALE; - const double delta_s_in_meter = delta_solid * fp_to_meter; + const double delta_s_in_meter = delta_solid * scn->fp_to_meter; double h; double h_in_meter; double cos_U_N; @@ -307,7 +306,7 @@ XD(conductive_path) } h = delta * fabs(cos_U_N); - h_in_meter = h * fp_to_meter; + h_in_meter = h * scn->fp_to_meter; /* The regular power term at wall */ tmp = h_in_meter * h_in_meter / (2.0 * lambda); @@ -343,7 +342,7 @@ XD(conductive_path) } /* Rewind the time */ - res = XD(time_rewind)(rwalk->mdm, rng, delta, fp_to_meter, ctx, rwalk, T); + res = XD(time_rewind)(rwalk->mdm, rng, delta * scn->fp_to_meter, ctx, rwalk, T); if(res != RES_OK) goto error; if(T->done) break; /* Limit condition was reached */ diff --git a/src/sdis_heat_path_convective_Xd.h b/src/sdis_heat_path_convective_Xd.h @@ -70,7 +70,6 @@ XD(register_heat_vertex_in_fluid) res_T XD(convective_path) (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -93,8 +92,8 @@ XD(convective_path) float st[2]; #endif res_T res = RES_OK; - (void)rng, (void)fp_to_meter, (void)ctx; - ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T); + (void)rng, (void)ctx; + ASSERT(scn && ctx && rwalk && rng && T); ASSERT(rwalk->mdm->type == SDIS_FLUID); tmp = fluid_get_temperature(rwalk->mdm, &rwalk->vtx); diff --git a/src/sdis_heat_path_radiative_Xd.h b/src/sdis_heat_path_radiative_Xd.h @@ -33,7 +33,6 @@ res_T XD(trace_radiative_path) (struct sdis_scene* scn, const float ray_dir[3], - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -45,8 +44,7 @@ XD(trace_radiative_path) float dir[3] = {0, 0, 0}; res_T res = RES_OK; - ASSERT(scn && ray_dir && fp_to_meter > 0 && ctx && rwalk && rng && T); - (void)fp_to_meter; + ASSERT(scn && ray_dir && ctx && rwalk && rng && T); f3_set(dir, ray_dir); @@ -81,11 +79,8 @@ XD(trace_radiative_path) T->done = 1; if(ctx->green_path) { - struct sdis_rwalk_vertex vtx; - d3_splat(vtx.P, INF); - vtx.time = rwalk->vtx.time; - res = green_path_set_limit_vertex - (ctx->green_path, rwalk->mdm, &vtx, rwalk->elapsed_time); + res = green_path_set_limit_radiative + (ctx->green_path, rwalk->elapsed_time); if(res != RES_OK) goto error; } if(ctx->heat_path) { @@ -193,7 +188,6 @@ error: res_T XD(radiative_path) (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -205,9 +199,8 @@ XD(radiative_path) float dir[3] = {0, 0, 0}; res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T); + ASSERT(scn && ctx && rwalk && rng && T); ASSERT(!SXD_HIT_NONE(&rwalk->hit)); - (void)fp_to_meter; /* Normalize the normal of the interface and ensure that it points toward the * current medium */ @@ -220,7 +213,7 @@ XD(radiative_path) ssp_ran_hemisphere_cos_float(rng, N, dir, NULL); /* Launch the radiative random walk */ - res = XD(trace_radiative_path)(scn, dir, fp_to_meter, ctx, rwalk, rng, T); + res = XD(trace_radiative_path)(scn, dir, ctx, rwalk, rng, T); if(res != RES_OK) goto error; exit: diff --git a/src/sdis_misc.h b/src/sdis_misc.h @@ -138,8 +138,7 @@ extern LOCAL_SYM res_T time_rewind_2d (struct sdis_medium* mdm, /* Medium into which the time is rewinded */ struct ssp_rng* rng, - const double delta, - const double fp_to_meter, + const double dist_in_meter, const struct rwalk_context* ctx, struct rwalk_2d* rwalk, struct temperature_2d* T); @@ -148,8 +147,7 @@ extern LOCAL_SYM res_T time_rewind_3d (struct sdis_medium* mdm, /* Medium into which the time is rewinded */ struct ssp_rng* rng, - const double delta, - const double fp_to_meter, + const double dist_in_meter, const struct rwalk_context* ctx, struct rwalk_3d* rwalk, struct temperature_3d* T); diff --git a/src/sdis_misc_Xd.h b/src/sdis_misc_Xd.h @@ -27,18 +27,16 @@ res_T XD(time_rewind) (struct sdis_medium* mdm, struct ssp_rng* rng, - const double delta, - const double fp_to_meter, + const double dist_in_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct XD(temperature)* T) { - const double delta_in_meter = delta * fp_to_meter; double temperature; double lambda, rho, cp; double tau, mu, t0; res_T res = RES_OK; - ASSERT(mdm && rng && delta && fp_to_meter && ctx && rwalk); + ASSERT(mdm && rng && ctx && rwalk && dist_in_meter > 0); ASSERT(sdis_medium_get_type(mdm) == SDIS_SOLID); ASSERT(T->done == 0); @@ -49,7 +47,7 @@ XD(time_rewind) t0 = solid_get_t0(mdm); /* Limit time */ /* Sample the time to reroll */ - mu = (2*DIM*lambda)/(rho*cp*delta_in_meter*delta_in_meter); + mu = (2*DIM*lambda)/(rho*cp*dist_in_meter*dist_in_meter); tau = ssp_ran_exp(rng, mu); /* Increment the elapsed time */ diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c @@ -29,9 +29,6 @@ ray_realisation_3d const double position[], const double direction[], const double time, - const double fp_to_meter, - const double Tarad, - const double Tref, struct sdis_heat_path* heat_path, /* May be NULL */ double* weight) { @@ -40,8 +37,8 @@ ray_realisation_3d struct temperature_3d T = TEMPERATURE_NULL_3d; float dir[3]; res_T res = RES_OK; - ASSERT(scn && position && direction && time>=0 && fp_to_meter>0 && weight); - ASSERT(Tref >= 0 && medium && medium->type == SDIS_FLUID); + ASSERT(scn && position && direction && time>=0 && weight); + ASSERT(medium && medium->type == SDIS_FLUID); d3_set(rwalk.vtx.P, position); rwalk.vtx.time = time; @@ -49,8 +46,9 @@ ray_realisation_3d rwalk.hit_side = SDIS_SIDE_NULL__; rwalk.mdm = medium; - ctx.Tarad = Tarad; - ctx.Tref3 = Tref*Tref*Tref; + ctx.Tarad = scn->ambient_radiative_temperature; + ctx.Tref3 = scn->reference_temperature * scn->reference_temperature + * scn->reference_temperature; ctx.heat_path = heat_path; f3_set_d3(dir, direction); @@ -59,11 +57,11 @@ ray_realisation_3d res = register_heat_vertex(heat_path, &rwalk.vtx, 0, SDIS_HEAT_VERTEX_RADIATIVE); if(res != RES_OK) goto error; - res = trace_radiative_path_3d(scn, dir, fp_to_meter, &ctx, &rwalk, rng, &T); + res = trace_radiative_path_3d(scn, dir, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; if(!T.done) { - res = compute_temperature_3d(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = compute_temperature_3d(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; } diff --git a/src/sdis_realisation.h b/src/sdis_realisation.h @@ -43,9 +43,6 @@ probe_realisation_2d struct sdis_medium* medium, const double position[2], const double time, - const double fp_to_meter,/* Scale factor from floating point unit to meter */ - const double ambient_radiative_temperature, - const double reference_temperature, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight); @@ -58,9 +55,6 @@ probe_realisation_3d struct sdis_medium* medium, const double position[3], const double time, - const double fp_to_meter,/* Scale factor from floating point unit to meter */ - const double ambient_radiative_temperature, - const double reference_temperature, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight); @@ -76,9 +70,6 @@ boundary_realisation_2d const double u[1], const double time, const enum sdis_side side, - const double fp_to_meter, - const double ambient_radiative_temperature, - const double reference_temperature, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight); @@ -91,9 +82,6 @@ boundary_realisation_3d const double uv[2], const double time, const enum sdis_side side, - const double fp_to_meter, - const double ambient_radiative_temperature, - const double reference_temperature, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight); @@ -106,9 +94,6 @@ boundary_flux_realisation_2d const double uv[1], const double time, const enum sdis_side solid_side, - const double fp_to_meter, - const double ambient_radiative_temperature, - const double reference_temperature, const int flux_mask, /* Combination of enum flux_flag */ double weight[FLUX_NAMES_COUNT__]); @@ -120,9 +105,6 @@ boundary_flux_realisation_3d const double uv[2], const double time, const enum sdis_side solid_side, - const double fp_to_meter, - const double ambient_radiative_temperature, - const double reference_temperature, const int flux_mask, /* Combination of enum flux_flag */ double weight[FLUX_NAMES_COUNT__]); @@ -137,9 +119,6 @@ ray_realisation_3d const double position[3], const double direction[3], const double time, - const double fp_to_meter, - const double ambient_radiative_temperature, - const double reference_temperature, struct sdis_heat_path* heat_path, /* May be NULL */ double* weight); diff --git a/src/sdis_realisation_Xd.h b/src/sdis_realisation_Xd.h @@ -32,7 +32,6 @@ static res_T XD(compute_temperature) (struct sdis_scene* scn, - const double fp_to_meter, const struct rwalk_context* ctx, struct XD(rwalk)* rwalk, struct ssp_rng* rng, @@ -50,7 +49,7 @@ XD(compute_temperature) /* Maximum accepted #failures before stopping the realisation */ const size_t MAX_FAILS = 1; res_T res = RES_OK; - ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T); + ASSERT(scn && ctx && rwalk && rng && T); if(ctx->heat_path && T->func == XD(boundary_path)) { heat_vtx = heat_path_get_last_vertex(ctx->heat_path); @@ -72,7 +71,7 @@ XD(compute_temperature) /* Reject the step if a BAD_OP occurs and retry up to MAX_FAILS times */ do { - res = T->func(scn, fp_to_meter, ctx, rwalk, rng, T); + 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; @@ -119,9 +118,6 @@ XD(probe_realisation) struct sdis_medium* medium, const double position[], const double time, - const double fp_to_meter,/* Scale factor from floating point unit to meter */ - const double ambient_radiative_temperature, - const double reference_temperature, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight) @@ -135,7 +131,7 @@ XD(probe_realisation) (const struct sdis_medium* mdm, const struct sdis_rwalk_vertex* vtx); res_T res = RES_OK; - ASSERT(medium && position && fp_to_meter > 0 && weight && time >= 0); + ASSERT(medium && position && weight && time >= 0); (void)irealisation; switch(medium->type) { @@ -186,13 +182,13 @@ XD(probe_realisation) ctx.green_path = green_path; ctx.heat_path = heat_path; - ctx.Tarad = ambient_radiative_temperature; + ctx.Tarad = scn->ambient_radiative_temperature; ctx.Tref3 = - reference_temperature - * reference_temperature - * reference_temperature; + scn->reference_temperature + * scn->reference_temperature + * scn->reference_temperature; - res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; ASSERT(T.value >= 0); @@ -212,9 +208,6 @@ XD(boundary_realisation) const double uv[2], const double time, const enum sdis_side side, - const double fp_to_meter, - const double Tarad, - const double Tref, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ double* weight) @@ -229,7 +222,7 @@ XD(boundary_realisation) float st[2]; #endif res_T res = RES_OK; - ASSERT(uv && fp_to_meter > 0 && weight && time >= 0); + ASSERT(uv && weight && time >= 0); T.func = XD(boundary_path); rwalk.hit_side = side; @@ -267,10 +260,11 @@ XD(boundary_realisation) ctx.green_path = green_path; ctx.heat_path = heat_path; - ctx.Tarad = Tarad; - ctx.Tref3 = Tref*Tref*Tref; + ctx.Tarad = scn->ambient_radiative_temperature; + ctx.Tref3 = scn->reference_temperature * scn->reference_temperature + * scn->reference_temperature; - res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; *weight = T.value; @@ -289,9 +283,6 @@ XD(boundary_flux_realisation) const double uv[DIM], const double time, const enum sdis_side solid_side, - const double fp_to_meter, - const double Tarad, - const double Tref, const int flux_mask, double weight[3]) { @@ -310,13 +301,14 @@ XD(boundary_flux_realisation) #endif double P[SDIS_XD_DIMENSION]; float N[SDIS_XD_DIMENSION]; - const double Tr3 = Tref * Tref * Tref; + const double Tr3 = scn->reference_temperature * scn->reference_temperature + * scn->reference_temperature; const enum sdis_side fluid_side = (solid_side == SDIS_FRONT) ? SDIS_BACK : SDIS_FRONT; res_T res = RES_OK; const char compute_radiative = (flux_mask & FLUX_FLAG_RADIATIVE) != 0; const char compute_convective = (flux_mask & FLUX_FLAG_CONVECTIVE) != 0; - ASSERT(uv && fp_to_meter > 0 && weight && time >= 0 && Tref >= 0); + ASSERT(uv && weight && time >= 0 ); #if SDIS_XD_DIMENSION == 2 #define SET_PARAM(Dest, Src) (Dest).u = (Src); @@ -345,7 +337,7 @@ XD(boundary_flux_realisation) rwalk.mdm = (Mdm); \ rwalk.hit.prim = prim; \ SET_PARAM(rwalk.hit, st); \ - ctx.Tarad = Tarad; \ + ctx.Tarad = scn->ambient_radiative_temperature; \ ctx.Tref3 = Tr3; \ dX(set)(rwalk.vtx.P, P); \ fX(set)(rwalk.hit.normal, N); \ @@ -355,7 +347,7 @@ XD(boundary_flux_realisation) /* Compute boundary temperature */ RESET_WALK(solid_side, NULL); T.func = XD(boundary_path); - res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) return res; weight[0] = T.value; @@ -367,7 +359,7 @@ XD(boundary_flux_realisation) if(compute_radiative) { RESET_WALK(fluid_side, fluid_mdm); T.func = XD(radiative_path); - res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) return res; weight[1] = T.value; } @@ -376,7 +368,7 @@ XD(boundary_flux_realisation) if(compute_convective) { RESET_WALK(fluid_side, fluid_mdm); T.func = XD(convective_path); - res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T); + res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) return res; weight[2] = T.value; } diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -130,11 +130,14 @@ sdis_scene_create void (*interf)(const size_t itri, struct sdis_interface** bound, void*), const size_t nverts, /* #vertices */ void (*position)(const size_t ivert, double pos[3], void* ctx), + const double fp_to_meter, + const double trad, + const double tref, void* ctx, struct sdis_scene** out_scn) { return scene_create_3d - (dev, ntris, indices, interf, nverts, position, ctx, out_scn); + (dev, ntris, indices, interf, nverts, position, fp_to_meter, trad, tref, ctx, out_scn); } res_T @@ -145,11 +148,14 @@ sdis_scene_2d_create 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), + const double fp_to_meter, + const double trad, + const double tref, void* ctx, struct sdis_scene** out_scn) { return scene_create_2d - (dev, nsegs, indices, interf, nverts, position, ctx, out_scn); + (dev, nsegs, indices, interf, nverts, position, fp_to_meter, trad, tref, ctx, out_scn); } res_T @@ -191,6 +197,66 @@ sdis_scene_get_aabb } res_T +sdis_scene_get_fp_to_meter + (const struct sdis_scene* scn, + double* fp_to_meter) +{ + if(!scn || !fp_to_meter) return RES_BAD_ARG; + *fp_to_meter = scn->fp_to_meter; + return RES_OK; +} + +res_T +sdis_scene_set_fp_to_meter + (struct sdis_scene* scn, + const double fp_to_meter) +{ + if(!scn || fp_to_meter <= 0) return RES_BAD_ARG; + scn->fp_to_meter = fp_to_meter; + return RES_OK; +} + +res_T +sdis_scene_get_ambient_radiative_temperature + (const struct sdis_scene* scn, + double* trad) +{ + if(!scn || !trad) return RES_BAD_ARG; + *trad = scn->ambient_radiative_temperature; + return RES_OK; +} + +res_T +sdis_scene_set_reference_temperature + (struct sdis_scene* scn, + const double tref) +{ + if(!scn || tref < 0) return RES_BAD_ARG; + scn->reference_temperature = tref; + return RES_OK; +} + +res_T +sdis_scene_get_reference_temperature + (const struct sdis_scene* scn, + double* tref) +{ + if(!scn || !tref) return RES_BAD_ARG; + *tref = scn->reference_temperature; + return RES_OK; +} + +res_T +sdis_scene_set_ambient_radiative_temperature + (struct sdis_scene* scn, + const double trad) +{ + if(!scn) return RES_BAD_ARG; + scn->ambient_radiative_temperature = trad; + return RES_OK; +} + +res_T sdis_scene_find_closest_point (const struct sdis_scene* scn, const double pos[3], diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -856,6 +856,9 @@ XD(scene_create) void (*interf)(const size_t iprim, struct sdis_interface** bound, void*), const size_t nverts, /* #vertices */ void (*position)(const size_t ivert, double pos[], void* ctx), + const double fp_to_meter, + const double trad, + const double tref, void* ctx, struct sdis_scene** out_scn) { @@ -864,7 +867,8 @@ XD(scene_create) res_T res = RES_OK; if(!dev || !out_scn || !nprims || !indices || !interf || !nverts - || !position || nprims > UINT_MAX || nverts > UINT_MAX) { + || !position || nprims > UINT_MAX || nverts > UINT_MAX + || fp_to_meter <= 0 || tref < 0) { res = RES_BAD_ARG; goto error; } @@ -878,7 +882,9 @@ XD(scene_create) ref_init(&scn->ref); SDIS(device_ref_get(dev)); scn->dev = dev; - scn->ambient_radiative_temperature = -1; + scn->fp_to_meter = fp_to_meter; + scn->ambient_radiative_temperature = trad; + scn->reference_temperature = tref; scn->outer_enclosure_id = UINT_MAX; darray_interf_init(dev->allocator, &scn->interfaces); darray_medium_init(dev->allocator, &scn->media); diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h @@ -208,7 +208,9 @@ struct sdis_scene { struct htable_enclosure enclosures; /* Map an enclosure id to its data */ unsigned outer_enclosure_id; + double fp_to_meter; double ambient_radiative_temperature; /* In Kelvin */ + double reference_temperature; ref_T ref; struct sdis_device* dev; diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -68,9 +68,6 @@ solve_pixel struct sdis_medium* mdm, const struct sdis_camera* cam, const double time_range[2], /* Observation time */ - const double fp_to_meter, /* Scale from floating point units to meters */ - const double Tarad, /* In Kelvin */ - const double Tref, /* In Kelvin */ const size_t ipix[2], /* Pixel coordinate in the image plane */ const size_t nrealisations, const int register_paths, /* Combination of enum sdis_heat_path_flag */ @@ -82,7 +79,7 @@ solve_pixel struct sdis_heat_path* pheat_path = NULL; size_t irealisation; res_T res = RES_OK; - ASSERT(scn && mdm && rng && cam && ipix && nrealisations && Tref >= 0); + ASSERT(scn && mdm && rng && cam && ipix && nrealisations); ASSERT(pix_sz && pix_sz[0] > 0 && pix_sz[1] > 0); ASSERT(estimator && time_range); @@ -115,7 +112,7 @@ solve_pixel /* Launch the realisation */ res_simul = ray_realisation_3d(scn, rng, mdm, ray_pos, ray_dir, - time, fp_to_meter, Tarad, Tref, pheat_path, &w); + time, pheat_path, &w); /* Handle fatal error */ if(res_simul != RES_OK && res_simul != RES_BAD_OP) { @@ -170,9 +167,6 @@ solve_tile struct sdis_medium* mdm, const struct sdis_camera* cam, const double time_range[2], - const double fp_to_meter, - const double Tarad, - const double Tref, const size_t origin[2], /* Tile origin in image plane */ const size_t size[2], /* #pixels in X and Y */ const size_t spp, /* #samples per pixel */ @@ -183,7 +177,7 @@ solve_tile size_t mcode; /* Morton code of the tile pixel */ size_t npixels; res_T res = RES_OK; - ASSERT(scn && rng && mdm && cam && spp && origin && Tref >= 0); + ASSERT(scn && rng && mdm && cam && spp && origin); ASSERT(size &&size[0] && size[1] && buf); ASSERT(pix_sz && pix_sz[0] > 0 && pix_sz[1] > 0 && time_range); @@ -206,7 +200,7 @@ solve_tile /* Fetch the pixel estimator */ estimator = estimator_buffer_grab(buf, ipix[0], ipix[1]); - res = solve_pixel(scn, rng, mdm, cam, time_range, fp_to_meter, Tarad, Tref, + res = solve_pixel(scn, rng, mdm, cam, time_range, ipix, spp, register_paths, pix_sz, estimator); if(res != RES_OK) goto error; } @@ -362,12 +356,9 @@ sdis_solve_camera || !args || !out_buf || !args->cam - || args->fp_to_meter <= 0 || !args->image_resolution[0] || !args->image_resolution[1] || !args->spp - || args->ambient_radiative_temperature < 0 - || args->reference_temperature < 0 || args->time_range[0] < 0 || args->time_range[1] < args->time_range[0] || ( args->time_range[1] > DBL_MAX @@ -448,9 +439,7 @@ sdis_solve_camera /* Draw the tile */ res_local = solve_tile(scn, rng, medium, args->cam, args->time_range, - args->fp_to_meter, args->ambient_radiative_temperature, - args->reference_temperature, tile_org, tile_sz, args->spp, - args->register_paths, pix_sz, buf); + tile_org, tile_sz, args->spp, args->register_paths, pix_sz, buf); if(res_local != RES_OK) { ATOMIC_SET(&res, res_local); continue; diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -102,8 +102,7 @@ XD(solve_boundary) ATOMIC res = RES_OK; if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX - || !args->primitives || !args->sides || !args->nprimitives - || args->fp_to_meter <= 0) { + || !args->primitives || !args->sides || !args->nprimitives) { res = RES_BAD_ARG; goto error; } @@ -299,8 +298,7 @@ XD(solve_boundary) /* Invoke the boundary realisation */ res_simul = XD(boundary_realisation)(scn, rng, iprim, uv, time, side, - args->fp_to_meter, args->ambient_radiative_temperature, - args->reference_temperature, pgreen_path, pheat_path, &w); + pgreen_path, pheat_path, &w); /* Fatal error */ if(res_simul != RES_OK && res_simul != RES_BAD_OP) { @@ -460,7 +458,6 @@ XD(solve_boundary_flux) || args->time_range[1] < args->time_range[0] || (args->time_range[1] > DBL_MAX && args->time_range[0] != args->time_range[1]) || !args->nprimitives - || args->fp_to_meter < 0 || !out_estimator) { res = RES_BAD_ARG; goto error; @@ -575,8 +572,7 @@ XD(solve_boundary_flux) const struct sdis_medium *fmd, *bmd; enum sdis_side solid_side, fluid_side; double T_brf[3] = { 0, 0, 0 }; - const double Tref = args->reference_temperature; - const double Tarad = args->ambient_radiative_temperature; + const double Tref = scn->reference_temperature; double epsilon, hc, hr, imposed_flux, imposed_temp; size_t iprim; double uv[DIM - 1]; @@ -659,7 +655,7 @@ XD(solve_boundary_flux) if(hr > 0) flux_mask |= FLUX_FLAG_RADIATIVE; if(hc > 0) flux_mask |= FLUX_FLAG_CONVECTIVE; res_simul = XD(boundary_flux_realisation)(scn, rng, iprim, uv, time, - solid_side, args->fp_to_meter, Tarad, Tref, flux_mask, T_brf); + solid_side, flux_mask, T_brf); /* Stop time registration */ time_sub(&t0, time_current(&t1), &t0); diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -222,7 +222,7 @@ XD(solve_medium) ATOMIC res = RES_OK; if(!scn || !args || !args->medium || !args->nrealisations - || args->nrealisations > INT64_MAX || args->fp_to_meter <= 0) { + || args->nrealisations > INT64_MAX) { res = RES_BAD_ARG; goto error; } @@ -349,9 +349,7 @@ XD(solve_medium) /* Run a probe realisation */ res_simul = XD(probe_realisation)((size_t)irealisation, scn, rng, - args->medium, pos, time, args->fp_to_meter, - args->ambient_radiative_temperature, args->reference_temperature, - pgreen_path, pheat_path, &weight); + args->medium, pos, time, pgreen_path, pheat_path, &weight); if(res_simul != RES_OK && res_simul != RES_BAD_OP) { ATOMIC_SET(&res, res_simul); @@ -497,7 +495,6 @@ XD(compute_power) || !args->medium || !args->nrealisations || args->nrealisations > INT64_MAX - || args->fp_to_meter <= 0 || args->time_range[0] < 0 || args->time_range[0] > args->time_range[1] || ( args->time_range[1] > DBL_MAX diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h @@ -53,8 +53,7 @@ XD(solve_probe) ATOMIC nsolved_realisations = 0; ATOMIC res = RES_OK; - if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX - || args->fp_to_meter <= 0) { + if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX) { res = RES_BAD_ARG; goto error; } @@ -167,9 +166,7 @@ XD(solve_probe) } res_simul = XD(probe_realisation)((size_t)irealisation, scn, rng, medium, - args->position, time, args->fp_to_meter, - args->ambient_radiative_temperature, args->reference_temperature, - pgreen_path, pheat_path, &w); + args->position, time, pgreen_path, pheat_path, &w); /* Handle fatal error */ if(res_simul != RES_OK && res_simul != RES_BAD_OP) { diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -53,7 +53,7 @@ XD(solve_probe_boundary) ATOMIC res = RES_OK; if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX - || args->fp_to_meter <= 0 || ((unsigned)args->side >= SDIS_SIDE_NULL__)) { + || ((unsigned)args->side >= SDIS_SIDE_NULL__)) { res = RES_BAD_ARG; goto error; } @@ -203,8 +203,7 @@ XD(solve_probe_boundary) } res_simul = XD(boundary_realisation)(scn, rng, args->iprim, args->uv, time, - args->side, args->fp_to_meter, args->ambient_radiative_temperature, - args->reference_temperature, pgreen_path, pheat_path, &w); + args->side, pgreen_path, pheat_path, &w); /* Handle fatal error */ if(res_simul != RES_OK && res_simul != RES_BAD_OP) { @@ -353,7 +352,7 @@ XD(solve_probe_boundary_flux) if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX || args->time_range[0] < 0 || args->time_range[1] < args->time_range[0] || (args->time_range[1]>DBL_MAX && args->time_range[0] != args->time_range[1]) - || args->fp_to_meter <= 0 || !out_estimator) { + || !out_estimator) { res = RES_BAD_ARG; goto error; } @@ -480,8 +479,7 @@ XD(solve_probe_boundary_flux) double time, epsilon, hc, hr, imposed_flux, imposed_temp; int flux_mask = 0; double T_brf[3] = { 0, 0, 0 }; - const double Tref = args->reference_temperature; - const double Tarad = args->ambient_radiative_temperature; + const double Tref = scn->reference_temperature; size_t n; int pcent; res_T res_simul = RES_OK; @@ -515,7 +513,7 @@ XD(solve_probe_boundary_flux) if(hr > 0) flux_mask |= FLUX_FLAG_RADIATIVE; if(hc > 0) flux_mask |= FLUX_FLAG_CONVECTIVE; res_simul = XD(boundary_flux_realisation)(scn, rng, args->iprim, args->uv, - time, solid_side, args->fp_to_meter, Tarad, Tref, flux_mask, T_brf); + time, solid_side, flux_mask, T_brf); /* Stop time registration */ time_sub(&t0, time_current(&t1), &t0); diff --git a/src/test_sdis_compute_mean_power.c b/src/test_sdis_compute_mean_power.c @@ -227,7 +227,7 @@ main(int argc, char** argv) ntris = ctx.msh0.nprimitives + ctx.msh1.nprimitives; nverts = ctx.msh0.nvertices + ctx.msh1.nvertices; OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); /* Test sdis_compute_power function */ args.nrealisations = N; @@ -243,9 +243,6 @@ main(int argc, char** argv) args.medium = NULL; BA(sdis_compute_power(scn, &args, &estimator)); args.medium = solid0; - args.fp_to_meter = 0; - BA(sdis_compute_power(scn, &args, &estimator)); - args.fp_to_meter = 1; args.time_range[0] = args.time_range[1] = -1; BA(sdis_compute_power(scn, &args, &estimator)); args.time_range[0] = 1; @@ -293,7 +290,7 @@ main(int argc, char** argv) ctx.interf0 = interf0; ctx.interf1 = interf0; OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); /* Check invalid medium */ args.time_range[0] = args.time_range[1] = 1; diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c @@ -392,7 +392,7 @@ main(int argc, char** argv) geom.indices = indices; geom.interfaces = prim_interfaces; OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface, nvertices, - get_position, &geom, &scn)); + get_position, 1, 0, Tref, &geom, &scn)); hr = 4.0 * BOLTZMANN_CONSTANT * Tref*Tref*Tref * emissivity; @@ -427,7 +427,6 @@ main(int argc, char** argv) solve_args.position[0] = ssp_rng_uniform_double(rng, -0.9, 0.9); solve_args.position[1] = ssp_rng_uniform_double(rng, -0.9, 0.9); solve_args.position[2] = ssp_rng_uniform_double(rng, -0.9, 0.9); - solve_args.reference_temperature = Tref; OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_estimator_get_realisation_count(estimator, &nreals)); diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c @@ -379,7 +379,7 @@ main(int argc, char** argv) geom.indices = indices; geom.interfaces = prim_interfaces; OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, nvertices, - get_position, &geom, &scn)); + get_position, 1, 0, Tref, &geom, &scn)); hr = 4*BOLTZMANN_CONSTANT * Tref*Tref*Tref * emissivity; tmp = lambda/(2*lambda + thickness*hr) * (T1 - T0); @@ -405,7 +405,6 @@ main(int argc, char** argv) solve_args.position[1] = ssp_rng_uniform_double(rng, -0.9, 0.9); solve_args.time_range[0] = INF; solve_args.time_range[1] = INF; - solve_args.reference_temperature = Tref; OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_estimator_get_realisation_count(estimator, &nreals)); diff --git a/src/test_sdis_convection.c b/src/test_sdis_convection.c @@ -246,12 +246,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, -1, 0, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, -1, 0, square_interfaces, &square_scn)); /* Release the interfaces */ diff --git a/src/test_sdis_convection_non_uniform.c b/src/test_sdis_convection_non_uniform.c @@ -262,12 +262,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, -1, 0, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, -1, 0, square_interfaces, &square_scn)); /* Release the interfaces */ diff --git a/src/test_sdis_flux.c b/src/test_sdis_flux.c @@ -426,12 +426,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, -1, 0, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, -1, 0, square_interfaces, &square_scn)); /* Release the interfaces */ diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -116,27 +116,29 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) #define POS get_position_3d #define IFA get_interface - BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, &ctx, NULL)); - BA(CREATE(dev, 0, IDS, IFA, npos, POS, &ctx, &scn)); - BA(CREATE(dev, ntris, NULL, IFA, npos, POS, &ctx, &scn)); - 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)); + BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, 0, -1, -1, &ctx, NULL)); + BA(CREATE(dev, 0, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, NULL, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, IDS, NULL, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, IDS, IFA, 0, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, IDS, IFA, npos, NULL, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, ntris, IDS, IFA, npos, POS, 1, -1, -1, &ctx, &scn)); /* Duplicated vertex */ ctx.positions = duplicated_vertices; ctx.indices = dup_vrtx_indices; - BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); /* Duplicated triangle */ ctx.positions = box_vertices; ctx.indices = duplicated_indices; - BA(CREATE(dev, 2, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 2, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); /* Degenerated triangle */ ctx.indices = degenerated_indices; - BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); ctx.positions = box_vertices; ctx.indices = box_indices; - OK(CREATE(dev, ntris, IDS, IFA, npos, POS, &ctx, &scn)); + OK(CREATE(dev, ntris, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); #undef CREATE #undef IDS @@ -244,7 +246,7 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) struct sdis_scene* scn = NULL; double lower[2], upper[2]; double u0, u1, u2, pos[2], pos1[2]; - double dst; + double dst, fp, t; struct context ctx; struct senc2d_scene* scn2d; struct senc3d_scene* scn3d; @@ -265,27 +267,29 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) #define POS get_position_2d #define IFA get_interface - BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, &ctx, NULL)); - BA(CREATE(dev, 0, IDS, IFA, npos, POS, &ctx, &scn)); - BA(CREATE(dev, nsegs, NULL, IFA, npos, POS, &ctx, &scn)); - 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)); + BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, 0, -1, -1, &ctx, NULL)); + BA(CREATE(dev, 0, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, NULL, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, IDS, NULL, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, IDS, IFA, 0, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, IDS, IFA, npos, NULL, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn)); + BA(CREATE(dev, nsegs, IDS, IFA, npos, POS, 1, -1, -1, &ctx, &scn)); /* Duplicated vertex */ ctx.positions = duplicated_vertices; ctx.indices = dup_vrtx_indices; - BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); /* Duplicated segment */ ctx.positions = square_vertices; ctx.indices = duplicated_indices; - BA(CREATE(dev, 2, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 2, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); /* Degenerated segment */ ctx.indices = degenerated_indices; - BA(CREATE(dev, 1, IDS, IFA, npos, POS, &ctx, &scn)); + BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); ctx.positions = square_vertices; ctx.indices = square_indices; - OK(CREATE(dev, nsegs, IDS, IFA, npos, POS, &ctx, &scn)); + OK(CREATE(dev, nsegs, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn)); #undef CREATE #undef IDS @@ -308,6 +312,46 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) u0 = 0.5; + BA(sdis_scene_get_fp_to_meter(NULL, NULL)); + BA(sdis_scene_get_fp_to_meter(scn, NULL)); + BA(sdis_scene_get_fp_to_meter(NULL, &fp)); + OK(sdis_scene_get_fp_to_meter(scn, &fp)); + CHK(fp == 1); + + fp = 0; + BA(sdis_scene_set_fp_to_meter(NULL, fp)); + BA(sdis_scene_set_fp_to_meter(scn, fp)); + fp = 2; + OK(sdis_scene_set_fp_to_meter(scn, fp)); + OK(sdis_scene_get_fp_to_meter(scn, &fp)); + CHK(fp == 2); + + BA(sdis_scene_get_ambient_radiative_temperature(NULL, NULL)); + BA(sdis_scene_get_ambient_radiative_temperature(scn, NULL)); + BA(sdis_scene_get_ambient_radiative_temperature(NULL, &t)); + OK(sdis_scene_get_ambient_radiative_temperature(scn, &t)); + CHK(t == -1); + + t = 100; + BA(sdis_scene_set_ambient_radiative_temperature(NULL, t)); + OK(sdis_scene_set_ambient_radiative_temperature(scn, t)); + OK(sdis_scene_get_ambient_radiative_temperature(scn, &t)); + CHK(t == 100); + + BA(sdis_scene_get_reference_temperature(NULL, NULL)); + BA(sdis_scene_get_reference_temperature(scn, NULL)); + BA(sdis_scene_get_reference_temperature(NULL, &t)); + OK(sdis_scene_get_reference_temperature(scn, &t)); + CHK(t == 0); + + t = -1; + BA(sdis_scene_set_reference_temperature(NULL, t)); + BA(sdis_scene_set_reference_temperature(scn, t)); + t = 100; + OK(sdis_scene_set_reference_temperature(scn, t)); + OK(sdis_scene_get_reference_temperature(scn, &t)); + CHK(t == 100); + BA(sdis_scene_get_boundary_position(NULL, 1, &u0, pos)); BA(sdis_scene_get_boundary_position(scn, 4, &u0, pos)); BA(sdis_scene_get_boundary_position(scn, 1, NULL, pos)); diff --git a/src/test_sdis_solid_random_walk_robustness.c b/src/test_sdis_solid_random_walk_robustness.c @@ -332,7 +332,7 @@ main(int argc, char** argv) /* Create the scene */ ctx.interf = interf; OK(sdis_scene_create(dev, ctx.msh.nprimitives, get_indices, get_interface, - ctx.msh.nvertices, get_position, &ctx, &scn)); + ctx.msh.nvertices, get_position, 1, -1, 0, &ctx, &scn)); /*dump_mesh(stdout, ctx.msh.positions, ctx.msh.nvertices, ctx.msh.indices, ctx.msh.nprimitives);*/ diff --git a/src/test_sdis_solve_boundary.c b/src/test_sdis_solve_boundary.c @@ -279,12 +279,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, -1, 0, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, -1, 0, square_interfaces, &square_scn)); /* Release the interfaces */ diff --git a/src/test_sdis_solve_boundary_flux.c b/src/test_sdis_solve_boundary_flux.c @@ -22,7 +22,7 @@ * The scene is composed of a solid cube/square whose temperature is unknown. * The convection coefficient with the surrounding fluid is null excepted for * the X faces whose value is 'H'. The Temperature T of the -X face is fixed - * to Tb. The ambiant radiative temperature is 0 excepted for the X faces + * to Tb. The ambient radiative temperature is 0 excepted for the X faces * whose value is 'Trad'. * This test computes temperature and fluxes on the X faces and check that * they are equal to: @@ -326,12 +326,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, Trad, Tref, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, Trad, Tref, square_interfaces, &square_scn)); /* Release the interfaces */ @@ -351,8 +351,6 @@ main(int argc, char** argv) probe_args.uv[1] = 0.3; probe_args.time_range[0] = INF; probe_args.time_range[1] = INF; - probe_args.ambient_radiative_temperature = Trad; - probe_args.reference_temperature = Tref; BA(SOLVE(NULL, &probe_args, &estimator)); BA(SOLVE(box_scn, NULL, &estimator)); BA(SOLVE(box_scn, &probe_args, NULL)); @@ -407,8 +405,6 @@ main(int argc, char** argv) bound_args.nprimitives = 2; bound_args.time_range[0] = INF; bound_args.time_range[1] = INF; - bound_args.ambient_radiative_temperature = Trad; - bound_args.reference_temperature = Tref; BA(SOLVE(NULL, &bound_args, &estimator)); BA(SOLVE(box_scn, NULL, &estimator)); diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c @@ -610,7 +610,7 @@ main(int argc, char** argv) npos = sa_size(geom.positions) / 3; /* #positions */ OK(sdis_scene_create(dev, ntris, geometry_get_indices, geometry_get_interface, npos, geometry_get_position, - &geom, &scn)); + 1, 300, 300, &geom, &scn)); #if 0 dump_mesh(stdout, geom.positions, sa_size(geom.positions)/3, geom.indices, @@ -635,8 +635,6 @@ main(int argc, char** argv) solve_args.time_range[0] = INF; solve_args.image_resolution[0] = IMG_WIDTH; solve_args.image_resolution[1] = IMG_HEIGHT; - solve_args.ambient_radiative_temperature = 300; - solve_args.reference_temperature = 300; solve_args.spp = SPP; BA(sdis_solve_camera(NULL, &solve_args, &buf)); @@ -645,15 +643,9 @@ main(int argc, char** argv) solve_args.cam = NULL; BA(sdis_solve_camera(scn, &solve_args, &buf)); solve_args.cam = cam; - solve_args.fp_to_meter = 0; + OK(sdis_scene_set_ambient_radiative_temperature(scn, -1)); BA(sdis_solve_camera(scn, &solve_args, &buf)); - solve_args.fp_to_meter = 1; - solve_args.ambient_radiative_temperature = -1; - BA(sdis_solve_camera(scn, &solve_args, &buf)); - solve_args.ambient_radiative_temperature = 300; - solve_args.reference_temperature = -1; - BA(sdis_solve_camera(scn, &solve_args, &buf)); - solve_args.reference_temperature = 300; + OK(sdis_scene_set_ambient_radiative_temperature(scn, 300)); solve_args.time_range[0] = solve_args.time_range[1] = -1; BA(sdis_solve_camera(scn, &solve_args, &buf)); solve_args.time_range[0] = 1; diff --git a/src/test_sdis_solve_medium.c b/src/test_sdis_solve_medium.c @@ -338,7 +338,7 @@ main(int argc, char** argv) #endif OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); BA(sdis_scene_get_medium_spread(NULL, solid0, &v0)); BA(sdis_scene_get_medium_spread(scn, NULL, &v0)); @@ -366,9 +366,6 @@ main(int argc, char** argv) solve_args.medium = NULL; BA(sdis_solve_medium(scn, &solve_args, &estimator)); solve_args.medium = solid0; - solve_args.fp_to_meter = 0; - BA(sdis_solve_medium(scn, &solve_args, &estimator)); - solve_args.fp_to_meter = 1; solve_args.time_range[0] = solve_args.time_range[1] = -1; BA(sdis_solve_medium(scn, &solve_args, &estimator)); solve_args.time_range[0] = 1; @@ -419,7 +416,7 @@ main(int argc, char** argv) ctx.interf0 = solid0_fluid0; ctx.interf1 = solid0_fluid1; OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); OK(sdis_scene_get_medium_spread(scn, solid0, &v)); CHK(eq_eps(v, v0+v1, 1.e-6)); @@ -451,9 +448,6 @@ main(int argc, char** argv) solve_args.medium = solid1; BA(sdis_solve_medium_green_function(scn, &solve_args, &green)); solve_args.medium = solid0; - solve_args.fp_to_meter = 0; - BA(sdis_solve_medium_green_function(scn, &solve_args, &green)); - solve_args.fp_to_meter = 1; OK(sdis_solve_medium_green_function(scn, &solve_args, &green)); OK(sdis_green_function_solve(green, &estimator2)); diff --git a/src/test_sdis_solve_medium_2d.c b/src/test_sdis_solve_medium_2d.c @@ -326,7 +326,7 @@ main(int argc, char** argv) ctx.interf0 = solid0_fluid0; ctx.interf1 = solid1_fluid1; OK(sdis_scene_2d_create(dev, sa_size(indices)/2, get_indices, get_interface, - sa_size(positions)/2, get_position, &ctx, &scn)); + sa_size(positions)/2, get_position, 1, -1, 0, &ctx, &scn)); OK(sdis_scene_get_medium_spread(scn, solid0, &a0)); CHK(eq_eps(a0, 1.0, 1.e-6)); @@ -371,7 +371,7 @@ main(int argc, char** argv) ctx.interf0 = solid0_fluid0; ctx.interf1 = solid0_fluid1; OK(sdis_scene_2d_create(dev, sa_size(indices)/2, get_indices, get_interface, - sa_size(positions)/2, get_position, &ctx, &scn)); + sa_size(positions)/2, get_position, 1, -1, 0, &ctx, &scn)); OK(sdis_scene_get_medium_spread(scn, solid0, &a)); CHK(eq_eps(a, a0+a1, 1.e-6)); diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c @@ -336,7 +336,7 @@ main(int argc, char** argv) ctx.indices = box_indices; ctx.interf = interf; OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface, - box_nvertices, get_position, &ctx, &scn)); + box_nvertices, get_position, 1, -1, 0, &ctx, &scn)); OK(sdis_interface_ref_put(interf)); @@ -354,9 +354,6 @@ main(int argc, char** argv) solve_args.nrealisations = 0; BA(sdis_solve_probe(scn, &solve_args, &estimator)); solve_args.nrealisations = N; - solve_args.fp_to_meter = 0; - BA(sdis_solve_probe(scn, &solve_args, &estimator)); - solve_args.fp_to_meter = 1; solve_args.time_range[0] = solve_args.time_range[1] = -1; BA(sdis_solve_probe(scn, &solve_args, &estimator)); solve_args.time_range[0] = 1; @@ -433,9 +430,6 @@ main(int argc, char** argv) solve_args.nrealisations = 0; BA(sdis_solve_probe_green_function(scn, &solve_args, &green)); solve_args.nrealisations = N; - solve_args.fp_to_meter = 0; - BA(sdis_solve_probe_green_function(scn, &solve_args, &green)); - solve_args.fp_to_meter = 1; OK(sdis_solve_probe_green_function(scn, &solve_args, &green)); BA(sdis_green_function_solve(NULL, &estimator2)); @@ -452,6 +446,7 @@ main(int argc, char** argv) /* Check same green used at a different temperature */ fluid_param->temperature = 500; + OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_estimator_get_realisation_count(estimator, &nreals)); OK(sdis_estimator_get_failure_count(estimator, &nfails)); @@ -532,6 +527,39 @@ main(int argc, char** argv) OK(sdis_estimator_for_each_path(estimator, process_heat_path, &dump_ctx)); OK(sdis_estimator_ref_put(estimator)); + + printf("\n"); + + /* Green and ambient radiative temperature */ + solve_args.nrealisations = N; + OK(sdis_scene_set_ambient_radiative_temperature(scn, 300)); + OK(sdis_scene_set_reference_temperature(scn, 300)); + + interface_param->epsilon = 1; + + OK(sdis_solve_probe(scn, &solve_args, &estimator)); + OK(sdis_solve_probe_green_function(scn, &solve_args, &green)); + OK(sdis_green_function_solve(green, &estimator2)); + + check_green_function(green); + check_estimator_eq(estimator, estimator2); + + OK(sdis_estimator_ref_put(estimator)); + OK(sdis_estimator_ref_put(estimator2)); + + /* Check same green used at different ambient radiative temperature */ + OK(sdis_scene_set_ambient_radiative_temperature(scn, 600)); + + OK(sdis_solve_probe(scn, &solve_args, &estimator)); + OK(sdis_green_function_solve(green, &estimator2)); + + check_green_function(green); + check_estimator_eq(estimator, estimator2); + + OK(sdis_estimator_ref_put(estimator)); + OK(sdis_estimator_ref_put(estimator2)); + OK(sdis_green_function_ref_put(green)); + OK(sdis_scene_ref_put(scn)); OK(sdis_device_ref_put(dev)); diff --git a/src/test_sdis_solve_probe2.c b/src/test_sdis_solve_probe2.c @@ -231,7 +231,7 @@ main(int argc, char** argv) ctx.indices = box_indices; ctx.interfaces = interfaces; OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface, - box_nvertices, get_position, &ctx, &scn)); + box_nvertices, get_position, 1, -1, 0, &ctx, &scn)); /* Release the interfaces */ OK(sdis_interface_ref_put(Tnone)); diff --git a/src/test_sdis_solve_probe2_2d.c b/src/test_sdis_solve_probe2_2d.c @@ -229,7 +229,7 @@ main(int argc, char** argv) ctx.indices = square_indices; ctx.interfaces = interfaces; OK(sdis_scene_2d_create(dev, square_nsegments, get_indices, get_interface, - square_nvertices, get_position, &ctx, &scn)); + square_nvertices, get_position, 1, -1, 0, &ctx, &scn)); /* Release the interfaces */ OK(sdis_interface_ref_put(Tnone)); diff --git a/src/test_sdis_solve_probe3.c b/src/test_sdis_solve_probe3.c @@ -283,7 +283,7 @@ main(int argc, char** argv) nverts = sa_size(ctx.positions) / 3; ntris = sa_size(ctx.indices) / 3; OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); /* Release the scene data */ OK(sdis_interface_ref_put(Tnone)); diff --git a/src/test_sdis_solve_probe3_2d.c b/src/test_sdis_solve_probe3_2d.c @@ -277,7 +277,7 @@ main(int argc, char** argv) nverts = sa_size(ctx.positions) / 2; nsegs = sa_size(ctx.indices) / 2; OK(sdis_scene_2d_create(dev, nsegs, get_indices, get_interface, nverts, - get_position, &ctx, &scn)); + get_position, 1, -1, 0, &ctx, &scn)); /* Release the scene data */ OK(sdis_interface_ref_put(Tnone)); diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c @@ -193,7 +193,7 @@ main(int argc, char** argv) ctx.indices = square_indices; ctx.interf = interf; OK(sdis_scene_2d_create(dev, square_nsegments, get_indices, get_interface, - square_nvertices, get_position, &ctx, &scn)); + square_nvertices, get_position, 1, -1, 0, &ctx, &scn)); OK(sdis_interface_ref_put(interf)); diff --git a/src/test_sdis_transcient.c b/src/test_sdis_transcient.c @@ -558,7 +558,7 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface, - box_nvertices, get_position, &ctx, &box_scn)); + box_nvertices, get_position, 1, -1, 0, &ctx, &box_scn)); /* Setup the box2 scene context */ ctx.indices = indices; @@ -578,7 +578,7 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface, - nvertices, get_position, &ctx, &box2_scn)); + nvertices, get_position, 1, -1, 0, &ctx, &box2_scn)); /* Setup the matriochka context */ matriochka_ctx.interfs[0] = matriochka_ctx.interfs[1] = interfs[4]; /* Zmin */ @@ -594,7 +594,7 @@ main(int argc, char** argv) /* Create the matriochka scene */ OK(sdis_scene_create(dev, box_ntriangles*nmatriochkas, matriochka_indices, matriocka_interface, box_nvertices*nmatriochkas, matriochka_position, - &matriochka_ctx, &box_matriochka_scn)); + 1, -1, 0, &matriochka_ctx, &box_matriochka_scn)); /* Setup and run the simulation */ probe[0] = 0.1; diff --git a/src/test_sdis_utils.c b/src/test_sdis_utils.c @@ -94,9 +94,10 @@ solve_green_path(struct sdis_green_path* path, void* ctx) struct green_accum* acc = NULL; struct sdis_data* data = NULL; enum sdis_medium_type type; + enum sdis_green_path_end_type end_type; double power = 0; double flux = 0; - double temp = 0; + double time, temp = 0; double weight = 0; CHK(path && ctx); @@ -110,11 +111,40 @@ solve_green_path(struct sdis_green_path* path, void* ctx) BA(sdis_green_path_for_each_flux_term(path, NULL, &acc)); OK(sdis_green_path_for_each_flux_term(path, accum_flux_terms, &flux)); + BA(sdis_green_path_get_elapsed_time(NULL, NULL)); + BA(sdis_green_path_get_elapsed_time(path, NULL)); + BA(sdis_green_path_get_elapsed_time(NULL, &time)); + OK(sdis_green_path_get_elapsed_time(path, &time)); + + BA(sdis_green_path_get_end_type(NULL, NULL)); + BA(sdis_green_path_get_end_type(path, NULL)); + BA(sdis_green_path_get_end_type(NULL, &end_type)); + OK(sdis_green_path_get_end_type(path, &end_type)); + + BA(sdis_green_path_get_limit_point(NULL, NULL)); BA(sdis_green_path_get_limit_point(NULL, &pt)); BA(sdis_green_path_get_limit_point(path, NULL)); - OK(sdis_green_path_get_limit_point(path, &pt)); - - switch(pt.type) { + if(end_type == SDIS_GREEN_PATH_END_RADIATIVE) { + struct sdis_green_function* green; + struct sdis_scene* scn; + BO(sdis_green_path_get_limit_point(path, &pt)); + BA(sdis_green_path_get_green_function(NULL, NULL)); + BA(sdis_green_path_get_green_function(path, NULL)); + BA(sdis_green_path_get_green_function(NULL, &green)); + OK(sdis_green_path_get_green_function(path, &green)); + + BA(sdis_green_function_get_scene(NULL, NULL)); + BA(sdis_green_function_get_scene(NULL, &scn)); + BA(sdis_green_function_get_scene(green, NULL)); + OK(sdis_green_function_get_scene(green, &scn)); + + BA(sdis_scene_get_ambient_radiative_temperature(NULL, NULL)); + BA(sdis_scene_get_ambient_radiative_temperature(scn, NULL)); + BA(sdis_scene_get_ambient_radiative_temperature(NULL, &temp)); + OK(sdis_scene_get_ambient_radiative_temperature(scn, &temp)); + } else { + OK(sdis_green_path_get_limit_point(path, &pt)); + switch(pt.type) { case SDIS_FRAGMENT: frag = pt.data.itfrag.fragment; OK(sdis_interface_get_shader(pt.data.itfrag.intface, &interf)); @@ -136,6 +166,7 @@ solve_green_path(struct sdis_green_path* path, void* ctx) } break; default: FATAL("Unreachable code.\n"); break; + } } weight = temp + power + flux; diff --git a/src/test_sdis_utils.h b/src/test_sdis_utils.h @@ -26,6 +26,7 @@ #define OK(Cond) CHK((Cond) == RES_OK) #define BA(Cond) CHK((Cond) == RES_BAD_ARG) +#define BO(Cond) CHK((Cond) == RES_BAD_OP) /******************************************************************************* * Box geometry diff --git a/src/test_sdis_volumic_power.c b/src/test_sdis_volumic_power.c @@ -464,12 +464,12 @@ main(int argc, char** argv) /* Create the box scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, - box_get_interface, box_nvertices, box_get_position, box_interfaces, - &box_scn)); + box_get_interface, box_nvertices, box_get_position, 1, -1, 0, + box_interfaces, &box_scn)); /* Create the square scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, - square_get_interface, square_nvertices, square_get_position, + square_get_interface, square_nvertices, square_get_position, 1, -1, 0, square_interfaces, &square_scn)); /* Release the interfaces */ diff --git a/src/test_sdis_volumic_power2.c b/src/test_sdis_volumic_power2.c @@ -426,7 +426,7 @@ main(int argc, char** argv) /* Create the scene */ OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface, - nvertices, get_position, interfaces, &scn)); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); #if 0 dump_mesh(stdout, vertices, nvertices, indices, ntriangles); @@ -442,7 +442,7 @@ main(int argc, char** argv) solid_param = sdis_data_get(data); solid_param->lambda = 0.1; OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface, - nvertices, get_position, interfaces, &scn)); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); printf("\n>>> Check 2\n"); check(scn, refs2, sizeof(refs2)/sizeof(struct reference)); diff --git a/src/test_sdis_volumic_power2_2d.c b/src/test_sdis_volumic_power2_2d.c @@ -447,7 +447,7 @@ main(int argc, char** argv) /* Create the scene */ OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, - nvertices, get_position, interfaces, &scn)); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); printf(">>> Check 1\n"); check(scn, refs1, sizeof(refs1)/sizeof(struct reference)); @@ -458,7 +458,7 @@ main(int argc, char** argv) solid_param = sdis_data_get(data); solid_param->lambda = 0.1; OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, - nvertices, get_position, interfaces, &scn) ); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); printf("\n>>> Check 2\n"); check(scn, refs2, sizeof(refs2)/sizeof(struct reference)); @@ -473,7 +473,7 @@ main(int argc, char** argv) solid_param->lambda = 10; solid_param->P = SDIS_VOLUMIC_POWER_NONE; OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, - nvertices, get_position, interfaces, &scn)); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); printf("\n>>> Check 3\n"); check(scn, refs3, sizeof(refs3)/sizeof(struct reference)); diff --git a/src/test_sdis_volumic_power3_2d.c b/src/test_sdis_volumic_power3_2d.c @@ -415,7 +415,7 @@ main(int argc, char** argv) /* Create the scene */ OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, - nvertices, get_position, interfaces, &scn)); + nvertices, get_position, 1, -1, 0, interfaces, &scn)); /* Release the interfaces */ OK(sdis_interface_ref_put(interf_solid_adiabatic)); diff --git a/src/test_sdis_volumic_power4.c b/src/test_sdis_volumic_power4.c @@ -327,7 +327,7 @@ main(int argc, char** argv) /* Create the 2D scene */ OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, get_interface, - square_nvertices, get_position_2d, interfaces, &scn_2d)); + square_nvertices, get_position_2d, 1, -1, 0, interfaces, &scn_2d)); /* Map the interfaces to their box triangles */ interfaces[0] = interfaces[1] = interf_adiabatic; /* Front */ @@ -339,7 +339,7 @@ main(int argc, char** argv) /* Create the 3D scene */ OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, get_interface, - box_nvertices, get_position_3d, interfaces, &scn_3d)); + box_nvertices, get_position_3d, 1, -1, 0, interfaces, &scn_3d)); /* Release the interfaces */ OK(sdis_interface_ref_put(interf_adiabatic));