1 #ifndef __CS_BOUNDARY_ZONE_H__ 2 #define __CS_BOUNDARY_ZONE_H__ 3 4 /*============================================================================ 5 * Boundary zones handling. 6 *============================================================================*/ 7 8 /* 9 This file is part of Code_Saturne, a general-purpose CFD tool. 10 11 Copyright (C) 1998-2021 EDF S.A. 12 13 This program is free software; you can redistribute it and/or modify it under 14 the terms of the GNU General Public License as published by the Free Software 15 Foundation; either version 2 of the License, or (at your option) any later 16 version. 17 18 This program is distributed in the hope that it will be useful, but WITHOUT 19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 details. 22 23 You should have received a copy of the GNU General Public License along with 24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 25 Street, Fifth Floor, Boston, MA 02110-1301, USA. 26 */ 27 28 /*----------------------------------------------------------------------------*/ 29 30 /*---------------------------------------------------------------------------- 31 * Standard C library headers 32 *----------------------------------------------------------------------------*/ 33 34 /*---------------------------------------------------------------------------- 35 * Local headers 36 *----------------------------------------------------------------------------*/ 37 38 #include "cs_base.h" 39 #include "cs_mesh_location.h" 40 41 /*---------------------------------------------------------------------------- 42 * Local headers 43 *----------------------------------------------------------------------------*/ 44 45 #include "cs_defs.h" 46 #include "cs_zone.h" 47 48 /*----------------------------------------------------------------------------*/ 49 50 BEGIN_C_DECLS 51 52 /*============================================================================ 53 * Macro definitions 54 *============================================================================*/ 55 56 /*! 57 * @defgroup boundary_zone_flags Flags specifying general boundary zone type 58 * 59 * @{ 60 */ 61 62 /* 63 * Zone type 64 */ 65 66 /*! initialization zone */ 67 #define CS_BOUNDARY_ZONE_WALL (1 << 0) 68 69 /*! zone defined for internal usage */ 70 #define CS_BOUNDARY_ZONE_PRIVATE (1 << 1) 71 72 /*! @} */ 73 74 /*============================================================================ 75 * Type definitions 76 *============================================================================*/ 77 78 /*============================================================================= 79 * Global variables 80 *============================================================================*/ 81 82 /*============================================================================ 83 * Public function prototypes 84 *============================================================================*/ 85 86 /*----------------------------------------------------------------------------*/ 87 /*! 88 * \brief Initialize boundary zone structures. 89 * 90 * This defines a default boundary zone. This is the first function of 91 * the boundary zone handling functions which should be called, and it should 92 * only be called after \ref cs_mesh_location_initialize. 93 */ 94 /*----------------------------------------------------------------------------*/ 95 96 void 97 cs_boundary_zone_initialize(void); 98 99 /*----------------------------------------------------------------------------*/ 100 /*! 101 * \brief Free all boundary zone structures. 102 */ 103 /*----------------------------------------------------------------------------*/ 104 105 void 106 cs_boundary_zone_finalize(void); 107 108 /*----------------------------------------------------------------------------*/ 109 /*! 110 * \brief Return number of boundary zones defined. 111 */ 112 /*----------------------------------------------------------------------------*/ 113 114 int 115 cs_boundary_zone_n_zones(void); 116 117 /*----------------------------------------------------------------------------*/ 118 /*! 119 * \brief Return number of boundary zones which may vary in time. 120 * 121 * \return number of zones which may vary in time 122 */ 123 /*----------------------------------------------------------------------------*/ 124 125 int 126 cs_boundary_zone_n_zones_time_varying(void); 127 128 /*----------------------------------------------------------------------------*/ 129 /*! 130 * \brief Update association of a given private boundary zone with a mesh. 131 * 132 * For time-varying zones, the associated mesh location is updated. 133 * 134 * \param[in] id zone id 135 */ 136 /*----------------------------------------------------------------------------*/ 137 138 void 139 cs_boundary_zone_build_private(int id); 140 141 /*----------------------------------------------------------------------------*/ 142 /*! 143 * \brief Update association of boundary zones with a mesh. 144 * 145 * For time-varying zones, the associated mesh location is updated. 146 * 147 * \param[in] mesh_modified indicate if mesh has been modified 148 */ 149 /*----------------------------------------------------------------------------*/ 150 151 void 152 cs_boundary_zone_build_all(bool mesh_modified); 153 154 /*----------------------------------------------------------------------------*/ 155 /*! 156 * \brief Define a new boundary zone using a selection criteria string. 157 * 158 * \param[in] name name of location to define 159 * \param[in] criteria selection criteria for associated elements 160 * \param[in] type_flag mask of zone category values 161 * 162 * \return id of newly defined boundary zone 163 */ 164 /*----------------------------------------------------------------------------*/ 165 166 int 167 cs_boundary_zone_define(const char *name, 168 const char *criteria, 169 int type_flag); 170 171 /*----------------------------------------------------------------------------*/ 172 /*! 173 * \brief Define a new mesh location with an associated selection function. 174 * 175 * So as to define a subset of mesh entities of a given type, a pointer 176 * to a selection function may be given. 177 * 178 * This requires more programming but allows finer control than selection 179 * criteria, as the function has access to the complete mesh structure. 180 * 181 * \param[in] name name of location to define 182 * \param[in] func pointer to selection function for associated elements 183 * \param[in, out] input pointer to optional (untyped) value 184 * or structure. 185 * \param[in] type_flag mask of zone category values 186 * 187 * \return id of newly defined created mesh location 188 */ 189 /*----------------------------------------------------------------------------*/ 190 191 int 192 cs_boundary_zone_define_by_func(const char *name, 193 cs_mesh_location_select_t *func, 194 void *input, 195 int type_flag); 196 197 /*----------------------------------------------------------------------------*/ 198 /*! 199 * \brief Return a pointer to a boundary zone based on its id. 200 * 201 * This function requires that a boundary zone of the given id is defined. 202 * 203 * \param[in] id zone id 204 * 205 * \return pointer to the boundary zone structure 206 */ 207 /*----------------------------------------------------------------------------*/ 208 209 const cs_zone_t * 210 cs_boundary_zone_by_id(int id); 211 212 /*----------------------------------------------------------------------------*/ 213 /*! 214 * \brief Return a pointer to a boundary zone based on its name if present. 215 * 216 * This function requires that a boundary zone of the given name is defined. 217 * 218 * \param[in] name boundary zone name 219 * 220 * \return pointer to (read-only) zone structure 221 */ 222 /*----------------------------------------------------------------------------*/ 223 224 const cs_zone_t * 225 cs_boundary_zone_by_name(const char *name); 226 227 /*----------------------------------------------------------------------------*/ 228 /*! 229 * \brief Return a pointer to a boundary zone based on its name if present. 230 * 231 * If no boundary zone of the given name is defined, NULL is returned. 232 * 233 * \param[in] name boundary zone name 234 * 235 * \return pointer to (read only) zone structure, or NULL 236 */ 237 /*----------------------------------------------------------------------------*/ 238 239 const cs_zone_t * 240 cs_boundary_zone_by_name_try(const char *name); 241 242 /*----------------------------------------------------------------------------*/ 243 /*! 244 * \brief Set type flag for a given boundary zone. 245 * 246 * \param[in] id boundary zone id 247 * \param[in] type_flag volume zone type flag 248 */ 249 /*----------------------------------------------------------------------------*/ 250 251 void 252 cs_boundary_zone_set_type(int id, 253 int type_flag); 254 255 /*----------------------------------------------------------------------------*/ 256 /*! 257 * \brief Set time varying behavior for a given boundary zone. 258 * 259 * \param[in] id boundary zone id 260 * \param[in] time_varying true if the zone's definition varies in time 261 */ 262 /*----------------------------------------------------------------------------*/ 263 264 void 265 cs_boundary_zone_set_time_varying(int id, 266 bool time_varying); 267 268 /*----------------------------------------------------------------------------*/ 269 /*! 270 * \brief Set overlay behavior for a given boundary zone. 271 * 272 * \param[in] id boundary zone id 273 * \param[in] allow_overlay true if the zone may be overlayed by another 274 */ 275 /*----------------------------------------------------------------------------*/ 276 277 void 278 cs_boundary_zone_set_overlay(int id, 279 bool allow_overlay); 280 281 /*----------------------------------------------------------------------------*/ 282 /*! 283 * \brief Return pointer to zone id associated with each boundary face. 284 * 285 * In case of overlayed zones, the highest zone id associated with 286 * a given face is given. Private (automatically defined) zones 287 * are excluded from this definition. 288 */ 289 /*----------------------------------------------------------------------------*/ 290 291 const int * 292 cs_boundary_zone_face_zone_id(void); 293 294 /*----------------------------------------------------------------------------*/ 295 /*! 296 * \brief Print info relative to a given boundary zone to log file. 297 * 298 * \param[in] z pointer to boundary zone structure 299 */ 300 /*----------------------------------------------------------------------------*/ 301 302 void 303 cs_boundary_zone_log_info(const cs_zone_t *z); 304 305 /*----------------------------------------------------------------------------*/ 306 /*! 307 * \brief Log setup information relative to defined boundary zones. 308 */ 309 /*----------------------------------------------------------------------------*/ 310 311 void 312 cs_boundary_zone_log_setup(void); 313 314 /*----------------------------------------------------------------------------*/ 315 /*! 316 * \brief Return number of boundary zones associated with a 317 * given zone flag. 318 * 319 * Private (automatic) zones are excluded from this count. 320 * 321 * \param[in] type_flag flag to compare to zone type 322 * 323 * \return number of zones matching the given type flag 324 */ 325 /*----------------------------------------------------------------------------*/ 326 327 int 328 cs_boundary_zone_n_type_zones(int type_flag); 329 330 /*----------------------------------------------------------------------------*/ 331 /*! 332 * \brief Get pointer to optional boundary face class ids. 333 * 334 * For each boundary face, a specific output (logging and postprocessing) 335 * class id may be assigned. This allows realizing logging, postprocessing, 336 * or otherwise extracting data based on this class. 337 * 338 * Using this function at a given point indicates that user-defined class 339 * ids will be used. The face class ids are initially equal to the 340 * face zone ids, but may be modified by the user. 341 * 342 * In the presence of a time-varying mesh or boundary zones, the face 343 * class ids will be reset to the zone ids, so it may be necessary to 344 * update the user definitions. 345 * 346 * The class id values are arbitrarily chosen by the user, but must be 347 * positive integers; numbers do not need to be contiguous, but very high 348 * numbers may also lead to higher memory consumption. 349 * 350 * \return pointer to array of boundary face output zone ids; 351 */ 352 /*----------------------------------------------------------------------------*/ 353 354 int * 355 cs_boundary_zone_face_class_id(void); 356 357 /*----------------------------------------------------------------------------*/ 358 /*! 359 * \brief Get read pointer to optional boundary face class or zone ids. 360 * 361 * If no face classes have been defined by \ref cs_boundary_zone_face_class_id 362 * the boundary face zone id is returned instead. 363 * 364 * \return pointer to array of boundary face output zone ids; 365 */ 366 /*----------------------------------------------------------------------------*/ 367 368 const int * 369 cs_boundary_zone_face_class_or_zone_id(void); 370 371 /*----------------------------------------------------------------------------*/ 372 /*! 373 * \brief Update boundary face output class ids if present. 374 * 375 * Face class ids lower than 0 are replaced by the matching face zone id. 376 */ 377 /*----------------------------------------------------------------------------*/ 378 379 void 380 cs_boundary_zone_update_face_class_id(void); 381 382 /*----------------------------------------------------------------------------*/ 383 /*! 384 * \brief Return the maximum defined face class or zone id. 385 * 386 * \return maximum face class or zone id; 387 */ 388 /*----------------------------------------------------------------------------*/ 389 390 int 391 cs_boundary_zone_max_class_or_zone_id(void); 392 393 /*----------------------------------------------------------------------------*/ 394 /*! 395 * \brief Print boundary zones information to listing file 396 */ 397 /*----------------------------------------------------------------------------*/ 398 399 void 400 cs_boundary_zone_print_info(void); 401 402 /*----------------------------------------------------------------------------*/ 403 404 END_C_DECLS 405 406 #endif /* __CS_BOUNDARY_ZONE_H__ */ 407