sdis_green.h (3546B)
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_GREEN_H 17 #define SDIS_GREEN_H 18 19 #include <rsys/hash.h> 20 #include <rsys/rsys.h> 21 22 /* Current version the green function data structure. One should increment it 23 * and perform a version management onto serialized data when the green function 24 * data structure is updated. */ 25 static const int SDIS_GREEN_FUNCTION_VERSION = 3; 26 27 /* Forward declaration */ 28 struct accum; 29 struct sdis_green_function; 30 struct ssp_rng_proxy; 31 struct green_path; 32 33 struct green_path_handle { 34 struct sdis_green_function* green; 35 struct green_path* path; 36 }; 37 #define GREEN_PATH_HANDLE_NULL__ {NULL, NULL} 38 static const struct green_path_handle GREEN_PATH_HANDLE_NULL = 39 GREEN_PATH_HANDLE_NULL__; 40 41 extern LOCAL_SYM res_T 42 green_function_create 43 (struct sdis_scene* scn, 44 const hash256_T signature, 45 struct sdis_green_function** green); 46 47 /* Merge `src' into `dst' an clear `src' */ 48 extern LOCAL_SYM res_T 49 green_function_merge_and_clear 50 (struct sdis_green_function* dst, 51 struct sdis_green_function* src); 52 53 extern LOCAL_SYM res_T 54 green_function_redux_and_clear 55 (struct sdis_green_function* dst, 56 struct sdis_green_function* greens[], 57 const size_t ngreens); 58 59 /* Finalize the green function state (e.g.: computes the #paths & #failures, 60 * save the rng state, etc.) */ 61 extern LOCAL_SYM res_T 62 green_function_finalize 63 (struct sdis_green_function* green, 64 struct ssp_rng_proxy* rng_proxy, /* Proxy RNG used to estimate the function */ 65 const struct accum* time); /* Accumulator of the realisation time */ 66 67 extern LOCAL_SYM res_T 68 green_function_create_path 69 (struct sdis_green_function* green, 70 struct green_path_handle* handle); 71 72 extern LOCAL_SYM res_T 73 green_path_set_limit_interface_fragment 74 (struct green_path_handle* path, 75 struct sdis_interface* interf, 76 const struct sdis_interface_fragment* fragment, 77 const double elapsed_time); 78 79 extern LOCAL_SYM res_T 80 green_path_set_limit_vertex 81 (struct green_path_handle* path, 82 struct sdis_medium* mdm, 83 const struct sdis_rwalk_vertex* vertex, 84 const double elapsed_time); 85 86 extern LOCAL_SYM res_T 87 green_path_set_limit_radiative_ray 88 (struct green_path_handle* handle, 89 const struct sdis_radiative_ray* ray, 90 const double elapsed_time); 91 92 extern LOCAL_SYM res_T 93 green_path_reset_limit 94 (struct green_path_handle* handle); 95 96 extern LOCAL_SYM res_T 97 green_path_add_power_term 98 (struct green_path_handle* path, 99 struct sdis_medium* mdm, 100 const struct sdis_rwalk_vertex* vertex, 101 const double term); 102 103 extern LOCAL_SYM res_T 104 green_path_add_flux_term 105 (struct green_path_handle* path, 106 struct sdis_interface* interf, 107 const struct sdis_interface_fragment* fragment, 108 const double term); 109 110 extern LOCAL_SYM res_T 111 green_path_add_external_flux_terms 112 (struct green_path_handle* handle, 113 const struct sdis_green_external_flux_terms* terms); 114 115 #endif /* SDIS_GREEN_H */ 116