atrstm

Load and structure a combustion gas mixture
git clone git://git.meso-star.fr/atrstm.git
Log | Files | Refs | README | LICENSE

atrstm_svx.h (3089B)


      1 /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     16 
     17 #ifndef ATRSTM_SVX_H
     18 #define ATRSTM_SVX_H
     19 
     20 #include "atrstm.h"
     21 
     22 /* SVX Memory layout
     23  * -----------------
     24  *
     25  * For each SVX voxel, the data of the optical property are stored
     26  * linearly as N single precision floating point data, with N computed as
     27  * below:
     28  *
     29  *  N = ATRSTM_RADCOEFS_COUNT__   #optical properties per voxel
     30  *    * ATRSTM_SVX_OPS_COUNT__ #supported operations on each properties
     31  *    * ATRSTM_CPNTS_COUNT__;  #components on which properties are defined
     32  *
     33  * In a given voxel, the index `id' in [0, N-1] corresponding to the optical
     34  * property `enum atrstm_radcoef P' of the component `enum atrstm_component
     35  * C' according to the operation `enum atrstm_svx_op O' is
     36  * then computed as bellow:
     37  *
     38  *  id = C * NFLOATS_PER_CPNT + P * ATRSTM_SVX_OPS_COUNT__ + O;
     39  *  NFLOATS_PER_CPNT = ATRSTM_SVX_OPS_COUNT__ * ATRSTM_RADCOEFS_COUNT__;
     40  */
     41 
     42 /* Constant defining the number of floating point data per component */
     43 #define NFLOATS_PER_CPNT (ATRSTM_SVX_OPS_COUNT__ * ATRSTM_RADCOEFS_COUNT__)
     44 
     45 /* Constant defining the overall number of floating point data of a voxel */
     46 #define NFLOATS_PER_VOXEL (NFLOATS_PER_CPNT * ATRSTM_CPNTS_COUNT__)
     47 
     48 static FINLINE float
     49 vox_get
     50   (const float* vox,
     51    const enum atrstm_component cpnt,
     52    const enum atrstm_radcoef prop,
     53    const enum atrstm_svx_op op)
     54 {
     55   ASSERT(vox);
     56   ASSERT((unsigned)cpnt < ATRSTM_CPNTS_COUNT__);
     57   ASSERT((unsigned)prop < ATRSTM_RADCOEFS_COUNT__);
     58   ASSERT((unsigned)op < ATRSTM_SVX_OPS_COUNT__);
     59   return vox[cpnt*NFLOATS_PER_CPNT + prop*ATRSTM_SVX_OPS_COUNT__ + op];
     60 }
     61 
     62 static FINLINE void
     63 vox_set
     64   (float* vox,
     65    const enum atrstm_component cpnt,
     66    const enum atrstm_radcoef prop,
     67    const enum atrstm_svx_op op,
     68    const float val)
     69 {
     70   ASSERT(vox);
     71   ASSERT((unsigned)cpnt < ATRSTM_CPNTS_COUNT__);
     72   ASSERT((unsigned)prop < ATRSTM_RADCOEFS_COUNT__);
     73   ASSERT((unsigned)op < ATRSTM_SVX_OPS_COUNT__);
     74   vox[cpnt*NFLOATS_PER_CPNT + prop*ATRSTM_SVX_OPS_COUNT__ + op] = val;
     75 }
     76 
     77 static FINLINE void
     78 vox_clear(float* vox)
     79 {
     80   int cpnt;
     81   ASSERT(vox);
     82 
     83   FOR_EACH(cpnt, 0, ATRSTM_CPNTS_COUNT__) {
     84     int prop;
     85     FOR_EACH(prop, 0, ATRSTM_RADCOEFS_COUNT__) {
     86       vox_set(vox, cpnt, prop, ATRSTM_SVX_OP_MIN, FLT_MAX);
     87       vox_set(vox, cpnt, prop, ATRSTM_SVX_OP_MAX,-FLT_MAX);
     88     }
     89   }
     90 }
     91 
     92 #endif /* ATRSTM_SVX_H */
     93