schiff

Estimate the radiative properties of soft particless
git clone git://git.meso-star.com/schiff.git
Log | Files | Refs | README | LICENSE

schiff_geometry.h (6719B)


      1 /* Copyright (C) 2015, 2016, 2026 Centre National de la Recherche Scientifique
      2  * Copyright (C) 2026 Clermont Auvergne INP
      3  * Copyright (C) 2026 Institut Mines Télécom Albi-Carmaux
      4  * Copyright (C) 2017, 2019-2021, 2026 |Méso|Star> (contact@meso-star.com)
      5  * Copyright (C) 2026 Université de Lorraine
      6  * Copyright (C) 2026 Université de Toulouse
      7  *
      8  * This program is free software: you can redistribute it and/or modify
      9  * it under the terms of the GNU General Public License as published by
     10  * the Free Software Foundation, either version 3 of the License, or
     11  * (at your option) any later version.
     12  *
     13  * This program is distributed in the hope that it will be useful,
     14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16  * GNU General Public License for more details.
     17  *
     18  * You should have received a copy of the GNU General Public License
     19  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     20 
     21 #ifndef SCHIFF_GEOMETRY_H
     22 #define SCHIFF_GEOMETRY_H
     23 
     24 #include <rsys/rsys.h>
     25 #include <star/ssp.h>
     26 
     27 enum schiff_param_distribution {
     28   SCHIFF_PARAM_CONSTANT,
     29   SCHIFF_PARAM_LOGNORMAL,
     30   SCHIFF_PARAM_GAUSSIAN,
     31   SCHIFF_PARAM_HISTOGRAM,
     32   SCHIFF_PARAM_NONE
     33 };
     34 
     35 struct schiff_param {
     36   enum schiff_param_distribution distribution;
     37   union {
     38     double constant;
     39     struct { double mu, sigma; } lognormal;
     40     struct { double mu, sigma, range[2]; } gaussian;
     41     struct { double *entries, lower, upper; } histogram;
     42   } data;
     43 };
     44 #define SCHIFF_PARAM_DEFAULT__ {SCHIFF_PARAM_CONSTANT, {1.0}}
     45 
     46 enum schiff_geometry_type {
     47   SCHIFF_CYLINDER,
     48   SCHIFF_ELLIPSOID,
     49   SCHIFF_HELICAL_PIPE,
     50   SCHIFF_SPHERE,
     51   SCHIFF_SUPERSHAPE,
     52 
     53   /* Volume is controlled by a sphere */
     54   SCHIFF_CYLINDER_AS_SPHERE,
     55   SCHIFF_ELLIPSOID_AS_SPHERE,
     56   SCHIFF_HELICAL_PIPE_AS_SPHERE,
     57   SCHIFF_SUPERSHAPE_AS_SPHERE,
     58 
     59   SCHIFF_NONE
     60 };
     61 
     62 /* (x/a)^2 + (y/a)^2 + (z/c)^2 = 1 */
     63 struct schiff_ellipsoid {
     64   struct schiff_param a;
     65   struct schiff_param c;
     66 
     67   /* In use by SCHIFF_ELLIPSOID_AS_SPHERE */
     68   struct schiff_param radius_sphere;
     69 
     70   unsigned nslices;
     71 };
     72 
     73 #define SCHIFF_ELLIPSOID_DEFAULT__ \
     74   {SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, 64}
     75 static const struct schiff_ellipsoid SCHIFF_ELLIPSOID_DEFAULT =
     76   SCHIFF_ELLIPSOID_DEFAULT__;
     77 
     78 struct schiff_sphere {
     79   struct schiff_param radius;
     80   unsigned nslices;
     81 };
     82 
     83 struct schiff_helical_pipe {
     84   struct schiff_param pitch; /* Elevation distance of a full revolution */
     85   struct schiff_param height; /* Total heigh of the helical pipe */
     86   struct schiff_param radius_helicoid; /* Radius of the helicoid */
     87   struct schiff_param radius_circle; /* Radius of the meridian circle */
     88 
     89   /* In use by SCHIFF_HELICAL_PIPE_AS_SPHERE */
     90   struct schiff_param radius_sphere;
     91 
     92   unsigned nslices_helicoid; /* # Discrete steps of the helicoid */
     93   unsigned nslices_circle; /* # Discrete steps along 2PI */
     94 };
     95 
     96 #define SCHIFF_HELICAL_PIPE_DEFAULT__                                          \
     97   {SCHIFF_PARAM_DEFAULT__,                                                     \
     98    SCHIFF_PARAM_DEFAULT__,                                                     \
     99    SCHIFF_PARAM_DEFAULT__,                                                     \
    100    SCHIFF_PARAM_DEFAULT__,                                                     \
    101    SCHIFF_PARAM_DEFAULT__,                                                     \
    102    128, 64}
    103 static const struct schiff_helical_pipe SCHIFF_HELICAL_PIPE_DEFAULT =
    104   SCHIFF_HELICAL_PIPE_DEFAULT__;
    105 
    106 #define SCHIFF_SPHERE_DEFAULT__ {SCHIFF_PARAM_DEFAULT__, 64}
    107 static const struct schiff_sphere SCHIFF_SPHERE_DEFAULT =
    108   SCHIFF_SPHERE_DEFAULT__;
    109 
    110 struct schiff_cylinder {
    111   struct schiff_param radius;
    112   struct schiff_param height;
    113 
    114   /* In use by SCHIFF_CYLINDER_AS_SPHERE */
    115   struct schiff_param radius_sphere;
    116 
    117   unsigned nslices;
    118 };
    119 
    120 #define SCHIFF_CYLINDER_DEFAULT__ \
    121   {SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, 64}
    122 static const struct schiff_cylinder SCHIFF_CYLINDER_DEFAULT =
    123   SCHIFF_CYLINDER_DEFAULT__;
    124 
    125 enum { A, B, M, N0, N1, N2 }; /* Super formula arguments */
    126 
    127 struct schiff_supershape {
    128   struct schiff_param formulas[2][6];
    129   /* In use by SCHIFF_SUPERSHAPE_AS_SPHERE */
    130   struct schiff_param radius_sphere;
    131   unsigned nslices;
    132 };
    133 #define SCHIFF_SUPERSHAPE_DEFAULT__ {                                         \
    134   {{SCHIFF_PARAM_DEFAULT__,                                                   \
    135     SCHIFF_PARAM_DEFAULT__,                                                   \
    136     SCHIFF_PARAM_DEFAULT__,                                                   \
    137     SCHIFF_PARAM_DEFAULT__,                                                   \
    138     SCHIFF_PARAM_DEFAULT__,                                                   \
    139     SCHIFF_PARAM_DEFAULT__},                                                  \
    140    {SCHIFF_PARAM_DEFAULT__,                                                   \
    141     SCHIFF_PARAM_DEFAULT__,                                                   \
    142     SCHIFF_PARAM_DEFAULT__,                                                   \
    143     SCHIFF_PARAM_DEFAULT__,                                                   \
    144     SCHIFF_PARAM_DEFAULT__,                                                   \
    145     SCHIFF_PARAM_DEFAULT__}},                                                 \
    146    SCHIFF_PARAM_DEFAULT__,                                                    \
    147    64                                                                         \
    148 }
    149 
    150 static const struct schiff_supershape SCHIFF_SUPERSHAPE_DEFAULT =
    151   SCHIFF_SUPERSHAPE_DEFAULT__;
    152 
    153 struct schiff_geometry {
    154   /* Shape of the geometry */
    155   enum schiff_geometry_type type;
    156   union {
    157     struct schiff_ellipsoid ellipsoid;
    158     struct schiff_cylinder cylinder;
    159     struct schiff_helical_pipe helical_pipe;
    160     struct schiff_sphere sphere;
    161     struct schiff_supershape supershape;
    162   } data;
    163 };
    164 
    165 #define SCHIFF_GEOMETRY_NULL__ {SCHIFF_NONE, { SCHIFF_ELLIPSOID_DEFAULT__ }}
    166 static const struct schiff_geometry SCHIFF_GEOMETRY_NULL =
    167 SCHIFF_GEOMETRY_NULL__;
    168 
    169 /* Forward declarations */
    170 struct s3d_device;
    171 struct schiff_optical_properties;
    172 struct sschiff_geometry_distribution;
    173 
    174 extern LOCAL_SYM res_T
    175 schiff_geometry_distribution_init
    176   (struct sschiff_geometry_distribution* distrib, /* The distribution to init */
    177    struct s3d_device* s3d,
    178    const struct schiff_geometry* geometry,
    179    const size_t ngeoms,
    180    const double characteristic_length,
    181    struct ssp_ranst_discrete* ran_geoms,
    182    struct schiff_optical_properties* properties);
    183 
    184 extern LOCAL_SYM void
    185 schiff_geometry_distribution_release
    186   (struct sschiff_geometry_distribution* distrib);
    187 
    188 #endif /* SCHIFF_GEOMETRY_H */
    189