stardis

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

stardis-compute.h (2993B)


      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_COMPUTE_H
     17 #define SDIS_COMPUTE_H
     18 
     19 #include <rsys/rsys.h>
     20 #include <rsys/dynamic_array.h>
     21 
     22 struct stardis;
     23 struct time;
     24 struct str;
     25 
     26 #define DARRAY_NAME estimators
     27 #define DARRAY_DATA struct sdis_estimator*
     28 #include <rsys/dynamic_array.h>
     29 
     30 #define READ_RANDOM_STATE(Name) \
     31   if(!stardis->mpi_initialized || stardis->mpi_rank == 0) { \
     32     if(str_is_empty(Name)) { \
     33       /* Force using threefry independently of the default RNG type */ \
     34       args.rng_type = SSP_RNG_THREEFRY; \
     35     } else { \
     36       const char* name = str_cget(Name); \
     37       stream_r = fopen(name, "r"); \
     38       if(!stream_r) { \
     39         res = RES_IO_ERR; \
     40         logger_print(stardis->logger, LOG_ERROR, \
     41           "Cannot open generator's state file ('%s').\n", \
     42           name); \
     43         goto error; \
     44       } \
     45       ERR(ssp_rng_create(stardis->allocator, SSP_RNG_THREEFRY, &args.rng_state)); \
     46       res =  read_random_generator_state(args.rng_state, stream_r); \
     47       if(res != RES_OK) { \
     48         logger_print(stardis->logger, LOG_ERROR, \
     49           "Cannot read random generator's state ('%s').\n", \
     50           name); \
     51         goto error; \
     52       } \
     53       fclose(stream_r); stream_r = NULL; \
     54     } \
     55   }
     56 
     57 #define WRITE_RANDOM_STATE(Name) \
     58   if(!stardis->mpi_initialized || stardis->mpi_rank == 0) { \
     59     if(!str_is_empty(Name)) { \
     60       const char* name = str_cget(Name); \
     61       stream_r = fopen(name, "wb"); \
     62       if(!stream_r) { \
     63         res = RES_IO_ERR; \
     64         logger_print(stardis->logger, LOG_ERROR, \
     65           "Cannot write random generator's state ('%s').\n", \
     66           name); \
     67         goto error; \
     68       } \
     69       ERR(write_random_generator_state(estimator, stream_r)); \
     70       fclose(stream_r); stream_r = NULL; \
     71     } \
     72   }
     73 
     74 extern LOCAL_SYM struct sdis_medium*
     75 find_medium_by_name
     76   (struct stardis* stardis,
     77    const char* name,
     78    unsigned* id); /* Can be NULL */
     79 
     80 extern LOCAL_SYM res_T
     81 stardis_compute
     82   (struct stardis* stardis,
     83    struct time* start);
     84 
     85 extern LOCAL_SYM res_T
     86 read_compute_surface
     87   (struct stardis* stardis);
     88 
     89 extern LOCAL_SYM res_T
     90 compute_probe_on_interface
     91   (struct stardis* stardis,
     92    struct time* start);
     93 
     94 extern  LOCAL_SYM res_T
     95 compute_flux_density_boundary
     96   (struct stardis* stardis,
     97    struct time* start);
     98 
     99 #endif