commit 8e81e195b34f1aeb8a28aba2fb2868e0de269919
parent 43efe315b016d644b429f526e0bcd332d8426523
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 24 Jun 2024 12:51:39 +0200
Update sdis_path data structure
Delete the "elapsed_time" member variable. This elapsed time can be
calculated from the random walk time and the sampled path time.
Diffstat:
4 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -224,11 +224,10 @@ SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL = SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NUL
struct sdis_path {
struct sdis_rwalk_vertex vtx; /* Current position and time */
- /* Surface intersection. When defined, the path is on a border */
+ /* Surface intersected by the path. When defined, the path is on a border */
struct s2d_primitive prim_2d;
struct s3d_primitive prim_3d;
- double elapsed_time; /* Time elapsed along the path */
double weight; /* Monte Carlo weight update along the path */
/* Define whether the path has reached a boundary condition in time/space */
@@ -238,7 +237,6 @@ struct sdis_path {
SDIS_RWALK_VERTEX_NULL__, \
S2D_PRIMITIVE_NULL__, \
S3D_PRIMITIVE_NULL__, \
- 0, /* Elapsed time */ \
0, /* MC weight */ \
0 /* At limit */ \
}
diff --git a/src/sdis_heat_path_conductive_custom_Xd.h b/src/sdis_heat_path_conductive_custom_Xd.h
@@ -28,6 +28,7 @@
static res_T
XD(check_sampled_path)
(struct sdis_scene* scn,
+ const struct rwalk* rwalk,
const struct sdis_path* path)
{
int null_prim = 0;
@@ -46,6 +47,16 @@ XD(check_sampled_path)
goto error;
}
+ /* Check path time */
+ if(path->vtx.time > rwalk->vtx.time) {
+ log_err(scn->dev,
+ "%s: the sampled trajectory cannot be in the future. "
+ "It can only go back in time -- starting time=%g s; current time=%g s\n",
+ FUNC_NAME, rwalk->vtx.time, path->vtx.time);
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
if(!null_prim) {
struct sXd(primitive) prim;
const unsigned iprim = path->XD(prim).prim_id;
@@ -154,15 +165,15 @@ XD(conductive_path_custom)
goto error;
}
- res = XD(check_sampled_path)(scn, &path);
+ res = XD(check_sampled_path)(scn, rwalk, &path);
if(res!= RES_OK) goto error;
res = XD(get_path_hit)(scn, &path, mdm, &rwalk->XD(hit));
if(res != RES_OK) goto error;
/* Update random walk position and time from sampled path */
+ rwalk->elapsed_time += rwalk->vtx.time - path.vtx.time;
rwalk->vtx = path.vtx;
- rwalk->elapsed_time += path.elapsed_time;
/* The path reached a boundary */
if(!SXD_HIT_NONE(&rwalk->XD(hit))) {
diff --git a/src/test_sdis_custom_solid_path_sampling.c b/src/test_sdis_custom_solid_path_sampling.c
@@ -291,7 +291,6 @@ sample_steady_diffusive_path
path->weight = 0;
path->at_limit = 0;
path->prim_2d = S2D_PRIMITIVE_NULL;
- path->elapsed_time = 0;
path->weight = 0;
path->at_limit = 0;
setup_solver_primitive(scn, solid->shape, &hit, &path->prim_3d);
diff --git a/src/test_sdis_custom_solid_path_sampling_2d.c b/src/test_sdis_custom_solid_path_sampling_2d.c
@@ -316,7 +316,6 @@ sample_steady_diffusive_path
path->weight = 0;
path->at_limit = 0;
path->prim_3d = S3D_PRIMITIVE_NULL;
- path->elapsed_time = 0;
path->weight = 0;
path->at_limit = 0;
setup_solver_primitive(scn, solid->shape, &hit, &path->prim_2d);