stardis

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

commit 4c7b0552c087cffd51a48dcf1f3c9170f0a225c2
parent b1c67dd920c94c96950782218686bc35d60ffc49
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Mon, 28 Jan 2019 11:00:33 +0100

Fix invalid data detection and add debug code

Diffstat:
Msrc/stardis-app.h | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/stardis-compute.c | 27++++++++++++++++++++-------
2 files changed, 128 insertions(+), 7 deletions(-)

diff --git a/src/stardis-app.h b/src/stardis-app.h @@ -63,6 +63,19 @@ struct triangle { #define NULL_TRIANGLE__ {{{0, 0, 0}}, UINT_MAX, UINT_MAX, UINT_MAX } static const struct triangle NULL_TRIANGLE = NULL_TRIANGLE__; +static INLINE void +print_trg_as_obj + (FILE* stream, + const struct vertex* vertices, + const struct triangle* trg) +{ + assert(stream && vertices && trg); + fprintf(stream, "v %.8e %.8e %.8e\nv %.8e %.8e %.8e\nv %.8e %.8e %.8e\nf 1 2 3\n", + SPLIT3(vertices[trg->indices.data[0]].xyz), + SPLIT3(vertices[trg->indices.data[1]].xyz), + SPLIT3(vertices[trg->indices.data[2]].xyz)); +} + static INLINE char eq_indices(const struct unsigned3* a, const struct unsigned3* b) { @@ -115,6 +128,15 @@ struct mat_fluid { char* Tinit; }; +static void +print_fluid(FILE* stream, const struct mat_fluid* f) +{ + assert(stream && f); + fprintf(stream, + "Fluid %u: cp=%g rho=%g Tinit='%s'\n", + f->fluid_id, f->cp, f->rho, f->Tinit); +} + static char eq_fluid(const struct mat_fluid* a, const struct mat_fluid* b) { @@ -195,6 +217,16 @@ struct mat_solid { int has_power; }; +static void +print_solid(FILE* stream, const struct mat_solid* s) +{ + assert(stream && s); + fprintf(stream, + "Solid %u: lambda=%g cp=%g rho=%g delta=%g Tinit='%s' Power='%s'\n", + s->solid_id, s->lambda, s->cp, s->rho, s->delta, + s->Tinit, (s->has_power ? s->power : "0")); +} + static char eq_solid(const struct mat_solid* a, const struct mat_solid* b) { @@ -312,6 +344,24 @@ struct h_boundary { int has_emissivity, has_hc; }; +static void +print_h_boundary + (FILE* stream, + const struct h_boundary* b, + const enum description_type type) +{ + assert(stream && b + && (type == DESC_BOUND_H_FOR_SOLID || type == DESC_BOUND_H_FOR_FLUID)); + fprintf(stream, + "H boundary for %s: emissivity=%g specular_fraction=%g hc=%g hc_max=%g T='%s'\n", + (type == DESC_BOUND_H_FOR_SOLID ? "solid" : "fluid"), + (b->has_emissivity ? b->emissivity : 0), + (b->has_emissivity ? b->specular_fraction : 0), + (b->has_hc ? b->hc : 0), + (b->has_hc ? b->hc_max : 0), + (b->T ? b->T : "0")); +} + static char eq_h_boundary (const struct h_boundary* a, @@ -429,6 +479,22 @@ struct t_boundary { int has_hc; }; +static void +print_t_boundary + (FILE* stream, + const struct t_boundary* b, + const enum description_type type) +{ + assert(stream && b + && (type == DESC_BOUND_T_FOR_SOLID || type == DESC_BOUND_T_FOR_FLUID)); + fprintf(stream, + "T boundary for %s: hc=%g hc_max=%g T='%s'\n", + (type == DESC_BOUND_T_FOR_SOLID ? "solid" : "fluid"), + (b->has_hc ? b->hc : 0), + (b->has_hc ? b->hc_max : 0), + (b->T ? b->T : "0")); +} + static char eq_t_boundary (const struct t_boundary* a, @@ -530,6 +596,20 @@ struct f_boundary { int has_hc; }; +static void +print_f_boundary + (FILE* stream, + const struct f_boundary* b, + const enum description_type type) +{ + assert(stream && b && type == DESC_BOUND_F_FOR_SOLID); + fprintf(stream, + "F boundary for SOLID: hc=%g hc_max=%g flux='%s'\n", + (b->has_hc ? b->hc : 0), + (b->has_hc ? b->hc_max : 0), + (b->flux ? b->flux : "0")); +} + static char eq_f_boundary(const struct f_boundary* a, const struct f_boundary* b) { @@ -712,6 +792,34 @@ struct description { } d; }; +static INLINE void +print_description + (FILE* stream, + struct description* desc) +{ + ASSERT(stream && desc); + switch (desc->type) { + case DESC_MAT_SOLID: + print_solid(stream, &desc->d.solid); + break; + case DESC_MAT_FLUID: + print_fluid(stream, &desc->d.fluid); + break; + case DESC_BOUND_T_FOR_SOLID: + case DESC_BOUND_T_FOR_FLUID: + print_t_boundary(stream, &desc->d.t_boundary, desc->type); + break; + case DESC_BOUND_H_FOR_SOLID: + case DESC_BOUND_H_FOR_FLUID: + print_h_boundary(stream, &desc->d.h_boundary, desc->type); + break; + case DESC_BOUND_F_FOR_SOLID: + print_f_boundary(stream, &desc->d.f_boundary, desc->type); + break; + default: FATAL("Invalid type.\n"); + } +} + static INLINE char eq_description(const struct description* a, const struct description* b) { diff --git a/src/stardis-compute.c b/src/stardis-compute.c @@ -857,22 +857,35 @@ stardis_compute(struct stardis* stardis, enum stardis_mode mode) } } - if(fluid_count == 2 - || fluid_count + solid_count + connection_count < 2 - || boundary_count ? - (fluid_count + solid_count != 1) : (fluid_count + solid_count != 2) + if((fluid_count == 2) + || (fluid_count + solid_count + connection_count < 2) + || (boundary_count ? + (fluid_count + solid_count != 1) : (fluid_count + solid_count != 2)) || (solid_fluid_connection_count && (fluid_count != 1 || solid_count != 1))) { /* Incoherent triangle description */ - if(fluid_count == 2) - fprintf(stderr, "Incoherent triangle description\n"); + fprintf(stderr, "Incoherent triangle description (%u)\n", i); + print_trg_as_obj(stderr, stardis->geometry.vertex, trg); + fprintf(stderr, "Front: "); + if(!front_defined) fprintf(stderr, "undefined\n"); + else print_description(stderr, &stardis->descriptions[fd]); + fprintf(stderr, "Back: "); + if (!back_defined) fprintf(stderr, "undefined\n"); + else print_description(stderr, &stardis->descriptions[bd]); + fprintf(stderr, "Connection: "); + if (!connect_defined) fprintf(stderr, "undefined\n"); + else print_description(stderr, &stardis->descriptions[cd]); res = RES_BAD_ARG; goto error; } res = sdis_interface_create(dev, front_med, back_med, &interface_shader, data, &intface); - if (res != RES_OK) goto error; + if (res != RES_OK) { + fprintf(stderr, + "Cannot create interface associated to triangle %u\n", i); + goto error; + } SDIS(data_ref_put(data)); data = NULL; res = htable_intface_set(&htable_interfaces, &int_descs, &intface); if (res != RES_OK) goto error;