stardis-radiative-env.h (3351B)
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 STARDIS_RADIATIVE_ENV_H 17 #define STARDIS_RADIATIVE_ENV_H 18 19 #include "stardis-default.h" 20 #include <rsys/rsys.h> 21 22 /* Forward declaration */ 23 struct stardis; 24 25 enum radiative_env_type { 26 RADIATIVE_ENV_CONST, 27 RADIATIVE_ENV_PROG 28 }; 29 30 struct radiative_env_const { 31 double temperature; 32 double reference_temperature; 33 }; 34 #define RADIATIVE_ENV_CONST_DEFAULT__ { \ 35 STARDIS_DEFAULT_TRAD, \ 36 STARDIS_DEFAULT_TRAD_REFERENCE \ 37 } 38 static const struct radiative_env_const RADIATIVE_ENV_CONST_DEFAULT = 39 RADIATIVE_ENV_CONST_DEFAULT__; 40 41 struct radiative_env_prog { 42 struct str prog_name; 43 struct program* program; 44 void* data; /* Pointer toward the program data */ 45 struct mem_allocator* allocator; 46 47 /* Input arguments */ 48 size_t argc; 49 char** argv; 50 51 void* 52 (*create) 53 (const struct stardis_description_create_context* ctx, 54 void* lib_data, 55 size_t argc, 56 char* argv[]); 57 58 void 59 (*release) 60 (void* data); 61 62 double 63 (*temperature) 64 (const double time, /* [s] */ 65 const double dir[3], 66 void* data); 67 68 double 69 (*reference_temperature) 70 (const double time, /* [s] */ 71 const double dir[3], 72 void* data); 73 74 double* 75 (*t_range) 76 (void* data, 77 double t_range[2]); 78 }; 79 #define RADIATIVE_ENV_PROG_NULL__ \ 80 {{0}, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL} 81 static const struct radiative_env_prog RADIATIVE_ENV_PROG_NULL = 82 RADIATIVE_ENV_PROG_NULL__; 83 84 struct radiative_env { 85 enum radiative_env_type type; 86 union { 87 struct radiative_env_const cst; 88 struct radiative_env_prog prg; 89 } data; 90 struct sdis_radiative_env* sdis_radenv; 91 }; 92 #define RADIATIVE_ENV_DEFAULT__ { \ 93 RADIATIVE_ENV_CONST, \ 94 {RADIATIVE_ENV_CONST_DEFAULT__}, \ 95 NULL \ 96 } 97 static const struct radiative_env RADIATIVE_ENV_DEFAULT = RADIATIVE_ENV_DEFAULT__; 98 99 extern LOCAL_SYM res_T 100 radiative_env_init_const 101 (struct mem_allocator* allocator, 102 struct radiative_env* radenv); 103 104 extern LOCAL_SYM res_T 105 radiative_env_init_prog 106 (struct mem_allocator* allocator, 107 struct radiative_env* radenv); 108 109 extern LOCAL_SYM void 110 radiative_env_release 111 (struct radiative_env* radenv); 112 113 extern LOCAL_SYM res_T 114 radiative_env_create_solver_radiative_env 115 (struct radiative_env* radenv, 116 struct stardis* stardis); 117 118 #endif /* STARDIS_RADIATIVE_ENV_H */