commit cef3e6ab6d7d6932201ded498d24b09b01d344c2 parent 56a82a822457a819360922255c8b55ac543eee1d Author: Vincent Forest <vincent.forest@meso-star.com> Date: Wed, 27 Oct 2021 10:49:23 +0200 Use picard1 to linearise the radiative temperature This commit replaces the solid/fluid boundary function with the picard1 solid/fluid function. Therefore, the sdis_scene_<get|set>_reference_temperature functions are removed because with picard1 the reference temperatures must be set at the interfaces. In addition, we had to rewrite the tests to manage the new way radiative temperatures are linearized: beyond the reference temperatures, a maximum temperature must be defined for the entire system. Currently, all tests pass, with the exception of the unstationary_atm test. Diffstat:
20 files changed, 184 insertions(+), 302 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -89,7 +89,6 @@ set(SDIS_FILES_INC sdis_heat_path_boundary_c.h sdis_heat_path_boundary_Xd.h sdis_heat_path_boundary_Xd_fixed_flux.h - sdis_heat_path_boundary_Xd_solid_fluid.h sdis_heat_path_boundary_Xd_solid_fluid_picard1.h sdis_heat_path_boundary_Xd_solid_solid.h sdis_heat_path_conductive_Xd.h diff --git a/src/sdis.h b/src/sdis.h @@ -373,8 +373,7 @@ struct sdis_scene_create_args { size_t nvertices; /* #vertices */ double fp_to_meter; /* Scale factor used to convert 1.0 in 1 meter */ double trad; /* Ambiant radiative temperature */ - double tref; /* Temperature used to linearize the radiative temperature */ - double tmax; /* Maxium temperature used to linearize the radiative temp */ + double tmax; /* Max temperature used to linearize the radiative temperature */ }; #define SDIS_SCENE_CREATE_ARGS_DEFAULT__ { \ @@ -386,7 +385,6 @@ struct sdis_scene_create_args { 0, /* #vertices */ \ 1.0, /* #Floating point to meter scale factor */ \ -1.0, /* Ambient radiative temperature */ \ - -1.0, /* Reference temperature */ \ -1.0, /* Maximum temperature */ \ } static const struct sdis_scene_create_args SDIS_SCENE_CREATE_ARGS_DEFAULT = @@ -840,19 +838,6 @@ sdis_scene_set_ambient_radiative_temperature (struct sdis_scene* scn, const double trad); -/* Get scene's reference temperature */ -SDIS_API res_T -sdis_scene_get_reference_temperature - (const struct sdis_scene* scn, - double* tref); - -/* Set scene's reference temperature. If set to 0, there is no radiative - * transfert in the whole system */ -SDIS_API res_T -sdis_scene_set_reference_temperature - (struct sdis_scene* scn, - const double tref); - /* Get scene's maximum temperature */ SDIS_API res_T sdis_scene_get_maximum_temperature diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -26,7 +26,6 @@ struct rwalk_context { struct green_path_handle* green_path; struct sdis_heat_path* heat_path; double Tarad; /* Ambient radiative temperature */ - double Tref3; /* Reference temperature ^ 3 */ double That; /* Upper bound temperature */ double That2; /* That^2 */ @@ -36,7 +35,6 @@ struct rwalk_context { NULL, /* Green path */ \ NULL, /* Heat path */ \ 0, /* Ambient radiative temperature */ \ - 0, /* (Reference temperature)^3 */ \ 0, /* Temperature upper bound */ \ 0, /* (Temperature upper bound)^2 */ \ 0 /* (Temperature upper bound)^3 */ \ diff --git a/src/sdis_heat_path_boundary.c b/src/sdis_heat_path_boundary.c @@ -28,10 +28,6 @@ #define SDIS_XD_DIMENSION 3 #include "sdis_heat_path_boundary_Xd_fixed_flux.h" #define SDIS_XD_DIMENSION 2 -#include "sdis_heat_path_boundary_Xd_solid_fluid.h" -#define SDIS_XD_DIMENSION 3 -#include "sdis_heat_path_boundary_Xd_solid_fluid.h" -#define SDIS_XD_DIMENSION 2 #include "sdis_heat_path_boundary_Xd_solid_fluid_picard1.h" #define SDIS_XD_DIMENSION 3 #include "sdis_heat_path_boundary_Xd_solid_fluid_picard1.h" diff --git a/src/sdis_heat_path_boundary_Xd.h b/src/sdis_heat_path_boundary_Xd.h @@ -90,7 +90,7 @@ XD(boundary_path) if(mdm_front->type == mdm_back->type) { res = XD(solid_solid_boundary_path)(scn, ctx, &frag, rwalk, rng, T); } else { - res = XD(solid_fluid_boundary_path)(scn, ctx, &frag, rwalk, rng, T); + res = XD(solid_fluid_boundary_picard1_path)(scn, ctx, &frag, rwalk, rng, T); } if(res != RES_OK) goto error; diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid.h b/src/sdis_heat_path_boundary_Xd_solid_fluid.h @@ -1,160 +0,0 @@ -/* Copyright (C) 2016-2021 |Meso|Star> (contact@meso-star.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include "sdis_green.h" -#include "sdis_heat_path_boundary_c.h" -#include "sdis_interface_c.h" -#include "sdis_medium_c.h" -#include "sdis_misc.h" -#include "sdis_scene_c.h" - -#include <star/ssp.h> - -#include "sdis_Xd_begin.h" - -/******************************************************************************* - * Boundary path between a solid and a fluid - ******************************************************************************/ -res_T -XD(solid_fluid_boundary_path) - (struct sdis_scene* scn, - const struct rwalk_context* ctx, - const struct sdis_interface_fragment* frag, - struct XD(rwalk)* rwalk, - struct ssp_rng* rng, - struct XD(temperature)* T) -{ - /* Input/output arguments of the function used to sample a reinjection */ - struct XD(sample_reinjection_step_args) samp_reinject_step_args = - XD(SAMPLE_REINJECTION_STEP_ARGS_NULL); - struct XD(reinjection_step) reinject_step = - XD(REINJECTION_STEP_NULL); - - /* Fragment on the fluid side of the boundary */ - struct sdis_interface_fragment frag_fluid; - - /* Data attached to the boundary */ - struct sdis_interface* interf = NULL; - struct sdis_medium* solid = NULL; - struct sdis_medium* fluid = NULL; - - double h_cond; /* Conductive coefficient */ - double h_conv; /* Convective coefficient */ - double h_radi; /* Radiative coefficient */ - double h; /* Sum of h_<conv|cond|radi> */ - double p_conv; /* Convective proba */ - double p_radi; /* Radiative proba */ - - 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_side solid_side = SDIS_SIDE_NULL__; - enum sdis_side fluid_side = SDIS_SIDE_NULL__; - res_T res = RES_OK; - - ASSERT(scn && rwalk && rng && T && ctx); - ASSERT(XD(check_rwalk_fragment_consistency)(rwalk, frag)); - - /* 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); - fluid = interface_get_medium(interf, SDIS_BACK); - solid_side = SDIS_FRONT; - fluid_side = SDIS_BACK; - if(solid->type != SDIS_SOLID) { - SWAP(struct sdis_medium*, solid, fluid); - SWAP(enum sdis_side, solid_side, fluid_side); - ASSERT(fluid->type == SDIS_FLUID); - } - - /* Setup a fragment for the fluid side */ - frag_fluid = *frag; - frag_fluid.side = fluid_side; - - /* Fetch the solid properties */ - lambda = solid_get_thermal_conductivity(solid, &rwalk->vtx); - delta = solid_get_delta(solid, &rwalk->vtx); - - /* Fetch the interface properties on the fluid side */ - epsilon = interface_side_get_emissivity(interf, &frag_fluid); - - /* Note that the reinjection distance is *FIXED*. It MUST ensure that the - * orthogonal distance from the boundary to the reinjection point is at most - * equal to delta. */ - delta_boundary = sqrt(DIM) * delta; - - /* Sample a reinjection step */ - samp_reinject_step_args.rng = rng; - samp_reinject_step_args.solid = solid; - samp_reinject_step_args.rwalk = rwalk; - samp_reinject_step_args.distance = delta_boundary; - samp_reinject_step_args.side = solid_side; - res = XD(sample_reinjection_step_solid_fluid) - (scn, &samp_reinject_step_args, &reinject_step); - if(res != RES_OK) goto error; - - /* Define the orthogonal dst from the boundary to the reinjection position */ - delta = reinject_step.distance / sqrt(DIM); - - /* Compute the convective, conductive and radiative coefficients */ - h_conv = interface_get_convection_coef(interf, frag); - h_cond = lambda / (delta * scn->fp_to_meter); - h_radi = 4.0 * BOLTZMANN_CONSTANT * ctx->Tref3 * epsilon; - h = h_conv + h_cond + h_radi; - - /* Compute the probas */ - p_conv = h_conv / h; - p_radi = h_radi / h; - - r = ssp_rng_canonical(rng); - - /* Switch in radiative path */ - if(r < p_radi) { - T->func = XD(radiative_path); - rwalk->mdm = fluid; - rwalk->hit_side = fluid_side; - - /* Switch to convective path */ - } else if(r < p_radi + p_conv) { - T->func = XD(convective_path); - rwalk->mdm = fluid; - rwalk->hit_side = fluid_side; - - /* Switch in conductive path */ - } else { - struct XD(solid_reinjection_args) solid_reinject_args = - XD(SOLID_REINJECTION_ARGS_NULL); - - /* Perform the reinjection into the solid */ - solid_reinject_args.reinjection = &reinject_step; - solid_reinject_args.rwalk_ctx = ctx; - solid_reinject_args.rwalk = rwalk; - solid_reinject_args.rng = rng; - solid_reinject_args.T = T; - solid_reinject_args.fp_to_meter = scn->fp_to_meter; - res = XD(solid_reinjection)(solid, &solid_reinject_args); - if(res != RES_OK) goto error; - } - -exit: - return res; -error: - goto exit; -} - -#include "sdis_Xd_end.h" diff --git a/src/sdis_realisation.c b/src/sdis_realisation.c @@ -51,11 +51,7 @@ ray_realisation_3d ctx.That = scn->maximum_temperature; ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; - ctx.Tref3 = - scn->reference_temperature - * scn->reference_temperature - * scn->reference_temperature; - + f3_set_d3(dir, direction); /* Register the starting position against the heat path */ diff --git a/src/sdis_realisation_Xd.h b/src/sdis_realisation_Xd.h @@ -185,10 +185,6 @@ XD(probe_realisation) ctx.That = scn->maximum_temperature; ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; - ctx.Tref3 = - scn->reference_temperature - * scn->reference_temperature - * scn->reference_temperature; res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; @@ -266,10 +262,6 @@ XD(boundary_realisation) ctx.That = scn->maximum_temperature; ctx.That2 = ctx.That * ctx.That; ctx.That3 = ctx.That * ctx.That2; - ctx.Tref3 = - scn->reference_temperature - * scn->reference_temperature - * scn->reference_temperature; res = XD(compute_temperature)(scn, &ctx, &rwalk, rng, &T); if(res != RES_OK) goto error; @@ -311,10 +303,6 @@ XD(boundary_flux_realisation) const double That = scn->maximum_temperature; const double That2 = That * That; const double That3 = That * That2; - const double Tref3 = - scn->reference_temperature - * scn->reference_temperature - * scn->reference_temperature; const enum sdis_side fluid_side = (solid_side == SDIS_FRONT) ? SDIS_BACK : SDIS_FRONT; res_T res = RES_OK; @@ -350,7 +338,6 @@ XD(boundary_flux_realisation) rwalk.hit.prim = prim; \ SET_PARAM(rwalk.hit, st); \ ctx.Tarad = scn->ambient_radiative_temperature; \ - ctx.Tref3 = Tref3; \ ctx.That = That; \ ctx.That2 = That2; \ ctx.That3 = That3; \ diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -219,26 +219,6 @@ sdis_scene_set_ambient_radiative_temperature } res_T -sdis_scene_get_reference_temperature - (const struct sdis_scene* scn, - double* tref) -{ - if(!scn || !tref) return RES_BAD_ARG; - *tref = scn->reference_temperature; - return RES_OK; -} - -res_T -sdis_scene_set_reference_temperature - (struct sdis_scene* scn, - const double tref) -{ - if(!scn || tref < 0) return RES_BAD_ARG; - scn->reference_temperature = tref; - return RES_OK; -} - -res_T sdis_scene_get_maximum_temperature(const struct sdis_scene* scn, double* tmax) { if(!scn || !tmax) return RES_BAD_ARG; @@ -488,7 +468,7 @@ scene_compute_hash(const struct sdis_scene* scn, hash256_T hash) } else { S3D(scene_view_primitives_count(scn->s3d_view, &nprims)); } - WRITE(&scn->reference_temperature, 1); + WRITE(&scn->maximum_temperature, 1); WRITE(&scn->fp_to_meter, 1); FOR_EACH(iprim, 0, nprims) { struct sdis_interface* interf = NULL; diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -913,7 +913,6 @@ XD(scene_create) scn->dev = dev; scn->fp_to_meter = args->fp_to_meter; scn->ambient_radiative_temperature = args->trad; - scn->reference_temperature = args->tref; scn->maximum_temperature = args->tmax; scn->outer_enclosure_id = UINT_MAX; darray_interf_init(dev->allocator, &scn->interfaces); diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h @@ -210,7 +210,6 @@ struct sdis_scene { double fp_to_meter; double ambient_radiative_temperature; /* In Kelvin */ - double reference_temperature; /* In Kelvin */ double maximum_temperature; /* In Kelvin */ ref_T ref; diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -573,8 +573,7 @@ XD(solve_boundary_flux) const struct sdis_medium *fmd, *bmd; enum sdis_side solid_side, fluid_side; struct bound_flux_result result = BOUND_FLUX_RESULT_NULL__; - const double Tref = scn->reference_temperature; - double epsilon, hc, hr, imposed_flux, imposed_temp; + double epsilon, hc, hr, imposed_flux, imposed_temp, Tref; size_t iprim; double uv[DIM - 1]; float st[DIM - 1]; @@ -638,6 +637,7 @@ XD(solve_boundary_flux) /* Fetch interface parameters */ epsilon = interface_side_get_emissivity(interf, &frag); + Tref = interface_side_get_reference_temperature(interf, &frag); hc = interface_get_convection_coef(interf, &frag); hr = 4.0 * BOLTZMANN_CONSTANT * Tref * Tref * Tref * epsilon; frag.side = solid_side; diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -480,7 +480,7 @@ XD(solve_probe_boundary_flux) double time, epsilon, hc, hr, imposed_flux, imposed_temp; int flux_mask = 0; struct bound_flux_result result = BOUND_FLUX_RESULT_NULL__; - const double Tref = scn->reference_temperature; + double Tref = -1; size_t n; int pcent; res_T res_simul = RES_OK; @@ -496,6 +496,7 @@ XD(solve_probe_boundary_flux) frag.time = time; frag.side = fluid_side; epsilon = interface_side_get_emissivity(interf, &frag); + Tref = interface_side_get_reference_temperature(interf, &frag); hc = interface_get_convection_coef(interf, &frag); hr = 4.0 * BOLTZMANN_CONSTANT * Tref * Tref * Tref * epsilon; frag.side = solid_side; diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c @@ -193,6 +193,7 @@ struct interfac { double convection_coef; double emissivity; double specular_fraction; + double Tref; }; static double @@ -227,6 +228,14 @@ interface_get_specular_fraction return ((const struct interfac*)sdis_data_cget(data))->specular_fraction; } +static double +interface_get_Tref + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + CHK(data != NULL && frag != NULL); + return ((const struct interfac*)sdis_data_cget(data))->Tref; +} + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -251,10 +260,12 @@ create_interface if(sdis_medium_get_type(front) == SDIS_FLUID) { shader.front.emissivity = interface_get_emissivity; shader.front.specular_fraction = interface_get_specular_fraction; + shader.front.reference_temperature = interface_get_Tref; } if(sdis_medium_get_type(back) == SDIS_FLUID) { shader.back.emissivity = interface_get_emissivity; shader.back.specular_fraction = interface_get_specular_fraction; + shader.back.reference_temperature = interface_get_Tref; } shader.convection_coef_upper_bound = MMAX(0, interf->convection_coef); @@ -337,6 +348,7 @@ main(int argc, char** argv) interf.convection_coef = -1; interf.emissivity = -1; interf.specular_fraction = -1; + interf.Tref = Tref; create_interface(dev, solid, solid2, &interf, interfaces+0); /* Create the interface that emits radiative heat from the solid */ @@ -344,6 +356,7 @@ main(int argc, char** argv) interf.convection_coef = 0; interf.emissivity = emissivity; interf.specular_fraction = 1; + interf.Tref = Tref; create_interface(dev, solid, fluid, &interf, interfaces+1); /* Create the interface that forces the radiative heat to bounce */ @@ -351,6 +364,7 @@ main(int argc, char** argv) interf.convection_coef = 0; interf.emissivity = 0; interf.specular_fraction = 1; + interf.Tref = Tref; create_interface(dev, fluid, solid2, &interf, interfaces+2); /* Create the interface with a limit condition of T0 Kelvin */ @@ -358,6 +372,7 @@ main(int argc, char** argv) interf.convection_coef = 0; interf.emissivity = 1; interf.specular_fraction = 1; + interf.Tref = -1; create_interface(dev, fluid, solid2, &interf, interfaces+3); /* Create the interface with a limit condition of T1 Kelvin */ @@ -365,6 +380,7 @@ main(int argc, char** argv) interf.convection_coef = 0; interf.emissivity = 1; interf.specular_fraction = 1; + interf.Tref = -1; create_interface(dev, fluid, solid2, &interf, interfaces+4); /* Setup the per primitive interface of the solid medium */ @@ -398,7 +414,7 @@ main(int argc, char** argv) scn_args.get_position = get_position; scn_args.nprimitives = ntriangles; scn_args.nvertices = nvertices; - scn_args.tref = Tref; + scn_args.tmax = MMAX(T0, T1); scn_args.context = &geom; OK(sdis_scene_create(dev, &scn_args, &scn)); @@ -476,6 +492,7 @@ main(int argc, char** argv) /* Check same green used at a different temperature */ p_intface->temperature = T1b = T1 + ((double)isimul + 1) * 10; + OK(sdis_scene_set_maximum_temperature(scn, MMAX(T0, T1b))); OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_estimator_get_realisation_count(estimator, &nreals)); diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c @@ -158,11 +158,12 @@ struct interfac { double temperature; double emissivity; double specular_fraction; + double reference_temperature; } front, back; }; static const struct interfac INTERFACE_NULL = { - 0, {-1, -1, -1}, {-1, -1, -1} + 0, {-1, -1, -1, -1}, {-1, -1, -1, -1} }; static double @@ -223,6 +224,22 @@ interface_get_specular_fraction return f; } +static double +interface_get_reference_temperature + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + const struct interfac* interf; + double T = -1; + CHK(data != NULL && frag != NULL); + interf = sdis_data_cget(data); + switch(frag->side) { + case SDIS_FRONT: T = interf->front.reference_temperature; break; + case SDIS_BACK: T = interf->back.reference_temperature; break; + default: FATAL("Unreachable code.\n"); break; + } + return T; +} + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -250,10 +267,12 @@ create_interface if(type_f == SDIS_FLUID) { shader.front.emissivity = interface_get_emissivity; shader.front.specular_fraction = interface_get_specular_fraction; + shader.front.reference_temperature = interface_get_reference_temperature; } if(type_b == SDIS_FLUID) { shader.back.emissivity = interface_get_emissivity; shader.back.specular_fraction = interface_get_specular_fraction; + shader.back.reference_temperature = interface_get_reference_temperature; } shader.convection_coef_upper_bound = MMAX(0, interf->convection_coef); @@ -336,6 +355,7 @@ main(int argc, char** argv) interf.back.temperature = UNKNOWN_TEMPERATURE; interf.back.emissivity = emissivity; interf.back.specular_fraction = -1; /* Should not be fetched */ + interf.back.reference_temperature = Tref; create_interface(dev, solid, fluid, &interf, interfaces+1); /* Create the interface that forces the radiative heat to bounce */ @@ -343,6 +363,7 @@ main(int argc, char** argv) interf.front.temperature = UNKNOWN_TEMPERATURE; interf.front.emissivity = 0; interf.front.specular_fraction = 1; + interf.front.reference_temperature = Tref; create_interface(dev, fluid, solid2, &interf, interfaces+2); /* Create the interface with a limit condition of T0 Kelvin */ @@ -350,6 +371,7 @@ main(int argc, char** argv) interf.front.temperature = T0; interf.front.emissivity = 1; interf.front.specular_fraction = 1; + interf.front.reference_temperature = -1; /* Should not be fetched */ create_interface(dev, fluid, solid2, &interf, interfaces+3); /* Create the interface with a limit condition of T1 Kelvin */ @@ -357,6 +379,7 @@ main(int argc, char** argv) interf.front.temperature = T1; interf.front.emissivity = 1; interf.front.specular_fraction = 1; + interf.front.reference_temperature = -1; /* Should not be fetched */ create_interface(dev, fluid, solid2, &interf, interfaces+4); /* Setup the per primitive interface of the solid medium */ @@ -384,8 +407,8 @@ main(int argc, char** argv) scn_args.get_position = get_position; scn_args.nprimitives = nsegments; scn_args.nvertices = nvertices; - scn_args.tref = Tref; scn_args.context = &geom; + scn_args.tmax = MMAX(T0, T1); OK(sdis_scene_2d_create(dev, &scn_args, &scn)); hr = 4*BOLTZMANN_CONSTANT * Tref*Tref*Tref * emissivity; diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -363,18 +363,18 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_get_ambient_radiative_temperature(scn, &t)); CHK(t == 100); - BA(sdis_scene_get_reference_temperature(NULL, NULL)); - BA(sdis_scene_get_reference_temperature(scn, NULL)); - BA(sdis_scene_get_reference_temperature(NULL, &t)); - OK(sdis_scene_get_reference_temperature(scn, &t)); - CHK(t == SDIS_SCENE_CREATE_ARGS_DEFAULT.tref); + BA(sdis_scene_get_maximum_temperature(NULL, NULL)); + BA(sdis_scene_get_maximum_temperature(scn, NULL)); + BA(sdis_scene_get_maximum_temperature(NULL, &t)); + OK(sdis_scene_get_maximum_temperature(scn, &t)); + CHK(t == SDIS_SCENE_CREATE_ARGS_DEFAULT.tmax); t = -1; - BA(sdis_scene_set_reference_temperature(NULL, t)); - BA(sdis_scene_set_reference_temperature(scn, t)); + BA(sdis_scene_set_maximum_temperature(NULL, t)); + BA(sdis_scene_set_maximum_temperature(scn, t)); t = 100; - OK(sdis_scene_set_reference_temperature(scn, t)); - OK(sdis_scene_get_reference_temperature(scn, &t)); + OK(sdis_scene_set_maximum_temperature(scn, t)); + OK(sdis_scene_get_maximum_temperature(scn, &t)); CHK(t == 100); BA(sdis_scene_get_boundary_position(NULL, 1, &u0, pos)); diff --git a/src/test_sdis_solve_boundary_flux.c b/src/test_sdis_solve_boundary_flux.c @@ -142,6 +142,7 @@ struct interf { double temperature; double emissivity; double hc; + double reference_temperature; }; static double @@ -171,6 +172,15 @@ interface_get_convection_coef return interf->hc; } +static double +interface_get_reference_temperature + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + const struct interf* interf = sdis_data_cget(data); + CHK(frag && data); + return interf->reference_temperature; +} + /******************************************************************************* * Helper function ******************************************************************************/ @@ -289,7 +299,9 @@ main(int argc, char** argv) interf_props->hc = H; interf_props->temperature = Tb; interf_props->emissivity = EPSILON; + interf_props->reference_temperature = -1; /* Should not be fetched */ interf_shader.back.emissivity = interface_get_emissivity; + interf_shader.back.reference_temperature = interface_get_reference_temperature; OK(sdis_interface_create (dev, solid, fluid, &interf_shader, data, &interf_Tb)); interf_shader.back.emissivity = NULL; @@ -301,7 +313,9 @@ main(int argc, char** argv) interf_props->hc = H; interf_props->temperature = UNKNOWN_TEMPERATURE; interf_props->emissivity = EPSILON; + interf_props->reference_temperature = Tref; interf_shader.back.emissivity = interface_get_emissivity; + interf_shader.back.reference_temperature = interface_get_reference_temperature; OK(sdis_interface_create (dev, solid, fluid, &interf_shader, data, &interf_H)); interf_shader.back.emissivity = NULL; @@ -332,7 +346,7 @@ main(int argc, char** argv) scn_args.nprimitives = box_ntriangles; scn_args.nvertices = box_nvertices; scn_args.trad = Trad; - scn_args.tref = Tref; + scn_args.tmax = MMAX(MMAX(Tf, Trad), Tb); scn_args.context = box_interfaces; OK(sdis_scene_create(dev, &scn_args, &box_scn)); @@ -343,7 +357,7 @@ main(int argc, char** argv) scn_args.nprimitives = square_nsegments; scn_args.nvertices = square_nvertices; scn_args.trad = Trad; - scn_args.tref = Tref; + scn_args.tmax = MMAX(MMAX(Tf, Trad), Tb); scn_args.context = square_interfaces; OK(sdis_scene_2d_create(dev, &scn_args, &square_scn)); diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c @@ -237,8 +237,11 @@ struct interf { double epsilon; double specular_fraction; double temperature; + double reference_temperature; +}; +static const struct interf INTERF_NULL = { + 0, 0, 0, UNKOWN_TEMPERATURE, UNKOWN_TEMPERATURE }; -static const struct interf INTERF_NULL = {0, 0, 0, UNKOWN_TEMPERATURE}; static double interface_get_convection_coef @@ -272,6 +275,14 @@ interface_get_temperature return ((const struct interf*)sdis_data_cget(data))->temperature; } +static double +interface_get_reference_temperature + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + CHK(data != NULL && frag != NULL); + return ((const struct interf*)sdis_data_cget(data))->reference_temperature; +} + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -372,10 +383,14 @@ create_interface if(sdis_medium_get_type(mdm_front) == SDIS_FLUID) { interface_shader.front.emissivity = interface_get_emissivity; interface_shader.front.specular_fraction = interface_get_specular_fraction; + interface_shader.front.reference_temperature = + interface_get_reference_temperature; } if(sdis_medium_get_type(mdm_back) == SDIS_FLUID) { interface_shader.back.emissivity = interface_get_emissivity; interface_shader.back.specular_fraction = interface_get_specular_fraction; + interface_shader.back.reference_temperature = + interface_get_reference_temperature; } /* Create the interface */ OK(sdis_interface_create @@ -590,6 +605,7 @@ main(int argc, char** argv) interface_param.epsilon = 1; interface_param.specular_fraction = 1; interface_param.temperature = UNKOWN_TEMPERATURE; + interface_param.reference_temperature = 300; create_interface(dev, fluid1, solid, &interface_param, &interf1); /* Setup the cube geometry */ @@ -615,7 +631,7 @@ main(int argc, char** argv) scn_args.nprimitives = ntris; scn_args.nvertices = npos; scn_args.trad = 300; - scn_args.tref = 300; + scn_args.tmax = 350; scn_args.context = &geom; OK(sdis_scene_create(dev, &scn_args, &scn)); diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c @@ -141,6 +141,7 @@ struct interf { double hc; double epsilon; double specular_fraction; + double reference_temperature; }; static double @@ -167,6 +168,14 @@ interface_get_specular_fraction return ((const struct interf*)sdis_data_cget(data))->specular_fraction; } +static double +interface_get_reference_temperature + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + CHK(data != NULL && frag != NULL); + return ((const struct interf*)sdis_data_cget(data))->reference_temperature; +} + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -324,6 +333,7 @@ main(int argc, char** argv) interface_shader.back.temperature = NULL; interface_shader.back.emissivity = interface_get_emissivity; interface_shader.back.specular_fraction = interface_get_specular_fraction; + interface_shader.back.reference_temperature = interface_get_reference_temperature; OK(sdis_interface_create (dev, solid, fluid, &interface_shader, data, &interf)); OK(sdis_data_ref_put(data)); @@ -539,9 +549,10 @@ main(int argc, char** argv) /* Green and ambient radiative temperature */ solve_args.nrealisations = N; OK(sdis_scene_set_ambient_radiative_temperature(scn, 300)); - OK(sdis_scene_set_reference_temperature(scn, 300)); + OK(sdis_scene_set_maximum_temperature(scn, 600)); interface_param->epsilon = 1; + interface_param->reference_temperature = 500; OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_solve_probe_green_function(scn, &solve_args, &green)); @@ -555,6 +566,7 @@ main(int argc, char** argv) /* Check same green used at different ambient radiative temperature */ OK(sdis_scene_set_ambient_radiative_temperature(scn, 600)); + OK(sdis_scene_set_maximum_temperature(scn, 600)); OK(sdis_solve_probe(scn, &solve_args, &estimator)); OK(sdis_green_function_solve(green, &estimator2)); diff --git a/src/test_sdis_unstationary_atm.c b/src/test_sdis_unstationary_atm.c @@ -307,6 +307,7 @@ struct interf { double temperature; double emissivity; double h; + double Tref; }; static double @@ -339,10 +340,56 @@ interface_get_emissivity return interf->emissivity; } +static double +interface_get_Tref + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + const struct interf* interf; + CHK(frag && data); + interf = sdis_data_cget(data); + return interf->Tref; +} + /******************************************************************************* * Helper functions ******************************************************************************/ static void +create_interface + (struct sdis_device* dev, + struct sdis_medium* front, + struct sdis_medium* back, + const struct interf* interf, + struct sdis_interface** out_interf) +{ + struct sdis_interface_shader shader = SDIS_INTERFACE_SHADER_NULL; + struct sdis_data* data = NULL; + + CHK(interf != NULL); + + 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; + shader.convection_coef_upper_bound = interf->h; + } + if(sdis_medium_get_type(front) == SDIS_FLUID) { + shader.front.emissivity = interface_get_emissivity; + shader.front.reference_temperature = interface_get_Tref; + } + if(sdis_medium_get_type(back) == SDIS_FLUID) { + shader.back.emissivity = interface_get_emissivity; + shader.back.reference_temperature = interface_get_Tref; + } + + OK(sdis_data_create(dev, sizeof(struct interf), ALIGNOF(struct interf), + NULL, &data)); + *((struct interf*)sdis_data_get(data)) = *interf; + + OK(sdis_interface_create(dev, front, back, &shader, data, out_interf)); + OK(sdis_data_ref_put(data)); +} + +static void solve_tbound1 (struct sdis_scene* scn, struct ssp_rng* rng) @@ -648,10 +695,9 @@ main(int argc, char** argv) struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT; struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER; struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER; - struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL; struct sdis_interface* model3d_interfaces[22 /*#triangles*/]; struct sdis_interface* model2d_interfaces[7/*#segments*/]; - struct interf* interf_props = NULL; + struct interf interf_props; struct solid* solid_props = NULL; struct fluid* fluid_props = NULL; struct ssp_rng* rng = NULL; @@ -716,66 +762,34 @@ main(int argc, char** argv) OK(sdis_fluid_create(dev, &fluid_shader, data, &fluid_A)); OK(sdis_data_ref_put(data)); - /* Setup the interface shader */ - interf_shader.front.temperature = interface_get_temperature; - interf_shader.back.temperature = interface_get_temperature; - interf_shader.convection_coef = interface_get_convection_coef; - interf_shader.convection_coef_upper_bound = 0; - /* Create the adiabatic interfaces */ - OK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data)); - interf_props = sdis_data_get(data); - interf_props->temperature = UNKNOWN_TEMPERATURE; - interf_props->h = 0; - OK(sdis_interface_create - (dev, fluid, dummy_solid, &interf_shader, data, &interf_adiabatic_1)); - OK(sdis_data_ref_put(data)); - - interf_shader.convection_coef = NULL; - OK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data)); - interf_props = sdis_data_get(data); - interf_props->temperature = UNKNOWN_TEMPERATURE; - interf_props->h = 0; - OK(sdis_interface_create - (dev, solid, dummy_solid, &interf_shader, data, &interf_adiabatic_2)); - OK(sdis_data_ref_put(data)); + interf_props.temperature = UNKNOWN_TEMPERATURE; + interf_props.h = 0; + interf_props.emissivity = 0; + interf_props.Tref = TREF; + create_interface(dev, fluid, dummy_solid, &interf_props, &interf_adiabatic_1); + create_interface(dev, solid, dummy_solid, &interf_props, &interf_adiabatic_2); /* Create the P interface */ - interf_shader.convection_coef_upper_bound = HC; - interf_shader.convection_coef = interface_get_convection_coef; - interf_shader.front.emissivity = interface_get_emissivity; - OK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data)); - interf_props = sdis_data_get(data); - interf_props->temperature = UNKNOWN_TEMPERATURE; - interf_props->h = HC; - interf_props->emissivity = 1; - OK(sdis_interface_create - (dev, fluid, solid, &interf_shader, data, &interf_P)); - OK(sdis_data_ref_put(data)); + interf_props.temperature = UNKNOWN_TEMPERATURE; + interf_props.h = HC; + interf_props.emissivity = 1; + interf_props.Tref = TREF; + create_interface(dev, fluid, solid, &interf_props, &interf_P); /* Create the TG interface */ - interf_shader.convection_coef_upper_bound = HG; - OK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data)); - interf_props = sdis_data_get(data); - interf_props->temperature = TG; - interf_props->h = HG; - interf_props->emissivity = 1; - OK(sdis_interface_create - (dev, fluid, dummy_solid, &interf_shader, data, &interf_TG)); - OK(sdis_data_ref_put(data)); + interf_props.temperature = TG; + interf_props.h = HG; + interf_props.emissivity = 1; + interf_props.Tref = UNKNOWN_TEMPERATURE; + create_interface(dev, fluid, dummy_solid, &interf_props, &interf_TG); /* Create the TA interface */ - interf_shader.convection_coef_upper_bound = HA; - interf_shader.front.emissivity = NULL; - interf_shader.back.emissivity = interface_get_emissivity; - OK(sdis_data_create(dev, sizeof(struct interf), 16, NULL, &data)); - interf_props = sdis_data_get(data); - interf_props->temperature = UNKNOWN_TEMPERATURE; - interf_props->h = HA; - interf_props->emissivity = 1; - OK(sdis_interface_create - (dev, solid, fluid_A, &interf_shader, data, &interf_TA)); - OK(sdis_data_ref_put(data)); + interf_props.temperature = UNKNOWN_TEMPERATURE; + interf_props.h = HA; + interf_props.emissivity = 1; + interf_props.Tref = TREF; + create_interface(dev, solid, fluid_A, &interf_props, &interf_TA); /* Release the media */ OK(sdis_medium_ref_put(solid)); @@ -834,7 +848,10 @@ main(int argc, char** argv) scn_args.nvertices = model3d_nvertices; scn_args.context = model3d_interfaces; scn_args.trad = TR; - scn_args.tref = TREF; + scn_args.tmax = MMAX(T0_FLUID, T0_SOLID); + scn_args.tmax = MMAX(scn_args.tmax, TA); + scn_args.tmax = MMAX(scn_args.tmax, TG); + scn_args.tmax = MMAX(scn_args.tmax, TR); OK(sdis_scene_create(dev, &scn_args, &box_scn)); /* Create the square scene */ @@ -845,7 +862,10 @@ main(int argc, char** argv) scn_args.nvertices = model2d_nvertices; scn_args.context = model2d_interfaces; scn_args.trad = TR; - scn_args.tref = TREF; + scn_args.tmax = MMAX(T0_FLUID, T0_SOLID); + scn_args.tmax = MMAX(scn_args.tmax, TA); + scn_args.tmax = MMAX(scn_args.tmax, TG); + scn_args.tmax = MMAX(scn_args.tmax, TR); OK(sdis_scene_2d_create(dev, &scn_args, &square_scn)); /* Release the interfaces */