stardis-solver

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

commit 6e0bfd185bd1452256a177312a35032160d14cff
parent b86286bc83b43d7dec3430b34ccb6eaa1c95eef9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 18 Dec 2021 12:31:08 +0100

Test the MPI support of the function sdis_solve_medium

Diffstat:
Mcmake/CMakeLists.txt | 21++++++++++++++++-----
Msrc/test_sdis_solve_medium.c | 93++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Msrc/test_sdis_solve_medium_2d.c | 92+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
3 files changed, 123 insertions(+), 83 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -222,16 +222,16 @@ if(NOT NO_TEST) new_test(test_sdis_solve_probe_2d) new_test(test_sdis_solve_probe2_2d) new_test(test_sdis_solve_probe3_2d) - new_test(test_sdis_solve_medium) - new_test(test_sdis_solve_medium_2d) new_test(test_sdis_transcient) new_test(test_sdis_unstationary_atm) new_test(test_sdis_volumic_power) new_test(test_sdis_volumic_power4) - build_test(test_sdis_solve_probe2) + build_test(test_sdis_solve_medium) + build_test(test_sdis_solve_medium_2d) build_test(test_sdis_solve_boundary) build_test(test_sdis_solve_boundary_flux) + build_test(test_sdis_solve_probe2) # Additionnal tests build_test(test_sdis_volumic_power2) @@ -252,6 +252,8 @@ if(NOT NO_TEST) target_link_libraries(test_sdis_solve_camera Star3DUT) if(NOT ENABLE_MPI) + add_test(test_sdis_solve_medium test_sdis_solve_medium) + add_test(test_sdis_solve_medium_2d test_sdis_solve_medium_2d) add_test(test_sdis_solve_probe2 test_sdis_solve_probe2) add_test(test_sdis_solve_boundary test_sdis_solve_boundary) add_test(test_sdis_solve_boundary_flux test_sdis_solve_boundary_flux) @@ -260,6 +262,10 @@ if(NOT NO_TEST) COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") set_target_properties(test_sdis_device PROPERTIES COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") + set_target_properties(test_sdis_solve_medium PROPERTIES + COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") + set_target_properties(test_sdis_solve_medium_2d PROPERTIES + COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") set_target_properties(test_sdis_solve_probe2 PROPERTIES COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") set_target_properties(test_sdis_solve_boundary PROPERTIES @@ -267,11 +273,16 @@ if(NOT NO_TEST) set_target_properties(test_sdis_solve_boundary_flux PROPERTIES COMPILE_DEFINITIONS "SDIS_ENABLE_MPI") + add_test(test_sdis_solve_medium_mpi_on mpirun -n 2 test_sdis_solve_medium mpi) + add_test(test_sdis_solve_medium_2d_mpi_on mpirun -n 2 test_sdis_solve_medium_2d mpi) add_test(test_sdis_solve_probe2_mpi_on mpirun -n 2 test_sdis_solve_probe2 mpi) - add_test(test_sdis_solve_probe2_no_mpi test_sdis_solve_probe2) add_test(test_sdis_solve_boundary_mpi_on mpirun -n 2 test_sdis_solve_boundary mpi) - add_test(test_sdis_solve_boundary_no_mpi test_sdis_solve_boundary) add_test(test_sdis_solve_boundary_flux_mpi_on mpirun -n 2 test_sdis_solve_boundary_flux mpi) + + add_test(test_sdis_solve_medium_no_mpi test_sdis_solve_medium) + add_test(test_sdis_solve_medium_2d_no_mpi test_sdis_solve_medium_2d) + add_test(test_sdis_solve_probe2_no_mpi test_sdis_solve_probe2) + add_test(test_sdis_solve_boundary_no_mpi test_sdis_solve_boundary) add_test(test_sdis_solve_boundary_flux_no_mpi test_sdis_solve_boundary_flux) endif() diff --git a/src/test_sdis_solve_medium.c b/src/test_sdis_solve_medium.c @@ -231,9 +231,10 @@ main(int argc, char** argv) size_t nfails; size_t ntris; size_t nverts; + int is_master_process; (void)argc, (void)argv; - OK(sdis_device_create(&SDIS_DEVICE_CREATE_ARGS_DEFAULT, &dev)); + create_default_device(&argc, &argv, &is_master_process, &dev); fluid_shader.temperature = fluid_get_temperature; @@ -379,16 +380,20 @@ main(int argc, char** argv) solve_args.time_range[0] = solve_args.time_range[1] = INF; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - printf("Shape0 temperature = "STR(Tf0)" ~ %g +/- %g\n", T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu/%lu\n\n", (unsigned long)nfails, N); - CHK(eq_eps(T.E, Tf0, T.SE)); - CHK(nreals + nfails == N); - OK(sdis_estimator_ref_put(estimator)); + if(!is_master_process) { + CHK(estimator == NULL); + } else { + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + printf("Shape0 temperature = "STR(Tf0)" ~ %g +/- %g\n", T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu/%lu\n\n", (unsigned long)nfails, N); + CHK(eq_eps(T.E, Tf0, T.SE)); + CHK(nreals + nfails == N); + OK(sdis_estimator_ref_put(estimator)); + } solve_args.medium = solid1; @@ -399,21 +404,25 @@ main(int argc, char** argv) BA(sdis_solve_medium(scn, &solve_args, &estimator)); fluid_param->temperature = Tf1; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_ref_put(estimator)); + if(is_master_process) { + OK(sdis_estimator_ref_put(estimator)); + } solve_args.nrealisations = N; solve_args.register_paths = SDIS_HEAT_PATH_NONE; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - printf("Shape1 temperature = "STR(Tf1)" ~ %g +/- %g\n", T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu/%lu\n\n", (unsigned long)nfails, N); - CHK(eq_eps(T.E, Tf1, T.SE)); - CHK(nreals + nfails == N); - OK(sdis_estimator_ref_put(estimator)); + if(is_master_process) { + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + printf("Shape1 temperature = "STR(Tf1)" ~ %g +/- %g\n", T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu/%lu\n\n", (unsigned long)nfails, N); + CHK(eq_eps(T.E, Tf1, T.SE)); + CHK(nreals + nfails == N); + OK(sdis_estimator_ref_put(estimator)); + } /* Create a new scene with the same medium in the 2 super shapes */ OK(sdis_scene_ref_put(scn)); @@ -429,15 +438,17 @@ main(int argc, char** argv) solve_args.medium = solid0; solve_args.nrealisations = Np; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - ref = Tf0 * v0/v + Tf1 * v1/v; - printf("Shape0 + Shape1 temperature = %g ~ %g +/- %g\n", ref, T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu/%lu\n", (unsigned long)nfails, Np); - CHK(eq_eps(T.E, ref, T.SE*3)); + if(is_master_process) { + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + ref = Tf0 * v0/v + Tf1 * v1/v; + printf("Shape0 + Shape1 temperature = %g ~ %g +/- %g\n", ref, T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu/%lu\n", (unsigned long)nfails, Np); + CHK(eq_eps(T.E, ref, T.SE*3)); + } /* Solve green */ BA(sdis_solve_medium_green_function(NULL, &solve_args, &green)); @@ -456,20 +467,23 @@ main(int argc, char** argv) solve_args.picard_order = 1; OK(sdis_solve_medium_green_function(scn, &solve_args, &green)); - OK(sdis_green_function_solve(green, &estimator2)); - check_green_function(green); - check_estimator_eq(estimator, estimator2); - check_green_serialization(green, scn); + if(!is_master_process) { + CHK(green == NULL); + } else { + OK(sdis_green_function_solve(green, &estimator2)); + check_green_function(green); + check_estimator_eq(estimator, estimator2); + check_green_serialization(green, scn); - OK(sdis_green_function_ref_put(green)); + OK(sdis_green_function_ref_put(green)); - OK(sdis_estimator_ref_put(estimator)); - OK(sdis_estimator_ref_put(estimator2)); + OK(sdis_estimator_ref_put(estimator)); + OK(sdis_estimator_ref_put(estimator2)); + } /* Release */ OK(s3dut_mesh_ref_put(msh0)); OK(s3dut_mesh_ref_put(msh1)); - OK(sdis_device_ref_put(dev)); OK(sdis_medium_ref_put(fluid0)); OK(sdis_medium_ref_put(fluid1)); OK(sdis_medium_ref_put(solid0)); @@ -478,6 +492,7 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(solid0_fluid1)); OK(sdis_interface_ref_put(solid1_fluid1)); OK(sdis_scene_ref_put(scn)); + free_default_device(dev); CHK(mem_allocated_size() == 0); return 0; diff --git a/src/test_sdis_solve_medium_2d.c b/src/test_sdis_solve_medium_2d.c @@ -218,9 +218,10 @@ main(int argc, char** argv) size_t nreals; size_t nfails; size_t i; + int is_master_process; (void)argc, (void)argv; - OK(sdis_device_create(&SDIS_DEVICE_CREATE_ARGS_DEFAULT, &dev)); + create_default_device(&argc, &argv, &is_master_process, &dev); fluid_shader.temperature = fluid_get_temperature; @@ -345,30 +346,36 @@ main(int argc, char** argv) /* Estimate the temperature of the square */ solve_args.medium = solid0; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - printf("Square temperature = "STR(Tf0)" ~ %g +/- %g\n", T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu / %lu\n\n", (unsigned long)nfails, N); - CHK(eq_eps(T.E, Tf0, T.SE)); - CHK(nreals + nfails == N); - OK(sdis_estimator_ref_put(estimator)); + if(!is_master_process) { + CHK(estimator == NULL); + } else { + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + printf("Square temperature = "STR(Tf0)" ~ %g +/- %g\n", T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu / %lu\n\n", (unsigned long)nfails, N); + CHK(eq_eps(T.E, Tf0, T.SE)); + CHK(nreals + nfails == N); + OK(sdis_estimator_ref_put(estimator)); + } /* Estimate the temperature of the disk */ solve_args.medium = solid1; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - printf("Disk temperature = "STR(Tf1)" ~ %g +/- %g\n", T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu / %lu\n\n", (unsigned long)nfails, N); - CHK(eq_eps(T.E, Tf1, T.SE)); - CHK(nreals + nfails == N); - OK(sdis_estimator_ref_put(estimator)); + if(is_master_process) { + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + printf("Disk temperature = "STR(Tf1)" ~ %g +/- %g\n", T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu / %lu\n\n", (unsigned long)nfails, N); + CHK(eq_eps(T.E, Tf1, T.SE)); + CHK(nreals + nfails == N); + OK(sdis_estimator_ref_put(estimator)); + } /* Create a new scene with the same medium for the disk and the square */ OK(sdis_scene_ref_put(scn)); @@ -385,16 +392,18 @@ main(int argc, char** argv) BA(sdis_solve_medium(scn, &solve_args, &estimator)); solve_args.medium = solid0; OK(sdis_solve_medium(scn, &solve_args, &estimator)); - OK(sdis_estimator_get_temperature(estimator, &T)); - OK(sdis_estimator_get_realisation_time(estimator, &time)); - OK(sdis_estimator_get_realisation_count(estimator, &nreals)); - OK(sdis_estimator_get_failure_count(estimator, &nfails)); - ref = Tf0 * a0/a + Tf1 * a1/a; - printf("Square + Disk temperature = %g ~ %g +/- %g\n", ref, T.E, T.SE); - printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); - printf("#failures = %lu / %lu\n", (unsigned long)nfails, Np); - CHK(eq_eps(T.E, ref, 3*T.SE)); - CHK(nreals + nfails == Np); + if(is_master_process) { + OK(sdis_estimator_get_temperature(estimator, &T)); + OK(sdis_estimator_get_realisation_time(estimator, &time)); + OK(sdis_estimator_get_realisation_count(estimator, &nreals)); + OK(sdis_estimator_get_failure_count(estimator, &nfails)); + ref = Tf0 * a0/a + Tf1 * a1/a; + printf("Square + Disk temperature = %g ~ %g +/- %g\n", ref, T.E, T.SE); + printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE); + printf("#failures = %lu / %lu\n", (unsigned long)nfails, Np); + CHK(eq_eps(T.E, ref, 3*T.SE)); + CHK(nreals + nfails == Np); + } /* Solve green */ BA(sdis_solve_medium_green_function(NULL, &solve_args, &green)); @@ -402,18 +411,21 @@ main(int argc, char** argv) BA(sdis_solve_medium_green_function(scn, &solve_args, NULL)); OK(sdis_solve_medium_green_function(scn, &solve_args, &green)); - OK(sdis_green_function_solve(green, &estimator2)); - check_green_function(green); - check_estimator_eq(estimator, estimator2); - check_green_serialization(green, scn); + if(!is_master_process) { + CHK(green == NULL); + } else { + OK(sdis_green_function_solve(green, &estimator2)); + check_green_function(green); + check_estimator_eq(estimator, estimator2); + check_green_serialization(green, scn); - OK(sdis_green_function_ref_put(green)); + OK(sdis_green_function_ref_put(green)); - OK(sdis_estimator_ref_put(estimator)); - OK(sdis_estimator_ref_put(estimator2)); + OK(sdis_estimator_ref_put(estimator)); + OK(sdis_estimator_ref_put(estimator2)); + } /* Release */ - OK(sdis_device_ref_put(dev)); OK(sdis_medium_ref_put(solid0)); OK(sdis_medium_ref_put(solid1)); OK(sdis_medium_ref_put(fluid0)); @@ -423,6 +435,8 @@ main(int argc, char** argv) OK(sdis_interface_ref_put(solid1_fluid1)); OK(sdis_scene_ref_put(scn)); + free_default_device(dev); + sa_release(positions); sa_release(indices);