stardis

Perform coupled heat transfer calculations
git clone git://git.meso-star.fr/stardis.git
Log | Files | Refs | README | LICENSE

commit eaefa2aa20187d6fac4a3ebefea1378b9818a80c
parent 50006778648b3efb4aa8643058b563aa6305788d
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Sat, 28 Apr 2018 12:40:38 +0200

ajout des conditions limites en flux

Diffstat:
Msrc/bc.txt | 3++-
Msrc/stardis-app.c | 9++++++++-
Msrc/stardis-app.h | 3++-
Msrc/stardis-compute.c | 40++++++++++++++++++++++++++++++++++++++--
4 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/src/bc.txt b/src/bc.txt @@ -1,4 +1,5 @@ -#STL_filename h h_coeff T_env(x,y,z,t) | STL_filename T T_value(x,y,z,t) +#STL_filename h h_coeff T_env(x,y,z,t) | STL_filename T T_value(x,y,z,t) | STL_filename F F_value(x,y,z,t) b_h_1.stl h 0 "300" +#b_h_1.stl F "100" b_T_1.stl T "300" b_T_2.stl T "300" diff --git a/src/stardis-app.c b/src/stardis-app.c @@ -124,6 +124,13 @@ parse_boundary_line(char* line, char** stl_filename, struct boundary* bound) bound->T = malloc(strlen(tk) + 1); strcpy(bound->T,tk); + } else if (strcmp(tk,"f")==0 || strcmp(tk,"F")==0 ){ + + tk = strtok(NULL,"\""); + tk = strtok(NULL,"\""); + bound->flux = malloc(strlen(tk) + 1); + strcpy(bound->flux,tk); + } else { fprintf(stderr,"unknown boundary type: %s\n", tk); goto error; @@ -328,7 +335,7 @@ check_consistency int i = 0; for (i=0; i<sa_size(boundary); ++i){ - if (strchr(boundary[i].T,'t') && probe[3] == INF) { + if ( boundary[i].T && strchr(boundary[i].T,'t') && probe[3] == INF) { fprintf(stderr,"Transient boundary condition is inconsistent with INF time of the probe.\n"); res = RES_BAD_ARG; goto error; diff --git a/src/stardis-app.h b/src/stardis-app.h @@ -105,8 +105,9 @@ static const struct material NULL_MATERIAL = NULL_MATERIAL__; struct boundary{ double hc; char* T; + char* flux; }; -#define NULL_BOUNDARY__ {-1, NULL} +#define NULL_BOUNDARY__ {-1, NULL, NULL} static const struct boundary NULL_BOUNDARY = NULL_BOUNDARY__; diff --git a/src/stardis-compute.c b/src/stardis-compute.c @@ -196,6 +196,7 @@ solid_get_power struct interface { double hc; /* Convection coefficient */ char* temperature; + char* flux; double emissivity; double alpha; }; @@ -238,6 +239,35 @@ interface_get_temperature } static double +interface_get_flux + (const struct sdis_interface_fragment* frag, struct sdis_data* data) +{ + const struct interface* interface_props = sdis_data_cget(data); + + if (interface_props->flux == NULL) { + return SDIS_FLUX_NONE; + } else { + + double flux = 0; + char* math_expr = interface_props->flux; + double x, y, z, t; + /* Store variable names and pointers. */ + te_variable vars[] = {{"x", &x}, {"y", &y}, {"z", &z}, {"t", &t}}; + int err; + + /* Compile the expression with variables. */ + te_expr *expr = te_compile(math_expr, vars, 4, &err); + x = frag->P[0]; + y = frag->P[1]; + z = frag->P[2]; + t = frag->time; + flux = te_eval(expr); + te_free(expr); + return flux; + } +} + +static double interface_get_emissivity (const struct sdis_interface_fragment* frag, struct sdis_data* data) { @@ -379,7 +409,7 @@ stardis_compute(struct stardis* stardis) /* Setup the interface shader */ interface_shader_front.temperature = interface_get_temperature; - interface_shader_front.flux = NULL; + interface_shader_front.flux = interface_get_flux; interface_shader_front.emissivity = interface_get_emissivity; interface_shader_front.specular_fraction = interface_get_alpha; @@ -395,6 +425,7 @@ stardis_compute(struct stardis* stardis) if (bound_id > -1){ /* boundary interface */ double hc = stardis->boundary[bound_id].hc; char* T = stardis->boundary[bound_id].T; + char* flux = stardis->boundary[bound_id].flux; double emissivity = stardis->material[stardis->geometry.triangle[i].medium_front].emissivity; double alpha = @@ -405,8 +436,13 @@ stardis_compute(struct stardis* stardis) if (hc > -1) { interface_props->hc = hc; interface_props->temperature = NULL; - } else { + interface_props->flux = NULL; + } else if (T != NULL){ interface_props->temperature = T; + interface_props->flux = NULL; + } else if (flux != NULL){ + interface_props->temperature = NULL; + interface_props->flux = flux; } interface_props->emissivity = emissivity; interface_props->alpha = alpha;