sdis_heat_path_boundary_c.h (10427B)
1 /* Copyright (C) 2016-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_HEAT_PATH_BOUNDARY_C_H 17 #define SDIS_HEAT_PATH_BOUNDARY_C_H 18 19 #include <star/s2d.h> 20 #include <star/s3d.h> 21 #include <rsys/rsys.h> 22 23 /* Forward declarations */ 24 struct rwalk; 25 struct sdis_scene; 26 struct sdis_medium; 27 28 /******************************************************************************* 29 * Sample a reinjection step 30 ******************************************************************************/ 31 struct sample_reinjection_step_args { 32 struct ssp_rng* rng; /* Random number generator to use */ 33 struct rwalk* rwalk; /* Current state of the random walk */ 34 double distance; /* Maximum Reinjection distance */ 35 unsigned solid_enc_id; /* Enclosured Id of the solid in which to reinject */ 36 enum sdis_side side; /* Side of the boundary to re-inject */ 37 }; 38 39 #define SAMPLE_REINJECTION_STEP_ARGS_NULL__ \ 40 {NULL, NULL, -1, ENCLOSURE_ID_NULL, SDIS_SIDE_NULL__} 41 static const struct sample_reinjection_step_args 42 SAMPLE_REINJECTION_STEP_ARGS_NULL = SAMPLE_REINJECTION_STEP_ARGS_NULL__; 43 44 struct reinjection_step { 45 struct s2d_hit hit_2d; /* 2D Intersection along the reinjection direction */ 46 struct s3d_hit hit_3d; /* 3D Intersection along the reinjection direction */ 47 float direction[3]; /* Reinjection direction */ 48 float distance; /* Reinjection distance */ 49 }; 50 51 #define REINJECTION_STEP_NULL__ {S2D_HIT_NULL__, S3D_HIT_NULL__, {0,0,0}, 0} 52 static const struct reinjection_step REINJECTION_STEP_NULL = 53 REINJECTION_STEP_NULL__; 54 55 extern LOCAL_SYM res_T 56 sample_reinjection_step_solid_fluid_2d 57 (struct sdis_scene* scn, 58 const struct sample_reinjection_step_args* args, 59 struct reinjection_step* step); 60 61 extern LOCAL_SYM res_T 62 sample_reinjection_step_solid_fluid_3d 63 (struct sdis_scene* scn, 64 const struct sample_reinjection_step_args* args, 65 struct reinjection_step *step); 66 67 extern LOCAL_SYM res_T 68 sample_reinjection_step_solid_solid_2d 69 (struct sdis_scene* scn, 70 const struct sample_reinjection_step_args* args_front, 71 const struct sample_reinjection_step_args* args_back, 72 struct reinjection_step* step_front, 73 struct reinjection_step* step_back); 74 75 extern LOCAL_SYM res_T 76 sample_reinjection_step_solid_solid_3d 77 (struct sdis_scene* scn, 78 const struct sample_reinjection_step_args* args_front, 79 const struct sample_reinjection_step_args* args_back, 80 struct reinjection_step* step_front, 81 struct reinjection_step* step_back); 82 83 /******************************************************************************* 84 * Reinject the random walk into a solid 85 ******************************************************************************/ 86 struct solid_reinjection_args { 87 const struct reinjection_step* reinjection; /* Reinjection to do */ 88 struct rwalk_context* rwalk_ctx; 89 struct rwalk* rwalk; /* Current state of the random walk */ 90 struct ssp_rng* rng; /* Random number generator */ 91 struct temperature* T; 92 double fp_to_meter; 93 }; 94 95 #define SOLID_REINJECTION_ARGS_NULL__ {NULL,NULL,NULL,NULL,NULL,0} 96 static const struct solid_reinjection_args SOLID_REINJECTION_ARGS_NULL = 97 SOLID_REINJECTION_ARGS_NULL__; 98 99 extern LOCAL_SYM res_T 100 solid_reinjection_2d 101 (struct sdis_scene* scn, 102 const unsigned solid_enc_id, 103 struct solid_reinjection_args* args); 104 105 extern LOCAL_SYM res_T 106 solid_reinjection_3d 107 (struct sdis_scene* scn, 108 const unsigned solid_enc_id, 109 struct solid_reinjection_args* args); 110 111 /******************************************************************************* 112 * Handle net flux 113 ******************************************************************************/ 114 struct handle_net_flux_args { 115 struct sdis_interface* interf; 116 const struct sdis_interface_fragment* frag; 117 struct green_path_handle* green_path; 118 119 size_t picard_order; 120 double h_cond; /* Convective coefficient, i.e. lambda/delta */ 121 double h_conv; /* Condutive coefficient */ 122 double h_radi; /* Radiative coefficient */ 123 }; 124 #define HANDLE_NET_FLUX_ARGS_NULL__ {NULL,NULL,NULL,0,0,0,0} 125 static const struct handle_net_flux_args HANDLE_NET_FLUX_ARGS_NULL = 126 HANDLE_NET_FLUX_ARGS_NULL__; 127 128 extern LOCAL_SYM res_T 129 handle_net_flux_2d 130 (const struct sdis_scene* scn, 131 const struct handle_net_flux_args* args, 132 struct temperature* T); 133 134 extern LOCAL_SYM res_T 135 handle_net_flux_3d 136 (const struct sdis_scene* scn, 137 const struct handle_net_flux_args* args, 138 struct temperature* T); 139 140 /******************************************************************************* 141 * Handle external flux 142 ******************************************************************************/ 143 struct handle_external_net_flux_args { 144 struct sdis_interface* interf; 145 const struct sdis_interface_fragment* frag; 146 const struct s2d_hit* hit_2d; 147 const struct s3d_hit* hit_3d; 148 149 struct green_path_handle* green_path; /* Store the propagator */ 150 struct sdis_heat_path* heat_path; /* Save paths */ 151 152 size_t picard_order; 153 double h_cond; /* Convective coefficient, i.e. lambda/delta */ 154 double h_conv; /* Condutive coefficient */ 155 double h_radi; /* Radiative coefficient */ 156 }; 157 158 struct handle_external_net_flux_args_3d { 159 struct sdis_interface* interf; 160 const struct sdis_interface_fragment* frag; 161 const struct s3d_hit* hit; 162 163 struct green_path_handle* green_path; /* Store the propagator */ 164 struct sdis_heat_path* heat_path; /* Save paths */ 165 166 size_t picard_order; 167 double h_cond; /* Convective coefficient, i.e. lambda/delta */ 168 double h_conv; /* Condutive coefficient */ 169 double h_radi; /* Radiative coefficient */ 170 }; 171 172 #define HANDLE_EXTERNAL_NET_FLUX_ARGS_NULL__ {NULL,NULL,NULL,NULL,NULL,NULL,0,0,0,0} 173 static const struct handle_external_net_flux_args 174 HANDLE_EXTERNAL_NET_FLUX_ARGS_NULL = HANDLE_EXTERNAL_NET_FLUX_ARGS_NULL__; 175 176 extern LOCAL_SYM res_T 177 handle_external_net_flux_2d 178 (struct sdis_scene* scn, 179 struct ssp_rng* rng, 180 const struct handle_external_net_flux_args* args, 181 struct temperature* T); 182 183 extern LOCAL_SYM res_T 184 handle_external_net_flux_3d 185 (struct sdis_scene* scn, 186 struct ssp_rng* rng, 187 const struct handle_external_net_flux_args* args, 188 struct temperature* T); 189 190 /******************************************************************************* 191 * Miscellaneous functions 192 ******************************************************************************/ 193 extern LOCAL_SYM res_T 194 check_Tref_2d 195 (const struct sdis_scene* scn, 196 const double pos[2], 197 const double Tref, 198 const char* call_func_name); 199 200 extern LOCAL_SYM res_T 201 check_Tref_3d 202 (const struct sdis_scene* scn, 203 const double pos[3], 204 const double Tref, 205 const char* call_func_name); 206 207 /* Query medium temperature from the boundary. This medium can be different 208 * from the medium of the enclosure. Hence this function, which queries the 209 * medium on the path coming from a boundary. If the temperature is known, T is 210 * set to done. */ 211 extern LOCAL_SYM res_T 212 query_medium_temperature_from_boundary_2d 213 (struct sdis_scene* scn, 214 struct rwalk_context* ctx, 215 struct rwalk* rwalk, 216 struct temperature* T); 217 218 extern LOCAL_SYM res_T 219 query_medium_temperature_from_boundary_3d 220 (struct sdis_scene* scn, 221 struct rwalk_context* ctx, 222 struct rwalk* rwalk, 223 struct temperature* T); 224 225 /* Move the submitted position away from the primitive boundaries to avoid 226 * numerical issues leading to inconsistent random walks. */ 227 extern LOCAL_SYM void 228 move_away_primitive_boundaries_2d 229 (const struct s2d_hit* hit, 230 const double delta, 231 double position[2]); /* Position to move */ 232 233 extern LOCAL_SYM void 234 move_away_primitive_boundaries_3d 235 (const struct s3d_hit* hit, 236 const double delta, 237 double position[3]); /* Position to move */ 238 239 /******************************************************************************* 240 * Boundary sub-paths 241 ******************************************************************************/ 242 extern LOCAL_SYM res_T 243 solid_boundary_with_flux_path_2d 244 (struct sdis_scene* scn, 245 struct rwalk_context* ctx, 246 const struct sdis_interface_fragment* frag, 247 const double phi, 248 struct rwalk* rwalk, 249 struct ssp_rng* rng, 250 struct temperature* T); 251 252 extern LOCAL_SYM res_T 253 solid_boundary_with_flux_path_3d 254 (struct sdis_scene* scn, 255 struct rwalk_context* ctx, 256 const struct sdis_interface_fragment* frag, 257 const double phi, 258 struct rwalk* rwalk, 259 struct ssp_rng* rng, 260 struct temperature* T); 261 262 extern LOCAL_SYM res_T 263 solid_fluid_boundary_picard1_path_2d 264 (struct sdis_scene* scn, 265 struct rwalk_context* ctx, 266 const struct sdis_interface_fragment* frag, 267 struct rwalk* rwalk, 268 struct ssp_rng* rng, 269 struct temperature* T); 270 271 extern LOCAL_SYM res_T 272 solid_fluid_boundary_picard1_path_3d 273 (struct sdis_scene* scn, 274 struct rwalk_context* ctx, 275 const struct sdis_interface_fragment* frag, 276 struct rwalk* rwalk, 277 struct ssp_rng* rng, 278 struct temperature* T); 279 280 extern LOCAL_SYM res_T 281 solid_fluid_boundary_picardN_path_2d 282 (struct sdis_scene* scn, 283 struct rwalk_context* ctx, 284 const struct sdis_interface_fragment* frag, 285 struct rwalk* rwalk, 286 struct ssp_rng* rng, 287 struct temperature* T); 288 289 extern LOCAL_SYM res_T 290 solid_fluid_boundary_picardN_path_3d 291 (struct sdis_scene* scn, 292 struct rwalk_context* ctx, 293 const struct sdis_interface_fragment* frag, 294 struct rwalk* rwalk, 295 struct ssp_rng* rng, 296 struct temperature* T); 297 298 extern LOCAL_SYM res_T 299 solid_solid_boundary_path_2d 300 (struct sdis_scene* scn, 301 struct rwalk_context* ctx, 302 const struct sdis_interface_fragment* frag, 303 struct rwalk* rwalk, 304 struct ssp_rng* rng, 305 struct temperature* T); 306 307 extern LOCAL_SYM res_T 308 solid_solid_boundary_path_3d 309 (struct sdis_scene* scn, 310 struct rwalk_context* ctx, 311 const struct sdis_interface_fragment* frag, 312 struct rwalk* rwalk, 313 struct ssp_rng* rng, 314 struct temperature* T); 315 316 #endif /* SDIS_HEAT_PATH_BOUNDARY_C_H */