commit 90236fe178b26bed1724c30166e0fd1d5ecdabf4
parent ecc388950d7664630ee73e1ad44ccdad73f56723
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 3 Nov 2021 18:12:15 +0100
Finalise a 1st implementation of the PicardN algorithm
Diffstat:
18 files changed, 264 insertions(+), 101 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -382,7 +382,12 @@ struct sdis_scene_create_args {
size_t nvertices; /* #vertices */
double fp_to_meter; /* Scale factor used to convert 1.0 in 1 meter */
struct sdis_ambient_radiative_temperature trad; /* Ambient radiative temp */
+ double tmin; /* Min temperature */
double tmax; /* Max temperature used to linearize the radiative temperature */
+
+ /* Maximum number of heat path branchings. Actually the Picard order
+ * used to estimate the radiative temperature is max_branchings+1 */
+ size_t max_branchings;
};
#define SDIS_SCENE_CREATE_ARGS_DEFAULT__ { \
@@ -394,7 +399,9 @@ struct sdis_scene_create_args {
0, /* #vertices */ \
1.0, /* #Floating point to meter scale factor */ \
SDIS_AMBIENT_RADIATIVE_TEMPERATURE_NULL__,/* Ambient radiative temperature */\
+ 0.0, /* Minimum temperature */ \
-1.0, /* Maximum temperature */ \
+ 0 /* Maximum branchings */ \
}
static const struct sdis_scene_create_args SDIS_SCENE_CREATE_ARGS_DEFAULT =
SDIS_SCENE_CREATE_ARGS_DEFAULT__;
diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h
@@ -26,15 +26,27 @@ struct rwalk_context {
struct green_path_handle* green_path;
struct sdis_heat_path* heat_path;
- /* That is the upper bound temperature */
+ double Tmin; /* Lower bound temperature */
+ double Tmin2; /* Tmin^2 */
+ double Tmin3; /* Tmin^3 */
+
+ double That; /* Upper bound temperature */
double That2; /* That^2 */
double That3; /* That^3 */
+
+ /* Number of heat path branchings */
+ size_t nbranchings;
};
#define RWALK_CONTEXT_NULL__ { \
NULL, /* Green path */ \
NULL, /* Heat path */ \
- 0, /* (Temperature upper bound)^2 */ \
- 0 /* (Temperature upper bound)^3 */ \
+ 0, /* Tmin */ \
+ 0, /* Tmin^2 */ \
+ 0, /* Tmin^3 */ \
+ 0, /* That */ \
+ 0, /* That^2 */ \
+ 0, /* That^3 */ \
+ SIZE_MAX, /* #branchings */ \
}
static const struct rwalk_context RWALK_CONTEXT_NULL = RWALK_CONTEXT_NULL__;
@@ -112,7 +124,7 @@ static const struct XD(rwalk) XD(RWALK_NULL) = {
struct XD(temperature) {
res_T (*func)/* Next function to invoke in order to compute the temperature */
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* temp);
diff --git a/src/sdis_heat_path.h b/src/sdis_heat_path.h
@@ -150,7 +150,7 @@ extern LOCAL_SYM res_T
trace_radiative_path_2d
(struct sdis_scene* scn,
const float ray_dir[3],
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
struct temperature_2d* temperature);
@@ -159,7 +159,7 @@ extern LOCAL_SYM res_T
trace_radiative_path_3d
(struct sdis_scene* scn,
const float ray_dir[3],
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
struct temperature_3d* temperature);
@@ -167,7 +167,7 @@ trace_radiative_path_3d
extern LOCAL_SYM res_T
radiative_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
struct temperature_2d* temperature);
@@ -175,7 +175,7 @@ radiative_path_2d
extern LOCAL_SYM res_T
radiative_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
struct temperature_3d* temperature);
@@ -186,7 +186,7 @@ radiative_path_3d
extern LOCAL_SYM res_T
convective_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
struct temperature_2d* temperature);
@@ -194,7 +194,7 @@ convective_path_2d
extern LOCAL_SYM res_T
convective_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
struct temperature_3d* temperature);
@@ -205,7 +205,7 @@ convective_path_3d
extern LOCAL_SYM res_T
conductive_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
struct temperature_2d* temperature);
@@ -213,7 +213,7 @@ conductive_path_2d
extern LOCAL_SYM res_T
conductive_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
struct temperature_3d* temperature);
@@ -224,7 +224,7 @@ conductive_path_3d
extern LOCAL_SYM res_T
boundary_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
struct temperature_2d* temperature);
@@ -232,7 +232,7 @@ boundary_path_2d
extern LOCAL_SYM res_T
boundary_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
struct temperature_3d* temperature);
diff --git a/src/sdis_heat_path_boundary.c b/src/sdis_heat_path_boundary.c
@@ -32,6 +32,10 @@
#define SDIS_XD_DIMENSION 3
#include "sdis_heat_path_boundary_Xd_solid_fluid_picard1.h"
#define SDIS_XD_DIMENSION 2
+#include "sdis_heat_path_boundary_Xd_solid_fluid_picardN.h"
+#define SDIS_XD_DIMENSION 3
+#include "sdis_heat_path_boundary_Xd_solid_fluid_picardN.h"
+#define SDIS_XD_DIMENSION 2
#include "sdis_heat_path_boundary_Xd_solid_solid.h"
#define SDIS_XD_DIMENSION 3
#include "sdis_heat_path_boundary_Xd_solid_solid.h"
diff --git a/src/sdis_heat_path_boundary_Xd.h b/src/sdis_heat_path_boundary_Xd.h
@@ -30,7 +30,7 @@
res_T
XD(boundary_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -89,8 +89,11 @@ XD(boundary_path)
if(mdm_front->type == mdm_back->type) {
res = XD(solid_solid_boundary_path)(scn, ctx, &frag, rwalk, rng, T);
- } else {
+ } else if(ctx->nbranchings == scn->max_branchings) {
res = XD(solid_fluid_boundary_picard1_path)(scn, ctx, &frag, rwalk, rng, T);
+ } else {
+ ASSERT(ctx->nbranchings < scn->max_branchings);
+ res = XD(solid_fluid_boundary_picardN_path)(scn, ctx, &frag, rwalk, rng, T);
}
if(res != RES_OK) goto error;
diff --git a/src/sdis_heat_path_boundary_Xd_fixed_flux.h b/src/sdis_heat_path_boundary_Xd_fixed_flux.h
@@ -31,7 +31,7 @@
res_T
XD(solid_boundary_with_flux_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
const double phi,
struct XD(rwalk)* rwalk,
diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h
@@ -114,7 +114,7 @@ error:
res_T
XD(solid_fluid_boundary_picard1_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h
@@ -18,6 +18,7 @@
#include "sdis_interface_c.h"
#include "sdis_medium_c.h"
#include "sdis_misc.h"
+#include "sdis_realisation.h"
#include "sdis_scene_c.h"
#include <star/ssp.h>
@@ -25,12 +26,95 @@
#include "sdis_Xd_begin.h"
/*******************************************************************************
+ * Non generic helper functions
+ ******************************************************************************/
+#ifndef SDIS_HEAT_PATH_BOUNDARY_XD_SOLID_FLUID_PICARDN_H
+#define SDIS_HEAT_PATH_BOUNDARY_XD_SOLID_FLUID_PICARDN_H
+
+static INLINE res_T
+restart_heat_path
+ (struct sdis_heat_path* path,
+ const struct sdis_heat_vertex* vtx)
+{
+ size_t nverts = 0;
+ size_t nbreaks = 0;
+ res_T res = RES_OK;
+
+ if(path) goto exit;
+ ASSERT(vtx);
+
+ nbreaks = darray_size_t_size_get(&path->breaks);
+ nverts = darray_heat_vertex_size_get(&path->vertices);
+
+ res = heat_path_add_break(path);
+ if(res != RES_OK) goto error;
+ res = heat_path_add_vertex(path, vtx);
+ if(res != RES_OK) goto error;
+
+exit:
+ return res;
+error:
+ CHK(darray_size_t_resize(&path->breaks, nbreaks) == RES_OK);
+ CHK(darray_heat_vertex_resize(&path->vertices, nverts) == RES_OK);
+ goto exit;
+}
+
+#endif /* SDIS_HEAT_PATH_BOUNDARY_XD_SOLID_FLUID_PICARDN_H */
+
+/*******************************************************************************
+ * Generic helper functions
+ ******************************************************************************/
+static INLINE res_T
+XD(sample_path)
+ (struct sdis_scene* scn,
+ const struct XD(rwalk)* rwalk_from,
+ struct rwalk_context* ctx,
+ struct ssp_rng* rng,
+ struct XD(temperature)* T)
+{
+ struct XD(rwalk) rwalk = XD(RWALK_NULL);
+ res_T res = RES_OK;
+ ASSERT(rwalk_from && rng && T);
+
+ *T = XD(TEMPERATURE_NULL);
+
+ rwalk.vtx = rwalk_from->vtx;
+ rwalk.mdm = rwalk_from->mdm;
+ rwalk.hit = rwalk_from->hit;
+ rwalk.hit_side = rwalk_from->hit_side;
+
+ if(ctx->heat_path) {
+ struct sdis_heat_vertex heat_vtx = SDIS_HEAT_VERTEX_NULL;
+
+ heat_vtx.P[0] = rwalk.vtx.P[0];
+ heat_vtx.P[1] = rwalk.vtx.P[1];
+ heat_vtx.P[2] = rwalk.vtx.P[2];
+ heat_vtx.time = rwalk.vtx.time;
+ heat_vtx.weight = 0;
+ heat_vtx.type = SDIS_HEAT_VERTEX_RADIATIVE;
+
+ res = restart_heat_path(ctx->heat_path, &heat_vtx);
+ if(res != RES_OK) goto error;
+ }
+
+ res = XD(compute_temperature)(scn, ctx, &rwalk, rng, T);
+ if(res != RES_OK) goto error;
+
+ ASSERT(T->done);
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
+/*******************************************************************************
* Boundary path between a solid and a fluid
******************************************************************************/
res_T
XD(solid_fluid_boundary_picardN_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
@@ -45,6 +129,10 @@ XD(solid_fluid_boundary_picardN_path)
/* Fragment on the fluid side of the boundary */
struct sdis_interface_fragment frag_fluid;
+ /* Vertex of the heat path */
+ struct sdis_heat_vertex hvtx = SDIS_HEAT_VERTEX_NULL;
+ struct sdis_heat_vertex hvtx_s = SDIS_HEAT_VERTEX_NULL;
+
/* Data attached to the boundary */
struct sdis_interface* interf = NULL;
struct sdis_medium* solid = NULL;
@@ -53,18 +141,20 @@ XD(solid_fluid_boundary_picardN_path)
double h_cond; /* Conductive coefficient */
double h_conv; /* Convective coefficient */
double h_radi_hat; /* Radiative coefficient with That */
- double h_radi_min;
double h_hat; /* Sum of h_<conv|cond|rad_hat> */
double p_conv; /* Convective proba */
double p_cond; /* Conductive proba */
+ /* Min/Max Temperatures */
+ double Tmin, Tmin2, Tmin3;
+ double That, That2, That3;
+
double epsilon; /* Interface emissivity */
double lambda; /* Solid conductivity */
double delta_boundary; /* Orthogonal reinjection dst at the boundary */
double delta; /* Orthogonal fitted reinjection dst at the boundary */
double r;
- enum sdis_heat_vertex_type current_vertex_type;
enum sdis_side solid_side = SDIS_SIDE_NULL__;
enum sdis_side fluid_side = SDIS_SIDE_NULL__;
res_T res = RES_OK;
@@ -72,6 +162,14 @@ XD(solid_fluid_boundary_picardN_path)
ASSERT(scn && rwalk && rng && T && ctx);
ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag));
+ /* Fetch the Min/max temperature */
+ Tmin = ctx->Tmin;
+ Tmin2 = ctx->Tmin2;
+ Tmin3 = ctx->Tmin3;
+ That = ctx->That;
+ That2 = ctx->That2;
+ That3 = ctx->That3;
+
/* Retrieve the solid and the fluid split by the boundary */
interf = scene_get_interface(scn, rwalk->hit.prim.prim_id);
solid = interface_get_medium(interf, SDIS_FRONT);
@@ -121,16 +219,23 @@ XD(solid_fluid_boundary_picardN_path)
/* Compute a global upper bound coefficient */
h_hat = h_conv + h_cond + h_radi_hat;
- /* Compute the probas to switch in solid, fluid or radiative random walk */
+ /* Compute the probas to switch in convection or conduction */
p_conv = h_conv / h_hat;
p_cond = h_cond / h_hat;
- /* Null collision */
+ /* Fetch the last registered heat path vertex */
+ if(ctx->heat_path) hvtx = *heat_path_get_last_vertex(ctx->heat_path);
+
+ /* Null collision main loop */
for(;;) {
+ /* Temperature and random walk state of the sampled radiative path */
+ struct XD(temperature) T_s;
+ struct XD(rwalk) rwalk_s;
+
double h_radi, h_radi_min, h_radi_max; /* Radiative coefficients */
double p_radi, p_radi_min, p_radi_max; /* Radiative probas */
double T0, T1, T2, T3, T4, T5; /* Computed temperatures */
-
+
r = ssp_rng_canonical(rng);
/* Switch in convective path */
@@ -138,7 +243,7 @@ XD(solid_fluid_boundary_picardN_path)
T->func = XD(convective_path);
rwalk->mdm = fluid;
rwalk->hit_side = fluid_side;
- break exit;
+ break;
}
/* Switch in conductive path */
@@ -155,74 +260,95 @@ XD(solid_fluid_boundary_picardN_path)
solid_reinject_args.fp_to_meter = scn->fp_to_meter;
res = XD(solid_reinjection)(solid, &solid_reinject_args);
if(res != RES_OK) goto error;
- break exit;
+ break;
}
/* Sample a radiative path */
T_s = *T;
rwalk_s = *rwalk;
- rwalk_s.mdm = fluid_side;
+ rwalk_s.mdm = fluid;
rwalk_s.hit_side = fluid_side;
res = XD(radiative_path)(scn, ctx, &rwalk_s, rng, &T_s);
if(res != RES_OK) goto error;
+ /* Fetch the last registered heat path vertex of the radiative path */
+ if(ctx->heat_path) hvtx_s = *heat_path_get_last_vertex(ctx->heat_path);
+
h_radi_min = 4.0 * BOLTZMANN_CONSTANT * Tmin3 * epsilon;
p_radi_min = h_radi_min / h_radi_hat;
/* Switch in radiative path */
- if(r < p_cond + p_cond + p_radi_min) { *rwalk = rwalk_s; *T = T_s; break; }
+ if(r < p_conv + p_cond + p_radi_min) { *rwalk = rwalk_s; *T = T_s; break; }
+
+ /* Define some helper macros */
+ #define SWITCH_IN_RADIATIVE { \
+ *rwalk = rwalk_s; *T = T_s; \
+ res = restart_heat_path(ctx->heat_path, &hvtx_s); \
+ if(res != RES_OK) goto error; \
+ } (void)0
- #define COMPUTE_TEMPERATURE(Result, RWalk, Temperature) { \
- struct XD(temperature) T_p = *(Temperature); \
- struct XD(rwalk) rwalk_p = *(RWalk); \
- res = XD(compute_temperature)(scn, ctx, &rwalk_p, rng, &T_p); \
+ #define NULL_COLLISION { \
+ res = restart_heat_path(ctx->heat_path, &hvtx); \
if(res != RES_OK) goto error; \
- Result = (Temperature)->temperature; \
} (void)0
- #define CHECK_PMIN_PMAX() { \
- p_radi_min = h_radi_min / h_radi_hat; \
- p_radi_max = h_radi_max / h_radi_hat; \
- /* Switch in radiative path */ \
- if(r < p_cond + p_conv + p_radi_min) { *rwalk=rwalk_s; *T=T_s; break; } \
- /* Null collision reject the sampled path */ \
- if(r > p_cond + p_conv + p_radi_max) { continue; /* Null collision */ } \
+ #define COMPUTE_TEMPERATURE(Result, RWalk) { \
+ struct XD(temperature) T_p; \
+ res = XD(sample_path)(scn, RWalk, ctx, rng, &T_p); \
+ if(res != RES_OK) goto error; \
+ Result = T_p.value; \
} (void)0
- COMPUTE_TEMPERATURE(T0, &rwalk_s, &T_s);
+ #define CHECK_PMIN_PMAX { \
+ p_radi_min = h_radi_min*epsilon / h_radi_hat; \
+ p_radi_max = h_radi_max*epsilon / h_radi_hat; \
+ if(r < p_conv + p_cond + p_radi_min) { SWITCH_IN_RADIATIVE; break; } \
+ if(r > p_conv + p_cond + p_radi_max) { NULL_COLLISION; continue; } \
+ } (void)0
+
+ /* Sample a 1st heat path at the end of the radiative path */
+ COMPUTE_TEMPERATURE(T0, &rwalk_s);
h_radi_min = BOLTZMANN_CONSTANT*(Tmin3 * 3*Tmin2*T0);
h_radi_max = BOLTZMANN_CONSTANT*(That3 * 3*That2*T0);
- CHECK_PMIN_PMAX();
-
- COMPUTE_TEMPERATURE(T1, &rwalk_s, &T_s);
+ CHECK_PMIN_PMAX;
+
+ /* Sample a 2nd heat path at the end of the radiative path */
+ COMPUTE_TEMPERATURE(T1, &rwalk_s);
h_radi_min = BOLTZMANN_CONSTANT*(Tmin3 + Tmin2*T0 + 2*Tmin*T0*T1);
h_radi_max = BOLTZMANN_CONSTANT*(That3 + That2*T0 + 2*That*T0*T1);
- CHECK_PMIN_PMAX();
-
- COMPUTE_TEMPERATURE(T2, &rwalk_s, &T_s);
+ CHECK_PMIN_PMAX;
+
+ /* Sample a 3rd heat path at the end of the radiative path */
+ COMPUTE_TEMPERATURE(T2, &rwalk_s);
h_radi_min = BOLTZMANN_CONSTANT*(Tmin3 + Tmin2*T0 + Tmin*T0*T1 + T0*T1*T2);
h_radi_max = BOLTZMANN_CONSTANT*(That3 + That2*T0 + That*T0*T1 + T0*T1*T2);
- CHECK_PMIN_PMAX();
+ CHECK_PMIN_PMAX;
- COMPUTE_TEMPERATURE(T3, rwalk, T);
+ /* Sample a 1st heat path at the current position onto the interface */
+ COMPUTE_TEMPERATURE(T3, rwalk);
h_radi_min = BOLTZMANN_CONSTANT*(Tmin2*T3 + Tmin*T0*T3 + T0*T1*T3 + T0*T1*T2);
h_radi_max = BOLTZMANN_CONSTANT*(That2*T3 + That*T0*T3 + T0*T1*T3 + T0*T1*T2);
- CHECK_PMIN_PMAX();
+ CHECK_PMIN_PMAX;
- COMPUTE_TEMPERATURE(T4, rwalk, T);
+ /* Sample a 2nd heat path at the current position onto the interface */
+ COMPUTE_TEMPERATURE(T4, rwalk);
h_radi_min = BOLTZMANN_CONSTANT*(Tmin*T3*T4 + T0*T3*T4 + T0*T1*T3 + T0*T1*T2);
h_radi_max = BOLTZMANN_CONSTANT*(That*T3*T4 + T0*T3*T4 + T0*T1*T3 + T0*T1*T2);
- CHECK_PMIN_PMAX();
+ CHECK_PMIN_PMAX;
- COMPUTE_TEMPERATURE(T5, rwalk, T);
+ /* Sample a 3rd heat path at the current position onto the interface */
+ COMPUTE_TEMPERATURE(T5, rwalk);
h_radi = BOLTZMANN_CONSTANT*(T3*T4*T5 + T0*T3*T4 + T0*T1*T3 + T0*T1*T2);
- p_radi = h_radi / h_radi_hat;
+ p_radi = h_radi * epsilon / h_radi_hat;
/* Switch in radiative path */
- if(r < p_cond + p_conv + p_radi) { *rwalk=rwalk_s; *T=T_s; break; }
+ if(r < p_cond + p_conv + p_radi) { SWITCH_IN_RADIATIVE; break; }
/* Null-collision, looping at the beginning */
+ NULL_COLLISION;
+ #undef SWITCH_IN_RADIATIVE
+ #undef NULL_COLLISION
#undef COMPUTE_TEMPERATURE
#undef CHECK_PMIN_PMAX
}
diff --git a/src/sdis_heat_path_boundary_Xd_solid_solid.h b/src/sdis_heat_path_boundary_Xd_solid_solid.h
@@ -31,7 +31,7 @@
res_T
XD(solid_solid_boundary_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
diff --git a/src/sdis_heat_path_boundary_c.h b/src/sdis_heat_path_boundary_c.h
@@ -106,7 +106,7 @@ sample_reinjection_step_solid_solid_3d
******************************************************************************/
struct solid_reinjection_args_2d {
const struct reinjection_step_2d* reinjection; /* Reinjection to do */
- const struct rwalk_context* rwalk_ctx;
+ struct rwalk_context* rwalk_ctx;
struct rwalk_2d* rwalk; /* Current state of the random walk */
struct ssp_rng* rng; /* Random number generator */
struct temperature_2d* T;
@@ -115,7 +115,7 @@ struct solid_reinjection_args_2d {
struct solid_reinjection_args_3d {
const struct reinjection_step_3d* reinjection; /* Reinjection to do */
- const struct rwalk_context* rwalk_ctx;
+ struct rwalk_context* rwalk_ctx;
struct rwalk_3d* rwalk; /* Current state of the random walk */
struct ssp_rng* rng; /* Random number generator */
struct temperature_3d* T;
@@ -145,7 +145,7 @@ solid_reinjection_3d
extern LOCAL_SYM res_T
solid_boundary_with_flux_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
const double phi,
struct rwalk_2d* rwalk,
@@ -155,7 +155,7 @@ solid_boundary_with_flux_path_2d
extern LOCAL_SYM res_T
solid_boundary_with_flux_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
const double phi,
struct rwalk_3d* rwalk,
@@ -163,27 +163,9 @@ solid_boundary_with_flux_path_3d
struct temperature_3d* T);
extern LOCAL_SYM res_T
-solid_fluid_boundary_path_2d
- (struct sdis_scene* scn,
- const struct rwalk_context* ctx,
- const struct sdis_interface_fragment* frag,
- struct rwalk_2d* rwalk,
- struct ssp_rng* rng,
- struct temperature_2d* T);
-
-extern LOCAL_SYM res_T
-solid_fluid_boundary_path_3d
- (struct sdis_scene* scn,
- const struct rwalk_context* ctx,
- const struct sdis_interface_fragment* frag,
- struct rwalk_3d* rwalk,
- struct ssp_rng* rng,
- struct temperature_3d* T);
-
-extern LOCAL_SYM res_T
solid_fluid_boundary_picard1_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
@@ -192,7 +174,7 @@ solid_fluid_boundary_picard1_path_2d
extern LOCAL_SYM res_T
solid_fluid_boundary_picard1_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
@@ -201,7 +183,7 @@ solid_fluid_boundary_picard1_path_3d
extern LOCAL_SYM res_T
solid_fluid_boundary_picardN_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
@@ -210,7 +192,7 @@ solid_fluid_boundary_picardN_path_2d
extern LOCAL_SYM res_T
solid_fluid_boundary_picardN_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
@@ -219,7 +201,7 @@ solid_fluid_boundary_picardN_path_3d
extern LOCAL_SYM res_T
solid_solid_boundary_path_2d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_2d* rwalk,
struct ssp_rng* rng,
@@ -228,7 +210,7 @@ solid_solid_boundary_path_2d
extern LOCAL_SYM res_T
solid_solid_boundary_path_3d
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct rwalk_3d* rwalk,
struct ssp_rng* rng,
diff --git a/src/sdis_heat_path_conductive_Xd.h b/src/sdis_heat_path_conductive_Xd.h
@@ -199,7 +199,7 @@ error:
res_T
XD(conductive_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
diff --git a/src/sdis_heat_path_convective_Xd.h b/src/sdis_heat_path_convective_Xd.h
@@ -29,7 +29,7 @@
static res_T
XD(register_heat_vertex_in_fluid)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
const double weight)
{
@@ -70,7 +70,7 @@ XD(register_heat_vertex_in_fluid)
res_T
XD(convective_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
diff --git a/src/sdis_heat_path_radiative_Xd.h b/src/sdis_heat_path_radiative_Xd.h
@@ -33,7 +33,7 @@ res_T
XD(trace_radiative_path)
(struct sdis_scene* scn,
const float ray_dir[3],
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -188,7 +188,7 @@ error:
res_T
XD(radiative_path)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c
@@ -47,8 +47,12 @@ ray_realisation_3d
rwalk.mdm = medium;
ctx.heat_path = heat_path;
- ctx.That2 = scn->tmax * scn->tmax;
- ctx.That3 = scn->tmax * ctx.That2;
+ ctx.Tmin = scn->tmin;
+ ctx.Tmin2 = ctx.Tmin * ctx.Tmin;
+ ctx.Tmin3 = ctx.Tmin * ctx.Tmin2;
+ ctx.That = scn->tmax;
+ ctx.That2 = ctx.That * ctx.That;
+ ctx.That3 = ctx.That * ctx.That2;
f3_set_d3(dir, direction);
diff --git a/src/sdis_realisation.h b/src/sdis_realisation.h
@@ -35,6 +35,25 @@ enum flux_flag {
};
/*******************************************************************************
+ * Helper function used to compute a temperature
+ ******************************************************************************/
+extern LOCAL_SYM res_T
+compute_temperature_2d
+ (struct sdis_scene* scn,
+ struct rwalk_context* ctx,
+ struct rwalk_2d* rwalk,
+ struct ssp_rng* rng,
+ struct temperature_2d* T);
+
+extern LOCAL_SYM res_T
+compute_temperature_3d
+ (struct sdis_scene* scn,
+ struct rwalk_context* ctx,
+ struct rwalk_3d* rwalk,
+ struct ssp_rng* rng,
+ struct temperature_3d* T);
+
+/*******************************************************************************
* Realisation at a given position and time IN a medium
******************************************************************************/
extern LOCAL_SYM res_T
diff --git a/src/sdis_realisation_Xd.h b/src/sdis_realisation_Xd.h
@@ -27,12 +27,12 @@
#include "sdis_Xd_begin.h"
/*******************************************************************************
- * Helper functions
+ * Local functions
******************************************************************************/
-static res_T
+res_T
XD(compute_temperature)
(struct sdis_scene* scn,
- const struct rwalk_context* ctx,
+ struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -51,12 +51,13 @@ XD(compute_temperature)
res_T res = RES_OK;
ASSERT(scn && ctx && rwalk && rng && T);
+ ctx->nbranchings += 1;
+ CHK(ctx->nbranchings <= scn->max_branchings);
+
if(ctx->heat_path && T->func == XD(boundary_path)) {
heat_vtx = heat_path_get_last_vertex(ctx->heat_path);
}
- /* TODO incremente Picard order */
-
while(!T->done) {
/* Save the current random walk state */
const struct XD(rwalk) rwalk_bkp = *rwalk;
@@ -98,21 +99,17 @@ XD(compute_temperature)
}
}
- /* TODO Decrement Picard order */
exit:
#ifndef NDEBUG
sa_release(stack);
#endif
+ ctx->nbranchings -= 1;
return res == RES_BAD_OP_IRRECOVERABLE ? RES_BAD_OP : res;
error:
goto exit;
}
-
-/*******************************************************************************
- * Local functions
- ******************************************************************************/
res_T
XD(probe_realisation)
(const size_t irealisation, /* For debug */
diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h
@@ -913,8 +913,10 @@ XD(scene_create)
scn->dev = dev;
scn->fp_to_meter = args->fp_to_meter;
scn->trad = args->trad;
+ scn->tmin = args->tmin;
scn->tmax = args->tmax;
scn->outer_enclosure_id = UINT_MAX;
+ scn->max_branchings = args->max_branchings;
darray_interf_init(dev->allocator, &scn->interfaces);
darray_medium_init(dev->allocator, &scn->media);
darray_prim_prop_init(dev->allocator, &scn->prim_props);
diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h
@@ -210,8 +210,15 @@ struct sdis_scene {
double fp_to_meter;
struct sdis_ambient_radiative_temperature trad;
+ double tmin; /* Minimum temperature of the system (In Kelvin) */
double tmax; /* Maximum temperature of the system (In Kelvin) */
+ /* Maximum branchings i.e. the maximum number of times
+ * XD(compute_temperature) can be called. It controls the number of
+ * ramifications of the heat path and currently corresponds to the Picard
+ * order used to estimate the radiative temperature. */
+ size_t max_branchings;
+
ref_T ref;
struct sdis_device* dev;
};