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 (6338B)


      1 /* Copyright (C) 2015-2016 CNRS
      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 SCHIFF_GEOMETRY_H
     17 #define SCHIFF_GEOMETRY_H
     18 
     19 #include <rsys/rsys.h>
     20 #include <star/ssp.h>
     21 
     22 enum schiff_param_distribution {
     23   SCHIFF_PARAM_CONSTANT,
     24   SCHIFF_PARAM_LOGNORMAL,
     25   SCHIFF_PARAM_GAUSSIAN,
     26   SCHIFF_PARAM_HISTOGRAM,
     27   SCHIFF_PARAM_NONE
     28 };
     29 
     30 struct schiff_param {
     31   enum schiff_param_distribution distribution;
     32   union {
     33     double constant;
     34     struct { double mu, sigma; } lognormal;
     35     struct { double mu, sigma, range[2]; } gaussian;
     36     struct { double *entries, lower, upper; } histogram;
     37   } data;
     38 };
     39 #define SCHIFF_PARAM_DEFAULT__ {SCHIFF_PARAM_CONSTANT, {1.0}}
     40 
     41 enum schiff_geometry_type {
     42   SCHIFF_CYLINDER,
     43   SCHIFF_ELLIPSOID,
     44   SCHIFF_HELICAL_PIPE,
     45   SCHIFF_SPHERE,
     46   SCHIFF_SUPERSHAPE,
     47 
     48   /* Volume is controlled by a sphere */
     49   SCHIFF_CYLINDER_AS_SPHERE,
     50   SCHIFF_ELLIPSOID_AS_SPHERE,
     51   SCHIFF_HELICAL_PIPE_AS_SPHERE,
     52   SCHIFF_SUPERSHAPE_AS_SPHERE,
     53 
     54   SCHIFF_NONE
     55 };
     56 
     57 /* (x/a)^2 + (y/a)^2 + (z/c)^2 = 1 */
     58 struct schiff_ellipsoid {
     59   struct schiff_param a;
     60   struct schiff_param c;
     61 
     62   /* In use by SCHIFF_ELLIPSOID_AS_SPHERE */
     63   struct schiff_param radius_sphere;
     64 
     65   unsigned nslices;
     66 };
     67 
     68 #define SCHIFF_ELLIPSOID_DEFAULT__ \
     69   {SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, 64}
     70 static const struct schiff_ellipsoid SCHIFF_ELLIPSOID_DEFAULT =
     71   SCHIFF_ELLIPSOID_DEFAULT__;
     72 
     73 struct schiff_sphere {
     74   struct schiff_param radius;
     75   unsigned nslices;
     76 };
     77 
     78 struct schiff_helical_pipe {
     79   struct schiff_param pitch; /* Elevation distance of a full revolution */
     80   struct schiff_param height; /* Total heigh of the helical pipe */
     81   struct schiff_param radius_helicoid; /* Radius of the helicoid */
     82   struct schiff_param radius_circle; /* Radius of the meridian circle */
     83 
     84   /* In use by SCHIFF_HELICAL_PIPE_AS_SPHERE */
     85   struct schiff_param radius_sphere;
     86 
     87   unsigned nslices_helicoid; /* # Discrete steps of the helicoid */
     88   unsigned nslices_circle; /* # Discrete steps along 2PI */
     89 };
     90 
     91 #define SCHIFF_HELICAL_PIPE_DEFAULT__                                          \
     92   {SCHIFF_PARAM_DEFAULT__,                                                     \
     93    SCHIFF_PARAM_DEFAULT__,                                                     \
     94    SCHIFF_PARAM_DEFAULT__,                                                     \
     95    SCHIFF_PARAM_DEFAULT__,                                                     \
     96    SCHIFF_PARAM_DEFAULT__,                                                     \
     97    128, 64}
     98 static const struct schiff_helical_pipe SCHIFF_HELICAL_PIPE_DEFAULT =
     99   SCHIFF_HELICAL_PIPE_DEFAULT__;
    100 
    101 #define SCHIFF_SPHERE_DEFAULT__ {SCHIFF_PARAM_DEFAULT__, 64}
    102 static const struct schiff_sphere SCHIFF_SPHERE_DEFAULT =
    103   SCHIFF_SPHERE_DEFAULT__;
    104 
    105 struct schiff_cylinder {
    106   struct schiff_param radius;
    107   struct schiff_param height;
    108 
    109   /* In use by SCHIFF_CYLINDER_AS_SPHERE */
    110   struct schiff_param radius_sphere;
    111 
    112   unsigned nslices;
    113 };
    114 
    115 #define SCHIFF_CYLINDER_DEFAULT__ \
    116   {SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, SCHIFF_PARAM_DEFAULT__, 64}
    117 static const struct schiff_cylinder SCHIFF_CYLINDER_DEFAULT =
    118   SCHIFF_CYLINDER_DEFAULT__;
    119 
    120 enum { A, B, M, N0, N1, N2 }; /* Super formula arguments */
    121 
    122 struct schiff_supershape {
    123   struct schiff_param formulas[2][6];
    124   /* In use by SCHIFF_SUPERSHAPE_AS_SPHERE */
    125   struct schiff_param radius_sphere;
    126   unsigned nslices;
    127 };
    128 #define SCHIFF_SUPERSHAPE_DEFAULT__                                            \
    129   {{{SCHIFF_PARAM_DEFAULT__,                                                   \
    130      SCHIFF_PARAM_DEFAULT__,                                                   \
    131      SCHIFF_PARAM_DEFAULT__,                                                   \
    132      SCHIFF_PARAM_DEFAULT__,                                                   \
    133      SCHIFF_PARAM_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     64}
    143 
    144 static const struct schiff_supershape SCHIFF_SUPERSHAPE_DEFAULT =
    145   SCHIFF_SUPERSHAPE_DEFAULT__;
    146 
    147 struct schiff_geometry {
    148   /* Shape of the geometry */
    149   enum schiff_geometry_type type;
    150   union {
    151     struct schiff_ellipsoid ellipsoid;
    152     struct schiff_cylinder cylinder;
    153     struct schiff_helical_pipe helical_pipe;
    154     struct schiff_sphere sphere;
    155     struct schiff_supershape supershape;
    156   } data;
    157 };
    158 
    159 #define SCHIFF_GEOMETRY_NULL__ {SCHIFF_NONE, { SCHIFF_ELLIPSOID_DEFAULT__ }}
    160 static const struct schiff_geometry SCHIFF_GEOMETRY_NULL =
    161 SCHIFF_GEOMETRY_NULL__;
    162 
    163 /* Forward declarations */
    164 struct s3d_device;
    165 struct schiff_optical_properties;
    166 struct sschiff_geometry_distribution;
    167 
    168 extern LOCAL_SYM res_T
    169 schiff_geometry_distribution_init
    170   (struct sschiff_geometry_distribution* distrib, /* The distribution to init */
    171    struct s3d_device* s3d,
    172    const struct schiff_geometry* geometry,
    173    const size_t ngeoms,
    174    const double characteristic_length,
    175    struct ssp_ran_discrete* ran_geoms,
    176    struct schiff_optical_properties* properties);
    177 
    178 extern LOCAL_SYM void
    179 schiff_geometry_distribution_release
    180   (struct sschiff_geometry_distribution* distrib);
    181 
    182 #endif /* SCHIFF_GEOMETRY_H */
    183