stardis-solver

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

sdis_source_c.h (3287B)


      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_SOURCE_C_H
     17 #define SDIS_SOURCE_C_H
     18 
     19 #include <rsys/hash.h>
     20 #include <rsys/rsys.h>
     21 
     22 struct sdis_source;
     23 struct ssp_rng;
     24 
     25 struct source_props {
     26   double pos[3]; /* [m/fp_to_meter] */
     27   double radius; /* [m/fp_to_meter] */
     28   double power; /* [W] */
     29   double area; /* [m^2/fp_to_meter] */
     30   double time; /* [s] */
     31 };
     32 #define SOURCE_PROPS_NULL__ {0}
     33 static const struct source_props SOURCE_PROPS_NULL = SOURCE_PROPS_NULL__;
     34 
     35 struct source_sample {
     36   double dir[3]; /* Direction _to_ the source */
     37   double pdf; /* pdf of sampled direction */
     38   double dst; /* Distance to the source [m] */
     39 
     40   double radiance; /* [W/m^2/sr] */
     41 
     42   /* Radiance relative to power, i.e. the source power is assumed to be equal to
     43    * 1. It must be multiplied by the source power to obtain the actual radiance
     44    * of the source. In other words, this variable defines the contribution of
     45    * the source independently of its power, and can therefore be recorded in the
     46    * green function */
     47   double radiance_term; /* [W/m^2/sr] */
     48 };
     49 #define SOURCE_SAMPLE_NULL__ {0}
     50 static const struct source_sample SOURCE_SAMPLE_NULL = SOURCE_SAMPLE_NULL__;
     51 
     52 /* Helper macro used to define whether a sample is valid or not */
     53 #define SOURCE_SAMPLE_NONE(Sample) ((Sample)->pdf == 0)
     54 
     55 extern LOCAL_SYM res_T
     56 source_get_props
     57   (const struct sdis_source* source,
     58    const double time, /* Time at which props are retrieved [s] */
     59    struct source_props* props);
     60 
     61 extern LOCAL_SYM res_T
     62 source_sample
     63   (const struct sdis_source* source,
     64    const struct source_props* props,
     65    struct ssp_rng* rng,
     66    const double pos[3], /* Position from which the source is sampled */
     67    struct source_sample* sample);
     68 
     69 /* Trace a ray toward the source. The returned sample has a pdf of 1 or 0
     70  * whether the source is intersected by the ray or not, respectively. You can
     71  * use the SOURCE_SAMPLE_NONE macro to check this */
     72 extern LOCAL_SYM res_T
     73 source_trace_to
     74   (const struct sdis_source* source,
     75    const struct source_props* props,
     76    const double pos[3], /* Ray origin */
     77    const double dir[3], /* Ray direction */
     78    struct source_sample* sample); /* pdf == 0 if no source is reached */
     79 
     80 extern LOCAL_SYM double /* [W] */
     81 source_get_power
     82   (const struct sdis_source* source,
     83    const double time); /* [s] */
     84 
     85 extern LOCAL_SYM double /* [W/m^2/sr] */
     86 source_get_diffuse_radiance
     87   (const struct sdis_source* source,
     88    const double time, /* [s] */
     89    const double dir[3]);
     90 
     91 extern LOCAL_SYM void
     92 source_compute_signature
     93   (const struct sdis_source* source,
     94    hash256_T hash);
     95 
     96 #endif /* SDIS_SOURCE_C_H */