stardis

Perform coupled heat transfer calculations
git clone git://git.meso-star.fr/stardis.git
Log | Files | Refs | README | LICENSE

stardis-extern-source.h (3026B)


      1 /* Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
      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 SDIS_EXTERN_SOURCE_H
     17 #define SDIS_EXTERN_SOURCE_H
     18 
     19 #include <rsys/rsys.h>
     20 
     21 /* Forward declaration */
     22 struct stardis;
     23 struct stardis_description_create_context;
     24 
     25 enum source_type {
     26   EXTERN_SOURCE_SPHERE,
     27   EXTERN_SOURCE_SPHERE_PROG,
     28   EXTERN_SOURCE_NONE__
     29 };
     30 
     31 struct spherical_source {
     32   double position[3];
     33   double radius;
     34   double power; /* [W] */
     35   double diffuse_radiance; /* [W/m^2/sr] */
     36 };
     37 #define SPHERICAL_SOURCE_NULL__ {{0,0,0}, -1, 0, 0}
     38 static const struct spherical_source SPHERICAL_SOURCE_NULL =
     39   SPHERICAL_SOURCE_NULL__;
     40 
     41 struct spherical_source_prog {
     42   struct str prog_name;
     43   struct program* program;
     44   void* data; /* Pointer toward the program data */
     45   struct mem_allocator* allocator;
     46 
     47   /* Input arguments */
     48   size_t argc;
     49   char** argv;
     50 
     51   double radius; /* Not programmable */
     52 
     53   void*
     54   (*create)
     55     (const struct stardis_description_create_context*,
     56      void* lib_data,
     57      size_t argc,
     58      char* argv[]);
     59 
     60   void
     61   (*release)
     62     (void* data);
     63 
     64   double*
     65   (*position)
     66     (const double time,
     67      double position[3],
     68      void* data);
     69 
     70   double
     71   (*power)
     72     (const double time,
     73      void* data);
     74 
     75   double
     76   (*diffuse_radiance)
     77     (const double time,
     78      const double dir[3],
     79      void* data);
     80 };
     81 #define SPHERICAL_SOURCE_PROG_NULL__ \
     82   {{0}, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL}
     83 static const struct spherical_source_prog SPHERICAL_SOURCE_PROG_NULL=
     84   SPHERICAL_SOURCE_PROG_NULL__;
     85 
     86 /* Interface of an external source */
     87 struct extern_source {
     88   enum source_type type;
     89   union {
     90     struct spherical_source sphere;
     91     struct spherical_source_prog sphere_prog;
     92   } data;
     93   struct sdis_source* sdis_src;
     94 };
     95 #define EXTERN_SOURCE_NULL__ \
     96   {EXTERN_SOURCE_NONE__, {SPHERICAL_SOURCE_NULL__}, NULL}
     97 static const struct extern_source EXTERN_SOURCE_NULL = EXTERN_SOURCE_NULL__;
     98 
     99 extern LOCAL_SYM res_T
    100 extern_source_init_sphere
    101   (struct mem_allocator* allocator,
    102    struct extern_source* src);
    103 
    104 extern LOCAL_SYM res_T
    105 extern_source_init_sphere_prog
    106   (struct mem_allocator* allocator,
    107    struct extern_source* src);
    108 
    109 extern LOCAL_SYM void
    110 extern_source_release
    111   (struct extern_source* src);
    112 
    113 extern LOCAL_SYM res_T
    114 extern_source_create_solver_source
    115   (struct extern_source* src,
    116    struct stardis* stardis);
    117 
    118 #endif /* SDIS_EXTERN_SOURCE_H */