commit 7cfa92c4b1c423eb9a0e962ef9230ac5d1c62bbb
parent 071e07722348df13f627b06755d0fa3796c6fa3d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 15 Mar 2024 10:35:22 +0100
Time travel correction for WoS diffusion
The backtracking time was wrong. In addition, the algorithm always
assumed that it was stationary in certain situations: when an
intersection occurred, it assumed that the path reached it, whereas the
initial condition might have been reached first.
Diffstat:
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/sdis_heat_path_conductive_wos_Xd.h b/src/sdis_heat_path_conductive_wos_Xd.h
@@ -87,7 +87,7 @@ XD(time_travel)
if(IS_INF(rwalk->vtx.time)) goto exit; /* Steady computation */
/* Let's take a trip back in time */
- rwalk->vtx.time -= MMAX(t0, rwalk->vtx.time - tau);
+ rwalk->vtx.time = MMAX(t0, rwalk->vtx.time - tau);
/* Thepath does not reach the initial condition */
if(rwalk->vtx.time > t0) goto exit;
@@ -273,11 +273,13 @@ XD(setup_hit_wos)
goto error;
}
- /* Update the random walk */
+ /* Random walk update. Do not set the medium to NULL as the intersection is
+ * found regardless of time, so the initial condition could be reached before
+ * the interface. So we can't yet assume that the random walk has left the
+ * current medium */
dX(set)(rwalk->vtx.P, tgt);
rwalk->hit = *hit;
rwalk->hit_side = side;
- rwalk->mdm = NULL;
exit:
return res;
@@ -326,11 +328,13 @@ XD(setup_hit_rt)
goto error;
}
- /* Update the random walk */
+ /* Random walk update. Do not set the medium to NULL as the intersection is
+ * found regardless of time, so the initial condition could be reached before
+ * the interface. So we can't yet assume that the random walk has left the
+ * current medium */
dX(set)(rwalk->vtx.P, tgt);
rwalk->hit = *hit;
rwalk->hit_side = side;
- rwalk->mdm = NULL;
exit:
return res;
@@ -504,10 +508,17 @@ XD(conductive_path_wos)
if(res != RES_OK) goto error;
/* The path reaches the initial condition */
- if(T->done) break;
+ if(T->done) {
+ T->func = NULL;
+ break;
+ }
/* The path reaches a boundary */
- if(!SXD_HIT_NONE(&rwalk->hit)) break;
+ if(!SXD_HIT_NONE(&rwalk->hit)) {
+ T->func = XD(boundary_path);
+ rwalk->mdm = NULL;
+ break;
+ }
/* Retreive and check solid properties at the new position */
res = solid_get_properties(rwalk->mdm, &rwalk->vtx, &props);
@@ -525,9 +536,6 @@ XD(conductive_path_wos)
++ndiffusion_steps;
}
- T->func = XD(boundary_path);
- ASSERT(rwalk->mdm == NULL);
-
exit:
return res;
error: