stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit 7a67a6dd6b7957a639ba3f4c5a69f70cc200c826
parent 0fa2ae557ac229fd574ba4584a0fd8e097f114cc
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 18 Apr 2018 11:58:46 +0200

Make some interface properties double sided

The emissivity, temperature and flux are defined for each side of the
interface. The interface fragment has a new attribute that define the
side on which it lies.

Note that the flux is not taken into account by the solver, yet.

Diffstat:
Msrc/sdis.h | 51++++++++++++++++++++++++++++++++++++++-------------
Msrc/sdis_interface.c | 38+++++++++++++++++++++++++-------------
Msrc/sdis_interface_c.h | 58+++++++++++++++++++++++++++++++++++++++++++++++-----------
Msrc/sdis_medium_c.h | 4++--
Msrc/sdis_solve.c | 7++++---
Msrc/sdis_solve_Xd.h | 67+++++++++++++++++++++++++++++++++++++++++++------------------------
Msrc/test_sdis_conducto_radiative.c | 19++++++++++++++-----
Msrc/test_sdis_conducto_radiative_2d.c | 105++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Msrc/test_sdis_interface.c | 25+++++++++++++++----------
Msrc/test_sdis_scene.c | 4+++-
Msrc/test_sdis_solve_camera.c | 16+++++++++++-----
Msrc/test_sdis_solve_probe.c | 7++++---
Msrc/test_sdis_solve_probe2.c | 14+++-----------
Msrc/test_sdis_solve_probe2_2d.c | 18+++++++-----------
Msrc/test_sdis_solve_probe3.c | 19++++---------------
Msrc/test_sdis_solve_probe3_2d.c | 20++++++--------------
Msrc/test_sdis_solve_probe_2d.c | 13++-----------
Msrc/test_sdis_solve_probe_boundary.c | 41++++++++++++++---------------------------
Msrc/test_sdis_utils.h | 12+++++++++---
Msrc/test_sdis_volumic_power.c | 22++--------------------
20 files changed, 325 insertions(+), 235 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -40,6 +40,9 @@ * as CPU cores */ #define SDIS_NTHREADS_DEFAULT (~0u) +#define SDIS_VOLUMIC_POWER_NONE DBL_MAX /* <=> No volumic power */ +#define SDIS_FLUX_NONE DBL_MAX /* <=> No flux */ + /* Forward declaration of external opaque data types */ struct logger; struct mem_allocator; @@ -91,8 +94,9 @@ struct sdis_interface_fragment { double Ng[3]; /* Normalized world space geometry normal at the interface */ double uv[2]; /* Parametric coordinates of the interface */ double time; /* Current time */ + enum sdis_side_flag side; }; -#define SDIS_INTERFACE_FRAGMENT_NULL__ {{0}, {0}, {0}, -1} +#define SDIS_INTERFACE_FRAGMENT_NULL__ {{0}, {0}, {0}, -1, SDIS_SIDE_NULL__} static const struct sdis_interface_fragment SDIS_INTERFACE_FRAGMENT_NULL = SDIS_INTERFACE_FRAGMENT_NULL__; @@ -129,13 +133,16 @@ typedef double /* Define the physical properties of a solid */ struct sdis_solid_shader { /* Properties */ - sdis_medium_getter_T calorific_capacity; - sdis_medium_getter_T thermal_conductivity; - sdis_medium_getter_T volumic_mass; + sdis_medium_getter_T calorific_capacity; /* In J.K^-1.kg^-1 */ + sdis_medium_getter_T thermal_conductivity; /* In W.m^-1.K^-1 */ + sdis_medium_getter_T volumic_mass; /* In kg.m^-3 */ sdis_medium_getter_T delta_solid; sdis_medium_getter_T delta_boundary; - sdis_medium_getter_T volumic_power; /* May be NULL <=> no volumic power */ + /* May be NULL if there is no volumic power. One can also return + * SDIS_VOLUMIC_POWER_NONE to define that there is no volumic power at the + * submitted position and time */ + sdis_medium_getter_T volumic_power; /* In W.m^-3 */ /* Initial/limit condition. A temperature < 0 means that the temperature is * unknown for the submitted random walk vertex. */ @@ -148,8 +155,8 @@ static const struct sdis_solid_shader SDIS_SOLID_SHADER_NULL = /* Define the physical properties of a fluid */ struct sdis_fluid_shader { /* Properties */ - sdis_medium_getter_T calorific_capacity; - sdis_medium_getter_T volumic_mass; + sdis_medium_getter_T calorific_capacity; /* In J.K^-1.kg^-1 */ + sdis_medium_getter_T volumic_mass; /* In kg.m^-3 */ /* Initial/limit condition. A temperature < 0 means that the temperature is * unknown for the submitted position and time. */ @@ -159,16 +166,33 @@ struct sdis_fluid_shader { static const struct sdis_fluid_shader SDIS_FLUID_SHADER_NULL = SDIS_FLUID_SHADER_NULL__; +/* Define the physical properties of one side of an interface. */ +struct sdis_interface_side_shader { + /* Fixed temperature/flux. May be NULL if the temperature/flux is unknown + * onto the whole interface */ + sdis_interface_getter_T temperature; /* In Kelvin. < 0 <=> Unknown temp */ + sdis_interface_getter_T flux; /* In W.m^-2. SDIS_FLUX_NONE <=> no flux */ + + /* Control the emissivity of the interface. May be NULL for solid/sold + * interface or if the emissivity is 0 onto the whole interface. */ + sdis_interface_getter_T emissivity; /* Overall emissivity. */ + sdis_interface_getter_T specular_fraction; /* Specular part in [0,1] */ +}; +#define SDIS_INTERFACE_SIDE_SHADER_NULL__ { NULL, NULL, NULL, NULL } +static const struct sdis_interface_side_shader SDIS_INTERFACE_SIDE_SHADER_NULL = + SDIS_INTERFACE_SIDE_SHADER_NULL__; + /* Define the physical properties of an interface between 2 media .*/ struct sdis_interface_shader { - sdis_interface_getter_T temperature; /* Limit condition. NULL <=> Unknown */ - sdis_interface_getter_T convection_coef; /* May be NULL for solid/solid */ + /* May be NULL for solid/solid or if the convection coefficient is 0 onto + * the whole interface. */ + sdis_interface_getter_T convection_coef; /* In W.K^-1.m^-2 */ - /* Interface emssivity. May be NULL for solid/solid interface */ - sdis_interface_getter_T emissivity; /* Overall emissivity */ - sdis_interface_getter_T specular_fraction; /* Specular fraction in [0, 1] */ + struct sdis_interface_side_shader front; + struct sdis_interface_side_shader back; }; -#define SDIS_INTERFACE_SHADER_NULL__ {NULL, NULL, NULL, NULL} +#define SDIS_INTERFACE_SHADER_NULL__ \ + {NULL, SDIS_INTERFACE_SIDE_SHADER_NULL__, SDIS_INTERFACE_SIDE_SHADER_NULL__} static const struct sdis_interface_shader SDIS_INTERFACE_SHADER_NULL = SDIS_INTERFACE_SHADER_NULL__; @@ -530,6 +554,7 @@ sdis_solve_probe_boundary const size_t iprim, /* Identifier of the primitive on which the probe lies */ const double uv[2], /* Parametric coordinates of the probe onto the primitve */ const double time, /* Observation time */ + const enum sdis_side_flag side, /* Side of iprim on which the probe lies */ const double fp_to_meter, /* Scale from floating point units to meters */ const double ambient_radiative_temperature, /* In Kelvin */ const double reference_temperature, /* In Kelvin */ diff --git a/src/sdis_interface.c b/src/sdis_interface.c @@ -33,22 +33,28 @@ check_interface_shader const struct sdis_medium* front, const struct sdis_medium* back) { - enum sdis_medium_type type0; - enum sdis_medium_type type1; + enum sdis_medium_type type_front; + enum sdis_medium_type type_back; ASSERT(shader && front && back); - type0 = sdis_medium_get_type(front); - type1 = sdis_medium_get_type(back); + type_front = sdis_medium_get_type(front); + type_back = sdis_medium_get_type(back); - /* Fluid<->solid interface */ - if(type0 != type1) { - if(shader->convection_coef == NULL - || shader->emissivity == NULL - || shader->specular_fraction == NULL) { - return 0; - } + if(type_front == SDIS_MEDIUM_SOLID + && (shader->front.emissivity || shader->front.specular_fraction)) { + return 0; + } + if(type_back == SDIS_MEDIUM_SOLID + && (shader->back.emissivity || shader->back.specular_fraction)) { + return 0; } + /* Fluid<->solid interface */ + if(type_front == SDIS_MEDIUM_SOLID + && type_back == SDIS_MEDIUM_SOLID + && shader->convection_coef) { + return 0; + } return 1; } @@ -177,27 +183,33 @@ void setup_interface_fragment_2d (struct sdis_interface_fragment* frag, const struct sdis_rwalk_vertex* vertex, - const struct s2d_hit* hit) + const struct s2d_hit* hit, + const enum sdis_side_flag side) { ASSERT(frag && vertex && hit && !S2D_HIT_NONE(hit)); + ASSERT(side == SDIS_FRONT || side == SDIS_BACK); d2_set(frag->P, vertex->P); frag->P[2] = 0; d2_normalize(frag->Ng, d2_set_f2(frag->Ng, hit->normal)); frag->Ng[2] = 0; frag->uv[0] = hit->u; frag->time = vertex->time; + frag->side = side; } void setup_interface_fragment_3d (struct sdis_interface_fragment* frag, const struct sdis_rwalk_vertex* vertex, - const struct s3d_hit* hit) + const struct s3d_hit* hit, + const enum sdis_side_flag side) { ASSERT(frag && vertex && hit && !S3D_HIT_NONE(hit)); + ASSERT(side == SDIS_FRONT || side == SDIS_BACK); d3_set(frag->P, vertex->P); d3_normalize(frag->Ng, d3_set_f3(frag->Ng, hit->normal)); d2_set_f2(frag->uv, hit->uv); frag->time = vertex->time; + frag->side = side; } diff --git a/src/sdis_interface_c.h b/src/sdis_interface_c.h @@ -49,49 +49,85 @@ extern LOCAL_SYM void setup_interface_fragment_2d (struct sdis_interface_fragment* frag, const struct sdis_rwalk_vertex* vertex, - const struct s2d_hit* hit); + const struct s2d_hit* hit, + const enum sdis_side_flag side); extern LOCAL_SYM void setup_interface_fragment_3d (struct sdis_interface_fragment* frag, const struct sdis_rwalk_vertex* vertex, - const struct s3d_hit* hit); + const struct s3d_hit* hit, + const enum sdis_side_flag side); static INLINE double -interface_get_temperature +interface_get_convection_coef (const struct sdis_interface* interf, const struct sdis_interface_fragment* frag) { ASSERT(interf && frag); - if(!interf->shader.temperature) return -DBL_MAX; - return interf->shader.temperature(frag, interf->data); + return interf->shader.convection_coef + ? interf->shader.convection_coef(frag, interf->data) : 0; } static INLINE double -interface_get_convection_coef +interface_side_get_temperature + (const struct sdis_interface* interf, + const struct sdis_interface_fragment* frag) +{ + const struct sdis_interface_side_shader* shader; + ASSERT(interf && frag); + switch(frag->side) { + case SDIS_FRONT: shader = &interf->shader.front; break; + case SDIS_BACK: shader = &interf->shader.back; break; + default: FATAL("Unreachable code.\n"); + } + return shader->temperature ? shader->temperature(frag, interf->data) : -1; +} + +static INLINE double +interface_side_get_flux (const struct sdis_interface* interf, const struct sdis_interface_fragment* frag) { + const struct sdis_interface_side_shader* shader; ASSERT(interf && frag); - return interf->shader.convection_coef(frag, interf->data); + switch(frag->side) { + case SDIS_FRONT: shader = &interf->shader.front; break; + case SDIS_BACK: shader = &interf->shader.back; break; + default: FATAL("Unreachable code.\n"); + } + return shader->flux ? shader->flux(frag, interf->data) : SDIS_FLUX_NONE; } static INLINE double -interface_get_emissivity +interface_side_get_emissivity (const struct sdis_interface* interf, const struct sdis_interface_fragment* frag) { + const struct sdis_interface_side_shader* shader; ASSERT(interf && frag); - return interf->shader.emissivity(frag, interf->data); + switch(frag->side) { + case SDIS_FRONT: shader = &interf->shader.front; break; + case SDIS_BACK: shader = &interf->shader.back; break; + default: FATAL("Unreachable code\n"); break; + } + return shader->emissivity ? shader->emissivity(frag, interf->data) : 0; } static INLINE double -interface_get_specular_fraction +interface_side_get_specular_fraction (const struct sdis_interface* interf, const struct sdis_interface_fragment* frag) { + const struct sdis_interface_side_shader* shader; ASSERT(interf && frag); - return interf->shader.specular_fraction(frag, interf->data); + switch(frag->side) { + case SDIS_FRONT: shader = &interf->shader.front; break; + case SDIS_BACK: shader = &interf->shader.back; break; + default: FATAL("Unreachable code\n"); break; + } + return shader->specular_fraction + ? shader->specular_fraction(frag, interf->data) : 0; } #endif /* SDIS_INTERFACE_C_H */ diff --git a/src/sdis_medium_c.h b/src/sdis_medium_c.h @@ -106,9 +106,9 @@ solid_get_volumic_power (const struct sdis_medium* mdm, const struct sdis_rwalk_vertex* vtx) { ASSERT(mdm && mdm->type == SDIS_MEDIUM_SOLID); - return mdm->shader.solid.volumic_power + return mdm->shader.solid.volumic_power ? mdm->shader.solid.volumic_power(vtx, mdm->data) - : 0; + : SDIS_VOLUMIC_POWER_NONE; } static INLINE double diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -273,6 +273,7 @@ sdis_solve_probe_boundary const size_t iprim, /* Identifier of the primitive on which the probe lies */ const double uv[2], /* Parametric coordinates of the probe onto the primitve */ const double time, /* Observation time */ + const enum sdis_side_flag side, /* Side of iprim on which the probe lies */ const double fp_to_meter, /* Scale from floating point units to meters */ const double Tarad, /* In Kelvin */ const double Tref, /* In Kelvin */ @@ -289,7 +290,7 @@ sdis_solve_probe_boundary res_T res = RES_OK; if(!scn || !nrealisations || !uv || time < 0 || fp_to_meter <= 0 - || Tref < 0 || !out_estimator) { + || Tref < 0 || (side != SDIS_FRONT && side != SDIS_BACK) || !out_estimator) { res = RES_BAD_ARG; goto error; } @@ -363,10 +364,10 @@ sdis_solve_probe_boundary if(scene_is_2d(scn)) { res_local = boundary_realisation_2d - (scn, rng, iprim, uv, time, fp_to_meter, Tarad, Tref, &w); + (scn, rng, iprim, uv, time, side, fp_to_meter, Tarad, Tref, &w); } else { res_local = boundary_realisation_3d - (scn, rng, iprim, uv, time, fp_to_meter, Tarad, Tref, &w); + (scn, rng, iprim, uv, time, side, fp_to_meter, Tarad, Tref, &w); } if(res_local != RES_OK) { if(res_local != RES_BAD_OP) { diff --git a/src/sdis_solve_Xd.h b/src/sdis_solve_Xd.h @@ -94,9 +94,10 @@ struct XD(rwalk) { struct sdis_rwalk_vertex vtx; /* Position and time of the Random walk */ const struct sdis_medium* mdm; /* Medium in which the random walk lies */ struct sXd(hit) hit; /* Hit of the random walk */ + enum sdis_side_flag hit_side; }; static const struct XD(rwalk) XD(RWALK_NULL) = { - SDIS_RWALK_VERTEX_NULL__, NULL, SXD_HIT_NULL__ + SDIS_RWALK_VERTEX_NULL__, NULL, SXD_HIT_NULL__, SDIS_SIDE_NULL__ }; struct XD(temperature) { @@ -231,6 +232,7 @@ XD(trace_radiative_path) (scn->sXd(view), pos, dir, range, &rwalk->hit, &rwalk->hit)); #endif if(SXD_HIT_NONE(&rwalk->hit)) { /* Fetch the ambient radiative temperature */ + rwalk->hit_side = SDIS_SIDE_NULL__; if(ctx->Tarad >= 0) { T->value += ctx->Tarad; T->done = 1; @@ -250,16 +252,20 @@ XD(trace_radiative_path) } } + /* Define the hit side */ + rwalk->hit_side = fX(dot)(dir, rwalk->hit.normal) < 0 + ? SDIS_FRONT : SDIS_BACK; + /* 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); + XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit, rwalk->hit_side); /* Fetch the interface emissivity */ - epsilon = interface_get_emissivity(interf, &frag); - if(epsilon > 1 && epsilon >= 0) { + epsilon = interface_side_get_emissivity(interf, &frag); + if(epsilon > 1 || epsilon < 0) { log_err(scn->dev, "%s: invalid overall emissivity `%g' at position `%g %g %g'.\n", FUNC_NAME, epsilon, SPLIT3(rwalk->vtx.P)); @@ -278,7 +284,7 @@ XD(trace_radiative_path) /* 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) { + if(rwalk->hit_side == SDIS_BACK){ chk_mdm = interf->medium_back; fX(minus)(N, N); } else { @@ -288,10 +294,10 @@ XD(trace_radiative_path) 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; + res = RES_BAD_OP; goto error; } - alpha = interface_get_specular_fraction(interf, &frag); + alpha = interface_side_get_specular_fraction(interf, &frag); r = ssp_rng_canonical(rng); if(r < alpha) { /* Sample specular part */ reflect(dir, f3_minus(dir, dir), N); @@ -315,8 +321,6 @@ XD(radiative_temperature) 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}; @@ -327,13 +331,10 @@ XD(radiative_temperature) 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) { + if(rwalk->hit_side == SDIS_BACK) { fX(minus(N, N)); } @@ -442,6 +443,8 @@ XD(solid_solid_boundary_temperature) /* Switch in solid random walk */ T->func = XD(solid_temperature); + rwalk->hit = SXD_HIT_NULL; + rwalk->hit_side = SDIS_SIDE_NULL__; } static void @@ -459,6 +462,7 @@ XD(solid_fluid_boundary_temperature) const struct sdis_medium* mdm_back = NULL; const struct sdis_medium* solid = NULL; const struct sdis_medium* fluid = NULL; + struct sdis_interface_fragment frag_fluid; double hc; double hr; double epsilon; /* Interface emissivity */ @@ -478,12 +482,16 @@ XD(solid_fluid_boundary_temperature) mdm_front = interface_get_medium(interf, SDIS_FRONT); mdm_back = interface_get_medium(interf, SDIS_BACK); ASSERT(mdm_front->type != mdm_back->type); + + frag_fluid = *frag; if(mdm_front->type == SDIS_MEDIUM_SOLID) { solid = mdm_front; fluid = mdm_back; + frag_fluid.side = SDIS_BACK; } else { solid = mdm_back; fluid = mdm_front; + frag_fluid.side = SDIS_FRONT; } /* Fetch the solid properties */ @@ -491,7 +499,7 @@ XD(solid_fluid_boundary_temperature) delta_boundary = solid_get_delta_boundary(solid, &rwalk->vtx); /* Fetch the boundary properties */ - epsilon = interface_get_emissivity(interf, frag); + epsilon = interface_side_get_emissivity(interf, &frag_fluid); hc = interface_get_convection_coef(interf, frag); /* Compute the radiative coefficient */ @@ -505,11 +513,13 @@ XD(solid_fluid_boundary_temperature) r = ssp_rng_canonical(rng); 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; + rwalk->hit_side = rwalk->mdm == mdm_front ? SDIS_FRONT : SDIS_BACK; + } else if(r < fluid_proba + radia_proba) { /* Switch to fluid random walk */ T->func = XD(fluid_temperature); + rwalk->mdm = fluid; + rwalk->hit_side = rwalk->mdm == mdm_front ? SDIS_FRONT : SDIS_BACK; } else { /* Solid random walk */ rwalk->mdm = solid; fX(normalize)(dir, rwalk->hit.normal); @@ -525,6 +535,8 @@ XD(solid_fluid_boundary_temperature) /* Switch in solid random walk */ T->func = XD(solid_temperature); + rwalk->hit = SXD_HIT_NULL; + rwalk->hit_side = SDIS_SIDE_NULL__; } } @@ -546,13 +558,13 @@ XD(boundary_temperature) ASSERT(rwalk->mdm == NULL); ASSERT(!SXD_HIT_NONE(&rwalk->hit)); - XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit); + XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit, rwalk->hit_side); /* Retrieve the current interface */ interf = scene_get_interface(scn, rwalk->hit.prim.prim_id); - /* Check if the boundary condition is known */ - tmp = interface_get_temperature(interf, &frag); + /* Check if the boundary temperature is known */ + tmp = interface_side_get_temperature(interf, &frag); if(tmp >= 0) { T->value += tmp; T->done = 1; @@ -665,14 +677,20 @@ XD(solid_temperature) /* Add the volumic power density to the measured temperature */ power = solid_get_volumic_power(mdm, &rwalk->vtx); - if(power > 0) { + if(power != SDIS_VOLUMIC_POWER_NONE) { const double delta_in_meter = delta * fp_to_meter; tmp = power * delta_in_meter * delta_in_meter / (2.0 * DIM * lambda); T->value += tmp; } /* Define if the random walk hits something along dir0 */ - rwalk->hit = hit0.distance > delta ? SXD_HIT_NULL : hit0; + if(hit0.distance > delta) { + rwalk->hit = SXD_HIT_NULL; + rwalk->hit_side = SDIS_SIDE_NULL__; + } else { + rwalk->hit = hit0; + rwalk->hit_side = fX(dot)(hit0.normal, dir0) < 0 ? SDIS_FRONT : SDIS_BACK; + } /* Update the random walk position */ XD(move_pos)(rwalk->vtx.P, dir0, delta); @@ -683,9 +701,7 @@ XD(solid_temperature) } else { const struct sdis_interface* interf; interf = scene_get_interface(scn, rwalk->hit.prim.prim_id); - mdm = interface_get_medium - (interf, - fX(dot(rwalk->hit.normal, dir0)) < 0 ? SDIS_FRONT : SDIS_BACK); + mdm = interface_get_medium(interf, rwalk->hit_side); } /* Check random walk consistency */ @@ -796,6 +812,7 @@ XD(boundary_realisation) const size_t iprim, const double uv[DIM], const double time, + const enum sdis_side_flag side, const double fp_to_meter, const double Tarad, const double Tref, @@ -815,6 +832,7 @@ XD(boundary_realisation) T.func = XD(boundary_temperature); + rwalk.hit_side = side; rwalk.hit.distance = 0; rwalk.vtx.time = time; rwalk.mdm = NULL; /* The random walk is at an interface between 2 media */ @@ -878,6 +896,7 @@ XD(ray_realisation) dX(set)(rwalk.vtx.P, position); rwalk.vtx.time = time; rwalk.hit = SXD_HIT_NULL; + rwalk.hit_side = SDIS_SIDE_NULL__; rwalk.mdm = medium; ctx.Tarad = Tarad; diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c @@ -229,15 +229,24 @@ create_interface const struct interface* interf, struct sdis_interface** out_interf) { - struct sdis_interface_shader shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader shader = SDIS_INTERFACE_SHADER_NULL; struct sdis_data* data = NULL; CHK(interf != NULL); - shader.temperature = interface_get_temperature; - shader.convection_coef = interface_get_convection_coef; - shader.emissivity = interface_get_emissivity; - shader.specular_fraction = interface_get_specular_fraction; + shader.front.temperature = interface_get_temperature; + shader.back.temperature = interface_get_temperature; + if(sdis_medium_get_type(front) != sdis_medium_get_type(back)) { + shader.convection_coef = interface_get_convection_coef; + } + if(sdis_medium_get_type(front) == SDIS_MEDIUM_FLUID) { + shader.front.emissivity = interface_get_emissivity; + shader.front.specular_fraction = interface_get_specular_fraction; + } + if(sdis_medium_get_type(back) == SDIS_MEDIUM_FLUID) { + shader.back.emissivity = interface_get_emissivity; + shader.back.specular_fraction = interface_get_specular_fraction; + } CHK(sdis_data_create(dev, sizeof(struct interface), ALIGNOF(struct interface), NULL, &data) == RES_OK); diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c @@ -161,42 +161,74 @@ solid_get_delta_boundary * Interface ******************************************************************************/ struct interface { - double temperature; double convection_coef; - double emissivity; - double specular_fraction; + struct { + double temperature; + double emissivity; + double specular_fraction; + } front, back; +}; + +static const struct interface INTERFACE_NULL = { + 0, {-1, -1, -1}, {-1, -1, -1} }; static double interface_get_temperature (const struct sdis_interface_fragment* frag, struct sdis_data* data) { + const struct interface* interf; + double T = -1; CHK(data != NULL && frag != NULL); - return ((const struct interface*)sdis_data_cget(data))->temperature; + interf = sdis_data_cget(data); + switch(frag->side) { + case SDIS_FRONT: T = interf->front.temperature; break; + case SDIS_BACK: T = interf->back.temperature; break; + default: FATAL("Unreachable code.\n"); break; + } + return T; } static double interface_get_convection_coef (const struct sdis_interface_fragment* frag, struct sdis_data* data) { + const struct interface* interf; CHK(data != NULL && frag != NULL); - return ((const struct interface*)sdis_data_cget(data))->convection_coef; + interf = sdis_data_cget(data); + return interf->convection_coef; } static double interface_get_emissivity (const struct sdis_interface_fragment* frag, struct sdis_data* data) { + const struct interface* interf; + double e = -1; CHK(data != NULL && frag != NULL); - return ((const struct interface*)sdis_data_cget(data))->emissivity; + interf = sdis_data_cget(data); + switch(frag->side) { + case SDIS_FRONT: e = interf->front.emissivity; break; + case SDIS_BACK: e = interf->back.emissivity; break; + default: FATAL("Unreachable code.\n"); break; + } + return e; } static double interface_get_specular_fraction (const struct sdis_interface_fragment* frag, struct sdis_data* data) { + const struct interface* interf; + double f = -1; CHK(data != NULL && frag != NULL); - return ((const struct interface*)sdis_data_cget(data))->specular_fraction; + interf = sdis_data_cget(data); + switch(frag->side) { + case SDIS_FRONT: f = interf->front.specular_fraction; break; + case SDIS_BACK: f = interf->back.specular_fraction; break; + default: FATAL("Unreachable code.\n"); break; + } + return f; } /******************************************************************************* @@ -210,16 +242,27 @@ create_interface const struct interface* interf, struct sdis_interface** out_interf) { - struct sdis_interface_shader shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader shader = SDIS_INTERFACE_SHADER_NULL; struct sdis_data* data = NULL; + const enum sdis_medium_type type_f = sdis_medium_get_type(front); + const enum sdis_medium_type type_b = sdis_medium_get_type(back); CHK(interf != NULL); - shader.temperature = interface_get_temperature; - shader.convection_coef = interface_get_convection_coef; - shader.emissivity = interface_get_emissivity; - shader.specular_fraction = interface_get_specular_fraction; + shader.back.temperature = interface_get_temperature; + shader.front.temperature = interface_get_temperature; + if(type_f != type_b) { + shader.convection_coef = interface_get_convection_coef; + } + if(type_f == SDIS_MEDIUM_FLUID) { + shader.front.emissivity = interface_get_emissivity; + shader.front.specular_fraction = interface_get_specular_fraction; + } + if(type_b == SDIS_MEDIUM_FLUID) { + shader.back.emissivity = interface_get_emissivity; + shader.back.specular_fraction = interface_get_specular_fraction; + } CHK(sdis_data_create(dev, sizeof(struct interface), ALIGNOF(struct interface), NULL, &data) == RES_OK); *((struct interface*)sdis_data_get(data)) = *interf; @@ -228,7 +271,6 @@ create_interface CHK(sdis_data_ref_put(data) == RES_OK); } - /******************************************************************************* * Test ******************************************************************************/ @@ -293,38 +335,35 @@ main(int argc, char** argv) CHK(sdis_data_ref_put(data) == RES_OK); /* Create the interface that forces to keep in conduction */ - interf.temperature = UNKNOWN_TEMPERATURE; - interf.convection_coef = -1; - interf.emissivity = -1; - interf.specular_fraction = -1; + interf = INTERFACE_NULL; create_interface(dev, solid, solid2, &interf, interfaces+0); /* Create the interface that emits radiative heat from the solid */ - interf.temperature = UNKNOWN_TEMPERATURE; - interf.convection_coef = 0; - interf.emissivity = emissivity; - interf.specular_fraction = -1; + interf = INTERFACE_NULL; + interf.back.temperature = UNKNOWN_TEMPERATURE; + interf.back.emissivity = emissivity; + interf.back.specular_fraction = -1; /* Should not be fetched */ create_interface(dev, solid, fluid, &interf, interfaces+1); /* Create the interface that forces the radiative heat to bounce */ - interf.temperature = UNKNOWN_TEMPERATURE; - interf.convection_coef = 0; - interf.emissivity = 0; - interf.specular_fraction = 1; + interf = INTERFACE_NULL; + interf.front.temperature = UNKNOWN_TEMPERATURE; + interf.front.emissivity = 0; + interf.front.specular_fraction = 1; create_interface(dev, fluid, solid2, &interf, interfaces+2); /* Create the interface with a limit condition of T0 Kelvin */ - interf.temperature = T0; - interf.convection_coef = 0; - interf.emissivity = 1; - interf.specular_fraction = 1; + interf = INTERFACE_NULL; + interf.front.temperature = T0; + interf.front.emissivity = 1; + interf.front.specular_fraction = 1; create_interface(dev, fluid, solid2, &interf, interfaces+3); /* Create the interface with a limit condition of T1 Kelvin */ - interf.temperature = T1; - interf.convection_coef = 0; - interf.emissivity = 1; - interf.specular_fraction = 1; + interf = INTERFACE_NULL; + interf.front.temperature = T1; + interf.front.emissivity = 1; + interf.front.specular_fraction = 1; create_interface(dev, fluid, solid2, &interf, interfaces+4); /* Setup the per primitive interface of the solid medium */ diff --git a/src/test_sdis_interface.c b/src/test_sdis_interface.c @@ -36,6 +36,9 @@ main(int argc, char** argv) CHK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid) == RES_OK); CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK); + + shader = SDIS_INTERFACE_SHADER_NULL; + #define CREATE sdis_interface_create CHK(CREATE(NULL, NULL, NULL, NULL, NULL, NULL) == RES_BAD_ARG); CHK(CREATE(dev, NULL, NULL, NULL, NULL, NULL) == RES_BAD_ARG); @@ -78,24 +81,26 @@ main(int argc, char** argv) CHK(CREATE(dev, solid, solid, &shader, NULL, &interf) == RES_OK); CHK(sdis_interface_ref_put(interf) == RES_OK); - shader.convection_coef = NULL; - shader.specular_fraction = NULL; - shader.emissivity = NULL; + shader = SDIS_INTERFACE_SHADER_NULL; CHK(CREATE(dev, solid, solid, &shader, NULL, &interf) == RES_OK); CHK(sdis_interface_ref_put(interf) == RES_OK); - shader.temperature = NULL; + shader.front.temperature = dummy_interface_getter; CHK(CREATE(dev, solid, solid, &shader, NULL, &interf) == RES_OK); CHK(sdis_interface_ref_put(interf) == RES_OK); - CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); - shader.convection_coef = DUMMY_INTERFACE_SHADER.convection_coef; - CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); - shader.emissivity = DUMMY_INTERFACE_SHADER.emissivity; - CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); - shader.specular_fraction = DUMMY_INTERFACE_SHADER.specular_fraction; + shader.back.emissivity = dummy_interface_getter; CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_OK); CHK(sdis_interface_ref_put(interf) == RES_OK); + shader.back.specular_fraction = dummy_interface_getter; + CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_OK); + CHK(sdis_interface_ref_put(interf) == RES_OK); + shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; + shader.front.emissivity = dummy_interface_getter; + CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); + shader.front.emissivity = NULL; + shader.front.specular_fraction = dummy_interface_getter; + CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); #undef CREATE CHK(sdis_device_ref_put(dev) == RES_OK); diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -261,9 +261,11 @@ main(int argc, char** argv) struct sdis_interface* interf = NULL; struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER; struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER; - struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL; (void)argc, (void)argv; + interface_shader.convection_coef = DUMMY_INTERFACE_SHADER.convection_coef; + CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); CHK(sdis_device_create(NULL, &allocator, 1, 0, &dev) == RES_OK); diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c @@ -361,7 +361,7 @@ create_interface { struct sdis_data* data = NULL; struct interf* interface_param = NULL; - struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL; CHK(mdm_front != NULL); CHK(mdm_back != NULL); @@ -376,10 +376,16 @@ create_interface /* Setup the interface shader */ interface_shader.convection_coef = interface_get_convection_coef; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = interface_get_emissivity; - interface_shader.specular_fraction = interface_get_specular_fraction; - + interface_shader.front.temperature = interface_get_temperature; + interface_shader.back.temperature = interface_get_temperature; + if(sdis_medium_get_type(mdm_front) == SDIS_MEDIUM_FLUID) { + interface_shader.front.emissivity = interface_get_emissivity; + interface_shader.front.specular_fraction = interface_get_specular_fraction; + } + if(sdis_medium_get_type(mdm_back) == SDIS_MEDIUM_FLUID) { + interface_shader.back.emissivity = interface_get_emissivity; + interface_shader.back.specular_fraction = interface_get_specular_fraction; + } /* Create the interface */ CHK(sdis_interface_create (dev, mdm_front, mdm_back, &interface_shader, data, interf) == RES_OK); diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c @@ -243,9 +243,10 @@ main(int argc, char** argv) interface_param->epsilon = 0; interface_param->specular_fraction = 0; interface_shader.convection_coef = interface_get_convection_coef; - interface_shader.temperature = NULL; - interface_shader.emissivity = interface_get_emissivity; - interface_shader.specular_fraction = interface_get_specular_fraction; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back.temperature = NULL; + interface_shader.back.emissivity = interface_get_emissivity; + interface_shader.back.specular_fraction = interface_get_specular_fraction; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &interf) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); diff --git a/src/test_sdis_solve_probe2.c b/src/test_sdis_solve_probe2.c @@ -197,9 +197,8 @@ main(int argc, char** argv) /* Create the fluid/solid interface with no limit conidition */ interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = NULL; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK); @@ -208,10 +207,7 @@ 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_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front.temperature = interface_get_temperature; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T300) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); @@ -221,10 +217,6 @@ 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_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T350) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); diff --git a/src/test_sdis_solve_probe2_2d.c b/src/test_sdis_solve_probe2_2d.c @@ -194,21 +194,21 @@ main(int argc, char** argv) /* Create the fluid/solid interface with no limit conidition */ interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = NULL; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK); + interface_shader.convection_coef = null_interface_value; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.front.temperature = interface_get_temperature; + /* Create the fluid/solid interface with a fixed temperature of 300K */ CHK(sdis_data_create(dev, sizeof(struct interf), ALIGNOF(struct interf), NULL, &data) == RES_OK); interface_param = sdis_data_get(data); interface_param->temperature = 300; - interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T300) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); @@ -218,10 +218,6 @@ 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_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T350) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); diff --git a/src/test_sdis_solve_probe3.c b/src/test_sdis_solve_probe3.c @@ -224,9 +224,8 @@ main(int argc, char** argv) /* Create the fluid/solid interface with no limit conidition */ interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = NULL; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK); @@ -235,10 +234,7 @@ 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_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front.temperature = interface_get_temperature; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T300) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); @@ -248,19 +244,12 @@ 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_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T350) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); /* Create the solid/solid interface */ - interface_shader.convection_coef = NULL; - interface_shader.temperature = NULL; - interface_shader.specular_fraction = NULL; - interface_shader.emissivity = NULL; + interface_shader = SDIS_INTERFACE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, solid, &interface_shader, NULL, &solid_solid) == RES_OK); diff --git a/src/test_sdis_solve_probe3_2d.c b/src/test_sdis_solve_probe3_2d.c @@ -218,10 +218,7 @@ 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_interface_value; - interface_shader.temperature = NULL; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader = SDIS_INTERFACE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, NULL, &Tnone) == RES_OK); @@ -231,9 +228,8 @@ main(int argc, char** argv) interface_param = sdis_data_get(data); interface_param->temperature = 300; interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front.temperature = interface_get_temperature; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T300) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); @@ -244,18 +240,14 @@ main(int argc, char** argv) interface_param = sdis_data_get(data); interface_param->temperature = 350; interface_shader.convection_coef = null_interface_value; - interface_shader.temperature = interface_get_temperature; - interface_shader.emissivity = null_interface_value; - interface_shader.specular_fraction = null_interface_value; + interface_shader.front.temperature = interface_get_temperature; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &T350) == RES_OK); CHK(sdis_data_ref_put(data) == RES_OK); /* Create the solid/solid interface */ - interface_shader.convection_coef = NULL; - interface_shader.temperature = NULL; - interface_shader.specular_fraction = NULL; - interface_shader.emissivity = NULL; + interface_shader = SDIS_INTERFACE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, solid, &interface_shader, NULL, &solid_solid) == RES_OK); diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c @@ -131,14 +131,6 @@ 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 ******************************************************************************/ @@ -184,9 +176,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.emissivity = interface_null_reflectivity; - interface_shader.specular_fraction = interface_null_reflectivity; + interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL; + interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; CHK(sdis_interface_create (dev, solid, fluid, &interface_shader, NULL, &interf) == RES_OK); diff --git a/src/test_sdis_solve_probe_boundary.c b/src/test_sdis_solve_probe_boundary.c @@ -204,22 +204,6 @@ interface_get_convection_coef return interf->hc; } -static double -interface_get_emissivity - (const struct sdis_interface_fragment* frag, struct sdis_data* data) -{ - CHK(frag && data); - return 0; -} - -static double -interface_get_specular_fraction - (const struct sdis_interface_fragment* frag, struct sdis_data* data) -{ - CHK(frag && data); - return 0; -} - /******************************************************************************* * Test ******************************************************************************/ @@ -270,10 +254,11 @@ main(int argc, char** argv) CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK); /* Setup the interface shader */ - interf_shader.temperature = interface_get_temperature; interf_shader.convection_coef = interface_get_convection_coef; - interf_shader.emissivity = interface_get_emissivity; - interf_shader.specular_fraction = interface_get_specular_fraction; + interf_shader.front.temperature = interface_get_temperature; + interf_shader.front.emissivity = NULL; + interf_shader.front.specular_fraction = NULL; + interf_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL; /* Create the adiabatic interface */ CHK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data) == RES_OK); @@ -340,13 +325,15 @@ main(int argc, char** argv) iprim = 6; #define SOLVE sdis_solve_probe_boundary - CHK(SOLVE(NULL, N, iprim, uv, INF, 1.0, 0, 0, &estimator) == RES_BAD_ARG); - CHK(SOLVE(box_scn, 0, iprim, uv, INF, 1.0, 0, 0, &estimator) == RES_BAD_ARG); - CHK(SOLVE(box_scn, N, 12, uv, INF, 1.0, 0, 0, &estimator) == RES_BAD_ARG); - CHK(SOLVE(box_scn, N, iprim, NULL, INF, 1.0, 0, 0, &estimator) == RES_BAD_ARG); - CHK(SOLVE(box_scn, N, iprim, uv, -1, 1.0, 0, 0, &estimator) == RES_BAD_ARG); - CHK(SOLVE(box_scn, N, iprim, uv, INF, 1.0, 0, 0, NULL) == RES_BAD_ARG); - CHK(SOLVE(box_scn, N, iprim, uv, INF, 1.0, 0, 0, &estimator) == RES_OK); + #define F SDIS_FRONT + CHK(SOLVE(NULL, N, iprim, uv, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, 0, iprim, uv, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, 12, uv, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, iprim, NULL, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, iprim, uv, -1, F, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, iprim, uv, INF, -1, 1.0, 0, 0, &estimator) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, iprim, uv, INF, F, 1.0, 0, 0, NULL) == RES_BAD_ARG); + CHK(SOLVE(box_scn, N, iprim, uv, INF, F, 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); @@ -366,7 +353,7 @@ main(int argc, char** argv) uv[0] = 0.5; iprim = 3; - CHK(SOLVE(square_scn, N, iprim, uv, INF, 1.0, 0, 0, &estimator) == RES_OK); + CHK(SOLVE(square_scn, N, iprim, uv, INF, F, 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); CHK(nfails + nreals == N); diff --git a/src/test_sdis_utils.h b/src/test_sdis_utils.h @@ -114,11 +114,17 @@ static const struct sdis_fluid_shader DUMMY_FLUID_SHADER = { dummy_medium_getter }; + +#define DUMMY_INTERFACE_SIDE_SHADER__ { \ + dummy_interface_getter, \ + dummy_interface_getter, \ + dummy_interface_getter, \ + dummy_interface_getter \ +} static const struct sdis_interface_shader DUMMY_INTERFACE_SHADER = { dummy_interface_getter, - dummy_interface_getter, - dummy_interface_getter, - dummy_interface_getter + DUMMY_INTERFACE_SIDE_SHADER__, + DUMMY_INTERFACE_SIDE_SHADER__ }; /******************************************************************************* diff --git a/src/test_sdis_volumic_power.c b/src/test_sdis_volumic_power.c @@ -210,22 +210,6 @@ interface_get_convection_coef return 0; } -static double -interface_get_emissivity - (const struct sdis_interface_fragment* frag, struct sdis_data* data) -{ - CHK(frag && data); - return 0; -} - -static double -interface_get_specular_fraction - (const struct sdis_interface_fragment* frag, struct sdis_data* data) -{ - CHK(frag && data); - return 0; -} - /******************************************************************************* * Test ******************************************************************************/ @@ -245,7 +229,7 @@ main(int argc, char** argv) struct sdis_estimator* estimator = NULL; struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER; struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER; - struct sdis_interface_shader interf_shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL; struct sdis_interface* box_interfaces[12 /*#triangles*/]; struct sdis_interface* square_interfaces[4/*#segments*/]; struct interf* interf_props = NULL; @@ -275,10 +259,8 @@ main(int argc, char** argv) CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK); /* Setup the interface shader */ - interf_shader.temperature = interface_get_temperature; interf_shader.convection_coef = interface_get_convection_coef; - interf_shader.emissivity = interface_get_emissivity; - interf_shader.specular_fraction = interface_get_specular_fraction; + interf_shader.front.temperature = interface_get_temperature; /* Create the adiabatic interface */ CHK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data) == RES_OK);