sgas.h (3033B)
1 /* Copyright (C) 2025, 2026 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2025, 2026 Université de Lorraine 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 SGAS_H 18 #define SGAS_H 19 20 #include <rsys/rsys.h> 21 22 /* Library symbol management */ 23 #if defined(SGAS_SHARED_BUILD) 24 #define SGAS_API extern EXPORT_SYM 25 #else 26 #define SGAS_API extern IMPORT_SYM 27 #endif 28 29 /* Helper macro that asserts if the invocation of the sgas function `Func' 30 * returns an error. One should use this macro on sgas function calls for which 31 * no explicit error checking is performed */ 32 #ifndef NDEBUG 33 #define SGAS(Func) ASSERT(sgas_##Func == RES_OK) 34 #else 35 #define SGAS(Func) sgas_##Func 36 #endif 37 38 /* Forward declarations */ 39 struct logger; 40 struct mem_allocator; 41 42 struct sgas_file { 43 /* The name variable is either the stream name or the file to load, depending 44 * on whether stream is set or not. If name is NULL, then the data is loaded 45 * from stream, which must be set. In this case, the name of the stream is a 46 * default name. */ 47 const char* name; /* NULL <=> load from stream */ 48 FILE* stream; /* NULL <=> load from name */ 49 }; 50 #define SGAS_FILE_NULL__ {0} 51 static const struct sgas_file SGAS_FILE_NULL = SGAS_FILE_NULL__; 52 53 struct sgas_create_args { 54 struct sgas_file mesh; /* Tetrahedral mesh in smsh(5) format */ 55 struct sgas_file therm_props_list; /* Time varying thermodynamic properties */ 56 57 struct logger* logger; /* NULL <=> default logger */ 58 struct mem_allocator* allocator; /* NULL <=> default allocator */ 59 int verbose; /* Verbosity level */ 60 }; 61 #define SGAS_CREATE_ARGS_DEFAULT__ {0} 62 static const struct sgas_create_args SGAS_CREATE_ARGS_DEFAULT = 63 SGAS_CREATE_ARGS_DEFAULT__; 64 65 struct sgas_props { 66 double pressure; /* [Pa] */ 67 double temperature; /* [K] */ 68 double xH2O; /* [mol(H2O)/mol(mixture)] */ 69 double xCO2; /* [mol(CO2)/mol(mixture)] */ 70 double xCO; /* [mol(CO) /mol(mixture)] */ 71 }; 72 #define SGAS_PROPS_NULL__ {0} 73 static const struct sgas_props SGAS_PROPS_NULL = 74 SGAS_PROPS_NULL__; 75 76 /* Forward declarations */ 77 struct sgas; 78 79 BEGIN_DECLS 80 81 SGAS_API res_T 82 sgas_create 83 (const struct sgas_create_args* args, 84 struct sgas** gas); 85 86 SGAS_API res_T 87 sgas_ref_get 88 (struct sgas* gas); 89 90 SGAS_API res_T 91 sgas_ref_put 92 (struct sgas* gas); 93 94 SGAS_API res_T 95 sgas_get_props 96 (const struct sgas* gas, 97 const double pos[3], 98 const double time, 99 struct sgas_props* props); 100 101 END_DECLS 102 103 #endif /* SGAS_H */