htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

htrdr_planets_c.h (6130B)


      1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
      2  * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
      3  * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
      4  * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
      5  * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
      6  * Copyright (C) 2022-2025 Observatoire de Paris
      7  * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
      8  * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
      9  * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
     10  *
     11  * This program is free software: you can redistribute it and/or modify
     12  * it under the terms of the GNU General Public License as published by
     13  * the Free Software Foundation, either version 3 of the License, or
     14  * (at your option) any later version.
     15  *
     16  * This program is distributed in the hope that it will be useful,
     17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     19  * GNU General Public License for more details.
     20  *
     21  * You should have received a copy of the GNU General Public License
     22  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     23 
     24 #ifndef HTRDR_PLANETS_C_H
     25 #define HTRDR_PLANETS_C_H
     26 
     27 #include "planets/htrdr_planets_args.h"
     28 
     29 #include "core/htrdr_accum.h"
     30 #include "core/htrdr_args.h"
     31 #include "core/htrdr_buffer.h"
     32 
     33 #include <rsys/ref_count.h>
     34 #include <rsys/str.h>
     35 
     36 /* Forward declarations */
     37 struct htrdr;
     38 struct htrdr_pixel_format;
     39 struct htrdr_ran_wlen_cie_xyz;
     40 struct htrdr_ran_wlen_planck;
     41 struct rnatm;
     42 struct rngrd;
     43 struct scam;
     44 
     45 struct planets_pixel_xwave {
     46   struct htrdr_accum radiance; /* In W/m²/sr */
     47   struct htrdr_accum time; /* In µs */
     48   struct htrdr_estimate radiance_temperature; /* In W/m²/sr */
     49 };
     50 #define PLANETS_PIXEL_XWAVE_NULL__ {                                           \
     51   HTRDR_ACCUM_NULL__,                                                          \
     52   HTRDR_ACCUM_NULL__,                                                          \
     53   HTRDR_ESTIMATE_NULL__                                                        \
     54 }
     55 static const struct planets_pixel_xwave PLANETS_PIXEL_XWAVE_NULL =
     56   PLANETS_PIXEL_XWAVE_NULL__;
     57 
     58 struct planets_pixel_image {
     59   struct htrdr_estimate X; /* In W/m^2/sr */
     60   struct htrdr_estimate Y; /* In W/m^2/sr */
     61   struct htrdr_estimate Z; /* In W/m^2/sr */
     62   struct htrdr_accum time; /* In us */
     63 };
     64 #define PLANETS_PIXEL_IMAGE_NULL__ {                                           \
     65   HTRDR_ESTIMATE_NULL__,                                                       \
     66   HTRDR_ESTIMATE_NULL__,                                                       \
     67   HTRDR_ESTIMATE_NULL__,                                                       \
     68   HTRDR_ACCUM_NULL__                                                           \
     69 }
     70 
     71 enum planets_volrad_weight_type {
     72   PLANETS_VOLRAD_TOTAL, /* 0 */
     73   PLANETS_VOLRAD_DIRECT, /* 1 */
     74   PLANETS_VOLRAD_DIFFUSE, /* 2 */
     75   PLANETS_VOLRAD_WEIGHTS_COUNT /* 3 */
     76 };
     77 
     78 struct planets_voxel_radiative_budget {
     79   struct htrdr_accum volrad_budget[PLANETS_VOLRAD_WEIGHTS_COUNT]; /* W/m^3 */
     80   struct htrdr_accum time; /* In us */
     81 };
     82 #define PLANETS_VOXEL_RADIATIVE_BUDGET_NULL__ {                                \
     83   {                                                                            \
     84     HTRDR_ACCUM_NULL__,                                                        \
     85     HTRDR_ACCUM_NULL__,                                                        \
     86     HTRDR_ACCUM_NULL__                                                         \
     87   },                                                                           \
     88   HTRDR_ACCUM_NULL__                                                           \
     89 }
     90 static const struct planets_voxel_radiative_budget
     91 PLANETS_VOXEL_RADIATIVE_BUDGET_NULL = PLANETS_VOXEL_RADIATIVE_BUDGET_NULL__;
     92 
     93 enum planets_radiance_cpnt_flag {
     94   PLANETS_RADIANCE_CPNT_DIRECT = BIT(0),
     95   PLANETS_RADIANCE_CPNT_DIFFUSE = BIT(1),
     96   PLANETS_RADIANCE_CPNT_NONE = 0,
     97   PLANETS_RADIANCE_CPNT_ALL =
     98     PLANETS_RADIANCE_CPNT_DIRECT
     99   | PLANETS_RADIANCE_CPNT_DIFFUSE
    100 };
    101 
    102 struct planets_compute_radiance_args {
    103   struct ssp_rng* rng;
    104   size_t ithread; /* Index of the thread executing the function */
    105 
    106   double path_org[3]; /* Origin of the path to trace */
    107   double path_dir[3]; /* Initial direction of the path to trace */
    108 
    109   double wlen; /* In nm */
    110   size_t iband; /* Spectral band index */
    111   size_t iquad; /* Quadrature point */
    112 
    113   int component; /* Combination of planets_radiance_cpnt_flag */
    114 };
    115 #define PLANETS_COMPUTE_RADIANCE_ARGS_NULL__ \
    116   {NULL, 0, {0,0,0}, {0,0,0}, 0, 0, 0, PLANETS_RADIANCE_CPNT_ALL}
    117 static const struct planets_compute_radiance_args
    118 PLANETS_COMPUTE_RADIANCE_ARGS_NULL = PLANETS_COMPUTE_RADIANCE_ARGS_NULL__;
    119 
    120 struct htrdr_planets {
    121   struct rnatm* atmosphere;
    122   struct rngrd* ground;
    123   struct htrdr_planets_source* source;
    124 
    125   struct htrdr_planets_spectral_args spectral_domain;
    126   struct htrdr_ran_wlen_cie_xyz* cie; /* HTRDR_SPECTRAL_SW_CIE_XYZ */
    127   struct htrdr_ran_wlen_planck* planck; /* HTRDR_SPECTRAL_<LW|SW> */
    128   struct htrdr_ran_wlen_discrete* discrete; /* HTRDR_SPECTRAL_SW */
    129 
    130   FILE* octrees_storage;
    131 
    132   FILE* output;
    133   struct str output_name;
    134   enum htrdr_planets_args_output_type output_type;
    135 
    136   /* Image rendering */
    137   struct scam* camera;
    138   struct htrdr_buffer_layout buf_layout;
    139   struct htrdr_buffer* buf; /* NULL on non master processes */
    140   size_t spp; /* Samples per pixel */
    141 
    142   /* Volumic radiative budget */
    143   struct smsh* volrad_mesh;
    144   size_t spt; /* Samples per tetrahedron */
    145 
    146   ref_T ref;
    147   struct htrdr* htrdr;
    148 };
    149 
    150 extern LOCAL_SYM res_T
    151 planets_draw_map
    152   (struct htrdr_planets* cmd);
    153 
    154 extern LOCAL_SYM res_T
    155 planets_solve_volrad_budget
    156   (struct htrdr_planets* cmd);
    157 
    158 extern LOCAL_SYM void
    159 planets_get_pixel_format
    160   (const struct htrdr_planets* cmd,
    161    struct htrdr_pixel_format* fmt);
    162 
    163 /* Return the radiance in W/m²/sr/m */
    164 extern LOCAL_SYM double
    165 planets_compute_radiance
    166   (struct htrdr_planets* cmd,
    167    const struct planets_compute_radiance_args* args);
    168 
    169 #endif /* HTRDR_PLANETS_C_H */