commit 6b425ba0f1929bbe654c4388be78f6e8cc62d494
parent 8da139276a64b856e2aca031232414096a037cf1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 29 Mar 2024 16:35:45 +0100
Add geometry dump to unsteady 3D analytical test
Dump the super shape and sampled paths. The latter cheks path
registration.
Diffstat:
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -276,6 +276,7 @@ test_all: test
clean_test:
@$(SHELL) make.sh clean_test $(TEST_SRC) $(TEST_SRC_MPI) $(TEST_SRC_LONG)
rm -f super_shape_2d.obj paths_wos_2d.vtk paths_delta_sphere_2d.vtk
+ rm -f super_shape_3d.obj paths_wos_3d.vtk paths_delta_sphere_3d.vtk
rm -f rng_state
################################################################################
diff --git a/src/test_sdis_unsteady_analytic_profile.c b/src/test_sdis_unsteady_analytic_profile.c
@@ -78,6 +78,43 @@ temperature(const double pos[3], const double time)
return temp;
}
+static INLINE void
+dump_s3dut_mesh(FILE* fp, const struct s3dut_mesh* mesh)
+{
+ struct s3dut_mesh_data mesh_data;
+
+ OK(s3dut_mesh_get_data(mesh, &mesh_data));
+ dump_mesh(fp, mesh_data .positions, mesh_data.nvertices,
+ mesh_data.indices, mesh_data.nprimitives);
+}
+
+static void
+dump_paths
+ (FILE* fp,
+ struct sdis_scene* scn,
+ const enum sdis_diffusion_algorithm diff_algo,
+ const double pos[3],
+ const double time,
+ const size_t npaths)
+{
+ struct sdis_solve_probe_args args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
+ struct sdis_estimator* estimator = NULL;
+
+ args.nrealisations = npaths;
+ args.position[0] = pos[0];
+ args.position[1] = pos[1];
+ args.position[2] = pos[2];
+ args.time_range[0] = time;
+ args.time_range[1] = time;
+ args.diff_algo = diff_algo;
+ args.register_paths = SDIS_HEAT_PATH_ALL;
+ OK(sdis_solve_probe(scn, &args, &estimator));
+
+ dump_heat_paths(fp, estimator);
+
+ OK(sdis_estimator_ref_put(estimator));
+}
+
/*******************************************************************************
* Geometry
******************************************************************************/
@@ -296,6 +333,7 @@ main(int argc, char** argv)
struct sdis_scene* scn = NULL;
/* Miscellaneous */
+ FILE* fp = NULL;
struct s3dut_mesh* super_shape = NULL;
const double pos[3] = {0.2,0.3,0.4}; /* [m/fp_to_meter] */
const double time = 5; /* [s] */
@@ -306,6 +344,11 @@ main(int argc, char** argv)
super_shape = create_super_shape();
+ /* Save the super shape geometry for debug and visualisation */
+ CHK(fp = fopen("super_shape_3d.obj", "w"));
+ dump_s3dut_mesh(fp, super_shape);
+ CHK(fclose(fp) == 0);
+
solid = create_solid(sdis);
dummy = create_dummy(sdis);
interf = create_interface(sdis, solid, dummy);
@@ -315,6 +358,16 @@ main(int argc, char** argv)
check_probe(scn, SDIS_DIFFUSION_WOS, pos, time, 0/*green*/);
check_probe(scn, SDIS_DIFFUSION_WOS, pos, time, 1/*green*/);
+ /* Write 10 heat paths sampled by the delta sphere algorithm */
+ CHK(fp = fopen("paths_delta_sphere_3d.vtk", "w"));
+ dump_paths(fp, scn, SDIS_DIFFUSION_DELTA_SPHERE, pos, time, 10);
+ CHK(fclose(fp) == 0);
+
+ /* Write 10 heat paths sampled by the WoS algorithm */
+ CHK(fp = fopen("paths_wos_3d.vtk", "w"));
+ dump_paths(fp, scn, SDIS_DIFFUSION_WOS, pos, time, 10);
+ CHK(fclose(fp) == 0);
+
OK(s3dut_mesh_ref_put(super_shape));
OK(sdis_device_ref_put(sdis));
OK(sdis_interface_ref_put(interf));
diff --git a/src/test_sdis_unsteady_analytic_profile_2d.c b/src/test_sdis_unsteady_analytic_profile_2d.c
@@ -84,7 +84,7 @@ static double temperature(const double pos[2], const double time)
}
static void
-dump_heat_path
+dump_paths
(FILE* fp,
struct sdis_scene* scn,
const enum sdis_diffusion_algorithm diff_algo,
@@ -390,12 +390,12 @@ main(int argc, char** argv)
/* Write 10 heat paths sampled by the delta sphere algorithm */
CHK(fp = fopen("paths_delta_sphere_2d.vtk", "w"));
- dump_heat_path(fp, scn, SDIS_DIFFUSION_DELTA_SPHERE, pos, time, 10);
+ dump_paths(fp, scn, SDIS_DIFFUSION_DELTA_SPHERE, pos, time, 10);
CHK(fclose(fp) == 0);
/* Write 10 heat paths sampled by the WoS algorithm */
CHK(fp = fopen("paths_wos_2d.vtk", "w"));
- dump_heat_path(fp, scn, SDIS_DIFFUSION_WOS, pos, time, 10);
+ dump_paths(fp, scn, SDIS_DIFFUSION_WOS, pos, time, 10);
CHK(fclose(fp) == 0);
release_super_shape(&sshape);