9.2
general documentation
cs_boundary_zone.h
Go to the documentation of this file.
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-2026 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 "base/cs_base.h"
40
41/*----------------------------------------------------------------------------
42 * Local headers
43 *----------------------------------------------------------------------------*/
44
45#include "base/cs_defs.h"
46#include "base/cs_zone.h"
47
48/*============================================================================
49 * Macro definitions
50 *============================================================================*/
51
58/*
59 * Zone type
60 */
61
63#define CS_BOUNDARY_ZONE_WALL (1 << 0)
64
66#define CS_BOUNDARY_ZONE_PRIVATE (1 << 1)
67
70/*============================================================================
71 * Type definitions
72 *============================================================================*/
73
74/*=============================================================================
75 * Global variables
76 *============================================================================*/
77
78/*============================================================================
79 * Public function prototypes
80 *============================================================================*/
81
82/*----------------------------------------------------------------------------*/
83/*
84 * \brief Initialize boundary zone structures.
85 *
86 * This defines a default boundary zone. This is the first function of
87 * the boundary zone handling functions which should be called, and it should
88 * only be called after \ref cs_mesh_location_initialize.
89 */
90/*----------------------------------------------------------------------------*/
91
92void
94
95/*----------------------------------------------------------------------------*/
96/*
97 * \brief Free all boundary zone structures.
98 */
99/*----------------------------------------------------------------------------*/
100
101void
103
104/*----------------------------------------------------------------------------*/
105/*
106 * \brief Return number of boundary zones defined.
107 */
108/*----------------------------------------------------------------------------*/
109
110int
112
113/*----------------------------------------------------------------------------*/
114/*
115 * \brief Return number of boundary zones which may vary in time.
116 *
117 * \return number of zones which may vary in time
118 */
119/*----------------------------------------------------------------------------*/
120
121int
123
124/*----------------------------------------------------------------------------*/
125/*
126 * \brief Update association of a given private boundary zone with a mesh.
127 *
128 * For time-varying zones, the associated mesh location is updated.
129 *
130 * \param[in] id zone id
131 */
132/*----------------------------------------------------------------------------*/
133
134void
136
137/*----------------------------------------------------------------------------*/
145/*----------------------------------------------------------------------------*/
146
147void
148cs_boundary_zone_build_all(bool mesh_modified);
149
150/*----------------------------------------------------------------------------*/
151/*
152 * \brief Define a new boundary zone using a selection criteria string.
153 *
154 * \param[in] name name of location to define
155 * \param[in] criteria selection criteria for associated elements
156 * \param[in] type_flag mask of zone category values
157 *
158 * \return id of newly defined boundary zone
159 */
160/*----------------------------------------------------------------------------*/
161
162int
163cs_boundary_zone_define(const char *name,
164 const char *criteria,
165 int type_flag);
166
167/*----------------------------------------------------------------------------*/
168/*
169 * \brief Define a new mesh location with an associated selection function.
170 *
171 * So as to define a subset of mesh entities of a given type, a pointer
172 * to a selection function may be given.
173 *
174 * This requires more programming but allows finer control than selection
175 * criteria, as the function has access to the complete mesh structure.
176 *
177 * \param[in] name name of location to define
178 * \param[in] func pointer to selection function for associated elements
179 * \param[in, out] input pointer to optional (untyped) value
180 * or structure.
181 * \param[in] type_flag mask of zone category values
182 *
183 * \return id of newly defined created mesh location
184 */
185/*----------------------------------------------------------------------------*/
186
187int
188cs_boundary_zone_define_by_func(const char *name,
190 void *input,
191 int type_flag);
192
193/*----------------------------------------------------------------------------*/
194/*
195 * \brief Return a pointer to a boundary zone based on its id.
196 *
197 * This function requires that a boundary zone of the given id is defined.
198 *
199 * \param[in] id zone id
200 *
201 * \return pointer to the boundary zone structure
202 */
203/*----------------------------------------------------------------------------*/
204
205const cs_zone_t *
207
208/*----------------------------------------------------------------------------*/
209/*
210 * \brief Return a pointer to a boundary zone based on its name if present.
211 *
212 * This function requires that a boundary zone of the given name is defined.
213 *
214 * \param[in] name boundary zone name
215 *
216 * \return pointer to (read-only) zone structure
217 */
218/*----------------------------------------------------------------------------*/
219
220const cs_zone_t *
221cs_boundary_zone_by_name(const char *name);
222
223/*----------------------------------------------------------------------------*/
233/*----------------------------------------------------------------------------*/
234
235const cs_zone_t *
236cs_boundary_zone_by_name_try(const char *name);
237
238/*----------------------------------------------------------------------------*/
239/*
240 * \brief Retrieve the boundary zone id from its zone name.
241 * If the zone name is equal to NULL or has an empty length, then
242 * the default zone id (=0) corresponding to all entities is returned
243 *
244 * \param[in] z_name name of the zone or NULL or ""
245 *
246 * \return the id of the boundary zone
247 */
248/*----------------------------------------------------------------------------*/
249
250int
251cs_boundary_zone_id_by_name(const char *z_name);
252
253/*----------------------------------------------------------------------------*/
254/*
255 * \brief Set type flag for a given boundary zone.
256 *
257 * \param[in] id boundary zone id
258 * \param[in] type_flag volume zone type flag
259 */
260/*----------------------------------------------------------------------------*/
261
262void
264 int type_flag);
265
266/*----------------------------------------------------------------------------*/
267/*
268 * \brief Set time varying behavior for a given boundary zone.
269 *
270 * \param[in] id boundary zone id
271 * \param[in] time_varying true if the zone's definition varies in time
272 */
273/*----------------------------------------------------------------------------*/
274
275void
277 bool time_varying);
278
279/*----------------------------------------------------------------------------*/
280/*
281 * \brief Set overlay behavior for a given boundary zone.
282 *
283 * \param[in] id boundary zone id
284 * \param[in] allow_overlay true if the zone may be overlayed by another
285 */
286/*----------------------------------------------------------------------------*/
287
288void
290 bool allow_overlay);
291
292/*----------------------------------------------------------------------------*/
293/*
294 * \brief Return pointer to zone id associated with each boundary face.
295 *
296 * In case of overlayed zones, the highest zone id associated with
297 * a given face is given. Private (automatically defined) zones
298 * are excluded from this definition.
299 */
300/*----------------------------------------------------------------------------*/
301
302const int *
304
305/*----------------------------------------------------------------------------*/
306/*
307 * \brief Print info relative to a given boundary zone to log file.
308 *
309 * \param[in] z pointer to boundary zone structure
310 */
311/*----------------------------------------------------------------------------*/
312
313void
315
316/*----------------------------------------------------------------------------*/
317/*
318 * \brief Log setup information relative to defined boundary zones.
319 */
320/*----------------------------------------------------------------------------*/
321
322void
324
325/*----------------------------------------------------------------------------*/
326/*
327 * \brief Return number of boundary zones associated with a
328 * given zone flag.
329 *
330 * Private (automatic) zones are excluded from this count.
331 *
332 * \param[in] type_flag flag to compare to zone type
333 *
334 * \return number of zones matching the given type flag
335 */
336/*----------------------------------------------------------------------------*/
337
338int
339cs_boundary_zone_n_type_zones(int type_flag);
340
341/*----------------------------------------------------------------------------*/
342/*
343 * \brief Get pointer to optional boundary face class ids.
344 *
345 * For each boundary face, a specific output (logging and postprocessing)
346 * class id may be assigned. This allows realizing logging, postprocessing,
347 * or otherwise extracting data based on this class.
348 *
349 * Using this function at a given point indicates that user-defined class
350 * ids will be used. The face class ids are initially equal to the
351 * face zone ids, but may be modified by the user.
352 *
353 * In the presence of a time-varying mesh or boundary zones, the face
354 * class ids will be reset to the zone ids, so it may be necessary to
355 * update the user definitions.
356 *
357 * The class id values are arbitrarily chosen by the user, but must be
358 * positive integers; numbers do not need to be contiguous, but very high
359 * numbers may also lead to higher memory consumption.
360 *
361 * \return pointer to array of boundary face output zone ids;
362 */
363/*----------------------------------------------------------------------------*/
364
365int *
367
368/*----------------------------------------------------------------------------*/
369/*
370 * \brief Get read pointer to optional boundary face class or zone ids.
371 *
372 * If no face classes have been defined by \ref cs_boundary_zone_face_class_id
373 * the boundary face zone id is returned instead.
374 *
375 * \return pointer to array of boundary face output zone ids;
376 */
377/*----------------------------------------------------------------------------*/
378
379const int *
381
382/*----------------------------------------------------------------------------*/
383/*
384 * \brief Update boundary face output class ids if present.
385 *
386 * Face class ids lower than 0 are replaced by the matching face zone id.
387 */
388/*----------------------------------------------------------------------------*/
389
390void
392
393/*----------------------------------------------------------------------------*/
394/*
395 * \brief Return the maximum defined face class or zone id.
396 *
397 * \return maximum face class or zone id;
398 */
399/*----------------------------------------------------------------------------*/
400
401int
403
404/*----------------------------------------------------------------------------*/
405/*
406 * \brief Print boundary zones information to listing file
407 */
408/*----------------------------------------------------------------------------*/
409
410void
412
413/*----------------------------------------------------------------------------*/
414
415#endif /* CS_BOUNDARY_ZONE_H */
void cs_boundary_zone_initialize(void)
Initialize boundary zone structures.
Definition: cs_boundary_zone.cpp:372
void cs_boundary_zone_build_all(bool mesh_modified)
Update association of boundary zones with a mesh.
Definition: cs_boundary_zone.cpp:488
const int * cs_boundary_zone_face_class_or_zone_id(void)
Get read pointer to optional boundary face class or zone ids.
Definition: cs_boundary_zone.cpp:1079
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.cpp:708
int * cs_boundary_zone_face_class_id(void)
Get pointer to optional boundary face class ids.
Definition: cs_boundary_zone.cpp:1023
int cs_boundary_zone_define_by_func(const char *name, cs_mesh_location_select_t *func, void *input, int type_flag)
Define a new mesh location with an associated selection function.
Definition: cs_boundary_zone.cpp:649
int cs_boundary_zone_n_zones(void)
Return number of boundary zones defined.
Definition: cs_boundary_zone.cpp:423
int cs_boundary_zone_define(const char *name, const char *criteria, int type_flag)
Define a new boundary zone using a selection criteria string.
Definition: cs_boundary_zone.cpp:605
const cs_zone_t * cs_boundary_zone_by_name_try(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.cpp:734
void cs_boundary_zone_set_overlay(int id, bool allow_overlay)
Set overlay behavior for a given boundary zone.
Definition: cs_boundary_zone.cpp:823
void cs_boundary_zone_build_private(int id)
Update association of a given private boundary zone with a mesh.
Definition: cs_boundary_zone.cpp:460
void cs_boundary_zone_print_info(void)
Print boundary zones information to listing file.
Definition: cs_boundary_zone.cpp:1116
void cs_boundary_zone_finalize(void)
Free all boundary zone structures.
Definition: cs_boundary_zone.cpp:398
int cs_boundary_zone_id_by_name(const char *z_name)
Retrieve the boundary zone id from its zone name. If the zone name is equal to null or has an empty l...
Definition: cs_boundary_zone.cpp:758
int cs_boundary_zone_n_zones_time_varying(void)
Return number of boundary zones which may vary in time.
Definition: cs_boundary_zone.cpp:437
const cs_zone_t * cs_boundary_zone_by_id(int id)
Return a pointer to a boundary zone based on its id.
Definition: cs_boundary_zone.cpp:684
void cs_boundary_zone_update_face_class_id(void)
Update boundary face output class ids if present.
Definition: cs_boundary_zone.cpp:1042
void cs_boundary_zone_log_setup(void)
Log setup information relative to defined boundary zones.
Definition: cs_boundary_zone.cpp:957
int cs_boundary_zone_max_class_or_zone_id(void)
Return the maximum defined face class or zone id.
Definition: cs_boundary_zone.cpp:1099
int cs_boundary_zone_n_type_zones(int type_flag)
Return number of boundary zones associated with a given zone flag.
Definition: cs_boundary_zone.cpp:985
void cs_boundary_zone_log_info(const cs_zone_t *z)
Print info relative to a given boundary zone to log file.
Definition: cs_boundary_zone.cpp:856
void cs_boundary_zone_set_type(int id, int type_flag)
Set type flag for a given boundary zone.
Definition: cs_boundary_zone.cpp:787
void cs_boundary_zone_set_time_varying(int id, bool time_varying)
Set time varying behavior for a given boundary zone.
Definition: cs_boundary_zone.cpp:805
const int * cs_boundary_zone_face_zone_id(void)
Return pointer to zone id associated with each boundary face.
Definition: cs_boundary_zone.cpp:842
void() cs_mesh_location_select_t(void *input, const cs_mesh_t *m, int location_id, cs_lnum_t *n_elts, cs_lnum_t **elt_ids)
Definition: cs_mesh_location.h:110
Definition: cs_zone.h:51