stardis-intface.h (2757B)
1 /* Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #ifndef SDIS_INTFACE_H 17 #define SDIS_INTFACE_H 18 19 #include <rsys/hash_table.h> 20 21 #include <limits.h> 22 23 struct stardis; 24 struct stardis_interface_fragment; 25 26 /******************************************************************************* 27 * Interface data 28 ******************************************************************************/ 29 struct intface { 30 /* programmed interfaces */ 31 double (*get_temp)(const struct stardis_interface_fragment*, void*); 32 double (*get_flux)(const struct stardis_interface_fragment*, void*); 33 double (*get_hc)(const struct stardis_interface_fragment*, void*); 34 double (*get_ref_temp)(const struct stardis_interface_fragment*, void*); 35 double (*get_tcr)(const struct stardis_interface_fragment*, void*); 36 double (*get_emissivity) 37 (const struct stardis_interface_fragment*, const unsigned src_id, void*); 38 double (*get_alpha) 39 (const struct stardis_interface_fragment*, const unsigned src_id, void*); 40 41 void* prog_data; 42 /* fluid - solid */ 43 double hc; 44 double ref_temperature; 45 double emissivity; 46 double alpha; 47 /* solid - solid */ 48 double tcr; 49 /* Imposed compute temperature & flux */ 50 double imposed_temperature; 51 double imposed_flux; 52 /* IDs */ 53 unsigned front_medium_id, back_medium_id; 54 unsigned desc_id; /* The description this interfaces comes from */ 55 }; 56 57 /* Declare the hash table that map an interface to its descriptor */ 58 struct int_descs { 59 unsigned front, back, intface; 60 }; 61 #define INT_DESCS_NULL__ { UINT_MAX, UINT_MAX, UINT_MAX } 62 static const struct int_descs INT_DESCS_NULL = INT_DESCS_NULL__; 63 64 static INLINE char 65 eq_desc(const struct int_descs* a, const struct int_descs* b) 66 { 67 return (char)(a->front == b->front && a->back == b->back 68 && a->intface == b->intface); 69 } 70 71 #define HTABLE_NAME intface 72 #define HTABLE_DATA struct sdis_interface* 73 #define HTABLE_KEY struct int_descs 74 #define HTABLE_KEY_FUNCTOR_EQ eq_desc 75 #include <rsys/hash_table.h> 76 77 res_T 78 create_intface 79 (struct stardis* stardis, 80 unsigned tr_idx, 81 struct htable_intface* htable_interfaces); 82 83 #endif