stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

sdis.h (68910B)


      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_H
     17 #define SDIS_H
     18 
     19 #include <star/s2d.h>
     20 #include <star/s3d.h>
     21 #include <star/ssp.h>
     22 
     23 #include <rsys/hash.h>
     24 #include <rsys/rsys.h>
     25 
     26 #include <float.h> /* DBL_MAX */
     27 #include <limits.h> /* UINT_MAX */
     28 
     29 /* Library symbol management */
     30 #if defined(SDIS_SHARED_BUILD)
     31   #define SDIS_API extern EXPORT_SYM
     32 #elif defined(SDIS_STATIC_BUILD)
     33   #define SDIS_API extern LOCAL_SYM
     34 #else /* Use shared library */
     35   #define SDIS_API extern IMPORT_SYM
     36 #endif
     37 
     38 /* Helper macro that asserts if the invocation of the Stardis function `Func'
     39  * returns an error. One should use this macro on Stardis function calls for
     40  * which no explicit error checking is performed. */
     41 #ifndef NDEBUG
     42   #define SDIS(Func) ASSERT(sdis_ ## Func == RES_OK)
     43 #else
     44   #define SDIS(Func) sdis_ ## Func
     45 #endif
     46 
     47 /* Syntactic sugar used to inform the library that it can use as many threads
     48  * as CPU cores */
     49 #define SDIS_NTHREADS_DEFAULT (~0u)
     50 
     51 #define SDIS_VOLUMIC_POWER_NONE DBL_MAX /* <=> No volumic power */
     52 #define SDIS_FLUX_NONE DBL_MAX /* <=> No flux */
     53 #define SDIS_PRIMITIVE_NONE SIZE_MAX /* Invalid primitive */
     54 
     55 /* Syntactic sugar used to define whether a temperature is known or not */
     56 #define SDIS_TEMPERATURE_NONE NaN /* Unknown temperature */
     57 #define SDIS_TEMPERATURE_IS_KNOWN(Temp) (!IS_NaN(Temp))
     58 #define SDIS_TEMPERATURE_IS_UNKNOWN(Temp) (IS_NaN(Temp))
     59 
     60 /* Identifier of the internal source of radiation */
     61 #define SDIS_INTERN_SOURCE_ID UINT_MAX
     62 
     63 /* Forward declaration of external opaque data types */
     64 struct logger;
     65 struct mem_allocator;
     66 struct senc2d_scene;
     67 struct senc3d_scene;
     68 
     69 /* Forward declaration of the Stardis opaque data types. These data types are
     70  * ref counted. Once created the caller implicitly owns the created data, i.e.
     71  * its reference counter is set to 1. The sdis_<TYPE>_ref_<get|put> functions
     72  * get or release a reference on the data, i.e. they increment or decrement the
     73  * reference counter, respectively. When this counter reaches 0, the object is
     74  * silently destroyed and cannot be used anymore. */
     75 struct sdis_camera;
     76 struct sdis_data;
     77 struct sdis_device;
     78 struct sdis_estimator;
     79 struct sdis_estimator_buffer;
     80 struct sdis_green_function;
     81 struct sdis_interface;
     82 struct sdis_medium;
     83 struct sdis_radiative_env; /* Radiative environment */
     84 struct sdis_scene;
     85 struct sdis_source;
     86 
     87 /* Forward declaration of non ref counted types */
     88 struct sdis_green_path;
     89 struct sdis_heat_path;
     90 
     91 /*******************************************************************************
     92  * Miscellaneous data types
     93  ******************************************************************************/
     94 enum sdis_side {
     95   SDIS_FRONT,
     96   SDIS_BACK,
     97   SDIS_SIDE_NULL__
     98 };
     99 
    100 enum sdis_scene_dimension {
    101   SDIS_SCENE_2D,
    102   SDIS_SCENE_3D
    103 };
    104 
    105 enum sdis_diffusion_algorithm {
    106   SDIS_DIFFUSION_DELTA_SPHERE,
    107   SDIS_DIFFUSION_WOS, /* Walk on Sphere */
    108   SDIS_DIFFUSION_ALGORITHMS_COUNT__,
    109   SDIS_DIFFUSION_NONE = SDIS_DIFFUSION_ALGORITHMS_COUNT__
    110 };
    111 
    112 /* Random walk vertex, i.e. a spatio-temporal position at a given step of the
    113  * random walk. */
    114 struct sdis_rwalk_vertex {
    115   double P[3]; /* World space position */
    116   double time; /* "Time" of the vertex */
    117 };
    118 #define SDIS_RWALK_VERTEX_NULL__ {{0}, -1}
    119 static const struct sdis_rwalk_vertex SDIS_RWALK_VERTEX_NULL =
    120   SDIS_RWALK_VERTEX_NULL__;
    121 
    122 /* Spatio-temporal position onto an interface. As a random walk vertex, it
    123  * stores the position and time of the random walk, but since it lies onto an
    124  * interface, it has additionnal parameters as the normal of the interface and
    125  * the parametric coordinate of the position onto the interface */
    126 struct sdis_interface_fragment {
    127   double P[3]; /* World space position */
    128   double Ng[3]; /* Normalized world space geometry normal at the interface */
    129   double uv[2]; /* Parametric coordinates of the interface */
    130   double time; /* Current time */
    131   enum sdis_side side;
    132 };
    133 #define SDIS_INTERFACE_FRAGMENT_NULL__ {{0}, {0}, {0}, -1, SDIS_SIDE_NULL__}
    134 static const struct sdis_interface_fragment SDIS_INTERFACE_FRAGMENT_NULL =
    135   SDIS_INTERFACE_FRAGMENT_NULL__;
    136 
    137 /* Ray traced in radiative environment */
    138 struct sdis_radiative_ray {
    139   double dir[3]; /* Direction */
    140   double time; /* Time */
    141 };
    142 #define SDIS_RADIATIVE_RAY_NULL__ {{0,0,0}, DBL_MAX}
    143 static const struct sdis_radiative_ray SDIS_RADIATIVE_RAY_NULL=
    144   SDIS_RADIATIVE_RAY_NULL__;
    145 
    146 /* Input arguments of the sdis_device_create function */
    147 struct sdis_device_create_args {
    148   struct logger* logger; /* NULL <=> default logger */
    149   struct mem_allocator* allocator; /* NULL <=> default allocator */
    150   unsigned nthreads_hint; /* Hint on the number of threads to use */
    151   int verbosity; /* Verbosity level */
    152   int no_escape_sequence; /* Rm escape sequences from log messages */
    153 
    154   /* Use the Message Passing Interface to distribute work between processes.
    155    * This option is taken into account only if Stardis-Solver is compiled with
    156    * MPI support */
    157   int use_mpi;
    158 };
    159 #define SDIS_DEVICE_CREATE_ARGS_DEFAULT__ {                                    \
    160   NULL, NULL, SDIS_NTHREADS_DEFAULT, 1, 0, 0                                   \
    161 }
    162 static const struct sdis_device_create_args SDIS_DEVICE_CREATE_ARGS_DEFAULT =
    163   SDIS_DEVICE_CREATE_ARGS_DEFAULT__;
    164 
    165 /* Informations on the Stardis-Solver library */
    166 struct sdis_info {
    167   int mpi_enabled; /* Define if Stardis-Solver was built with MPI support */
    168 };
    169 #define SDIS_INFO_NULL__ {0}
    170 static const struct sdis_info SDIS_INFO_NULL = SDIS_INFO_NULL__;
    171 
    172 /* Type of functor used to retrieve the source's position relative to time */
    173 typedef void
    174 (*sdis_get_position_T)
    175   (const double time, /* [s] */
    176    double pos[3],
    177    struct sdis_data* data);
    178 
    179 /* Type of functor used to retrieve the source's power relative to time */
    180 typedef double
    181 (*sdis_get_power_T)
    182   (const double time, /* [s] */
    183    struct sdis_data* data);
    184 
    185 /* Type of functor used to retrieve the diffuse part of the external radiance */
    186 typedef double /* [W/perpendicular m^2/sr] */
    187 (*sdis_get_diffuse_radiance_T)
    188   (const double time, /* [s] */
    189    const double dir[3],
    190    struct sdis_data* data);
    191 
    192 /* Parameters of an external spherical source */
    193 struct sdis_spherical_source_shader {
    194   sdis_get_position_T position; /* [m/fp_to_meter] */
    195   sdis_get_power_T power; /* Total power [W] */
    196 
    197   /* Describes the diffuse part of the source's radiance, i.e. the radiance
    198    * emitted by the source and scattered at least once in the environment. This
    199    * parameter is actually used to approximate a semi-transparent medium. Its
    200    * value can be NULL, meaning that the source has not been scattered by the
    201    * environment, or, to put it another way, that the source is in a vacuum. */
    202   sdis_get_diffuse_radiance_T diffuse_radiance; /* [W/m^2/sr] */
    203 
    204   double radius; /* [m] */
    205 };
    206 #define SDIS_SPHERICAL_SOURCE_SHADER_NULL__ {NULL, NULL, NULL, 0}
    207 static const struct sdis_spherical_source_shader
    208 SDIS_SPHERICAL_SOURCE_SHADER_NULL = SDIS_SPHERICAL_SOURCE_SHADER_NULL__;
    209 
    210 struct sdis_scene_find_closest_point_args {
    211   double position[3]; /* Query position */
    212   double radius; /* Maxium search distance around pos */
    213 
    214   /* User defined filter function */
    215   s2d_hit_filter_function_T filter_2d;
    216   s3d_hit_filter_function_T filter_3d;
    217   void* filter_data; /* Filter function data */
    218 };
    219 #define SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL__ {{0,0,0}, 0, NULL, NULL, NULL}
    220 static const struct sdis_scene_find_closest_point_args
    221 SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL = SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL__;
    222 
    223 /* A sampled path */
    224 struct sdis_path {
    225   struct sdis_rwalk_vertex vtx; /* Current position and time */
    226 
    227   /* Surface intersected by the path. When defined, the path is on a border */
    228   struct s2d_primitive prim_2d;
    229   struct s3d_primitive prim_3d;
    230 
    231   double weight; /* Monte Carlo weight update along the path */
    232 
    233   /* Define whether the path has reached a boundary condition in time/space */
    234   int at_limit;
    235 };
    236 #define SDIS_PATH_NULL__ {                                                     \
    237   SDIS_RWALK_VERTEX_NULL__,                                                    \
    238   S2D_PRIMITIVE_NULL__,                                                        \
    239   S3D_PRIMITIVE_NULL__,                                                        \
    240   0, /* MC weight */                                                           \
    241   0 /* At limit */                                                             \
    242 }
    243 static const struct sdis_path SDIS_PATH_NULL = SDIS_PATH_NULL__;
    244 
    245 /* Type of functor used by the user to write the way in which the path is
    246  * sampled. So it's no longer Stardis that samples the path, but the user
    247  * through his own function. */
    248 typedef res_T
    249 (*sdis_sample_path_T)
    250   (struct sdis_scene* scn,
    251    struct ssp_rng* rng,
    252    struct sdis_path* path,
    253    struct sdis_data* data);
    254 
    255 /* Key to a geometric primitive, i.e its unique identifier. Its member variables
    256  * must be treated as private variables, i.e. the caller must not access them
    257  * directly but use the primkey API functions instead (see below) */
    258 struct sdis_primkey {
    259   /* List of primitive nodes sorted in ascending order */
    260   double nodes[9];
    261 
    262   /* Overall number of coordinates (4 in 2D, 9 in 3D) */
    263   unsigned ncoords;
    264 };
    265 #define SDIS_PRIMKEY_NULL__ {{0,0,0,0,0,0,0,0,0},0}
    266 static const struct sdis_primkey SDIS_PRIMKEY_NULL = SDIS_PRIMKEY_NULL__;
    267 
    268 /*******************************************************************************
    269  * Estimation data types
    270  ******************************************************************************/
    271 enum sdis_estimator_type {
    272   SDIS_ESTIMATOR_TEMPERATURE, /* In Kelvin */
    273   SDIS_ESTIMATOR_FLUX, /* In Watt/m^2 */
    274   SDIS_ESTIMATOR_POWER, /* In Watt */
    275   SDIS_ESTIMATOR_TYPES_COUNT__
    276 };
    277 
    278 /* Monte-Carlo estimation */
    279 struct sdis_mc {
    280   double E; /* Expected value */
    281   double V; /* Variance */
    282   double SE; /* Standard error */
    283 };
    284 #define SDIS_MC_NULL__ {0, 0, 0}
    285 static const struct sdis_mc SDIS_MC_NULL = SDIS_MC_NULL__;
    286 
    287 /*******************************************************************************
    288  * Data type used to describe physical properties
    289  ******************************************************************************/
    290 enum sdis_medium_type {
    291   SDIS_FLUID,
    292   SDIS_SOLID,
    293   SDIS_MEDIUM_TYPES_COUNT__
    294 };
    295 
    296 /* Functor type used to retrieve the spatio temporal physical properties of a
    297  * medium. */
    298 typedef double
    299 (*sdis_medium_getter_T)
    300   (const struct sdis_rwalk_vertex* vert, /* Medium position */
    301    struct sdis_data* data); /* User data */
    302 
    303 /* Functor type used to retrieve the spatio temporal physical properties of an
    304  * interface. */
    305 typedef double
    306 (*sdis_interface_getter_T)
    307   (const struct sdis_interface_fragment* frag, /* Interface position */
    308    struct sdis_data* data); /* User data */
    309 
    310 /* Type of functor for obtaining the spatio temporal physical properties of an
    311  * interface, as a function of the radiation source */
    312 typedef double
    313 (*sdis_radiative_interface_getter_T)
    314   (const struct sdis_interface_fragment* frag, /* Interface position */
    315    const unsigned source_id, /* Identifier of the radiation source */
    316    struct sdis_data* data); /* User data */
    317 
    318 /* Type of functor for obtaining radiative environment properties */
    319 typedef double
    320 (*sdis_radiative_ray_getter_T)
    321   (const struct sdis_radiative_ray* ray,
    322    struct sdis_data* data);
    323 
    324 /* Define the physical properties of a solid */
    325 struct sdis_solid_shader {
    326   /* Properties */
    327   sdis_medium_getter_T calorific_capacity; /* In J.K^-1.kg^-1 */
    328   sdis_medium_getter_T thermal_conductivity; /* In W.m^-1.K^-1 */
    329   sdis_medium_getter_T volumic_mass; /* In kg.m^-3 */
    330   sdis_medium_getter_T delta;
    331 
    332   /* May be NULL if there is no volumic power. One can also return
    333    * SDIS_VOLUMIC_POWER_NONE to define that there is no volumic power at the
    334    * submitted position and time */
    335   sdis_medium_getter_T volumic_power;  /* In W.m^-3 */
    336 
    337   /* Initial/limit condition. A temperature set to SDIS_TEMPERATURE_NONE
    338    * means that the temperature is unknown for the submitted random walk vertex.
    339    * This getter is always called at time >= t0 (see below). */
    340   sdis_medium_getter_T temperature;
    341 
    342   /* Function to be used to sample the path through the solid. If not defined,
    343    * let stardis sample a conductive path */
    344   sdis_sample_path_T sample_path;
    345 
    346   /* The time until the initial condition is maintained for this solid.
    347    * Can be negative or set to +/- infinity to simulate a system that is always
    348    * in the initial state or never reaches it, respectively. */
    349   double t0;
    350 };
    351 #define SDIS_SOLID_SHADER_NULL__ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}
    352 static const struct sdis_solid_shader SDIS_SOLID_SHADER_NULL =
    353   SDIS_SOLID_SHADER_NULL__;
    354 
    355 /* Define the physical properties of a fluid */
    356 struct sdis_fluid_shader {
    357   /* Properties */
    358   sdis_medium_getter_T calorific_capacity; /* In J.K^-1.kg^-1 */
    359   sdis_medium_getter_T volumic_mass; /* In kg.m^-3 */
    360 
    361   /* Initial/limit condition. A temperature set to SDIS_TEMPERATURE_NONE
    362    * means that the temperature is unknown for the submitted random walk vertex.
    363    * This getter is always called at time >= t0 (see below). */
    364   sdis_medium_getter_T temperature;
    365 
    366   /* The time until the initial condition is maintained for this fluid.
    367    * Can be negative or set to +/- infinity to simulate a system that is always
    368    * in the initial state or never reaches it, respectively. */
    369   double t0;
    370 };
    371 #define SDIS_FLUID_SHADER_NULL__ {NULL, NULL, NULL, 0}
    372 static const struct sdis_fluid_shader SDIS_FLUID_SHADER_NULL =
    373   SDIS_FLUID_SHADER_NULL__;
    374 
    375 /* Define the physical properties of one side of an interface. */
    376 struct sdis_interface_side_shader {
    377   /* Fixed temperature/flux. May be NULL if the temperature/flux is unknown
    378    * onto the whole interface */
    379   sdis_interface_getter_T temperature; /* [K]. SDIS_TEMPERATURE_NONE = Unknown */
    380   sdis_interface_getter_T flux; /* Toward solid. [W.m^-2]. SDIS_FLUX_NONE = no flux */
    381 
    382   /* Control the emissivity of the interface. May be NULL for solid/solid
    383    * interface or if the emissivity is 0 onto the whole interface. */
    384   sdis_radiative_interface_getter_T emissivity; /* Overall emissivity */
    385   sdis_radiative_interface_getter_T specular_fraction; /* Specular part in [0,1] */
    386 
    387   /* Reference temperature used in Picard 1 */
    388   sdis_interface_getter_T reference_temperature;
    389 
    390   /* Define whether external sources interact with the interface, i.e. whether
    391    * external fluxes should be processed or not */
    392   int handle_external_flux;
    393 };
    394 #define SDIS_INTERFACE_SIDE_SHADER_NULL__ { NULL, NULL, NULL, NULL, NULL, 1 }
    395 static const struct sdis_interface_side_shader SDIS_INTERFACE_SIDE_SHADER_NULL =
    396   SDIS_INTERFACE_SIDE_SHADER_NULL__;
    397 
    398 /* Define the physical properties of an interface between 2 media .*/
    399 struct sdis_interface_shader {
    400   /* May be NULL for solid/solid or if the convection coefficient is 0 onto
    401    * the whole interface. */
    402   sdis_interface_getter_T convection_coef;  /* In W.K^-1.m^-2 */
    403   /* Under no circumstance can convection_coef() return outside of
    404    * [0 convection_coef_upper_bound] */
    405   double convection_coef_upper_bound;
    406 
    407   /* May be NULL for solid/fluid or if the thermal contact resistance is 0 onto
    408    * the whole interface. */
    409   sdis_interface_getter_T thermal_contact_resistance;  /* In K.m^2.W^-1 */
    410 
    411   struct sdis_interface_side_shader front;
    412   struct sdis_interface_side_shader back;
    413 };
    414 #define SDIS_INTERFACE_SHADER_NULL__ \
    415   {NULL, 0, NULL, SDIS_INTERFACE_SIDE_SHADER_NULL__, \
    416    SDIS_INTERFACE_SIDE_SHADER_NULL__}
    417 static const struct sdis_interface_shader SDIS_INTERFACE_SHADER_NULL =
    418   SDIS_INTERFACE_SHADER_NULL__;
    419 
    420 /* Parameters of a radiative environment */
    421 struct sdis_radiative_env_shader {
    422   sdis_radiative_ray_getter_T temperature; /* [K] */
    423   sdis_radiative_ray_getter_T reference_temperature; /* [K] */
    424 };
    425 #define SDIS_RADIATIVE_ENV_SHADER_NULL__ {NULL, NULL}
    426 static const struct sdis_radiative_env_shader SDIS_RADIATIVE_ENV_SHADER_NULL =
    427   SDIS_RADIATIVE_ENV_SHADER_NULL__;
    428 
    429 /*******************************************************************************
    430  * Registered heat path data types
    431  ******************************************************************************/
    432 enum sdis_heat_vertex_type {
    433   SDIS_HEAT_VERTEX_CONDUCTION,
    434   SDIS_HEAT_VERTEX_CONVECTION,
    435   SDIS_HEAT_VERTEX_RADIATIVE
    436 };
    437 
    438 enum sdis_heat_path_flag {
    439   SDIS_HEAT_PATH_SUCCESS = BIT(0),
    440   SDIS_HEAT_PATH_FAILURE = BIT(1),
    441   SDIS_HEAT_PATH_ALL = SDIS_HEAT_PATH_SUCCESS | SDIS_HEAT_PATH_FAILURE,
    442   SDIS_HEAT_PATH_NONE = 0
    443 };
    444 
    445 /* Vertex of heat path */
    446 struct sdis_heat_vertex {
    447   double P[3];
    448   double time;
    449   double weight;
    450   enum sdis_heat_vertex_type type;
    451   int branch_id;
    452 };
    453 #define SDIS_HEAT_VERTEX_NULL__ {{0,0,0}, 0, 0, SDIS_HEAT_VERTEX_CONDUCTION, 0}
    454 static const struct sdis_heat_vertex SDIS_HEAT_VERTEX_NULL =
    455   SDIS_HEAT_VERTEX_NULL__;
    456 
    457 /* Functor used to process a heat path registered against the estimator */
    458 typedef res_T
    459 (*sdis_process_heat_path_T)
    460   (const struct sdis_heat_path* path,
    461    void* context);
    462 
    463 /* Functor used to process the vertices of a heat path */
    464 typedef res_T
    465 (*sdis_process_heat_vertex_T)
    466   (const struct sdis_heat_vertex* vertex,
    467    void* context);
    468 
    469 /*******************************************************************************
    470  * Green function data types
    471  ******************************************************************************/
    472 enum sdis_green_path_end_type {
    473   SDIS_GREEN_PATH_END_AT_INTERFACE,
    474   SDIS_GREEN_PATH_END_AT_RADIATIVE_ENV,
    475   SDIS_GREEN_PATH_END_IN_VOLUME,
    476   SDIS_GREEN_PATH_END_TYPES_COUNT__,
    477   SDIS_GREEN_PATH_END_ERROR = SDIS_GREEN_PATH_END_TYPES_COUNT__
    478 };
    479 
    480 /* Spatio temporal point */
    481 struct sdis_green_path_end {
    482   union {
    483     /* Path end in volume */
    484     struct {
    485       struct sdis_medium* medium;
    486       struct sdis_rwalk_vertex vertex;
    487     } mdmvert;
    488     /* Path end at interface */
    489     struct {
    490       struct sdis_interface* intface;
    491       struct sdis_interface_fragment fragment;
    492     } itfrag;
    493     /* Path end in radiative environement */
    494     struct {
    495       struct sdis_radiative_env* radenv;
    496       struct sdis_radiative_ray ray;
    497     } radenvray;
    498   } data;
    499   enum sdis_green_path_end_type type;
    500 };
    501 #define SDIS_GREEN_PATH_END_NULL__ {                                           \
    502   {{NULL, SDIS_RWALK_VERTEX_NULL__}},                                          \
    503   SDIS_GREEN_PATH_END_ERROR                                                    \
    504 }
    505 static const struct sdis_green_path_end SDIS_GREEN_PATH_END_NULL =
    506   SDIS_GREEN_PATH_END_NULL__;
    507 
    508 struct sdis_green_external_flux_terms {
    509   /* Term relative to source power [K/W] */
    510   double term_wrt_power;
    511 
    512   /* Term relative to diffuse source radiance [K/W/m^2/sr] */
    513   double term_wrt_diffuse_radiance;
    514 
    515   double time; /* [s] */
    516   double dir[3]; /* Direction on which term_wrt_diffuse_radiance depends */
    517 };
    518 #define SDIS_GREEN_EXTERNAL_FLUX_TERMS_NULL__ {0,0,0,{0,0,0}}
    519 static const struct sdis_green_external_flux_terms
    520 SDIS_GREEN_EXTERNAL_FLUX_TERMS_NULL = SDIS_GREEN_EXTERNAL_FLUX_TERMS_NULL__;
    521 
    522 /* Function profile used to process the paths stored in the green function */
    523 typedef res_T
    524 (*sdis_process_green_path_T)
    525   (struct sdis_green_path* path,
    526    void* context);
    527 
    528 /* Function profile used to process power factors registered along a green path
    529  * for a given medium */
    530 typedef res_T
    531 (*sdis_process_medium_power_term_T)
    532   (struct sdis_medium* medium,
    533    const double power_term, /* [K/W] */
    534    void* context);
    535 
    536 /* Function profile used to process flux factors recorded along a green path for
    537  * a given interface side */
    538 typedef res_T
    539 (*sdis_process_interface_flux_term_T)
    540   (struct sdis_interface* interf,
    541    const enum sdis_side side,
    542    const double flux_term, /* [K/W/m^2] */
    543    void* context);
    544 
    545 /* Function profile used to process external flux factors recorded along a green
    546  * path */
    547 typedef res_T
    548 (*sdis_process_external_flux_terms_T)
    549   (struct sdis_source* source,
    550    const struct sdis_green_external_flux_terms* terms,
    551    void* context);
    552 
    553 /*******************************************************************************
    554  * Data types of scene creation
    555  ******************************************************************************/
    556 /* Functor used to retrieve the indices toward the vertices of a geometric
    557  * primitive. Geometric primitive means for segment in 2D and triangle in 3D */
    558 typedef void
    559 (*sdis_get_primitive_indices_T)
    560   (const size_t iprim, /* Index of the primitive */
    561    size_t ids[], /* Output list of primitive indices */
    562    void* ctx); /* User defined data */
    563 
    564 /* Retrieve the interface, i.e. the physical properties,  associated to a given
    565  * geometric primitive */
    566 typedef void
    567 (*sdis_get_primitive_interface_T)
    568   (const size_t iprim, /* Index of the primitive */
    569    struct sdis_interface** interf,
    570    void* ctx);
    571 
    572 /* Retrieve the coordinates of a vertex */
    573 typedef void
    574 (*sdis_get_vertex_position_T)
    575   (const size_t ivert, /* Index of the vertex */
    576    double pos[], /* Output list of vertex coordinates */
    577    void* ctx);
    578 
    579 struct sdis_scene_create_args {
    580   /* Functors to retrieve the geometric description */
    581   sdis_get_primitive_indices_T get_indices;
    582   sdis_get_primitive_interface_T get_interface;
    583   sdis_get_vertex_position_T get_position;
    584 
    585   /* Pointer toward client side sent as the last argument of the callbacks */
    586   void* context;
    587 
    588   size_t nprimitives; /* #primitives, i.e. #segments or #triangles */
    589   size_t nvertices; /* #vertices */
    590   double fp_to_meter; /* Scale factor used to convert a float in meter */
    591 
    592   /* Min/max temperature used to linearise the radiative temperature */
    593   double t_range[2];
    594 
    595   /* External source. Can be NULL <=> no external flux will be calculated on
    596    * scene interfaces */
    597   struct sdis_source* source;
    598 
    599   /* Radiative environment. Can be NULL <=> sampled radiative trajectories
    600    * cannot (in fact must not) reach the surrounding environment */
    601   struct sdis_radiative_env* radenv;
    602 };
    603 
    604 #define SDIS_SCENE_CREATE_ARGS_DEFAULT__ {                                     \
    605   NULL, /* Get indices */                                                      \
    606   NULL, /* Get interfaces */                                                   \
    607   NULL, /* Get position */                                                     \
    608   NULL, /* Context */                                                          \
    609   0, /* #primitives */                                                         \
    610   0, /* #vertices */                                                           \
    611   1.0, /* #Floating point to meter scale factor */                             \
    612   {SDIS_TEMPERATURE_NONE, SDIS_TEMPERATURE_NONE}, /* Temperature range */      \
    613   NULL, /* source */                                                           \
    614   NULL /* Radiative environement */                                            \
    615 }
    616 static const struct sdis_scene_create_args SDIS_SCENE_CREATE_ARGS_DEFAULT =
    617   SDIS_SCENE_CREATE_ARGS_DEFAULT__;
    618 
    619 /*******************************************************************************
    620  * Data types of the input simulation parameters
    621  ******************************************************************************/
    622 struct sdis_solve_probe_args {
    623   size_t nrealisations; /* #realisations */
    624   double position[3]; /* Probe position */
    625   double time_range[2]; /* Observation time */
    626 
    627   /* Set the Picard recursion order to estimate the radiative temperature. An
    628    * order of one means that the radiative temperature is linearized, while
    629    * higher orders allow the estimation of the T4 radiative transfer. */
    630   size_t picard_order;
    631 
    632   int register_paths; /* Combination of enum sdis_heat_path_flag */
    633   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    634   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    635 
    636   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    637 
    638   /* Signature of the estimated green function. The signature is ignored in an
    639    * ordinary probe estimation. The signature of the green function can be
    640    * queried to verify that it is the expected one with respect to the caller's
    641    * constraints that the green function cannot otherwise ensure */
    642   hash256_T signature;
    643 };
    644 #define SDIS_SOLVE_PROBE_ARGS_DEFAULT__ {                                      \
    645   10000, /* #realisations */                                                   \
    646   {0,0,0}, /* Position  */                                                     \
    647   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    648   1, /* Picard order */                                                        \
    649   SDIS_HEAT_PATH_NONE, /* Register paths mask */                               \
    650   NULL, /* RNG state */                                                        \
    651   SSP_RNG_THREEFRY, /* RNG type */                                             \
    652   SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */                       \
    653   {0} /* Signature */                                                          \
    654 }
    655 static const struct sdis_solve_probe_args SDIS_SOLVE_PROBE_ARGS_DEFAULT =
    656   SDIS_SOLVE_PROBE_ARGS_DEFAULT__;
    657 
    658 struct sdis_solve_probe_list_args {
    659   struct sdis_solve_probe_args* probes; /* List of probes to compute */
    660   size_t nprobes; /* Total number of probes */
    661 
    662   /* State/type of the RNG to use for the list of probes to calculate.
    663    * The state/type defines per probe is ignored */
    664   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    665   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    666 };
    667 #define SDIS_SOLVE_PROBE_LIST_ARGS_DEFAULT__ {                                 \
    668   NULL, /* List of probes */                                                   \
    669   0, /* #probes */                                                             \
    670   NULL, /* RNG state */                                                        \
    671   SSP_RNG_THREEFRY /* RNG type */                                              \
    672 }
    673 static const struct sdis_solve_probe_list_args
    674 SDIS_SOLVE_PROBE_LIST_ARGS_DEFAULT = SDIS_SOLVE_PROBE_LIST_ARGS_DEFAULT__;
    675 
    676 /* Arguments of a probe simulation */
    677 struct sdis_solve_probe_boundary_args {
    678   size_t nrealisations; /* #realisations */
    679   size_t iprim; /* Identifier of the primitive on which the probe lies */
    680   double uv[2]; /* Parametric coordinates of the probe onto the primitve */
    681   double time_range[2]; /* Observation time */
    682 
    683   /* Set the Picard recursion order to estimate the radiative temperature. An
    684    * order of one means that the radiative temperature is linearized, while
    685    * higher orders allow the estimation of the T4 radiative transfer. */
    686   size_t picard_order;
    687 
    688   enum sdis_side side; /* Side of iprim on which the probe lies */
    689   int register_paths; /* Combination of enum sdis_heat_path_flag */
    690   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    691   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    692 
    693   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    694 
    695   /* Signature of the estimated green function. The signature is ignored in an
    696    * ordinary probe estimation. The signature of the green function can be
    697    * queried to verify that it is the expected one with respect to the caller's
    698    * constraints that the green function cannot otherwise ensure */
    699   hash256_T signature;
    700 };
    701 #define SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT__ {                             \
    702   10000, /* #realisations */                                                   \
    703   0, /* Primitive identifier */                                                \
    704   {0,0}, /* UV */                                                              \
    705   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    706   1, /* Picard order */                                                        \
    707   SDIS_SIDE_NULL__,                                                            \
    708   SDIS_HEAT_PATH_NONE,                                                         \
    709   NULL, /* RNG state */                                                        \
    710   SSP_RNG_THREEFRY, /* RNG type */                                             \
    711   SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */                       \
    712   {0} /* Signature */                                                          \
    713 }
    714 static const struct sdis_solve_probe_boundary_args
    715 SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT =
    716   SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT__;
    717 
    718 /* Input arguments of the solve function that distributes the calculations of
    719  * several boundary probes rather than the realizations of a probe */
    720 struct sdis_solve_probe_boundary_list_args {
    721   struct sdis_solve_probe_boundary_args* probes; /* List of probes to compute */
    722   size_t nprobes; /* Total number of probes */
    723 
    724   /* State/type of the RNG to use for the list of probes to calculate.
    725    * The state/type defines per probe is ignored */
    726   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    727   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    728 };
    729 #define SDIS_SOLVE_PROBE_BOUNDARY_LIST_ARGS_DEFAULT__ {                        \
    730   NULL, /* List of probes */                                                   \
    731   0, /* #probes */                                                             \
    732   NULL, /* RNG state */                                                        \
    733   SSP_RNG_THREEFRY /* RNG type */                                              \
    734 }
    735 static const struct sdis_solve_probe_boundary_list_args
    736 SDIS_SOLVE_PROBE_BOUNDARY_LIST_ARGS_DEFAULT =
    737   SDIS_SOLVE_PROBE_BOUNDARY_LIST_ARGS_DEFAULT__;
    738 
    739 struct sdis_solve_boundary_args {
    740   size_t nrealisations; /* #realisations */
    741   const size_t* primitives; /* List of boundary primitives to handle */
    742   const enum sdis_side* sides; /* Per primitive side to consider */
    743   size_t nprimitives; /* #primitives */
    744   double time_range[2]; /* Observation time */
    745 
    746   /* Set the Picard recursion order to estimate the radiative temperature. An
    747    * order of one means that the radiative temperature is linearized, while
    748    * higher orders allow the estimation of the T4 radiative transfer. */
    749   size_t picard_order;
    750 
    751   int register_paths; /* Combination of enum sdis_heat_path_flag */
    752   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    753   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    754 
    755   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    756 
    757   /* Signature of the estimated green function. The signature is ignored in an
    758    * ordinary probe estimation. The signature of the green function can be
    759    * queried to verify that it is the expected one with respect to the caller's
    760    * constraints that the green function cannot otherwise ensure */
    761   hash256_T signature;
    762 };
    763 #define SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT__ {                                   \
    764   10000, /* #realisations */                                                   \
    765   NULL, /* List or primitive ids */                                            \
    766   NULL, /* Per primitive side */                                               \
    767   0, /* #primitives */                                                         \
    768   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    769   1, /* Picard order */                                                        \
    770   SDIS_HEAT_PATH_NONE,                                                         \
    771   NULL, /* RNG state */                                                        \
    772   SSP_RNG_THREEFRY, /* RNG type */                                             \
    773   SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */                       \
    774   {0} /* Signature */                                                          \
    775 }
    776 static const struct sdis_solve_boundary_args SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT =
    777   SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT__;
    778 
    779 struct sdis_solve_medium_args {
    780   size_t nrealisations; /* #realisations */
    781   struct sdis_medium* medium; /* Medium to solve */
    782   double time_range[2]; /* Observation time */
    783 
    784   /* Set the Picard recursion order to estimate the radiative temperature. An
    785    * order of one means that the radiative temperature is linearized, while
    786    * higher orders allow the estimation of the T4 radiative transfer. */
    787   size_t picard_order;
    788 
    789   int register_paths; /* Combination of enum sdis_heat_path_flag */
    790   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    791   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    792 
    793   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    794 
    795   /* Signature of the estimated green function. The signature is ignored in an
    796    * ordinary probe estimation. The signature of the green function can be
    797    * queried to verify that it is the expected one with respect to the caller's
    798    * constraints that the green function cannot otherwise ensure */
    799   hash256_T signature;
    800 };
    801 #define SDIS_SOLVE_MEDIUM_ARGS_DEFAULT__ {                                     \
    802   10000, /* #realisations */                                                   \
    803   NULL, /* Medium */                                                           \
    804   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    805   1, /* Picard order */                                                        \
    806   SDIS_HEAT_PATH_NONE,                                                         \
    807   NULL, /* RNG state */                                                        \
    808   SSP_RNG_THREEFRY, /* RNG type */                                             \
    809   SDIS_DIFFUSION_DELTA_SPHERE, /* Diffusion algorithm */                       \
    810   {0} /* Signature */                                                          \
    811 }
    812 static const struct sdis_solve_medium_args SDIS_SOLVE_MEDIUM_ARGS_DEFAULT =
    813   SDIS_SOLVE_MEDIUM_ARGS_DEFAULT__;
    814 
    815 struct sdis_solve_probe_boundary_flux_args {
    816   size_t nrealisations; /* #realisations */
    817   size_t iprim; /* Identifier of the primitive on which the probe lies */
    818   double uv[2]; /* Parametric coordinates of the probe onto the primitive */
    819   double time_range[2]; /* Observation time */
    820 
    821   /* Set the Picard recursion order to estimate the radiative temperature. An
    822    * order of one means that the radiative temperature is linearized, while
    823    * higher orders allow the estimation of the T4 radiative transfer. */
    824   size_t picard_order;
    825 
    826   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    827   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    828 
    829   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    830 };
    831 #define SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT__ {                        \
    832   10000, /* #realisations */                                                   \
    833   0, /* Primitive identifier */                                                \
    834   {0,0}, /* UV */                                                              \
    835   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    836   1, /* Picard order */                                                        \
    837   NULL, /* RNG state */                                                        \
    838   SSP_RNG_THREEFRY, /* RNG type */                                             \
    839   SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */                        \
    840 }
    841 static const struct sdis_solve_probe_boundary_flux_args
    842 SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT =
    843   SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT__;
    844 
    845 struct sdis_solve_boundary_flux_args {
    846   size_t nrealisations; /* #realisations */
    847   const size_t* primitives; /* List of boundary primitives to handle */
    848   size_t nprimitives; /* #primitives */
    849   double time_range[2]; /* Observation time */
    850 
    851   /* Set the Picard recursion order to estimate the radiative temperature. An
    852    * order of one means that the radiative temperature is linearized, while
    853    * higher orders allow the estimation of the T4 radiative transfer. */
    854   size_t picard_order;
    855 
    856   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    857   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    858 
    859   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    860 };
    861 #define SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT__ {                              \
    862   10000, /* #realisations */                                                   \
    863   NULL, /* List or primitive ids */                                            \
    864   0, /* #primitives */                                                         \
    865   {DBL_MAX, DBL_MAX}, /* Time range */                                         \
    866   1, /* Picard order */                                                        \
    867   NULL, /* RNG state */                                                        \
    868   SSP_RNG_THREEFRY, /* RNG type */                                             \
    869   SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */                        \
    870 }
    871 static const struct sdis_solve_boundary_flux_args
    872 SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT =
    873   SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT__;
    874 
    875 struct sdis_solve_camera_args {
    876   struct sdis_camera* cam; /* Point of view */
    877   double time_range[2]; /* Observation time */
    878 
    879   /* Set the Picard recursion order to estimate the radiative temperature. An
    880    * order of one means that the radiative temperature is linearized, while
    881    * higher orders allow the estimation of the T4 radiative transfer. */
    882   size_t picard_order;
    883 
    884   size_t image_definition[2]; /* Image definition */
    885   size_t spp; /* #samples per pixel */
    886   int register_paths; /* Combination of enum sdis_heat_path_flag */
    887 
    888   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    889   enum ssp_rng_type rng_type; /* RNG type to use */
    890 
    891   enum sdis_diffusion_algorithm diff_algo; /* Diffusion algorithm to be used */
    892 };
    893 #define SDIS_SOLVE_CAMERA_ARGS_DEFAULT__ {                                     \
    894   NULL, /* Camera */                                                           \
    895   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    896   1, /* Picard order */                                                        \
    897   {512,512}, /* Image resolution */                                            \
    898   256, /* #realisations per pixel */                                           \
    899   SDIS_HEAT_PATH_NONE,                                                         \
    900   NULL, /* RNG state */                                                        \
    901   SSP_RNG_THREEFRY, /* RNG type */                                             \
    902   SDIS_DIFFUSION_DELTA_SPHERE /* Diffusion algorithm */                        \
    903 }
    904 static const struct sdis_solve_camera_args SDIS_SOLVE_CAMERA_ARGS_DEFAULT =
    905   SDIS_SOLVE_CAMERA_ARGS_DEFAULT__;
    906 
    907 struct sdis_compute_power_args {
    908   size_t nrealisations;
    909   struct sdis_medium* medium; /* Medium to solve */
    910   double time_range[2]; /* Observation time */
    911   struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
    912   enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */
    913 };
    914 #define SDIS_COMPUTE_POWER_ARGS_DEFAULT__ {                                    \
    915   10000, /* #realisations */                                                   \
    916   NULL, /* Medium */                                                           \
    917   {DBL_MAX,DBL_MAX}, /* Time range */                                          \
    918   NULL, /* RNG state */                                                        \
    919   SSP_RNG_THREEFRY /* RNG type */                                              \
    920 }
    921 static const struct sdis_compute_power_args
    922 SDIS_COMPUTE_POWER_ARGS_DEFAULT = SDIS_COMPUTE_POWER_ARGS_DEFAULT__;
    923 
    924 struct sdis_green_function_create_from_stream_args {
    925   struct sdis_scene* scene; /* Scene from which the green was evaluated */
    926   FILE* stream; /* Stream from which the green function is deserialized */
    927 
    928   /* This signature is compared to the one serialized with the green function.
    929    * An error is returned if they differ */
    930   hash256_T signature;
    931 };
    932 #define SDIS_GREEN_FUNCTION_CREATE_FROM_STREAM_ARGS_DEFAULT__ {                \
    933   NULL, /* Scene */                                                            \
    934   NULL, /* Stream */                                                           \
    935   {0} /* Signature */                                                          \
    936 }
    937 static const struct sdis_green_function_create_from_stream_args
    938 SDIS_GREEN_FUNCTION_CREATE_FROM_STREAM_ARGS_DEFAULT =
    939   SDIS_GREEN_FUNCTION_CREATE_FROM_STREAM_ARGS_DEFAULT__;
    940 
    941 BEGIN_DECLS
    942 
    943 /*******************************************************************************
    944  * Stardis Device. It is an handle toward the Stardis library. It manages the
    945  * Stardis resources.
    946  ******************************************************************************/
    947 SDIS_API res_T
    948 sdis_device_create
    949   (const struct sdis_device_create_args* args,
    950    struct sdis_device** dev);
    951 
    952 SDIS_API res_T
    953 sdis_device_ref_get
    954   (struct sdis_device* dev);
    955 
    956 SDIS_API res_T
    957 sdis_device_ref_put
    958   (struct sdis_device* dev);
    959 
    960 SDIS_API res_T
    961 sdis_device_is_mpi_used
    962   (struct sdis_device* dev,
    963    int* is_mpi_used);
    964 
    965 SDIS_API res_T
    966 sdis_device_get_mpi_rank
    967   (struct sdis_device* dev,
    968    int* rank);
    969 
    970 /*******************************************************************************
    971  * A data stores in the Stardis memory space a set of user defined data. It can
    972  * be seen as a ref counted memory space allocated by Stardis. It is used to
    973  * attach user data to the media and to the interfaces.
    974  ******************************************************************************/
    975 SDIS_API res_T
    976 sdis_data_create
    977   (struct sdis_device* dev,
    978    const size_t size, /* Size in bytes of user defined data */
    979    const size_t align, /* Data alignment. Must be a power of 2 */
    980    void (*release)(void*),/* Invoked priorly to data destruction. May be NULL */
    981    struct sdis_data** data);
    982 
    983 SDIS_API res_T
    984 sdis_data_ref_get
    985   (struct sdis_data* data);
    986 
    987 SDIS_API res_T
    988 sdis_data_ref_put
    989   (struct sdis_data* data);
    990 
    991 SDIS_API void*
    992 sdis_data_get
    993   (struct sdis_data* data);
    994 
    995 SDIS_API const void*
    996 sdis_data_cget
    997   (const struct sdis_data* data);
    998 
    999 /*******************************************************************************
   1000  * A camera describes a point of view
   1001  ******************************************************************************/
   1002 SDIS_API res_T
   1003 sdis_camera_create
   1004   (struct sdis_device* dev,
   1005    struct sdis_camera** cam);
   1006 
   1007 SDIS_API res_T
   1008 sdis_camera_ref_get
   1009   (struct sdis_camera* cam);
   1010 
   1011 SDIS_API res_T
   1012 sdis_camera_ref_put
   1013   (struct sdis_camera* cam);
   1014 
   1015 /* Width/height projection ratio */
   1016 SDIS_API res_T
   1017 sdis_camera_set_proj_ratio
   1018   (struct sdis_camera* cam,
   1019    const double proj_ratio);
   1020 
   1021 SDIS_API res_T
   1022 sdis_camera_set_fov /* Horizontal field of view */
   1023   (struct sdis_camera* cam,
   1024    const double fov); /* In radian */
   1025 
   1026 SDIS_API res_T
   1027 sdis_camera_look_at
   1028   (struct sdis_camera* cam,
   1029    const double position[3],
   1030    const double target[3],
   1031    const double up[3]);
   1032 
   1033 /*******************************************************************************
   1034  * An estimator buffer is 2D array of estimators
   1035 ******************************************************************************/
   1036 SDIS_API res_T
   1037 sdis_estimator_buffer_ref_get
   1038   (struct sdis_estimator_buffer* buf);
   1039 
   1040 SDIS_API res_T
   1041 sdis_estimator_buffer_ref_put
   1042   (struct sdis_estimator_buffer* buf);
   1043 
   1044 SDIS_API res_T
   1045 sdis_estimator_buffer_get_definition
   1046   (const struct sdis_estimator_buffer* buf,
   1047    size_t definition[2]);
   1048 
   1049 SDIS_API res_T
   1050 sdis_estimator_buffer_at
   1051   (const struct sdis_estimator_buffer* buf,
   1052    const size_t x,
   1053    const size_t y,
   1054    const struct sdis_estimator** estimator);
   1055 
   1056 SDIS_API res_T
   1057 sdis_estimator_buffer_get_realisation_count
   1058   (const struct sdis_estimator_buffer* buf,
   1059    size_t* nrealisations); /* Successful ones */
   1060 
   1061 SDIS_API res_T
   1062 sdis_estimator_buffer_get_failure_count
   1063   (const struct sdis_estimator_buffer* buf,
   1064    size_t* nfailures);
   1065 
   1066 SDIS_API res_T
   1067 sdis_estimator_buffer_get_temperature
   1068   (const struct sdis_estimator_buffer* buf,
   1069    struct sdis_mc* temperature);
   1070 
   1071 SDIS_API res_T
   1072 sdis_estimator_buffer_get_realisation_time
   1073   (const struct sdis_estimator_buffer* buf,
   1074    struct sdis_mc* time);
   1075 
   1076 SDIS_API res_T
   1077 sdis_estimator_buffer_get_rng_state
   1078   (const struct sdis_estimator_buffer* buf,
   1079    struct ssp_rng** rng_state);
   1080 
   1081 /*******************************************************************************
   1082  * A medium encapsulates the properties of either a fluid or a solid.
   1083  ******************************************************************************/
   1084 SDIS_API res_T
   1085 sdis_fluid_create
   1086   (struct sdis_device* dev,
   1087    const struct sdis_fluid_shader* shader,
   1088    struct sdis_data* data, /* Data sent to the shader. May be NULL */
   1089    struct sdis_medium** fluid);
   1090 
   1091 SDIS_API res_T
   1092 sdis_fluid_get_shader
   1093   (const struct sdis_medium* fluid,
   1094    struct sdis_fluid_shader* shader);
   1095 
   1096 SDIS_API res_T
   1097 sdis_solid_create
   1098   (struct sdis_device* dev,
   1099    const struct sdis_solid_shader* shader,
   1100    struct sdis_data* data, /* Data send to the shader. May be NULL */
   1101    struct sdis_medium** solid);
   1102 
   1103 SDIS_API res_T
   1104 sdis_solid_get_shader
   1105   (const struct sdis_medium* solid,
   1106    struct sdis_solid_shader* shader);
   1107 
   1108 SDIS_API res_T
   1109 sdis_medium_ref_get
   1110   (struct sdis_medium* medium);
   1111 
   1112 SDIS_API res_T
   1113 sdis_medium_ref_put
   1114   (struct sdis_medium* medium);
   1115 
   1116 SDIS_API enum sdis_medium_type
   1117 sdis_medium_get_type
   1118   (const struct sdis_medium* medium);
   1119 
   1120 SDIS_API struct sdis_data*
   1121 sdis_medium_get_data
   1122   (struct sdis_medium* medium);
   1123 
   1124 SDIS_API unsigned
   1125 sdis_medium_get_id
   1126   (const struct sdis_medium* medium);
   1127 
   1128 /*******************************************************************************
   1129  * An interface is the boundary between 2 media.
   1130  ******************************************************************************/
   1131 SDIS_API res_T
   1132 sdis_interface_create
   1133   (struct sdis_device* dev,
   1134    struct sdis_medium* front, /* Medium on the front side of the geometry */
   1135    struct sdis_medium* back, /* Medium on the back side of the geometry */
   1136    const struct sdis_interface_shader* shader,
   1137    struct sdis_data* data, /* Data sent to the shader. May be NULL */
   1138    struct sdis_interface** interf);
   1139 
   1140 SDIS_API res_T
   1141 sdis_interface_ref_get
   1142   (struct sdis_interface* interf);
   1143 
   1144 SDIS_API res_T
   1145 sdis_interface_ref_put
   1146   (struct sdis_interface* interf);
   1147 
   1148 SDIS_API res_T
   1149 sdis_interface_get_shader
   1150   (const struct sdis_interface* interf,
   1151    struct sdis_interface_shader* shader);
   1152 
   1153 SDIS_API struct sdis_data*
   1154 sdis_interface_get_data
   1155   (struct sdis_interface* interf);
   1156 
   1157 SDIS_API unsigned
   1158 sdis_interface_get_id
   1159   (const struct sdis_interface* interf);
   1160 
   1161 /*******************************************************************************
   1162  * API of the radiative environment. Describes the system when the sampled
   1163  * radiative paths reach infinity.
   1164  ******************************************************************************/
   1165 SDIS_API res_T
   1166 sdis_radiative_env_create
   1167   (struct sdis_device* dev,
   1168    const struct sdis_radiative_env_shader* shader,
   1169    struct sdis_data* data, /* Data sent to the shader. May be NULL */
   1170    struct sdis_radiative_env** radenv);
   1171 
   1172 SDIS_API res_T
   1173 sdis_radiative_env_ref_get
   1174   (struct sdis_radiative_env* radenv);
   1175 
   1176 SDIS_API res_T
   1177 sdis_radiative_env_ref_put
   1178   (struct sdis_radiative_env* radenv);
   1179 
   1180 SDIS_API res_T
   1181 sdis_radiative_env_get_shader
   1182   (struct sdis_radiative_env* radenv,
   1183    struct sdis_radiative_env_shader* shader);
   1184 
   1185 SDIS_API struct sdis_data*
   1186 sdis_radiative_env_get_data
   1187   (struct sdis_radiative_env* radenv);
   1188 
   1189 /*******************************************************************************
   1190  * External source API. When a scene has external sources, an external flux
   1191  * (in both its direct and diffuse parts) is imposed on the interfaces.
   1192  ******************************************************************************/
   1193 SDIS_API res_T
   1194 sdis_spherical_source_create
   1195   (struct sdis_device* dev,
   1196    const struct sdis_spherical_source_shader* shader,
   1197    struct sdis_data* data, /* Data sent to the shader. May be NULL */
   1198    struct sdis_source** source);
   1199 
   1200 SDIS_API res_T
   1201 sdis_spherical_source_get_shader
   1202   (const struct sdis_source* source,
   1203    struct sdis_spherical_source_shader* shader);
   1204 
   1205 SDIS_API res_T
   1206 sdis_source_ref_get
   1207   (struct sdis_source* source);
   1208 
   1209 SDIS_API res_T
   1210 sdis_source_ref_put
   1211   (struct sdis_source* source);
   1212 
   1213 SDIS_API struct sdis_data*
   1214 sdis_source_get_data
   1215   (struct sdis_source* source);
   1216 
   1217 SDIS_API unsigned
   1218 sdis_source_get_id
   1219   (const struct sdis_source* source);
   1220 
   1221 /*******************************************************************************
   1222  * A scene is a collection of primitives. Each primitive is the geometric
   1223  * support of the interface between 2 media.
   1224  ******************************************************************************/
   1225 /* Create a 3D scene. The geometry of the scene is defined by an indexed
   1226  * triangular mesh: each triangle is composed of 3 indices where each index
   1227  * references an absolute 3D position. The physical properties of an interface
   1228  * is defined by the interface of the triangle.
   1229  *
   1230  * No duplicate is allowed, either vertex or triangle. No degenerated triangle
   1231  * is allowed.
   1232  *
   1233  * Note that each triangle has 2 sides: a front and a back side. By convention,
   1234  * the front side of a triangle is the side where its vertices are clock wise
   1235  * ordered. The back side of a triangle is the exact opposite: it is the side
   1236  * where the triangle vertices are counter-clock wise ordered. The front and
   1237  * back media of a triangle interface directly refer to this convention and
   1238  * thus one has to take care of how the triangle vertices are defined to ensure
   1239  * that the front and the back media are correctly defined wrt the geometry. */
   1240 SDIS_API res_T
   1241 sdis_scene_create
   1242   (struct sdis_device* dev,
   1243    const struct sdis_scene_create_args* args,
   1244    struct sdis_scene** scn);
   1245 
   1246 /* Create a 2D scene. The geometry of the 2D scene is defined by an indexed
   1247  * line segments: each segment is composed of 2 indices where each index
   1248  * references an absolute 2D position. The physical properties of an interface
   1249  * is defined by the interface of the segment.
   1250  *
   1251  * No duplicate is allowed, either vertex or segment. No degenerated segment is
   1252  * allowed.
   1253  *
   1254  * Note that each segment has 2 sides: a front and a back side. By convention,
   1255  * the front side of a segment is the side where its vertices are clock wise
   1256  * ordered. The back side of a segment is the exact opposite: it is the side
   1257  * where the segment vertices are counter-clock wise ordered. The front and
   1258  * back media of a segment interface directly refer to this convention and
   1259  * thus one has to take care of how the segment vertices are defined to ensure
   1260  * that the front and the back media are correctly defined wrt the geometry. */
   1261 SDIS_API res_T
   1262 sdis_scene_2d_create
   1263   (struct sdis_device* dev,
   1264    const struct sdis_scene_create_args* args,
   1265    struct sdis_scene** scn);
   1266 
   1267 SDIS_API res_T
   1268 sdis_scene_ref_get
   1269   (struct sdis_scene* scn);
   1270 
   1271 SDIS_API res_T
   1272 sdis_scene_ref_put
   1273   (struct sdis_scene* scn);
   1274 
   1275 /* Retrieve the Axis Aligned Bounding Box of the scene */
   1276 SDIS_API res_T
   1277 sdis_scene_get_aabb
   1278   (const struct sdis_scene* scn,
   1279    double lower[],
   1280    double upper[]);
   1281 
   1282 /* Get scene's fp_to_meter */
   1283 SDIS_API res_T
   1284 sdis_scene_get_fp_to_meter
   1285   (const struct sdis_scene* scn,
   1286    double* fp_to_meter);
   1287 
   1288 /* Set scene's fp_to_meter */
   1289 SDIS_API res_T
   1290 sdis_scene_set_fp_to_meter
   1291   (struct sdis_scene* scn,
   1292    const double fp_to_meter);
   1293 
   1294 /* Get scene's minimum/maximum temperature */
   1295 SDIS_API res_T
   1296 sdis_scene_get_temperature_range
   1297   (const struct sdis_scene* scn,
   1298    double t_range[2]);
   1299 
   1300 /* Set scene's minimum/maximum temperature. Must be correctly defined if there
   1301  * is any radiative transfer in the scene */
   1302 SDIS_API res_T
   1303 sdis_scene_set_temperature_range
   1304   (struct sdis_scene* scn,
   1305    const double t_range[2]);
   1306 
   1307 /* Search the point onto the scene geometry that is the closest of `pos'. The
   1308  * `radius' parameter controls the maximum search distance around `pos'. The
   1309  * returned closest point is expressed locally to the geometric primitive onto
   1310  * which it lies. If not found, the returned primitive is SDIS_PRIMITIVE_NONE.
   1311  * Note that even though only one point is returned, several position can have
   1312  * the same minimal distance to the queried position. */
   1313 SDIS_API res_T
   1314 sdis_scene_find_closest_point
   1315   (const struct sdis_scene* scn,
   1316    const struct sdis_scene_find_closest_point_args* args,
   1317    size_t* iprim, /* Primitive index onto which the closest point lies */
   1318    double uv[]); /* Parametric cordinate onto the primitive */
   1319 
   1320 /* Define the world space position of a point onto the primitive `iprim' whose
   1321  * parametric coordinate is uv. */
   1322 SDIS_API res_T
   1323 sdis_scene_get_boundary_position
   1324   (const struct sdis_scene* scn,
   1325    const size_t iprim, /* Primitive index */
   1326    const double uv[], /* Parametric coordinate onto the primitive */
   1327    double pos[]); /* World space position */
   1328 
   1329 /* roject a world space position onto a primitive wrt its normal and compute
   1330  * the parametric coordinates of the projected point onto the primitive. This
   1331  * function may help to define the probe position onto a boundary as expected
   1332  * by the sdis_solve_probe_boundary function.
   1333  *
   1334  * Note that the projected point can lie outside the submitted primitive. In
   1335  * this case, the parametric coordinates are clamped against the primitive
   1336  * boundaries in order to ensure that the returned parametric coordinates are
   1337  * valid according to the primitive. To ensure this, in 2D, the parametric
   1338  * coordinate is simply clamped to [0, 1]. In 3D, the `uv' coordinates are
   1339  * clamped against the triangle edges. For instance, let the
   1340  * following triangle whose vertices are `a', `b' and `c':
   1341  *            ,     ,
   1342  *             , B ,
   1343  *              , ,
   1344  *               b         E1
   1345  *      E0      / \    ,P
   1346  *             /   \,*'
   1347  *            /     \
   1348  *       ....a-------c......
   1349  *          '         '
   1350  *       A '    E2     '  C
   1351  *        '             '
   1352  * The projected point `P' is orthogonally wrapped to the edge `ab', `bc' or
   1353  * `ca' if it lies in the `E0', `E1' or `E2' region, respectively. If `P' is in
   1354  * the `A', `B' or `C' region, then it is taken back to the `a', `b' or `c'
   1355  * vertex, respectively. */
   1356 SDIS_API res_T
   1357 sdis_scene_boundary_project_position
   1358   (const struct sdis_scene* scn,
   1359    const size_t iprim,
   1360    const double pos[],
   1361    double uv[]);
   1362 
   1363 /* Get Star-Enclosure-2D scene. Defined on 2D scene only */
   1364 SDIS_API res_T
   1365 sdis_scene_get_senc2d_scene
   1366   (struct sdis_scene* scn,
   1367    struct senc2d_scene** senc2d_scn);
   1368 
   1369 /* Get Star-Enclosure-3D scene. Defined on 3D scene only */
   1370 SDIS_API res_T
   1371 sdis_scene_get_senc3d_scene
   1372   (struct sdis_scene* scn,
   1373    struct senc3d_scene** senc3d_scn);
   1374 
   1375 /* Get Star-2D scene view. Defined on 2D scene only */
   1376 SDIS_API res_T
   1377 sdis_scene_get_s2d_scene_view
   1378   (struct sdis_scene* scn,
   1379    struct s2d_scene_view** s2d_view);
   1380 
   1381 /* Get Star-3D scene view. Defined on 3D scene only */
   1382 SDIS_API res_T
   1383 sdis_scene_get_s3d_scene_view
   1384   (struct sdis_scene* scn,
   1385    struct s3d_scene_view** s3d_view);
   1386 
   1387 SDIS_API res_T
   1388 sdis_scene_get_dimension
   1389   (const struct sdis_scene* scn,
   1390    enum sdis_scene_dimension* dim);
   1391 
   1392 /* Return the area/volume of occupied by a medium in a 2D/3D scene. Only
   1393  * enclosed media are handled, i.e. media whose border are explicitly defined
   1394  * by a geometry. */
   1395 SDIS_API res_T
   1396 sdis_scene_get_medium_spread
   1397   (struct sdis_scene* scn,
   1398    const struct sdis_medium* mdm,
   1399    double* spread);
   1400 
   1401 SDIS_API res_T
   1402 sdis_scene_get_device
   1403   (struct sdis_scene* scn,
   1404    struct sdis_device** device);
   1405 
   1406 SDIS_API res_T
   1407 sdis_scene_get_source
   1408   (struct sdis_scene* scn,
   1409    struct sdis_source** src); /* The returned pointer can be NULL <=> no source */
   1410 
   1411 SDIS_API res_T
   1412 sdis_scene_get_radiative_env
   1413   (struct sdis_scene* scn,
   1414    /* The returned pointer can be NULL, i.e. there is no radiative environement*/
   1415    struct sdis_radiative_env** radenv);
   1416 
   1417 /* Get the internal Star-2D primitive corresponding to the primitive key */
   1418 SDIS_API res_T
   1419 sdis_scene_get_s2d_primitive
   1420   (struct sdis_scene* scn,
   1421    const struct sdis_primkey* key,
   1422    struct s2d_primitive* primitive);
   1423 
   1424 /* Get the internal Star-3D primitive corresponding to the primitive key */
   1425 SDIS_API res_T
   1426 sdis_scene_get_s3d_primitive
   1427   (struct sdis_scene* scn,
   1428    const struct sdis_primkey* key,
   1429    struct s3d_primitive* primitive);
   1430 
   1431 /*******************************************************************************
   1432  * An estimator stores the state of a simulation
   1433  ******************************************************************************/
   1434 SDIS_API res_T
   1435 sdis_estimator_ref_get
   1436   (struct sdis_estimator* estimator);
   1437 
   1438 SDIS_API res_T
   1439 sdis_estimator_ref_put
   1440   (struct sdis_estimator* estimator);
   1441 
   1442 SDIS_API res_T
   1443 sdis_estimator_get_type
   1444   (const struct sdis_estimator* estimator,
   1445    enum sdis_estimator_type* type);
   1446 
   1447 SDIS_API res_T
   1448 sdis_estimator_get_realisation_count
   1449   (const struct sdis_estimator* estimator,
   1450    size_t* nrealisations); /* Successful ones */
   1451 
   1452 SDIS_API res_T
   1453 sdis_estimator_get_failure_count
   1454   (const struct sdis_estimator* estimator,
   1455    size_t* nfailures);
   1456 
   1457 SDIS_API res_T
   1458 sdis_estimator_get_temperature
   1459   (const struct sdis_estimator* estimator,
   1460    struct sdis_mc* temperature);
   1461 
   1462 SDIS_API res_T
   1463 sdis_estimator_get_realisation_time
   1464   (const struct sdis_estimator* estimator,
   1465    struct sdis_mc* time);
   1466 
   1467 SDIS_API res_T
   1468 sdis_estimator_get_convective_flux
   1469   (const struct sdis_estimator* estimator,
   1470    struct sdis_mc* flux); /* In W/m² */
   1471 
   1472 SDIS_API res_T
   1473 sdis_estimator_get_radiative_flux
   1474   (const struct sdis_estimator* estimator,
   1475    struct sdis_mc* flux); /* In W/m² */
   1476 
   1477 SDIS_API res_T
   1478 sdis_estimator_get_imposed_flux
   1479   (const struct sdis_estimator* estimator,
   1480    struct sdis_mc* flux); /* In W/m² */
   1481 
   1482 SDIS_API res_T
   1483 sdis_estimator_get_total_flux
   1484   (const struct sdis_estimator* estimator,
   1485    struct sdis_mc* flux); /* In W/m² */
   1486 
   1487 SDIS_API res_T
   1488 sdis_estimator_get_power
   1489   (const struct sdis_estimator* estimator,
   1490    struct sdis_mc* power);
   1491 
   1492 SDIS_API res_T
   1493 sdis_estimator_get_paths_count
   1494   (const struct sdis_estimator* estimator,
   1495    size_t* npaths);
   1496 
   1497 SDIS_API res_T
   1498 sdis_estimator_get_path
   1499   (const struct sdis_estimator* estimator,
   1500    const size_t ipath,
   1501    const struct sdis_heat_path** path);
   1502 
   1503 SDIS_API res_T
   1504 sdis_estimator_for_each_path
   1505   (const struct sdis_estimator* estimator,
   1506    sdis_process_heat_path_T func,
   1507    void* context);
   1508 
   1509 /* Retrieve the RNG state at the end of the simulation. */
   1510 SDIS_API res_T
   1511 sdis_estimator_get_rng_state
   1512   (const struct sdis_estimator* estimator,
   1513    /* The returned value may be NULL as for instance an estimator retrieved
   1514     * from an estimator buffer */
   1515    struct ssp_rng** rng_state);
   1516 
   1517 /*******************************************************************************
   1518  * The green function saves the estimation of the propagator
   1519  ******************************************************************************/
   1520 SDIS_API res_T
   1521 sdis_green_function_ref_get
   1522   (struct sdis_green_function* green);
   1523 
   1524 SDIS_API res_T
   1525 sdis_green_function_ref_put
   1526   (struct sdis_green_function* green);
   1527 
   1528 SDIS_API res_T
   1529 sdis_green_function_solve
   1530   (struct sdis_green_function* green,
   1531    struct sdis_estimator** estimator);
   1532 
   1533 SDIS_API res_T
   1534 sdis_green_function_write
   1535   (struct sdis_green_function* green,
   1536    FILE* stream);
   1537 
   1538 SDIS_API res_T
   1539 sdis_green_function_create_from_stream
   1540   (struct sdis_green_function_create_from_stream_args* args,
   1541    struct sdis_green_function** green);
   1542 
   1543 /* Retrieve the scene used to compute the green function */
   1544 SDIS_API res_T
   1545 sdis_green_function_get_scene
   1546   (const struct sdis_green_function* green,
   1547    struct sdis_scene** scn);
   1548 
   1549 /* Retrieve the number of valid paths used to estimate the green function. It
   1550  * is actually equal to the number of successful realisations. */
   1551 SDIS_API res_T
   1552 sdis_green_function_get_paths_count
   1553   (const struct sdis_green_function* green,
   1554    size_t* npaths);
   1555 
   1556 /* Retrieve the number of rejected paths during the estimation of the green
   1557  * function due to numerical issues and data inconsistency */
   1558 SDIS_API res_T
   1559 sdis_green_function_get_invalid_paths_count
   1560   (const struct sdis_green_function* green,
   1561    size_t* nfails);
   1562 
   1563 SDIS_API res_T
   1564 sdis_green_function_get_signature
   1565   (const struct sdis_green_function* green,
   1566    hash256_T signature);
   1567 
   1568 /* Iterate over all valid green function paths */
   1569 SDIS_API res_T
   1570 sdis_green_function_for_each_path
   1571   (struct sdis_green_function* green,
   1572    sdis_process_green_path_T func,
   1573    void* context);
   1574 
   1575 /* Retrieve the path's elapsed time */
   1576 SDIS_API res_T
   1577 sdis_green_path_get_elapsed_time
   1578   (struct sdis_green_path* path_handle,
   1579    double* elapsed);
   1580 
   1581 /* Retrieve the spatio-temporal limit of a path used to estimate the green
   1582  * function */
   1583 SDIS_API res_T
   1584 sdis_green_path_get_end
   1585   (struct sdis_green_path* path,
   1586    struct sdis_green_path_end* end);
   1587 
   1588 /* Retrieve the green function the path belongs to */
   1589 SDIS_API res_T
   1590 sdis_green_path_get_green_function
   1591   (struct sdis_green_path* path_handle,
   1592    struct sdis_green_function** green);
   1593 
   1594 /* Retrieve the number of "power terms" associated to a path. */
   1595 SDIS_API res_T
   1596 sdis_green_function_get_power_terms_count
   1597   (const struct sdis_green_path* path,
   1598    size_t* nterms);
   1599 
   1600 /* Retrieve the number of "flux terms" associated to a path. */
   1601 SDIS_API res_T
   1602 sdis_green_function_get_flux_terms_count
   1603   (const struct sdis_green_path* path,
   1604    size_t* nterms);
   1605 
   1606 SDIS_API res_T
   1607 sdis_green_function_get_external_flux_terms_count
   1608   (const struct sdis_green_path* path,
   1609    size_t* nterms);
   1610 
   1611 /* Iterate over all "power terms" associated to the path. Multiply each term
   1612  * by the power of their associated medium, that is assumed to be constant in
   1613  * time and space, gives the medium power registered along the path. */
   1614 SDIS_API res_T
   1615 sdis_green_path_for_each_power_term
   1616   (struct sdis_green_path* path,
   1617    sdis_process_medium_power_term_T func,
   1618    void* context);
   1619 
   1620 /* Iterate over all "flux terms" associated to the path. Multiply each term by
   1621  * the flux of their associated interface side, that is assumed to be constant
   1622  * in time and space, gives the interface side flux registered along the path. */
   1623 SDIS_API res_T
   1624 sdis_green_path_for_each_flux_term
   1625   (struct sdis_green_path* path,
   1626    sdis_process_interface_flux_term_T func,
   1627    void* context);
   1628 
   1629 /* Iterate over all external flux terms associated to the path */
   1630 SDIS_API res_T
   1631 sdis_green_path_for_each_external_flux_terms
   1632   (struct sdis_green_path* path,
   1633    sdis_process_external_flux_terms_T func,
   1634    void* context);
   1635 
   1636 /*******************************************************************************
   1637  * Heat path API
   1638  ******************************************************************************/
   1639 SDIS_API res_T
   1640 sdis_heat_path_get_status
   1641   (const struct sdis_heat_path* path,
   1642    enum sdis_heat_path_flag* status);
   1643 
   1644 SDIS_API res_T
   1645 sdis_heat_path_get_line_strips_count
   1646   (const struct sdis_heat_path* path,
   1647    size_t* nstrips);
   1648 
   1649 SDIS_API res_T
   1650 sdis_heat_path_line_strip_get_vertices_count
   1651   (const struct sdis_heat_path* path,
   1652    const size_t istrip,
   1653    size_t* nvertices);
   1654 
   1655 SDIS_API res_T
   1656 sdis_heat_path_line_strip_get_vertex
   1657   (const struct sdis_heat_path* path,
   1658    const size_t istrip,
   1659    const size_t ivert,
   1660    struct sdis_heat_vertex* vertex);
   1661 
   1662 SDIS_API res_T
   1663 sdis_heat_path_line_strip_for_each_vertex
   1664   (const struct sdis_heat_path* path,
   1665    const size_t istrip,
   1666    sdis_process_heat_vertex_T func,
   1667    void* context);
   1668 
   1669 /*******************************************************************************
   1670  * Solvers
   1671  ******************************************************************************/
   1672 SDIS_API res_T
   1673 sdis_solve_probe
   1674   (struct sdis_scene* scn,
   1675    const struct sdis_solve_probe_args* args,
   1676    struct sdis_estimator** estimator);
   1677 
   1678 SDIS_API res_T
   1679 sdis_solve_probe_boundary
   1680   (struct sdis_scene* scn,
   1681    const struct sdis_solve_probe_boundary_args* args,
   1682    struct sdis_estimator** estimator);
   1683 
   1684 SDIS_API res_T
   1685 sdis_solve_boundary
   1686   (struct sdis_scene* scn,
   1687    const struct sdis_solve_boundary_args* args,
   1688    struct sdis_estimator** estimator);
   1689 
   1690 /* Calculate the flux density in W/m² _entering_ the solid through the given
   1691  * boundary position, i.e. the flux density is positive or negative if the
   1692  * solid gains or loses energy, respectively. */
   1693 SDIS_API res_T
   1694 sdis_solve_probe_boundary_flux
   1695   (struct sdis_scene* scn,
   1696    const struct sdis_solve_probe_boundary_flux_args* args,
   1697    struct sdis_estimator** estimator);
   1698 
   1699 /* Calculate the average flux density in W/m² _entering_ the solid through the
   1700  * given boundary surfaces, i.e. the flux density is positive or negative if
   1701  * the solid gains or loses energy, respectively. */
   1702 SDIS_API res_T
   1703 sdis_solve_boundary_flux
   1704   (struct sdis_scene* scn,
   1705    const struct sdis_solve_boundary_flux_args* args,
   1706    struct sdis_estimator** estimator);
   1707 
   1708 SDIS_API res_T
   1709 sdis_solve_camera
   1710   (struct sdis_scene* scn,
   1711    const struct sdis_solve_camera_args* args,
   1712    struct sdis_estimator_buffer** buf);
   1713 
   1714 SDIS_API res_T
   1715 sdis_solve_medium
   1716   (struct sdis_scene* scn,
   1717    const struct sdis_solve_medium_args* args,
   1718    struct sdis_estimator** estimator);
   1719 
   1720 /* power (in Watt)  = SUM(volumic_power(x)) / Nrealisations * Volume */
   1721 SDIS_API res_T
   1722 sdis_compute_power
   1723   (struct sdis_scene* scn,
   1724    const struct sdis_compute_power_args* args,
   1725    struct sdis_estimator** estimator);
   1726 
   1727 /*******************************************************************************
   1728  * Solvers of a list of probes
   1729  *
   1730  * Unlike their single-probe counterpart, this function parallelizes the list of
   1731  * probes, rather than calculating a single probe. Calling these functions is
   1732  * therefore more advantageous in terms of load distribution when the number of
   1733  * probes to be evaluated is large compared to the cost of calculating a single
   1734  * probe.
   1735  ******************************************************************************/
   1736 SDIS_API res_T
   1737 sdis_solve_probe_list
   1738   (struct sdis_scene* scn,
   1739    const struct sdis_solve_probe_list_args* args,
   1740    struct sdis_estimator_buffer** buf);
   1741 
   1742 SDIS_API res_T
   1743 sdis_solve_probe_boundary_list
   1744   (struct sdis_scene* scn,
   1745    const struct sdis_solve_probe_boundary_list_args* args,
   1746    struct sdis_estimator_buffer** buf);
   1747 
   1748 /*******************************************************************************
   1749  * Green solvers.
   1750  *
   1751  * Note that only the interfaces/media with flux/volumic power defined during
   1752  * green estimation can update their flux/volumic power value for subsequent
   1753  * sdis_green_function_solve invocations: others interfaces/media are
   1754  * definitely registered against the green function as interfaces/media with no
   1755  * flux/volumic power.
   1756  *
   1757  * Also note that the green solvers assume that the interface fluxes are
   1758  * constant in time and space. The same applies to the volumic power of the
   1759  * solid media and the power of external sources.
   1760  *
   1761  * If these assumptions are not ensured by the caller, the behavior of the
   1762  * estimated green function is undefined.
   1763  ******************************************************************************/
   1764 SDIS_API res_T
   1765 sdis_solve_probe_green_function
   1766   (struct sdis_scene* scn,
   1767    const struct sdis_solve_probe_args* args,
   1768    struct sdis_green_function** green);
   1769 
   1770 SDIS_API res_T
   1771 sdis_solve_probe_boundary_green_function
   1772   (struct sdis_scene* scn,
   1773    const struct sdis_solve_probe_boundary_args* args,
   1774    struct sdis_green_function** green);
   1775 
   1776 SDIS_API res_T
   1777 sdis_solve_boundary_green_function
   1778   (struct sdis_scene* scn,
   1779    const struct sdis_solve_boundary_args* args,
   1780    struct sdis_green_function** green);
   1781 
   1782 SDIS_API res_T
   1783 sdis_solve_medium_green_function
   1784   (struct sdis_scene* scn,
   1785    const struct sdis_solve_medium_args* args,
   1786    struct sdis_green_function** green);
   1787 
   1788 /*******************************************************************************
   1789  * Retrieve infos from the Stardis-Solver library
   1790  ******************************************************************************/
   1791 SDIS_API res_T
   1792 sdis_get_info
   1793   (struct sdis_info* info);
   1794 
   1795 /*******************************************************************************
   1796  * Primitive identifier
   1797  ******************************************************************************/
   1798 SDIS_API void
   1799 sdis_primkey_setup
   1800   (struct sdis_primkey* key,
   1801    const double node0[3],
   1802    const double node1[3],
   1803    const double node2[3]);
   1804 
   1805 SDIS_API void
   1806 sdis_primkey_2d_setup
   1807   (struct sdis_primkey* key,
   1808    const double node0[2],
   1809    const double node1[2]);
   1810 
   1811 SDIS_API size_t
   1812 sdis_primkey_hash
   1813   (const struct sdis_primkey* key);
   1814 
   1815 SDIS_API char
   1816 sdis_primkey_eq
   1817   (const struct sdis_primkey* key0,
   1818    const struct sdis_primkey* key1);
   1819 
   1820 END_DECLS
   1821 
   1822 #endif /* SDIS_H */