stardis-solver

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

commit f13048f493ead83434cc627f75f743af7eb3511c
parent 22441dbce8822c2123ad4d30620caf2987311732
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 18 Oct 2021 16:12:41 +0200

Merge branch 'release_0.12.2'

Diffstat:
MREADME.md | 6++++++
Mcmake/CMakeLists.txt | 4++--
Msrc/sdis.h | 14+++++++-------
Msrc/sdis_device.c | 4++--
Msrc/sdis_green.c | 51+++++++--------------------------------------------
Asrc/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h | 257+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/sdis_interface.c | 4++--
Msrc/sdis_realisation.c | 4++--
Msrc/sdis_realisation_Xd.h | 6+++---
Msrc/sdis_scene.c | 8+++++---
Msrc/sdis_scene_Xd.h | 4++--
Msrc/sdis_solve.c | 2+-
Msrc/sdis_solve_boundary_Xd.h | 4++--
Msrc/sdis_solve_medium_Xd.h | 4++--
Msrc/sdis_solve_probe_Xd.h | 2+-
Msrc/sdis_solve_probe_boundary_Xd.h | 4++--
Msrc/test_sdis_compute_power.c | 8++++----
Msrc/test_sdis_conducto_radiative.c | 6+++---
Msrc/test_sdis_conducto_radiative_2d.c | 6+++---
Msrc/test_sdis_contact_resistance.c | 2+-
Msrc/test_sdis_contact_resistance.h | 8++++----
Msrc/test_sdis_contact_resistance_2.c | 2+-
Msrc/test_sdis_flux.c | 2+-
Msrc/test_sdis_transcient.c | 4++--
Msrc/test_sdis_unstationary_atm.c | 10+++++-----
Msrc/test_sdis_utils.h | 8++++----
Msrc/test_sdis_volumic_power.c | 2+-
Msrc/test_sdis_volumic_power2.c | 4++--
Msrc/test_sdis_volumic_power2_2d.c | 4++--
Msrc/test_sdis_volumic_power3_2d.c | 4++--
30 files changed, 338 insertions(+), 110 deletions(-)

