stardis-solver

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

commit 86fa69a78be287860f040aafd30997d62657bbf1
parent 7a67a6dd6b7957a639ba3f4c5a69f70cc200c826
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 18 Apr 2018 13:58:36 +0200

Handle the flux property of the interface

Diffstat:
Msrc/sdis.h | 2+-
Msrc/sdis_solve_Xd.h | 38++++++++++++++++++++++++++++++++++++++
Msrc/test_sdis_solve_probe_boundary.c | 2+-
3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -490,7 +490,7 @@ sdis_scene_get_boundary_position * , , * b E1 * E0 / \ ,P - * / \,*^ + * / \,*' * / \ * ....a-------c...... * ' ' diff --git a/src/sdis_solve_Xd.h b/src/sdis_solve_Xd.h @@ -553,6 +553,7 @@ XD(boundary_temperature) const struct sdis_interface* interf = NULL; const struct sdis_medium* mdm_front = NULL; const struct sdis_medium* mdm_back = NULL; + const struct sdis_medium* mdm = NULL; double tmp; ASSERT(scn && fp_to_meter > 0 && ctx && rwalk && rng && T); ASSERT(rwalk->mdm == NULL); @@ -571,6 +572,43 @@ XD(boundary_temperature) return RES_OK; } + /* Check if the boundary flux is known. Note that actually, only solid media + * can have a flux as limit condition */ + mdm = interface_get_medium(interf, frag.side); + if(sdis_medium_get_type(mdm) == SDIS_MEDIUM_SOLID) { + const double phi = interface_side_get_flux(interf, &frag); + + if(phi != SDIS_FLUX_NONE) { + double lambda = solid_get_thermal_conductivity(mdm, &rwalk->vtx); + double delta_b = solid_get_delta_boundary(mdm, &rwalk->vtx); + double delta_b_in_meter = delta_b * fp_to_meter; + float pos[3]; + float range[2]; + float dir[3]; + + /* Update the temperature */ + T->value += phi * delta_b_in_meter / lambda; + + /* Ensuure that the normal points toward the solid */ + fX(normalize)(dir, rwalk->hit.normal); + if(frag.side == SDIS_BACK) fX(minus)(dir, dir); + + /* "Reinject" the random walk into the solid */ + fX_set_dX(pos, rwalk->vtx.P); + range[0] = 0, range[1] = (float)delta_b*RAY_RANGE_MAX_SCALE; + SXD(scene_view_trace_ray + (scn->sXd(view), pos, dir, range, &rwalk->hit, &rwalk->hit)); + if(!SXD_HIT_NONE(&rwalk->hit)) delta_b = rwalk->hit.distance * 0.5; + XD(move_pos)(rwalk->vtx.P, dir, (float)delta_b); + + /* Switch in solid random walk */ + T->func = XD(solid_temperature); + rwalk->hit = SXD_HIT_NULL; + rwalk->hit_side = SDIS_SIDE_NULL__; + rwalk->mdm = mdm; + return RES_OK; + } + } mdm_front = interface_get_medium(interf, SDIS_FRONT); mdm_back = interface_get_medium(interf, SDIS_BACK); diff --git a/src/test_sdis_solve_probe_boundary.c b/src/test_sdis_solve_probe_boundary.c @@ -224,7 +224,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;