stardis-solver

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

commit b38f31cc8a571eb6becff1b466b1e1d6bbf15dea
parent 71720d93e0bf2c0307f6278c9e5bb10a0f8ba56c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 28 Feb 2022 16:29:30 +0100

Test the rng_<type|state> variables of sdis_solve_[probe]_boundary_flux

Diffstat:
Mcmake/CMakeLists.txt | 1+
Msrc/test_sdis_solve_boundary_flux.c | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -255,6 +255,7 @@ if(NOT NO_TEST) target_link_libraries(test_sdis_solve_camera Star3DUT) target_link_libraries(test_sdis_solve_boundary StarSP) + target_link_libraries(test_sdis_solve_boundary_flux StarSP) target_link_libraries(test_sdis_solve_probe2 StarSP) target_link_libraries(test_sdis_solve_medium StarSP) diff --git a/src/test_sdis_solve_boundary_flux.c b/src/test_sdis_solve_boundary_flux.c @@ -16,6 +16,7 @@ #include "sdis.h" #include "test_sdis_utils.h" +#include <star/ssp.h> #include <rsys/math.h> /* @@ -238,6 +239,7 @@ main(int argc, char** argv) struct sdis_scene* box_scn = NULL; struct sdis_scene* square_scn = NULL; struct sdis_estimator* estimator = NULL; + struct sdis_estimator* estimator2 = NULL; struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT; struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER; struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER; @@ -250,6 +252,7 @@ main(int argc, char** argv) SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT; struct interf* interf_props = NULL; struct fluid* fluid_param; + struct ssp_rng* rng = NULL; enum sdis_estimator_type type; double pos[3]; double analyticT, analyticCF, analyticRF, analyticTF; @@ -414,9 +417,47 @@ main(int argc, char** argv) (box_scn, probe_args.iprim, probe_args.uv, pos)); printf("Boundary values of the box at (%g %g %g) = ", SPLIT3(pos)); check_estimator(estimator, N, analyticT, analyticCF, analyticRF, analyticTF); - OK(sdis_estimator_ref_put(estimator)); } + /* Check the RNG type */ + probe_args.rng_state = NULL; + probe_args.rng_type = SSP_RNG_TYPE_NULL; + BA(SOLVE(box_scn, &probe_args, &estimator2)); + probe_args.rng_type = + SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_type == SSP_RNG_THREEFRY + ? SSP_RNG_MT19937_64 : SSP_RNG_THREEFRY; + OK(SOLVE(box_scn, &probe_args, &estimator2)); + if(is_master_process) { + struct sdis_mc T, T2; + check_estimator(estimator2, N, analyticT, analyticCF, analyticRF, analyticTF); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_temperature(estimator2, &T2)); + CHK(T2.E != T.E); + OK(sdis_estimator_ref_put(estimator2)); + } + + /* Check RNG state */ + OK(ssp_rng_create(NULL, SSP_RNG_THREEFRY, &rng)); + OK(ssp_rng_discard(rng, 31415926535)); /* Move the RNG state */ + probe_args.rng_state = rng; + probe_args.rng_type = SSP_RNG_TYPE_NULL; + OK(SOLVE(box_scn, &probe_args, &estimator2)); + OK(ssp_rng_ref_put(rng)); + if(is_master_process) { + struct sdis_mc T, T2; + check_estimator(estimator2, N, analyticT, analyticCF, analyticRF, analyticTF); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_temperature(estimator2, &T2)); + CHK(T2.E != T.E); + OK(sdis_estimator_ref_put(estimator2)); + } + + if(estimator) OK(sdis_estimator_ref_put(estimator)); + + /* Restore arguments */ + probe_args.rng_state = SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_state; + probe_args.rng_type = SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_type; + probe_args.uv[0] = 0.5; probe_args.iprim = 4; BA(SOLVE(square_scn, &probe_args, &estimator)); @@ -471,9 +512,47 @@ main(int argc, char** argv) /* Average temperature on the right side of the box */ printf("Average values of the right side of the box = "); check_estimator(estimator, N, analyticT, analyticCF, analyticRF, analyticTF); - OK(sdis_estimator_ref_put(estimator)); } + /* Check the RNG type */ + bound_args.rng_state = NULL; + bound_args.rng_type = SSP_RNG_TYPE_NULL; + BA(SOLVE(box_scn, &bound_args, &estimator2)); + bound_args.rng_type = + SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_type == SSP_RNG_THREEFRY + ? SSP_RNG_MT19937_64 : SSP_RNG_THREEFRY; + OK(SOLVE(box_scn, &bound_args, &estimator2)); + if(is_master_process) { + struct sdis_mc T, T2; + check_estimator(estimator2, N, analyticT, analyticCF, analyticRF, analyticTF); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_temperature(estimator2, &T2)); + CHK(T2.E != T.E); + OK(sdis_estimator_ref_put(estimator2)); + } + + /* Check RNG state */ + OK(ssp_rng_create(NULL, SSP_RNG_THREEFRY, &rng)); + OK(ssp_rng_discard(rng, 31415926535)); /* Move the RNG state */ + bound_args.rng_state = rng; + bound_args.rng_type = SSP_RNG_TYPE_NULL; + OK(SOLVE(box_scn, &bound_args, &estimator2)); + OK(ssp_rng_ref_put(rng)); + if(is_master_process) { + struct sdis_mc T, T2; + check_estimator(estimator2, N, analyticT, analyticCF, analyticRF, analyticTF); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_temperature(estimator2, &T2)); + CHK(T2.E != T.E); + OK(sdis_estimator_ref_put(estimator2)); + } + + if(estimator) OK(sdis_estimator_ref_put(estimator)); + + /* Restore arguments */ + bound_args.rng_state = SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_state; + bound_args.rng_type = SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT.rng_type; + /* Average temperature on the right side of the square */ prims[0] = 4; bound_args.nprimitives = 1;