diff --git a/README.md b/README.md @@ -111,6 +111,12 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.12.2 + +- Sets the required version of Star-SampPling to 0.12. This version fixes + compilation errors with gcc 11 but introduces API breaks. +- Fix warnings detected by gcc 11. + ### Version 0.12.1 Updates the way numerical issues are handled during a conductive random walk. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -31,7 +31,7 @@ CMAKE_DEPENDENT_OPTION(ALL_TESTS find_package(RCMake 0.4 REQUIRED) find_package(Star2D 0.5 REQUIRED) find_package(Star3D 0.8 REQUIRED) -find_package(StarSP 0.8 REQUIRED) +find_package(StarSP 0.12 REQUIRED) find_package(StarEnc2D 0.5 REQUIRED) find_package(StarEnc3D 0.5 REQUIRED) find_package(RSys 0.12 REQUIRED) @@ -57,7 +57,7 @@ rcmake_append_runtime_dirs(_runtime_dirs ############################################################################### set(VERSION_MAJOR 0) set(VERSION_MINOR 12) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(SDIS_FILES_SRC diff --git a/src/sdis.h b/src/sdis.h @@ -807,8 +807,8 @@ sdis_scene_ref_put SDIS_API res_T sdis_scene_get_aabb (const struct sdis_scene* scn, - double lower[3], - double upper[3]); + double lower[], + double upper[]); /* Get scene's fp_to_meter */ SDIS_API res_T @@ -857,10 +857,10 @@ sdis_scene_set_reference_temperature SDIS_API res_T sdis_scene_find_closest_point (const struct sdis_scene* scn, - const double pos[3], /* Query position */ + const double pos[], /* Query position */ const double radius, /* Maximum search distance around pos */ size_t* iprim, /* Primitive index onto which the closest point lies */ - double uv[2]); /* Parametric cordinate onto the primitive */ + double uv[]); /* Parametric cordinate onto the primitive */ /* Define the world space position of a point onto the primitive `iprim' whose * parametric coordinate is uv. */ @@ -868,8 +868,8 @@ SDIS_API res_T sdis_scene_get_boundary_position (const struct sdis_scene* scn, const size_t iprim, /* Primitive index */ - const double uv[2], /* Parametric coordinate onto the primitive */ - double pos[3]); /* World space position */ + const double uv[], /* Parametric coordinate onto the primitive */ + double pos[]); /* World space position */ /* roject a world space position onto a primitive wrt its normal and compute * the parametric coordinates of the projected point onto the primitive. This @@ -902,7 +902,7 @@ SDIS_API res_T sdis_scene_boundary_project_position (const struct sdis_scene* scn, const size_t iprim, - const double pos[3], + const double pos[], double uv[]); /* Get the 2D scene's enclosures. Only defined for a 2D scene. */ diff --git a/src/sdis_device.c b/src/sdis_device.c @@ -148,7 +148,7 @@ create_rng_from_rng_proxy const struct ssp_rng_proxy* proxy, struct ssp_rng** out_rng) { - struct ssp_rng_type rng_type; + enum ssp_rng_type rng_type; struct ssp_rng* rng = NULL; FILE* stream = NULL; res_T res = RES_OK; @@ -163,7 +163,7 @@ create_rng_from_rng_proxy } SSP(rng_proxy_get_type(proxy, &rng_type)); - res = ssp_rng_create(dev->allocator, &rng_type, &rng); + res = ssp_rng_create(dev->allocator, rng_type, &rng); if(res != RES_OK) { log_err(dev, "Could not create the RNG -- %s\n", res_to_cstr(res)); goto error; diff --git a/src/sdis_green.c b/src/sdis_green.c @@ -303,7 +303,7 @@ struct sdis_green_function { struct accum realisation_time; /* Time per realisation */ - struct ssp_rng_type rng_type; + enum ssp_rng_type rng_type; FILE* rng_state; ref_T ref; @@ -313,38 +313,6 @@ struct sdis_green_function { /******************************************************************************* * Helper functions ******************************************************************************/ -enum rng_type { - RNG_KISS, - RNG_MT_19937_64, - RNG_RANLUX48, - RNG_THREEFRY, - RNG_UNKNOWN -}; - -static INLINE enum rng_type -get_rng_type_enum(const struct ssp_rng_type* type) -{ - ASSERT(type); - if(ssp_rng_type_eq(type, &ssp_rng_kiss)) return RNG_KISS; - if(ssp_rng_type_eq(type, &ssp_rng_mt19937_64)) return RNG_MT_19937_64; - if(ssp_rng_type_eq(type, &ssp_rng_ranlux48)) return RNG_RANLUX48; - if(ssp_rng_type_eq(type, &ssp_rng_threefry)) return RNG_THREEFRY; - return RNG_UNKNOWN; -} - -static INLINE void -get_rng_type_ssp(const enum rng_type type, struct ssp_rng_type* ssp_type) -{ - switch(type) { - case RNG_KISS: *ssp_type = ssp_rng_kiss; break; - case RNG_MT_19937_64: *ssp_type = ssp_rng_mt19937_64; break; - case RNG_RANLUX48: *ssp_type = ssp_rng_ranlux48; break; - case RNG_THREEFRY: *ssp_type = ssp_rng_threefry; break; - case RNG_UNKNOWN: memset(ssp_type, 0, sizeof(*ssp_type)); break; - default: FATAL("Unreachable code.\n"); break; - } -} - static res_T ensure_medium_registration (struct sdis_green_function* green, @@ -894,7 +862,6 @@ res_T sdis_green_function_write(struct sdis_green_function* green, FILE* stream) { struct ssp_rng* rng = NULL; - enum rng_type rng_type = RNG_UNKNOWN; hash256_T hash; res_T res = RES_OK; @@ -910,10 +877,9 @@ sdis_green_function_write(struct sdis_green_function* green, FILE* stream) } \ } (void)0 - rng_type = get_rng_type_enum(&green->rng_type); - if(rng_type == RNG_UNKNOWN) { + if(green->rng_type == SSP_RNG_TYPE_NULL) { log_err(green->scn->dev, - "%s: could not function a green function with an unknown RNG type.\n", + "%s: could not write a green function with an unknown RNG type.\n", FUNC_NAME); res = RES_BAD_ARG; goto error; @@ -935,11 +901,11 @@ sdis_green_function_write(struct sdis_green_function* green, FILE* stream) WRITE(&green->npaths_valid, 1); WRITE(&green->npaths_invalid, 1); WRITE(&green->realisation_time, 1); - WRITE(&rng_type, 1); + WRITE(&green->rng_type, 1); #undef WRITE /* Create a temporary RNG used to serialise the RNG state */ - res = ssp_rng_create(green->scn->dev->allocator, &green->rng_type, &rng); + res = ssp_rng_create(green->scn->dev->allocator, green->rng_type, &rng); if(res != RES_OK) goto error; rewind(green->rng_state); res = ssp_rng_read(rng, green->rng_state); @@ -963,7 +929,6 @@ sdis_green_function_create_from_stream hash256_T hash0, hash1; struct sdis_green_function* green = NULL; struct ssp_rng* rng = NULL; - enum rng_type rng_type = RNG_UNKNOWN; int version = 0; res_T res = RES_OK; @@ -1020,13 +985,11 @@ sdis_green_function_create_from_stream READ(&green->npaths_valid, 1); READ(&green->npaths_invalid, 1); READ(&green->realisation_time, 1); - READ(&rng_type, 1); + READ(&green->rng_type, 1); #undef READ - get_rng_type_ssp(rng_type, &green->rng_type); - /* Create a temporary RNG used to deserialise the RNG state */ - res = ssp_rng_create(green->scn->dev->allocator, &green->rng_type, &rng); + res = ssp_rng_create(green->scn->dev->allocator, green->rng_type, &rng); if(res != RES_OK) goto error; res = ssp_rng_read(rng, stream); if(res != RES_OK) goto error; diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h @@ -0,0 +1,257 @@ +/* Copyright (C) 2016-2021 |Meso|Star> (contact@meso-star.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "sdis_green.h" +#include "sdis_heat_path_boundary_c.h" +#include "sdis_interface_c.h" +#include "sdis_medium_c.h" +#include "sdis_misc.h" +#include "sdis_scene_c.h" + +#include <star/ssp.h> + +#include "sdis_Xd_begin.h" + +/******************************************************************************* + * Boundary path between a solid and a fluid + ******************************************************************************/ +res_T +XD(solid_fluid_boundary_picard1_path) + (const struct sdis_scene* scn, + const struct rwalk_context* ctx, + const struct sdis_interface_fragment* frag, + struct XD(rwalk)* rwalk, + struct ssp_rng* rng, + struct XD(temperature)* T) +{ + struct sdis_interface* interf = NULL; + struct sdis_medium* mdm_front = NULL; + struct sdis_medium* mdm_back = NULL; + struct sdis_medium* solid = NULL; + struct sdis_medium* fluid = NULL; + struct XD(rwalk) rwalk_saved; + struct sXd(hit) hit = SXD_HIT_NULL; + struct sdis_interface_fragment frag_fluid; + double hc; + double hr; + double epsilon; /* Interface emissivity */ + double lambda; + double fluid_proba; + double radia_proba; + double delta; + double delta_boundary; + double r; + double tmp; + float dir0[DIM], dir1[DIM]; + float reinject_dst; + /* In 2D it is useless to try to resample a reinjection direction since there + * is only one possible direction */ + const int MAX_ATTEMPTS = DIM == 2 ? 1 : 10; + int iattempt; + int reinjection_is_valid = 0; + res_T res = RES_OK; + ASSERT(scn && rwalk && rng && T && ctx); + ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag)); + + /* Retrieve the solid and the fluid split by the boundary */ + interf = scene_get_interface(scn, rwalk->hit.prim.prim_id); + mdm_front = interface_get_medium(interf, SDIS_FRONT); + mdm_back = interface_get_medium(interf, SDIS_BACK); + ASSERT(mdm_front->type != mdm_back->type); + + /* Setup the fluid side fragment */ + frag_fluid = *frag; + if(mdm_front->type == SDIS_SOLID) { + solid = mdm_front; + fluid = mdm_back; + frag_fluid.side = SDIS_BACK; + } else { + solid = mdm_back; + fluid = mdm_front; + frag_fluid.side = SDIS_FRONT; + } + + /* Fetch the boundary properties */ + epsilon = interface_side_get_emissivity(interf, &frag_fluid); + Tref = interface_side_get_reference_temperature(interf, &frag_fluid); + + /* Fetch the solid properties */ + lambda = solid_get_thermal_conductivity(solid, &rwalk->vtx); + delta = solid_get_delta(solid, &rwalk->vtx); + + /* Note that the reinjection distance is *FIXED*. It MUST ensure that the + * orthogonal distance from the boundary to the point to chalenge is equal to + * delta. */ + delta_boundary = sqrt(DIM) * delta; + + rwalk_saved = *rwalk; + reinjection_is_valid = 0; + iattempt = 0; + do { + if(iattempt != 0) *rwalk = rwalk_saved; + + /* Sample a reinjection direction */ + XD(sample_reinjection_dir)(rwalk, rng, dir0); + + /* Reflect the sampled direction around the normal */ + XD(reflect)(dir1, dir0, rwalk->hit.normal); + + if(solid == mdm_back) { + fX(minus)(dir0, dir0); + fX(minus)(dir1, dir1); + } + + /* Select the solid reinjection direction and distance */ + res = XD(select_reinjection_dir_and_check_validity)(scn, solid, rwalk, + dir0, dir1, delta_boundary, dir0, &reinject_dst, 1, NULL, + &reinjection_is_valid, &hit); + if(res != RES_OK) goto error; + + } while(!reinjection_is_valid && ++iattempt < MAX_ATTEMPTS); + + /* Could not find a valid reinjecton */ + if(iattempt >= MAX_ATTEMPTS) { + *rwalk = rwalk_saved; + log_warn(scn->dev, + "%s: could not find a valid solid/fluid reinjection at {%g, %g %g}.\n", + FUNC_NAME, SPLIT3(rwalk->vtx.P)); + res = RES_BAD_OP_IRRECOVERABLE; + goto error; + } + + /* Define the orthogonal dst from the reinjection pos to the interface */ + delta = reinject_dst / sqrt(DIM); + + /* Compute the convective, conductive and the upper bound radiative coef */ + h_conv = interface_get_convection_coef(interf, frag); + h_cond = lambda / (delta * scn->fp_to_meter); + h_rad_hat = 4.0 * BOLTZMANN_CONSTANT * ctx->That3 * epsilon; + + /* Compute a global upper bound coefficient */ + h_hat = h_conv + h_cond + h_rad_hat; + + /* Compute the probas to switch in solid, fluid or radiative random walk */ + p_conv = h_conv / h_hat; + p_cond = h_cond / h_hat; + + /* Null collision */ + for(;;) { + r = ssp_rng_canonical(rng); + + /* Switch in convective path */ + if(r < p_conv) { + T->func = XD(convective_path); + rwalk->mdm = fluid; + rwalk->hit_side = rwalk->mdm == mdm_front ? SDIS_FRONT : SDIS_BACK; + break; + } + + /* Switch in conductive path */ + if(r < p_conv + p_cond) { + /* 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 * scn->fp_to_meter; + tmp = delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); + T->value += power * tmp; + + if(ctx->green_path) { + res = green_path_add_power_term(ctx->green_path, solid, &rwalk->vtx, tmp); + if(res != RES_OK) goto error; + } + } + + /* Time rewind */ + 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 */ + + /* Perform solid reinjection */ + XD(move_pos)(rwalk->vtx.P, dir0, reinject_dst); + if(hit.distance == reinject_dst) { + T->func = XD(boundary_path); + rwalk->mdm = NULL; + rwalk->hit = hit; + rwalk->hit_side = fX(dot)(hit.normal, dir0) < 0 ? SDIS_FRONT : SDIS_BACK; + } else { + T->func = XD(conductive_path); + rwalk->mdm = solid; + rwalk->hit = SXD_HIT_NULL; + rwalk->hit_side = SDIS_SIDE_NULL__; + } + + /* Register the new vertex against the heat path */ + res = register_heat_vertex + (ctx->heat_path, &rwalk->vtx, T->value, SDIS_HEAT_VERTEX_CONDUCTION); + if(res != RES_OK) goto error; + break; + } + + /* From there, we know the path is either a radiative path or a + * null-collision */ + + /* Trace a candidate radiative path and get the Tref at its end. + * TODO handle the registration of the path geometry */ + T_candidate = *T; + rwalk_candidate = *rwalk; + res = XD(radiative_path)(scn, ctx, &rwalk_candidate, rng, T_candidate); + if(res != RES_OK) goto error; + + /* Get the Tref at the end of the candidate radiative path */ + if(T_candidate->done) { + Tref_candidate = T_candidate->value; + } else { + ASSERT(!SXD_HIT_NONE(rwalk_candidate->hit)); + XD(setup_interface_fragment) + (&frag_candidate, &rwalk_candidate->vtx, &rwalk_candidate->hit, + rwalk_candidate->hit_side); + interf_candidate = scene_get_interface + (scn, rwalk_candidate->hit.prim.prim_id); + + Tref_candidate = interface_side_get_reference_temperature(interf, f&rag); + } + + if(Tref_candidate < 0) { + log_err(scn->dev, + "%s: invalid reference temperature `%gK' at the position `%g %g %g'.\n", + FUNC_NAME, Tref_candidate, SPLIT3(rwalk_candidate->vtx.P)); + res = RES_BAD_OP_IRRECOVERABLE; + goto error; + } + + h_rad = BOLTZMANN_CONSTANT + * epsilon + * ( Tref*Tref*Tref + + Tref*Tref * Tref_candidate + + Tref* Tref_candidate*Tref_candidate + + Tref_candidate*Tref_candidate*Tref_candidate); + + p_rad = h_rad / h_hat; + if(r < p_conv + p_cond + p_rad) { /* Radiative path */ + *rwalk = *rwalk_candidate; + *T = *T_candidate; + break; + } + + /* Null-collision, looping at the beginning */ + } + +exit: + return res; +error: + goto exit; +} + +#include "sdis_Xd_end.h" diff --git a/src/sdis_interface.c b/src/sdis_interface.c @@ -274,7 +274,7 @@ build_interface_fragment_2d (struct sdis_interface_fragment* frag, const struct sdis_scene* scn, const unsigned iprim, - const double* uv, + const double uv[1], const enum sdis_side side) { struct s2d_attrib attr_P, attr_N; @@ -317,7 +317,7 @@ build_interface_fragment_3d (struct sdis_interface_fragment* frag, const struct sdis_scene* scn, const unsigned iprim, - const double* uv, + const double uv[2], const enum sdis_side side) { struct s3d_attrib attr_P, attr_N; diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c @@ -26,8 +26,8 @@ ray_realisation_3d (struct sdis_scene* scn, struct ssp_rng* rng, struct sdis_medium* medium, - const double position[], - const double direction[], + const double position[3], + const double direction[3], const double time, 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 @@ -116,7 +116,7 @@ XD(probe_realisation) struct sdis_scene* scn, struct ssp_rng* rng, struct sdis_medium* medium, - const double position[], + const double position[DIM], const double time, struct green_path_handle* green_path, /* May be NULL */ struct sdis_heat_path* heat_path, /* May be NULL */ @@ -204,7 +204,7 @@ XD(boundary_realisation) (struct sdis_scene* scn, struct ssp_rng* rng, const size_t iprim, - const double uv[2], + const double uv[DIM-1], const double time, const enum sdis_side side, struct green_path_handle* green_path, /* May be NULL */ @@ -279,7 +279,7 @@ XD(boundary_flux_realisation) (struct sdis_scene* scn, struct ssp_rng* rng, const size_t iprim, - const double uv[DIM], + const double uv[DIM-1], const double time, const enum sdis_side solid_side, const int flux_mask, diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -158,7 +158,9 @@ sdis_scene_ref_put(struct sdis_scene* scn) res_T sdis_scene_get_aabb - (const struct sdis_scene* scn, double lower[], double upper[]) + (const struct sdis_scene* scn, + double lower[], + double upper[]) { float low[3], upp[3]; res_T res = RES_OK; @@ -241,10 +243,10 @@ sdis_scene_set_ambient_radiative_temperature res_T sdis_scene_find_closest_point (const struct sdis_scene* scn, - const double pos[3], + const double pos[], const double radius, size_t* iprim, - double uv[2]) + double uv[]) { if(!scn) return RES_BAD_ARG; if(scene_is_2d(scn)) { diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -186,8 +186,8 @@ check_sdis_scene_create_args(const struct sdis_scene_create_args* args) static INLINE int hit_on_vertex (const struct s2d_hit* hit, - const float org[3], - const float dir[3]) + const float org[2], + const float dir[2]) { struct s2d_attrib v0, v1; float E[2]; diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -384,7 +384,7 @@ sdis_solve_camera } /* Create the proxy RNG */ - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -187,7 +187,7 @@ XD(solve_boundary) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } @@ -524,7 +524,7 @@ XD(solve_boundary_flux) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -252,7 +252,7 @@ XD(solve_medium) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } @@ -520,7 +520,7 @@ XD(compute_power) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h @@ -83,7 +83,7 @@ XD(solve_probe) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -123,7 +123,7 @@ XD(solve_probe_boundary) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } @@ -427,7 +427,7 @@ XD(solve_probe_boundary_flux) scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } else { - res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64, + res = ssp_rng_proxy_create(scn->dev->allocator, SSP_RNG_MT19937_64, scn->dev->nthreads, &rng_proxy); if(res != RES_OK) goto error; } diff --git a/src/test_sdis_compute_power.c b/src/test_sdis_compute_power.c @@ -267,7 +267,7 @@ main(int argc, char** argv) ref = 4.0/3.0 * PI * POWER0; printf("Mean power of the solid0 = %g ~ %g +/- %g\n", ref, mpow.E, mpow.SE); - check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE); + check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE); OK(sdis_estimator_ref_put(estimator)); /* Check results for solid 1 */ @@ -277,7 +277,7 @@ main(int argc, char** argv) ref = PI * 10 * POWER1; printf("Mean power of the solid1 = %g ~ %g +/- %g\n", ref, mpow.E, mpow.SE); - check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE); + check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE); OK(sdis_estimator_ref_put(estimator)); /* Check for a not null time range */ @@ -288,7 +288,7 @@ main(int argc, char** argv) ref = PI * 10 * POWER1 / 10; printf("Mean power of the solid1 in [0, 10] s = %g ~ %g +/- %g\n", ref, mpow.E, mpow.SE); - check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE); + check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE); OK(sdis_estimator_ref_put(estimator)); /* Reset the scene with only one solid medium */ @@ -309,7 +309,7 @@ main(int argc, char** argv) ref = 4.0/3.0*PI*POWER0 + PI*10*POWER1; printf("Mean power of the sphere+cylinder = %g ~ %g +/- %g\n", ref, mpow.E, mpow.SE); - check_intersection(ref, 1.5e-1, mpow.E, 3*mpow.SE); + check_intersection(ref, 1e-3*ref, mpow.E, 3*mpow.SE); OK(sdis_estimator_ref_put(estimator)); #if 0 diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c @@ -69,7 +69,7 @@ static const double vertices[16/*#vertices*/*3/*#coords per vertex*/] = { -1.5, 1.0, 1.0, 1.5, 1.0, 1.0, }; -static const size_t nvertices = sizeof(vertices) / sizeof(double[3]); +static const size_t nvertices = sizeof(vertices) / (3*sizeof(double)); static const size_t indices[32/*#triangles*/*3/*#indices per triangle*/] = { 0, 2, 1, 1, 2, 3, /* Solid back face */ @@ -91,7 +91,7 @@ static const size_t indices[32/*#triangles*/*3/*#indices per triangle*/] = { 3, 7, 11, 11, 7, 15, /* Right fluid top face */ 1, 9, 5, 5, 9, 13 /* Right fluid bottom face */ }; -static const size_t ntriangles = sizeof(indices) / sizeof(size_t[3]); +static const size_t ntriangles = sizeof(indices) / (3*sizeof(size_t)); static void get_indices(const size_t itri, size_t ids[3], void* ctx) @@ -407,7 +407,7 @@ main(int argc, char** argv) /* Run the simulations */ p_intface = (struct interfac*)sdis_data_get(sdis_interface_get_data(interfaces[4])); - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); FOR_EACH(isimul, 0, nsimuls) { struct sdis_mc T = SDIS_MC_NULL; struct sdis_mc time = SDIS_MC_NULL; diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c @@ -58,7 +58,7 @@ static const double vertices[8/*#vertices*/*2/*#coords par vertex*/] = { -1.5, 1.0, 1.5, 1.0 }; -static const size_t nvertices = sizeof(vertices) / sizeof(double[2]); +static const size_t nvertices = sizeof(vertices) / (2*sizeof(double)); static const size_t indices[10/*#segments*/*2/*#indices per segment*/] = { 0, 1, /* Solid bottom segment */ @@ -74,7 +74,7 @@ static const size_t indices[10/*#segments*/*2/*#indices per segment*/] = { 3, 7, /* Right fluid top segment */ 7, 4 /* Right fluid right segment */ }; -static const size_t nsegments = sizeof(indices) / sizeof(size_t[2]); +static const size_t nsegments = sizeof(indices) / (2*sizeof(size_t)); static void get_indices(const size_t iseg, size_t ids[2], void* ctx) @@ -394,7 +394,7 @@ main(int argc, char** argv) Ts1 = T1 - tmp; /* Run the simulations */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); FOR_EACH(isimul, 0, nsimuls) { struct sdis_mc T = SDIS_MC_NULL; struct sdis_mc time = SDIS_MC_NULL; diff --git a/src/test_sdis_contact_resistance.c b/src/test_sdis_contact_resistance.c @@ -425,7 +425,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(interf_R)); /* Solve */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); printf(">> Box scene\n"); solve(box_scn, interf_props, rng); printf("\n>> Square scene\n"); diff --git a/src/test_sdis_contact_resistance.h b/src/test_sdis_contact_resistance.h @@ -52,7 +52,7 @@ static const double model3d_vertices[12/*#vertices*/ * 3/*#coords per vertex*/] X0, L, L, L, L, L }; -static const size_t model3d_nvertices = sizeof(model3d_vertices) / sizeof(double[3]); +static const size_t model3d_nvertices = sizeof(model3d_vertices) / (3*sizeof(double)); /* The following array lists the indices toward the 3D vertices of each * triangle. @@ -74,7 +74,7 @@ static const size_t model3d_indices[22/*#triangles*/ * 3/*#indices per triangle* 0, 1, 7, 7, 6, 0, 1, 2, 8, 8, 7, 1, /* -Y */ 4, 10, 7, 7, 1, 4 /* Inside */ }; -static const size_t model3d_ntriangles = sizeof(model3d_indices) / sizeof(size_t[3]); +static const size_t model3d_ntriangles = sizeof(model3d_indices) / (3*sizeof(size_t)); static INLINE void model3d_get_indices(const size_t itri, size_t ids[3], void* context) @@ -118,7 +118,7 @@ static const double model2d_vertices[6/*#vertices*/ * 2/*#coords per vertex*/] = X0, L, L, L }; -static const size_t model2d_nvertices = sizeof(model2d_vertices) / sizeof(double[2]); +static const size_t model2d_nvertices = sizeof(model2d_vertices) / (2*sizeof(double)); static const size_t model2d_indices[7/*#segments*/ * 2/*#indices per segment*/] = { 0, 1, 1, 2, /* Bottom */ @@ -127,7 +127,7 @@ static const size_t model2d_indices[7/*#segments*/ * 2/*#indices per segment*/] 5, 0, /* Right */ 4, 1 /* Inside */ }; -static const size_t model2d_nsegments = sizeof(model2d_indices) / sizeof(size_t[2]); +static const size_t model2d_nsegments = sizeof(model2d_indices) / (2*sizeof(size_t)); static INLINE void diff --git a/src/test_sdis_contact_resistance_2.c b/src/test_sdis_contact_resistance_2.c @@ -519,7 +519,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(interf_R)); /* Solve */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); printf(">> Box scene\n"); solve_probe(box_scn, interf_props, rng); solve(box_scn, interf_props, rng); diff --git a/src/test_sdis_flux.c b/src/test_sdis_flux.c @@ -449,7 +449,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(interf_phi)); /* Solve */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); printf(">> Box scene\n"); solve(box_scn, rng, interf_props); printf(">> Square Scene\n"); diff --git a/src/test_sdis_transcient.c b/src/test_sdis_transcient.c @@ -47,7 +47,7 @@ static const double vertices[12/*#vertices*/*3/*#coords per vertex*/] = { 1.0, 0.0, 1.0, 1.0, 1.0, 1.0 }; -static const size_t nvertices = sizeof(vertices) / sizeof(double[3]); +static const size_t nvertices = sizeof(vertices) / (3*sizeof(double)); /* The following array lists the indices toward the 3D vertices of each * triangle. @@ -67,7 +67,7 @@ static const size_t indices[22/*#triangles*/*3/*#indices per triangle*/] = { 0, 2, 1, 1, 2, 3, 1, 3, 8, 8, 3, 9, /* Z min */ 4, 5, 6, 6, 5, 7, 5,10, 7, 7,10,11 /* Z max */ }; -static const size_t ntriangles = sizeof(indices) / sizeof(size_t[3]); +static const size_t ntriangles = sizeof(indices) / (3*sizeof(size_t)); /******************************************************************************* * Box geometry functions diff --git a/src/test_sdis_unstationary_atm.c b/src/test_sdis_unstationary_atm.c @@ -91,7 +91,7 @@ static const double model3d_vertices[12/*#vertices*/ * 3/*#coords per vertex*/] XH, XHpE, XHpE, XHpE, XHpE, XHpE }; -static const size_t model3d_nvertices = sizeof(model3d_vertices) / sizeof(double[3]); +static const size_t model3d_nvertices = sizeof(model3d_vertices) / (3*sizeof(double)); /* The following array lists the indices toward the 3D vertices of each * triangle. @@ -113,7 +113,7 @@ static const size_t model3d_indices[22/*#triangles*/ * 3/*#indices per triangle* 0, 1, 7, 7, 6, 0, 1, 2, 8, 8, 7, 1, /* -Y */ 4, 10, 7, 7, 1, 4 /* Inside */ }; -static const size_t model3d_ntriangles = sizeof(model3d_indices) / sizeof(size_t[3]); +static const size_t model3d_ntriangles = sizeof(model3d_indices) / (3*sizeof(size_t)); static INLINE void model3d_get_indices(const size_t itri, size_t ids[3], void* context) @@ -157,7 +157,7 @@ static const double model2d_vertices[6/*#vertices*/ * 2/*#coords per vertex*/] = XH, XHpE, XHpE, XHpE }; -static const size_t model2d_nvertices = sizeof(model2d_vertices) / sizeof(double[2]); +static const size_t model2d_nvertices = sizeof(model2d_vertices) / (2*sizeof(double)); static const size_t model2d_indices[7/*#segments*/ * 2/*#indices per segment*/] = { 0, 1, 1, 2, /* Bottom */ @@ -166,7 +166,7 @@ static const size_t model2d_indices[7/*#segments*/ * 2/*#indices per segment*/] 5, 0, /* Right */ 4, 1 /* Inside */ }; -static const size_t model2d_nsegments = sizeof(model2d_indices) / sizeof(size_t[2]); +static const size_t model2d_nsegments = sizeof(model2d_indices) / (2*sizeof(size_t)); static INLINE void @@ -858,7 +858,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(interf_TA)); /* Solve */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); printf(">> Box scene\n"); solve_tfluid(box_scn); solve_tbound1(box_scn, rng); diff --git a/src/test_sdis_utils.h b/src/test_sdis_utils.h @@ -41,7 +41,7 @@ static const double box_vertices[8/*#vertices*/*3/*#coords per vertex*/] = { 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; -static const size_t box_nvertices = sizeof(box_vertices) / sizeof(double[3]); +static const size_t box_nvertices = sizeof(box_vertices) / (3*sizeof(double)); /* The following array lists the indices toward the 3D vertices of each * triangle. @@ -61,7 +61,7 @@ static const size_t box_indices[12/*#triangles*/*3/*#indices per triangle*/] = { 2, 6, 7, 7, 3, 2, /* +Y */ 0, 1, 5, 5, 4, 0 /* -Y */ }; -static const size_t box_ntriangles = sizeof(box_indices) / sizeof(size_t[3]); +static const size_t box_ntriangles = sizeof(box_indices) / (3*sizeof(size_t)); static INLINE void box_get_indices(const size_t itri, size_t ids[3], void* context) @@ -103,7 +103,7 @@ static const double square_vertices[4/*#vertices*/*2/*#coords per vertex*/] = { 0.0, 1.0, 1.0, 1.0 }; -static const size_t square_nvertices = sizeof(square_vertices)/sizeof(double[2]); +static const size_t square_nvertices = sizeof(square_vertices)/(2*sizeof(double)); static const size_t square_indices[4/*#segments*/*2/*#indices per segment*/]= { 0, 1, /* Bottom */ @@ -111,7 +111,7 @@ static const size_t square_indices[4/*#segments*/*2/*#indices per segment*/]= { 2, 3, /* Top */ 3, 0 /* Right */ }; -static const size_t square_nsegments = sizeof(square_indices)/sizeof(size_t[2]); +static const size_t square_nsegments = sizeof(square_indices)/(2*sizeof(size_t)); static INLINE void square_get_indices(const size_t iseg, size_t ids[2], void* context) diff --git a/src/test_sdis_volumic_power.c b/src/test_sdis_volumic_power.c @@ -487,7 +487,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(interf_T0)); /* Solve */ - OK(ssp_rng_create(&allocator, &ssp_rng_kiss, &rng)); + OK(ssp_rng_create(&allocator, SSP_RNG_KISS, &rng)); printf(">> Box scene\n"); solve(box_scn, rng, solid_props); printf(">> Square scene\n"); diff --git a/src/test_sdis_volumic_power2.c b/src/test_sdis_volumic_power2.c @@ -66,7 +66,7 @@ static const double vertices[16/*#vertices*/*3/*#coords per vertex*/] = { 0.1, 0.6, 0.5, 0.1, 0.4, 0.5 }; -static const size_t nvertices = sizeof(vertices)/sizeof(double[3]); +static const size_t nvertices = sizeof(vertices)/(3*sizeof(double)); static const size_t indices[36/*#triangles*/*3/*#indices per triangle*/]= { 0, 4, 5, 5, 1, 0, /* Cuboid left */ @@ -90,7 +90,7 @@ static const size_t indices[36/*#triangles*/*3/*#indices per triangle*/]= { 8, 9, 10, 10, 11, 8, /* Cube back */ 12, 15, 14, 14, 13, 12 /* Cube front */ }; -static const size_t ntriangles = sizeof(indices)/sizeof(size_t[3]); +static const size_t ntriangles = sizeof(indices)/(3*sizeof(size_t)); /******************************************************************************* * Geometry diff --git a/src/test_sdis_volumic_power2_2d.c b/src/test_sdis_volumic_power2_2d.c @@ -99,7 +99,7 @@ static const double vertices[8/*#vertices*/*2/*#coords per vertex*/] = { 0.1, 0.6, 0.1, 0.4 }; -static const size_t nvertices = sizeof(vertices)/sizeof(double[2]); +static const size_t nvertices = sizeof(vertices)/(2*sizeof(double)); static const size_t indices[8/*#segments*/*2/*#indices per segment*/]= { 0, 1, /* Rectangle left */ @@ -111,7 +111,7 @@ static const size_t indices[8/*#segments*/*2/*#indices per segment*/]= { 6, 7, /* Square right */ 7, 4 /* Square bottom */ }; -static const size_t nsegments = sizeof(indices)/sizeof(size_t[2]); +static const size_t nsegments = sizeof(indices)/(2*sizeof(size_t)); /******************************************************************************* * Geometry diff --git a/src/test_sdis_volumic_power3_2d.c b/src/test_sdis_volumic_power3_2d.c @@ -84,7 +84,7 @@ static const double vertices[8/*#vertices*/*2/*#coords per vertex*/] = { 100000.5, 1.4, /* 6 */ 100000.5, 0.0 /* 7 */ }; -static const size_t nvertices = sizeof(vertices)/sizeof(double[2]); +static const size_t nvertices = sizeof(vertices)/(2*sizeof(double)); static const size_t indices[10/*#segments*/*2/*#indices per segment*/]= { 0, 1, @@ -98,7 +98,7 @@ static const size_t indices[10/*#segments*/*2/*#indices per segment*/]= { 6, 1, 2, 5 }; -static const size_t nsegments = sizeof(indices)/sizeof(size_t[2]); +static const size_t nsegments = sizeof(indices)/(2*sizeof(size_t)); /******************************************************************************* * Geometry