stardis-solver

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

commit fa2c3578efc13d6fb35bbd860b81fd7bf7c94c9a
parent 9a53f940db55282fef4bb1808f5a9675e5d4c591
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 18 Apr 2018 15:15:11 +0200

Relax the conditions on interface creation

If some shader functions are defined while they should not be, the
interface is still created and a warning message is printed.

Diffstat:
Msrc/sdis.h | 2+-
Msrc/sdis_interface.c | 58+++++++++++++++++++++++++++++++++++++++-------------------
Msrc/sdis_solve_Xd.h | 11++++++-----
Msrc/test_sdis_interface.c | 8+++++---
Msrc/test_sdis_solve_probe.c | 4++--
5 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -173,7 +173,7 @@ struct sdis_interface_side_shader { 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 + /* Control the emissivity of the interface. May be NULL for solid/solid * 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] */ diff --git a/src/sdis_interface.c b/src/sdis_interface.c @@ -29,31 +29,51 @@ ******************************************************************************/ static int check_interface_shader - (const struct sdis_interface_shader* shader, + (struct sdis_device* dev, + const char* caller_name, + const struct sdis_interface_shader* shader, const struct sdis_medium* front, const struct sdis_medium* back) { - enum sdis_medium_type type_front; - enum sdis_medium_type type_back; - ASSERT(shader && front && back); + enum sdis_medium_type type[2]; + const struct sdis_interface_side_shader* shaders[2]; + int i; + ASSERT(dev && caller_name && shader && front && back); - type_front = sdis_medium_get_type(front); - type_back = sdis_medium_get_type(back); - - 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; - } + type[0] = sdis_medium_get_type(front); + type[1] = sdis_medium_get_type(back); + shaders[0] = &shader->front; + shaders[1] = &shader->back; /* Fluid<->solid interface */ - if(type_front == SDIS_MEDIUM_SOLID - && type_back == SDIS_MEDIUM_SOLID + if(type[0] == SDIS_MEDIUM_SOLID + && type[1] == SDIS_MEDIUM_SOLID && shader->convection_coef) { - return 0; + log_warn(dev, + "%s: a solid/solid interface can't have a convection coefficient. This " + "function of the interface shader should be NULL.\n", caller_name); + } + + FOR_EACH(i, 0, 2) { + switch(type[i]) { + case SDIS_MEDIUM_SOLID: + if(shaders[i]->emissivity || shaders[i]->specular_fraction) { + log_warn(dev, + "%s: the interface side toward a solid can't have the emissivity " + "and specular_fraction properties. The shader functions that return " + "these attributes should be NULL.\n", caller_name); + } + break; + case SDIS_MEDIUM_FLUID: + if(shaders[i]->flux) { + log_warn(dev, + "%s: the interface side toward a fluid can't have a flux property. " + "The shader function that returns this attribute should be NULL.\n", + caller_name); + } + break; + default: FATAL("Unreachable code.\n"); break; + } } return 1; } @@ -101,7 +121,7 @@ sdis_interface_create goto error; } - if(!check_interface_shader(shader, front, back)) { + if(!check_interface_shader(dev, FUNC_NAME, shader, front, back)) { log_err(dev, "%s: invalid interface shader.\n", FUNC_NAME); res = RES_BAD_ARG; goto error; diff --git a/src/sdis_solve_Xd.h b/src/sdis_solve_Xd.h @@ -239,11 +239,12 @@ XD(trace_radiative_path) 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", + "%s: the random walk reaches an invalid ambient radiative temperature " + "of `%gK' at position `%g %g %g'. This may be due to numerical " + "inaccuracies or to inconsistency in the simulated system (eg: " + "unclosed geometry). For systems where the random walks can reach " + "such temperature, one has to setup a valid ambient radiative " + "temperature, i.e. it must be greater or equal to 0.\n", FUNC_NAME, ctx->Tarad, SPLIT3(rwalk->vtx.P)); diff --git a/src/test_sdis_interface.c b/src/test_sdis_interface.c @@ -31,7 +31,7 @@ main(int argc, char** argv) CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); CHK(sdis_device_create - (NULL, &allocator, SDIS_NTHREADS_DEFAULT, 0, &dev) == RES_OK); + (NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev) == RES_OK); CHK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid) == RES_OK); CHK(sdis_solid_create(dev, &solid_shader, NULL, &solid) == RES_OK); @@ -97,10 +97,12 @@ main(int argc, char** argv) 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); + CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_OK); /* Warning */ + CHK(sdis_interface_ref_put(interf) == RES_OK); shader.front.emissivity = NULL; shader.front.specular_fraction = dummy_interface_getter; - CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_BAD_ARG); + CHK(CREATE(dev, solid, fluid, &shader, NULL, &interf) == RES_OK); /* Warning */ + CHK(sdis_interface_ref_put(interf) == RES_OK); #undef CREATE CHK(sdis_device_ref_put(dev) == RES_OK); diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c @@ -191,7 +191,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 interface_shader = DUMMY_INTERFACE_SHADER; + struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL; struct context ctx; struct fluid* fluid_param; struct solid* solid_param; @@ -206,7 +206,7 @@ main(int argc, char** argv) CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); CHK(sdis_device_create - (NULL, &allocator, SDIS_NTHREADS_DEFAULT, 0, &dev) == RES_OK); + (NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev) == RES_OK); /* Create the fluid medium */ CHK(sdis_data_create