commit 3a71aeb646307019a6a35beea8935093729d343b
parent a5f9211726fe4378464d84b9c53b9a804ed15f1d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 14 Feb 2018 15:16:39 +0100
Add the support of the radiative temperature
Diffstat:
15 files changed, 377 insertions(+), 78 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -144,6 +144,10 @@ static const struct sdis_fluid_shader SDIS_FLUID_SHADER_NULL =
struct sdis_interface_shader {
sdis_interface_getter_T temperature; /* Limit condition. NULL <=> Unknown */
sdis_interface_getter_T convection_coef; /* NULL <=> Solid/Solid interface */
+
+ /* BRDF parameter. NULL <=> Solid/solid interface */
+ sdis_interface_getter_T reflectivity_spec; /* Specular reflectivity */
+ sdis_interface_getter_T reflectivity_diff; /* Diffuse reflectivity */
};
#define SDIS_INTERFACE_SHADER_NULL__ {NULL}
static const struct sdis_interface_shader SDIS_INTERFACE_SHADER_NULL =
@@ -327,10 +331,12 @@ sdis_estimator_get_temperature
SDIS_API res_T
sdis_solve_probe
(struct sdis_scene* scn,
- const size_t nrealisations,
- const double position[3],
- const double time,
+ const size_t nrealisations, /* #realisations */
+ const double position[3], /* Probe position */
+ const double time, /* Observation time */
const double fp_to_meter,/* Scale from floating point units to meters */
+ const double ambient_radiative_temperature,
+ const double reference_temperature,
struct sdis_estimator** estimator);
END_DECLS
diff --git a/src/sdis_interface.c b/src/sdis_interface.c
@@ -41,15 +41,21 @@ check_interface_shader
type1 = sdis_medium_get_type(back);
/* Fluid<->solid interface */
- if(type0 != type1 && shader->convection_coef == NULL) {
- return 0;
+ if(type0 != type1) {
+ if(shader->convection_coef == NULL
+ || shader->reflectivity_spec == NULL
+ || shader->reflectivity_diff == NULL) {
+ return 0;
+ }
}
/* Solid<->solid interface */
- if(type0 == SDIS_MEDIUM_SOLID
- && type1 == SDIS_MEDIUM_SOLID
- && shader->convection_coef) {
- return 0;
+ if(type0 == SDIS_MEDIUM_SOLID && type1 == SDIS_MEDIUM_SOLID) {
+ if(shader->convection_coef != NULL
+ || shader->reflectivity_spec != NULL
+ || shader->reflectivity_diff != NULL) {
+ return 0;
+ }
}
return 1;
diff --git a/src/sdis_interface_c.h b/src/sdis_interface_c.h
@@ -76,5 +76,23 @@ interface_get_convection_coef
return interf->shader.convection_coef(frag, interf->data);
}
+static INLINE double
+interface_get_reflectivity_spec
+ (const struct sdis_interface* interf,
+ const struct sdis_interface_fragment* frag)
+{
+ ASSERT(interf && frag);
+ return interf->shader.reflectivity_spec(frag, interf->data);
+}
+
+static INLINE double
+interface_get_reflectivity_diff
+ (const struct sdis_interface* interf,
+ const struct sdis_interface_fragment* frag)
+{
+ ASSERT(interf && frag);
+ return interf->shader.reflectivity_diff(frag, interf->data);
+}
+
#endif /* SDIS_INTERFACE_C_H */
diff --git a/src/sdis_scene.c b/src/sdis_scene.c
@@ -361,6 +361,7 @@ scene_create
ref_init(&scn->ref);
SDIS(device_ref_get(dev));
scn->dev = dev;
+ scn->ambient_radiative_temperature = -1;
darray_interf_init(dev->allocator, &scn->interfaces);
darray_interf_init(dev->allocator, &scn->prim_interfaces);
diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h
@@ -40,6 +40,8 @@ struct sdis_scene {
struct s2d_scene_view* s2d_view;
struct s3d_scene_view* s3d_view;
+ double ambient_radiative_temperature; /* In Kelvin */
+
ref_T ref;
struct sdis_device* dev;
};
diff --git a/src/sdis_solve_probe.c b/src/sdis_solve_probe.c
@@ -36,6 +36,8 @@ sdis_solve_probe
const double position[3],
const double time,
const double fp_to_meter,/* Scale factor from floating point unit to meter */
+ const double Tarad, /* Ambient radiative temperature */
+ const double Tref, /* Reference temperature */
struct sdis_estimator** out_estimator)
{
const struct sdis_medium* medium = NULL;
@@ -50,7 +52,7 @@ sdis_solve_probe
ATOMIC res = RES_OK;
if(!scn || !nrealisations || !position || time < 0 || fp_to_meter <= 0
- || !out_estimator) {
+ || Tref < 0 || !out_estimator) {
res = RES_BAD_ARG;
goto error;
}
@@ -92,10 +94,10 @@ sdis_solve_probe
if(scene_is_2d(scn)) {
res_local = probe_realisation_2d
- (scn, rng, medium, position, time, fp_to_meter, &w);
+ (scn, rng, medium, position, time, fp_to_meter, Tarad, Tref, &w);
} else {
res_local = probe_realisation_3d
- (scn, rng, medium, position, time, fp_to_meter, &w);
+ (scn, rng, medium, position, time, fp_to_meter, Tarad, Tref, &w);
}
if(res_local != RES_OK) {
if(res_local == RES_BAD_OP) {
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -30,6 +30,13 @@
* to handle numerical imprecisions */
#define RAY_RANGE_MAX_SCALE 1.0001f
+#define BOLTZMANN_CONSTANT 5.6696e-8 /* W/m^2/K^4 */
+
+struct rwalk_context {
+ double Tarad; /* Ambient radiative temperature */
+ double Tref3; /* Reference temperature ^ 3 */
+};
+
#endif /* SDIS_SOLVE_PROBE_XD_H */
#else
@@ -79,6 +86,7 @@ struct XD(temperature) {
res_T (*func)/* Next function to invoke in order to compute the temperature */
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* temp);
@@ -91,6 +99,7 @@ static res_T
XD(boundary_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T);
@@ -99,6 +108,7 @@ static res_T
XD(solid_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T);
@@ -107,6 +117,16 @@ static res_T
XD(fluid_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
+ struct XD(rwalk)* rwalk,
+ struct ssp_rng* rng,
+ struct XD(temperature)* T);
+
+static res_T
+XD(radiative_temperature)
+ (const struct sdis_scene* scn,
+ const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T);
@@ -114,16 +134,31 @@ XD(fluid_temperature)
/*******************************************************************************
* Helper functions
******************************************************************************/
+/* Reflect the vector V wrt the normal N. By convention V points outward the
+ * surface. */
+static INLINE float*
+XD(reflect)(float res[DIM], const float V[DIM], const float N[DIM])
+{
+ float tmp[DIM];
+ float cos_V_N;
+ ASSERT(res && V && N);
+ ASSERT(fX(is_normalized)(V) && fX(is_normalized)(N));
+ cos_V_N = fX(dot)(V, N);
+ fX(mulf)(tmp, N, 2*cos_V_N);
+ fX(sub)(res, tmp, V);
+ return res;
+}
+
+
static FINLINE void
XD(move_pos)(double pos[DIM], const float dir[DIM], const float delta)
{
ASSERT(pos && dir);
pos[0] += dir[0] * delta;
pos[1] += dir[1] * delta;
-#if (SDIS_SOLVE_PROBE_DIMENSION == 3)
+#if(SDIS_SOLVE_PROBE_DIMENSION == 3)
pos[2] += dir[2] * delta;
#endif
-
}
/* Check that the interface fragment is consistent with the current state of
@@ -153,16 +188,148 @@ XD(check_rwalk_fragment_consistency)
}
res_T
+XD(radiative_temperature)
+ (const struct sdis_scene* scn,
+ const double fp_to_meter,
+ const struct rwalk_context* ctx,
+ struct XD(rwalk)* rwalk,
+ struct ssp_rng* rng,
+ struct XD(temperature)* T)
+{
+ const struct sdis_interface* interf;
+
+ /* The radiative random walk is always perform in 3D. In 2D, the geometry are
+ * assumed to be extruded to the infinty along the Z dimension. */
+ float N[3] = {0, 0, 0};
+ float dir[3] = {0, 0, 0};
+
+ res_T res = RES_OK;
+
+ ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T);
+ ASSERT(!SXD_HIT_NONE(&rwalk->hit));
+ (void)fp_to_meter;
+
+ /* Fetch the current interface */
+ interf = scene_get_interface(scn, rwalk->hit.prim.prim_id);
+
+ /* Normalize the normal of the interface and ensure that it points toward the
+ * current medium */
+ fX(normalize(N, rwalk->hit.normal));
+ if(interf->medium_back == rwalk->mdm) {
+ fX(minus(N, N));
+ }
+
+ /* Cosine weighted sampling of a direction around the surface normal */
+ ssp_ran_hemisphere_cos_float(rng, N, dir, NULL);
+
+ /* Launch the radiative random walk */
+ for(;;) {
+ struct sdis_interface_fragment frag = SDIS_INTERFACE_FRAGMENT_NULL;
+ const struct sdis_medium* chk_mdm = NULL;
+ double rho_s, rho_d, rho;
+ double r;
+ float pos[DIM];
+ const float range[2] = { 0, FLT_MAX };
+
+ fX_set_dX(pos, rwalk->vtx.P);
+
+ /* Trace the radiative ray */
+#if (SDIS_SOLVE_PROBE_DIMENSION == 2)
+ SXD(scene_view_trace_ray_3d
+ (scn->sXd(view), pos, dir, range, &rwalk->hit, &rwalk->hit));
+#else
+ SXD(scene_view_trace_ray
+ (scn->sXd(view), pos, dir, range, &rwalk->hit, &rwalk->hit));
+#endif
+ if(!SXD_HIT_NONE(&rwalk->hit)) { /* Fetch the ambient radiative temperature */
+ if(ctx->Tarad >= 0) {
+ T->value += ctx->Tarad;
+ T->done = 1;
+ break;
+ } else {
+ log_err(scn->dev,
+"%s: the random walk reaches an invalid ambient radiative temperature of `%gK'\n"
+"at position `%g %g %g'. This may be due to numerical inaccuracies or to\n"
+"inconsistency in the simulated system (eg: unclosed geometry). For systems\n"
+"where the random walks can reach such temperature, one has to setup a valid\n"
+"ambient radiative temperature, i.e. it must be greater or equal to 0.\n",
+ FUNC_NAME,
+ ctx->Tarad,
+ SPLIT3(rwalk->vtx.P));
+ res = RES_BAD_ARG;
+ goto error;
+ }
+ }
+
+ /* Move the random walk to the hit position */
+ XD(move_pos)(rwalk->vtx.P, dir, rwalk->hit.distance);
+
+ /* Fetch the new interface and setup the hit fragment */
+ interf = scene_get_interface(scn, rwalk->hit.prim.prim_id);
+ XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit);
+
+ /* Fetch the interface reflectivity */
+ rho_s = interface_get_reflectivity_spec(interf, &frag);
+ rho_d = interface_get_reflectivity_diff(interf, &frag);
+ rho = rho_s + rho_d;
+ if(rho > 1) {
+ log_err(scn->dev,
+ "%s: invalid overall reflectivity `%g' at position `%g %g %g'.\n",
+ FUNC_NAME, rho, SPLIT3(rwalk->vtx.P));
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ /* Switch in boundary temperature ? */
+ r = ssp_rng_canonical(rng);
+ if(r < rho) {
+ T->func = XD(boundary_temperature);
+ break;
+ }
+
+ /* Normalize the normal of the interface and ensure that it points toward the
+ * current medium */
+ fX(normalize)(N, rwalk->hit.normal);
+ if(f3_dot(N, dir) > 0) {
+ chk_mdm = interf->medium_back;
+ fX(minus)(N, N);
+ } else {
+ chk_mdm = interf->medium_front;
+ }
+
+ if(chk_mdm != rwalk->mdm) {
+ log_err(scn->dev, "%s: inconsistent medium definition at `%g %g %g'.\n",
+ FUNC_NAME, SPLIT3(rwalk->vtx.P));
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ r = ssp_rng_canonical(rng);
+ if(r < rho_s / rho) { /* Sample specular part */
+ XD(reflect)(dir, dir, N);
+ } else { /* Sample diffuse part */
+ ssp_ran_hemisphere_cos_float(rng, N, dir, NULL);
+ }
+ }
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
+res_T
XD(fluid_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
{
double tmp;
- (void)rng, (void)fp_to_meter;
- ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T);
+ (void)rng, (void)fp_to_meter, (void)ctx;
+ ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T);
ASSERT(rwalk->mdm->type == SDIS_MEDIUM_FLUID);
tmp = fluid_get_temperature(rwalk->mdm, &rwalk->vtx);
@@ -180,6 +347,7 @@ static void
XD(solid_solid_boundary_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
@@ -196,9 +364,9 @@ XD(solid_solid_boundary_temperature)
double tmp;
double r;
float pos[DIM], dir[DIM], range[2];
- ASSERT(scn && fp_to_meter > 0 && frag && rwalk && rng && T);
+ ASSERT(scn && fp_to_meter > 0 && ctx && frag && rwalk && rng && T);
ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag));
- (void)frag;
+ (void)frag, (void)ctx;
/* Retrieve the current boundary media */
interf = scene_get_interface(scn, rwalk->hit.prim.prim_id);
@@ -248,6 +416,7 @@ static void
XD(solid_fluid_boundary_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
const struct sdis_interface_fragment* frag,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
@@ -259,14 +428,17 @@ XD(solid_fluid_boundary_temperature)
const struct sdis_medium* solid = NULL;
const struct sdis_medium* fluid = NULL;
double hc;
+ double hr;
+ double rho; /* Interface reflectivity */
double lambda;
double fluid_proba;
+ double radia_proba;
double delta_boundary;
double r;
double tmp;
float dir[DIM], pos[DIM], range[2];
- ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T);
+ ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T && ctx);
ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag));
/* Retrieve the solid and the fluid split by the boundary */
@@ -285,14 +457,26 @@ XD(solid_fluid_boundary_temperature)
/* Fetch the solid properties */
lambda = solid_get_thermal_conductivity(solid, &rwalk->vtx);
delta_boundary = solid_get_delta_boundary(solid, &rwalk->vtx);
+
+ /* Fetch the boundary properties */
+ rho = interface_get_reflectivity_diff(interf, frag)
+ + interface_get_reflectivity_spec(interf, frag);
hc = interface_get_convection_coef(interf, frag);
+ /* Compute the radiative coefficient */
+ hr = 4.0 * BOLTZMANN_CONSTANT * ctx->Tref3 * rho;
+
/* Compute the probas to switch in solid or fluid random walk */
tmp = lambda / (delta_boundary*fp_to_meter);
- fluid_proba = hc / (tmp + hc);
+ fluid_proba = hc / (tmp + hr + hc);
+ radia_proba = hr / (tmp + hr + hc);
+ /*solid_proba = tmp / (tmp + hr + hc);*/
r = ssp_rng_canonical(rng);
- if(r < fluid_proba) { /* Switch to fluid random walk */
+ if(r < radia_proba) { /* Switch in radiative random walk */
+ rwalk->mdm = fluid;
+ T->func = XD(radiative_temperature);
+ } else if(r < fluid_proba + radia_proba) { /* Switch to fluid random walk */
rwalk->mdm = fluid;
T->func = XD(fluid_temperature);
} else { /* Solid random walk */
@@ -317,6 +501,7 @@ res_T
XD(boundary_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -326,7 +511,7 @@ XD(boundary_temperature)
const struct sdis_medium* mdm_front = NULL;
const struct sdis_medium* mdm_back = NULL;
double tmp;
- ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T);
+ ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T);
ASSERT(!SXD_HIT_NONE(&rwalk->hit));
XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit);
@@ -346,9 +531,11 @@ XD(boundary_temperature)
mdm_back = interface_get_medium(interf, SDIS_BACK);
if(mdm_front->type == mdm_back->type) {
- XD(solid_solid_boundary_temperature)(scn, fp_to_meter, &frag, rwalk, rng, T);
+ XD(solid_solid_boundary_temperature)
+ (scn, fp_to_meter, ctx, &frag, rwalk, rng, T);
} else {
- XD(solid_fluid_boundary_temperature)(scn, fp_to_meter, &frag, rwalk, rng, T);
+ XD(solid_fluid_boundary_temperature)
+ (scn, fp_to_meter, ctx, &frag, rwalk, rng, T);
}
return RES_OK;
}
@@ -357,6 +544,7 @@ res_T
XD(solid_temperature)
(const struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -365,6 +553,7 @@ XD(solid_temperature)
const struct sdis_medium* mdm;
ASSERT(scn && fp_to_meter > 0 && rwalk && rng && T);
ASSERT(rwalk->mdm->type == SDIS_MEDIUM_SOLID);
+ (void)ctx;
/* Check the random walk consistency */
CHK(scene_get_medium(scn, rwalk->vtx.P, &mdm) == RES_OK);
@@ -485,6 +674,7 @@ static res_T
XD(compute_temperature)
(struct sdis_scene* scn,
const double fp_to_meter,
+ const struct rwalk_context* ctx,
struct XD(rwalk)* rwalk,
struct ssp_rng* rng,
struct XD(temperature)* T)
@@ -494,10 +684,10 @@ XD(compute_temperature)
size_t istack = 0;
#endif
res_T res = RES_OK;
- ASSERT(scn && fp_to_meter && rwalk && rng && T);
+ ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T);
do {
- res = T->func(scn, fp_to_meter, rwalk, rng, T);
+ res = T->func(scn, fp_to_meter, ctx, rwalk, rng, T);
if(res != RES_OK) goto error;
#ifndef NDEBUG
@@ -523,31 +713,39 @@ XD(probe_realisation)
const double position[],
const double time,
const double fp_to_meter,/* Scale factor from floating point unit to meter */
+ const double ambient_radiative_temperature,
+ const double reference_temperature,
double* weight)
{
- struct XD(rwalk) rwalk = XD(RWALK_NULL);
- struct XD(temperature) T = XD(TEMPERATURE_NULL);
- res_T res = RES_OK;
- ASSERT(medium && position && fp_to_meter > 0 && weight && time >= 0);
-
- switch(medium->type) {
- case SDIS_MEDIUM_FLUID: T.func = XD(fluid_temperature); break;
- case SDIS_MEDIUM_SOLID: T.func = XD(solid_temperature); break;
- default: FATAL("Unreachable code\n"); break;
- }
-
- dX(set)(rwalk.vtx.P, position);
- rwalk.vtx.time = time;
- rwalk.hit = SXD_HIT_NULL;
- rwalk.mdm = medium;
-
- res = XD(compute_temperature)(scn, fp_to_meter, &rwalk, rng, &T);
- if(res != RES_OK) return res;
-
- *weight = T.value;
- return RES_OK;
-}
+ struct rwalk_context ctx;
+ struct XD(rwalk) rwalk = XD(RWALK_NULL);
+ struct XD(temperature) T = XD(TEMPERATURE_NULL);
+ res_T res = RES_OK;
+ ASSERT(medium && position && fp_to_meter > 0 && weight && time >= 0);
+
+ switch(medium->type) {
+ case SDIS_MEDIUM_FLUID: T.func = XD(fluid_temperature); break;
+ case SDIS_MEDIUM_SOLID: T.func = XD(solid_temperature); break;
+ default: FATAL("Unreachable code\n"); break;
+ }
+ dX(set)(rwalk.vtx.P, position);
+ rwalk.vtx.time = time;
+ rwalk.hit = SXD_HIT_NULL;
+ rwalk.mdm = medium;
+
+ ctx.Tarad = ambient_radiative_temperature;
+ ctx.Tref3 =
+ reference_temperature
+ * reference_temperature
+ * reference_temperature;
+
+ res = XD(compute_temperature)(scn, fp_to_meter, &ctx, &rwalk, rng, &T);
+ if(res != RES_OK) return res;
+
+ *weight = T.value;
+ return RES_OK;
+}
#undef SDIS_SOLVE_PROBE_DIMENSION
#undef DIM
diff --git a/src/test_sdis_interface.c b/src/test_sdis_interface.c
@@ -78,6 +78,8 @@ main(int argc, char** argv)
CHK(CREATE(dev, solid, solid, &shader, NULL, &interf) == RES_BAD_ARG);
shader.convection_coef = NULL;
+ shader.reflectivity_diff = NULL;
+ shader.reflectivity_spec = NULL;
CHK(CREATE(dev, solid, solid, &shader, NULL, &interf) == RES_OK);
CHK(sdis_interface_ref_put(interf) == RES_OK);
@@ -87,6 +89,8 @@ main(int argc, char** argv)
CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG);
shader.convection_coef = DUMMY_INTERFACE_SHADER.convection_coef;
+ shader.reflectivity_spec = DUMMY_INTERFACE_SHADER.reflectivity_spec;
+ shader.reflectivity_diff = DUMMY_INTERFACE_SHADER.reflectivity_diff;
CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_OK);
CHK(sdis_interface_ref_put(interf) == RES_OK);
#undef CREATE
diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c
@@ -146,6 +146,8 @@ solid_get_temperature
******************************************************************************/
struct interf {
double hc;
+ double rho_s;
+ double rho_d;
};
static double
@@ -156,6 +158,22 @@ interface_get_convection_coef
return ((const struct interf*)sdis_data_cget(data))->hc;
}
+static double
+interface_get_reflectivity_spec
+ (const struct sdis_interface_fragment* frag, struct sdis_data* data)
+{
+ CHK(data != NULL && frag != NULL);
+ return ((const struct interf*)sdis_data_cget(data))->rho_s;
+}
+
+static double
+interface_get_reflectivity_diff
+ (const struct sdis_interface_fragment* frag, struct sdis_data* data)
+{
+ CHK(data != NULL && frag != NULL);
+ return ((const struct interf*)sdis_data_cget(data))->rho_d;
+}
+
/*******************************************************************************
* Test
******************************************************************************/
@@ -222,8 +240,12 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->hc = 0.5;
+ interface_param->rho_s = 0;
+ interface_param->rho_d = 0;
interface_shader.convection_coef = interface_get_convection_coef;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = interface_get_reflectivity_spec;
+ interface_shader.reflectivity_diff = interface_get_reflectivity_diff;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &interf) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -246,12 +268,13 @@ main(int argc, char** argv)
pos[1] = 0.5;
pos[2] = 0.5;
time = INF;
- CHK(sdis_solve_probe(NULL, N, pos, time, 1.0, &estimator) == RES_BAD_ARG);
- CHK(sdis_solve_probe(scn, 0, pos, time, 1.0, &estimator) == RES_BAD_ARG);
- CHK(sdis_solve_probe(scn, N, NULL, time, 1.0, &estimator) == RES_BAD_ARG);
- CHK(sdis_solve_probe(scn, N, pos, time, 0, &estimator) == RES_BAD_ARG);
- CHK(sdis_solve_probe(scn, N, pos, time, 1.0, NULL) == RES_BAD_ARG);
- CHK(sdis_solve_probe(scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe(NULL, N, pos, time, 1.0, 0, 0, &estimator) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, 0, pos, time, 1.0, 0, 0, &estimator) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, N, NULL, time, 1.0, 0, 0, &estimator) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, N, pos, time, 0, 0, 0, &estimator) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, N, pos, time, 0, 0, -1, &estimator) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, N, pos, time, 1.0, 0, 0, NULL) == RES_BAD_ARG);
+ CHK(sdis_solve_probe(scn, N, pos, time, 1.0, 0, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, NULL) == RES_BAD_ARG);
CHK(sdis_estimator_get_realisation_count(NULL, &nreals) == RES_BAD_ARG);
diff --git a/src/test_sdis_solve_probe2.c b/src/test_sdis_solve_probe2.c
@@ -131,7 +131,7 @@ struct interf {
};
static double
-null_convection_coef
+null_interface_value
(const struct sdis_interface_fragment* frag, struct sdis_data* data)
{
CHK(frag != NULL);
@@ -196,8 +196,10 @@ main(int argc, char** argv)
CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK);
/* Create the fluid/solid interface with no limit conidition */
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK);
@@ -206,8 +208,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 300;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T300) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -217,8 +221,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 350;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T350) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -253,7 +259,7 @@ main(int argc, char** argv)
pos[1] = 0.5;
pos[2] = 0.5;
time = INF;
- CHK(sdis_solve_probe( scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe( scn, N, pos, time, 1.0, -1, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, &nreals) == RES_OK);
CHK(sdis_estimator_get_failure_count(estimator, &nfails) == RES_OK);
CHK(sdis_estimator_get_temperature(estimator, &T) == RES_OK);
diff --git a/src/test_sdis_solve_probe2_2d.c b/src/test_sdis_solve_probe2_2d.c
@@ -128,7 +128,7 @@ struct interf {
};
static double
-null_convection_coef
+null_interface_value
(const struct sdis_interface_fragment* frag, struct sdis_data* data)
{
CHK(frag != NULL);
@@ -193,8 +193,10 @@ main(int argc, char** argv)
CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK);
/* Create the fluid/solid interface with no limit conidition */
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK);
@@ -203,8 +205,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 300;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T300) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -214,8 +218,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 350;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T350) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -247,7 +253,7 @@ main(int argc, char** argv)
pos[0] = 0.5;
pos[1] = 0.5;
time = INF;
- CHK(sdis_solve_probe( scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe( scn, N, pos, time, 1.0, -1, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, &nreals) == RES_OK);
CHK(sdis_estimator_get_failure_count(estimator, &nfails) == RES_OK);
CHK(sdis_estimator_get_temperature(estimator, &T) == RES_OK);
diff --git a/src/test_sdis_solve_probe3.c b/src/test_sdis_solve_probe3.c
@@ -153,7 +153,7 @@ struct interf {
};
static double
-null_convection_coef
+null_interface_value
(const struct sdis_interface_fragment* frag, struct sdis_data* data)
{
CHK(frag != NULL);
@@ -223,8 +223,10 @@ main(int argc, char** argv)
CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK);
/* Create the fluid/solid interface with no limit conidition */
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK);
@@ -233,8 +235,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 300;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T300) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -244,8 +248,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 350;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T350) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -253,6 +259,8 @@ main(int argc, char** argv)
/* Create the solid/solid interface */
interface_shader.convection_coef = NULL;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_diff = NULL;
+ interface_shader.reflectivity_spec = NULL;
CHK(sdis_interface_create
(dev, solid, solid, &interface_shader, NULL, &solid_solid) == RES_OK);
@@ -310,7 +318,7 @@ main(int argc, char** argv)
pos[1] = 0.5;
pos[2] = 0.5;
time = INF;
- CHK(sdis_solve_probe( scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe( scn, N, pos, time, 1.0, -1, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, &nreals) == RES_OK);
CHK(sdis_estimator_get_failure_count(estimator, &nfails) == RES_OK);
CHK(sdis_estimator_get_temperature(estimator, &T) == RES_OK);
diff --git a/src/test_sdis_solve_probe3_2d.c b/src/test_sdis_solve_probe3_2d.c
@@ -150,7 +150,7 @@ struct interf {
};
static double
-null_convection_coef
+null_interface_value
(const struct sdis_interface_fragment* frag, struct sdis_data* data)
{
CHK(frag != NULL);
@@ -218,8 +218,10 @@ main(int argc, char** argv)
CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK);
/* Create the fluid/solid interface with no limit conidition */
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK);
@@ -228,8 +230,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 300;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T300) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -239,8 +243,10 @@ main(int argc, char** argv)
ALIGNOF(struct interf), NULL, &data) == RES_OK);
interface_param = sdis_data_get(data);
interface_param->temperature = 350;
- interface_shader.convection_coef = null_convection_coef;
+ interface_shader.convection_coef = null_interface_value;
interface_shader.temperature = interface_get_temperature;
+ interface_shader.reflectivity_spec = null_interface_value;
+ interface_shader.reflectivity_diff = null_interface_value;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, data, &T350) == RES_OK);
CHK(sdis_data_ref_put(data) == RES_OK);
@@ -248,6 +254,8 @@ main(int argc, char** argv)
/* Create the solid/solid interface */
interface_shader.convection_coef = NULL;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_diff = NULL;
+ interface_shader.reflectivity_spec = NULL;
CHK(sdis_interface_create
(dev, solid, solid, &interface_shader, NULL, &solid_solid) == RES_OK);
@@ -300,7 +308,7 @@ main(int argc, char** argv)
pos[0] = 0.5;
pos[1] = 0.5;
time = INF;
- CHK(sdis_solve_probe( scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe( scn, N, pos, time, 1.0, -1, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, &nreals) == RES_OK);
CHK(sdis_estimator_get_failure_count(estimator, &nfails) == RES_OK);
CHK(sdis_estimator_get_temperature(estimator, &T) == RES_OK);
@@ -325,5 +333,4 @@ main(int argc, char** argv)
mem_shutdown_proxy_allocator(&allocator);
CHK(mem_allocated_size() == 0);
return 0;
-
}
diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c
@@ -131,6 +131,14 @@ interface_get_convection_coef
return 0.5;
}
+static double
+interface_null_reflectivity
+ (const struct sdis_interface_fragment* frag, struct sdis_data* data)
+{
+ (void)frag, (void)data;
+ return 0;
+}
+
/*******************************************************************************
* Main test
******************************************************************************/
@@ -177,6 +185,8 @@ main(int argc, char** argv)
/* Create the solid/fluid interface */
interface_shader.convection_coef = interface_get_convection_coef;
interface_shader.temperature = NULL;
+ interface_shader.reflectivity_spec = interface_null_reflectivity;
+ interface_shader.reflectivity_diff = interface_null_reflectivity;
CHK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &interf) == RES_OK);
@@ -197,7 +207,7 @@ main(int argc, char** argv)
pos[0] = 0.5;
pos[1] = 0.5;
time = INF;
- CHK(sdis_solve_probe(scn, N, pos, time, 1.0, &estimator) == RES_OK);
+ CHK(sdis_solve_probe(scn, N, pos, time, 1.0, 0, 0, &estimator) == RES_OK);
CHK(sdis_estimator_get_realisation_count(estimator, &nreals) == RES_OK);
CHK(sdis_estimator_get_failure_count(estimator, &nfails) == RES_OK);
diff --git a/src/test_sdis_utils.h b/src/test_sdis_utils.h
@@ -82,7 +82,7 @@ dummy_medium_getter
{
(void)data;
CHK(vert != NULL);
- return 1;
+ return 0;
}
static INLINE double
@@ -91,7 +91,7 @@ dummy_interface_getter
{
(void)data;
CHK(frag != NULL);
- return 1;
+ return 0;
}
static const struct sdis_solid_shader DUMMY_SOLID_SHADER = {
@@ -111,6 +111,8 @@ static const struct sdis_fluid_shader DUMMY_FLUID_SHADER = {
static const struct sdis_interface_shader DUMMY_INTERFACE_SHADER = {
dummy_interface_getter,
+ dummy_interface_getter,
+ dummy_interface_getter,
dummy_interface_getter
};