stardis-description.h (4956B)
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 STARDIS_DESCRIPTION_H 17 #define STARDIS_DESCRIPTION_H 18 19 #include <rsys/rsys.h> 20 #include <rsys/dynamic_array.h> 21 #include <rsys/str.h> 22 23 #include <sdis.h> 24 25 #include <limits.h> 26 27 /* Forward declarations */ 28 struct mem_allocator; 29 30 /* Different types of descriptions */ 31 enum description_type { 32 DESC_MAT_SOLID, 33 DESC_MAT_FLUID, 34 DESC_BOUND_H_FOR_FLUID, 35 DESC_BOUND_H_FOR_SOLID, 36 DESC_BOUND_T_FOR_SOLID, 37 DESC_BOUND_F_FOR_SOLID, 38 DESC_SOLID_FLUID_CONNECT, 39 DESC_SOLID_SOLID_CONNECT, 40 DESC_MAT_SOLID_PROG, 41 DESC_MAT_FLUID_PROG, 42 DESC_BOUND_H_FOR_FLUID_PROG, 43 DESC_BOUND_H_FOR_SOLID_PROG, 44 DESC_BOUND_HF_FOR_SOLID, 45 DESC_BOUND_HF_FOR_SOLID_PROG, 46 DESC_BOUND_T_FOR_SOLID_PROG, 47 DESC_BOUND_F_FOR_SOLID_PROG, 48 DESC_SOLID_FLUID_CONNECT_PROG, 49 DESC_SOLID_SOLID_CONNECT_PROG, 50 DESC_PROGRAM, 51 DESCRIPTION_TYPE_COUNT__ 52 }; 53 54 #define DESC_IS_H(D) \ 55 ((D)->type == DESC_BOUND_H_FOR_SOLID || (D)->type == DESC_BOUND_H_FOR_FLUID \ 56 || (D)->type == DESC_BOUND_H_FOR_SOLID_PROG \ 57 || (D)->type == DESC_BOUND_H_FOR_FLUID_PROG) 58 #define DESC_IS_HF(D) \ 59 ((D)->type == DESC_BOUND_HF_FOR_SOLID\ 60 || (D)->type == DESC_BOUND_HF_FOR_SOLID_PROG) 61 #define DESC_IS_T(D) \ 62 ((D)->type == DESC_BOUND_T_FOR_SOLID \ 63 || (D)->type == DESC_BOUND_T_FOR_SOLID_PROG) 64 #define DESC_IS_F(D) \ 65 ((D)->type == DESC_BOUND_F_FOR_SOLID \ 66 || (D)->type == DESC_BOUND_F_FOR_SOLID_PROG) 67 #define DESC_IS_SOLID(D) \ 68 ((D)->type == DESC_MAT_SOLID || (D)->type == DESC_MAT_SOLID_PROG) 69 #define DESC_IS_FLUID(D) \ 70 ((D)->type == DESC_MAT_FLUID || (D)->type == DESC_MAT_FLUID_PROG) 71 #define DESC_IS_MEDIUM(D) \ 72 (DESC_IS_SOLID(D) || DESC_IS_FLUID(D)) 73 #define DESC_IS_BOUNDARY(D) \ 74 (DESC_IS_H(D) || DESC_IS_T(D) || DESC_IS_F(D)) 75 #define DESC_IS_SOLID_FLUID(D) \ 76 ((D)->type == DESC_SOLID_FLUID_CONNECT \ 77 || (D)->type == DESC_SOLID_FLUID_CONNECT_PROG) 78 #define DESC_IS_SOLID_SOLID(D) \ 79 ((D)->type == DESC_SOLID_SOLID_CONNECT \ 80 || (D)->type == DESC_SOLID_SOLID_CONNECT_PROG) 81 #define DESC_IS_CONNECTION(D) \ 82 (DESC_IS_SOLID_FLUID(D) || DESC_IS_SOLID_SOLID(D)) 83 #define DESC_IS_PROG(D) \ 84 ((D)->type == DESC_MAT_SOLID_PROG || (D)->type == DESC_MAT_FLUID_PROG \ 85 || (D)->type == DESC_BOUND_H_FOR_FLUID_PROG \ 86 || (D)->type == DESC_BOUND_H_FOR_SOLID_PROG \ 87 || (D)->type == DESC_BOUND_HF_FOR_SOLID_PROG \ 88 || (D)->type == DESC_BOUND_T_FOR_SOLID_PROG \ 89 || (D)->type == DESC_BOUND_F_FOR_SOLID_PROG \ 90 || (D)->type == DESC_SOLID_FLUID_CONNECT_PROG \ 91 || (D)->type == DESC_SOLID_SOLID_CONNECT_PROG) 92 93 /******************************************************************************/ 94 95 struct fluid; 96 struct fluid_prog; 97 struct solid; 98 struct solid_prog; 99 struct t_boundary; 100 struct t_boundary_prog; 101 struct f_boundary; 102 struct f_boundary_prog; 103 struct h_boundary; 104 struct h_boundary_prog; 105 struct hf_boundary; 106 struct hf_boundary_prog; 107 struct solid_fluid_connect; 108 struct solid_fluid_connect_prog; 109 struct solid_solid_connect; 110 struct solid_solid_connect_prog; 111 struct program; 112 113 struct description { 114 enum description_type type; 115 union { 116 struct fluid* fluid; 117 struct fluid_prog* fluid_prog; 118 struct solid* solid; 119 struct solid_prog* solid_prog; 120 struct t_boundary* t_boundary; 121 struct t_boundary_prog* t_boundary_prog; 122 struct f_boundary* f_boundary; 123 struct f_boundary_prog* f_boundary_prog; 124 struct h_boundary* h_boundary; 125 struct h_boundary_prog* h_boundary_prog; 126 struct hf_boundary* hf_boundary; 127 struct hf_boundary_prog* hf_boundary_prog; 128 struct solid_fluid_connect* sf_connect; 129 struct solid_fluid_connect_prog* sf_connect_prog; 130 struct solid_solid_connect* ss_connect; 131 struct solid_solid_connect_prog* ss_connect_prog; 132 struct program* program; 133 } d; 134 }; 135 136 /******************************************************************************/ 137 res_T 138 init_description 139 (struct mem_allocator* alloc, 140 struct description* desc); 141 142 void 143 release_description 144 (struct description* desc, 145 struct mem_allocator* allocator); 146 147 res_T 148 str_print_description 149 (struct str* str, 150 const unsigned rank, 151 const struct description* desc); 152 153 const struct str* 154 get_description_name 155 (const struct description* desc); 156 157 void 158 description_get_medium_id 159 (const struct description* desc, 160 unsigned* id); 161 162 #endif