htrdr

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

htrdr_combustion_phase_func.c (4449B)


      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 #include "htrdr_combustion_c.h"
     25 
     26 #include <astoria/atrstm.h>
     27 
     28 #include <star/ssf.h>
     29 
     30 /*******************************************************************************
     31  * Helper functions
     32  ******************************************************************************/
     33 static struct ssf_phase*
     34 combustion_fetch_phase_isotropic
     35   (struct htrdr_combustion* cmd,
     36    const double wavelength, /* In nanometer */
     37    const struct suvm_primitive* prim,
     38    const double bcoords[4],
     39    const size_t ithread)
     40 {
     41   struct ssf_phase* phase = NULL;
     42   ASSERT(cmd && wavelength > 0 && prim && bcoords);
     43   ASSERT(ithread < htrdr_get_threads_count(cmd->htrdr));
     44   ASSERT(cmd->phase_func_type == HTRDR_COMBUSTION_ARGS_PHASE_FUNC_ISOTROPIC);
     45   (void)wavelength, (void)prim, (void)bcoords;
     46 
     47   /* Setup the isotropic phase function */
     48   phase = cmd->phase_functions[ithread];
     49   SSF(phase_hg_setup(phase, 0));
     50   return phase;
     51 }
     52 
     53 static struct ssf_phase*
     54 combustion_fetch_phase_rdgfa
     55   (struct htrdr_combustion* cmd,
     56    const double wavelength, /* In nanometer */
     57    const struct suvm_primitive* prim,
     58    const double bcoords[4],
     59    const size_t ithread)
     60 {
     61   struct atrstm_rdgfa rdgfa_param = ATRSTM_RDGFA_NULL;
     62   struct atrstm_fetch_rdgfa_args fetch_rdgfa_args =
     63     ATRSTM_FETCH_RDGFA_ARGS_DEFAULT;
     64   struct ssf_phase_rdgfa_setup_args setup_rdgfa_args =
     65     SSF_PHASE_RDGFA_SETUP_ARGS_DEFAULT;
     66   struct ssf_phase* phase = NULL;
     67   ASSERT(cmd && wavelength > 0 && prim && bcoords);
     68   ASSERT(ithread < htrdr_get_threads_count(cmd->htrdr));
     69   ASSERT(cmd->phase_func_type == HTRDR_COMBUSTION_ARGS_PHASE_FUNC_RDGFA);
     70 
     71   /* Retrieve the RDG-FA phase function parameters from the semi transparent
     72    * medium */
     73   fetch_rdgfa_args.wavelength = wavelength;
     74   fetch_rdgfa_args.prim = *prim;
     75   fetch_rdgfa_args.bcoords[0] = bcoords[0];
     76   fetch_rdgfa_args.bcoords[1] = bcoords[1];
     77   fetch_rdgfa_args.bcoords[2] = bcoords[2];
     78   fetch_rdgfa_args.bcoords[3] = bcoords[3];
     79   ATRSTM(fetch_rdgfa(cmd->medium, &fetch_rdgfa_args, &rdgfa_param));
     80 
     81   /* Setup the RDG-FA phase function */
     82   phase = cmd->phase_functions[ithread];
     83   setup_rdgfa_args.wavelength = rdgfa_param.wavelength;
     84   setup_rdgfa_args.fractal_dimension = rdgfa_param.fractal_dimension;
     85   setup_rdgfa_args.gyration_radius = rdgfa_param.gyration_radius;
     86   setup_rdgfa_args.simd = cmd->rdgfa_simd;
     87   SSF(phase_rdgfa_setup(phase, &setup_rdgfa_args));
     88 
     89   return phase;
     90 }
     91 
     92 /*******************************************************************************
     93  * Local functions
     94  ******************************************************************************/
     95 struct ssf_phase*
     96 combustion_fetch_phase_function
     97   (struct htrdr_combustion* cmd,
     98    const double wlen, /* In nanometer */
     99    const struct suvm_primitive* prim,
    100    const double bcoords[4],
    101    const size_t ithread)
    102 {
    103   struct ssf_phase* phase = NULL;
    104   switch(cmd->phase_func_type) {
    105     case HTRDR_COMBUSTION_ARGS_PHASE_FUNC_ISOTROPIC:
    106       phase = combustion_fetch_phase_isotropic(cmd, wlen, prim, bcoords, ithread);
    107       break;
    108     case HTRDR_COMBUSTION_ARGS_PHASE_FUNC_RDGFA:
    109       phase = combustion_fetch_phase_rdgfa(cmd, wlen, prim, bcoords, ithread);
    110       break;
    111     default: FATAL("Unreachable code.\n"); break;
    112   }
    113   return phase;
    114 }
    115