atrtp.h (3323B)
1 /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef ATRTP_H 18 #define ATRTP_H 19 20 #include <rsys/rsys.h> 21 22 /* Library symbol management */ 23 #if defined(ATRTP_SHARED_BUILD) /* Build shared library */ 24 #define ATRTP_API extern EXPORT_SYM 25 #elif defined(ATRTP_STATIC) /* Use/build static library */ 26 #define ATRTP_API extern LOCAL_SYM 27 #else /* Use shared library */ 28 #define ATRTP_API extern IMPORT_SYM 29 #endif 30 31 /* Helper macro that asserts if the invocation of the atrtp function `Func' 32 * returns an error. One should use this macro on sth function calls for 33 * which no explicit error checking is performed */ 34 #ifndef NDEBUG 35 #define ATRTP(Func) ASSERT(atrtp_ ## Func == RES_OK) 36 #else 37 #define ATRTP(Func) atrtp_ ## Func 38 #endif 39 40 /* Type of the thermodynamic properties */ 41 enum atrtp_type { 42 ATRTP_PRESSURE, /* In Pascal */ 43 ATRTP_TEMPERATURE, /* In Kelvin */ 44 ATRTP_XH20, /* In mol(H2O)/mol(mixture) */ 45 ATRTP_XCO2, /* In mol(CO2)/mol(mixture) */ 46 ATRTP_XCO, /* In mol(CO)/mol(mixture) */ 47 ATRTP_SOOT_VOLFRAC, /* In m^3(soot)/m^3 */ 48 ATRTP_SOOT_PRIMARY_PARTICLES_COUNT, /* #primary particles per aggregate */ 49 ATRTP_SOOT_PRIMARY_PARTICLES_DIAMETER, /* Primary particles diameter in nm */ 50 ATRTP_COUNT__ 51 }; 52 53 struct atrtp_desc { 54 const double* properties; /* List of double[ATRTP_COUNT__] */ 55 size_t nnodes; 56 }; 57 static const struct atrtp_desc ATRTP_DESC_NULL; 58 59 /* Forward declaration of external data types */ 60 struct logger; 61 struct mem_allocator; 62 63 /* Forward declaration of opaque data types */ 64 struct atrtp; 65 66 BEGIN_DECLS 67 68 /******************************************************************************* 69 * ATRTP API 70 ******************************************************************************/ 71 ATRTP_API res_T 72 atrtp_create 73 (struct logger* logger, /* NULL <=> use default logger */ 74 struct mem_allocator* allocator, /* NULL <=> use default allocator */ 75 const int verbose, /* Verbosity level */ 76 struct atrtp** atrtp); 77 78 ATRTP_API res_T 79 atrtp_ref_get 80 (struct atrtp* atrtp); 81 82 ATRTP_API res_T 83 atrtp_ref_put 84 (struct atrtp* attrtp); 85 86 ATRTP_API res_T 87 atrtp_load 88 (struct atrtp* atrtp, 89 const char* path); 90 91 ATRTP_API res_T 92 atrtp_load_stream 93 (struct atrtp* atrtp, 94 FILE* stream, 95 const char* stream_name); /* Can be NULL */ 96 97 ATRTP_API res_T 98 atrtp_get_desc 99 (const struct atrtp* atrtp, 100 struct atrtp_desc* desc); 101 102 static INLINE const double* 103 atrtp_desc_get_node_properties 104 (const struct atrtp_desc* desc, 105 const size_t inode) 106 { 107 ASSERT(desc && inode < desc->nnodes); 108 return desc->properties + inode*ATRTP_COUNT__; 109 } 110 111 END_DECLS 112 113 #endif /* ATRTP_H */