9.2
general documentation
cs_volume_zone.h
Go to the documentation of this file.
1#ifndef CS_VOLUME_ZONE_H
2#define CS_VOLUME_ZONE_H
3
4/*============================================================================
5 * Volume 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#include "base/cs_zone.h"
41
42/*============================================================================
43 * Macro definitions
44 *============================================================================*/
45
52/*
53 * Zone type
54 */
55
57#define CS_VOLUME_ZONE_INITIALIZATION (1 << 0)
58
60#define CS_VOLUME_ZONE_POROSITY (1 << 1)
61
63#define CS_VOLUME_ZONE_HEAD_LOSS (1 << 2)
64
66#define CS_VOLUME_ZONE_SOURCE_TERM (1 << 3)
67
69#define CS_VOLUME_ZONE_MASS_SOURCE_TERM (1 << 4)
70
72#define CS_VOLUME_ZONE_GWF_SOIL (1 << 5)
73
75#define CS_VOLUME_ZONE_SOLID (1 << 6)
76
78#define CS_VOLUME_ZONE_PHYSICAL_PROPERTIES (1 << 7)
79
82/*============================================================================
83 * Type definitions
84 *============================================================================*/
85
86/*=============================================================================
87 * Global variables
88 *============================================================================*/
89
90/*============================================================================
91 * Public function prototypes
92 *============================================================================*/
93
94/*----------------------------------------------------------------------------*/
95/*
96 * \brief Initialize volume zone structures.
97 *
98 * This defines a default volume zone. This is the first function of
99 * the volume zone handling functions which should be called, and it should
100 * only be called after \ref cs_mesh_location_initialize.
101 */
102/*----------------------------------------------------------------------------*/
103
104void
106
107/*----------------------------------------------------------------------------*/
108/*
109 * \brief Free all volume zone structures.
110 */
111/*----------------------------------------------------------------------------*/
112
113void
115
116/*----------------------------------------------------------------------------*/
117/*
118 * \brief Return number of volume zones defined.
119 */
120/*----------------------------------------------------------------------------*/
121
122int
124
125/*----------------------------------------------------------------------------*/
126/*
127 * \brief Return number of volume zones which may vary in time.
128 *
129 * \return number of zones which may vary in time
130 */
131/*----------------------------------------------------------------------------*/
132
133int
135
136/*----------------------------------------------------------------------------*/
137/*
138 * \brief Update association of volume zones with a mesh.
139 *
140 * For time-varying zones, the associated mesh location is updated.
141 *
142 * \param[in] mesh_modified indicate if mesh has been modified
143 */
144/*----------------------------------------------------------------------------*/
145
146void
147cs_volume_zone_build_all(bool mesh_modified);
148
149/*----------------------------------------------------------------------------*/
150/*
151 * \brief Define a new volume zone using a selection criteria string.
152 *
153 * \param[in] name name of location to define
154 * \param[in] criteria selection criteria for associated elements
155 * \param[in] type_flag mask of zone category values
156 *
157 * \return id of newly defined volume zone
158 */
159/*----------------------------------------------------------------------------*/
160
161int
162cs_volume_zone_define(const char *name,
163 const char *criteria,
164 int type_flag);
165
166/*----------------------------------------------------------------------------*/
167/*
168 * \brief Define a new mesh location with an associated selection function.
169 *
170 * So as to define a subset of mesh entities of a given type, a pointer
171 * to a selection function may be given.
172 *
173 * This requires more programming but allows finer control than selection
174 * criteria, as the function has access to the complete mesh structure.
175 *
176 * \param[in] name name of location to define
177 * \param[in] func pointer to selection function for associated elements
178 * \param[in, out] input pointer to optional (untyped) value
179 * or structure.
180 * \param[in] type_flag mask of zone category values
181 *
182 * \return id of newly defined created mesh location
183 */
184/*----------------------------------------------------------------------------*/
185
186int
187cs_volume_zone_define_by_func(const char *name,
189 void *input,
190 int type_flag);
191
192/*----------------------------------------------------------------------------*/
193/*
194 * \brief Return a pointer to a volume zone based on its id.
195 *
196 * This function requires that a volume zone of the given id is defined.
197 *
198 * \param[in] id zone id
199 *
200 * \return pointer to the volume zone structure
201 */
202/*----------------------------------------------------------------------------*/
203
204const cs_zone_t *
206
207/*----------------------------------------------------------------------------*/
208/*
209 * \brief Return a pointer to a volume zone based on its name if present.
210 *
211 * This function requires that a volume zone of the given name is defined.
212 *
213 * \param[in] name volume zone name
214 *
215 * \return pointer to (read-only) zone structure
216 */
217/*----------------------------------------------------------------------------*/
218
219const cs_zone_t *
220cs_volume_zone_by_name(const char *name);
221
222/*----------------------------------------------------------------------------*/
223/*
224 * \brief Return a pointer to a volume zone based on its name if present.
225 *
226 * If no volume zone of the given name is defined, returned pointer is null.
227 *
228 * \param[in] name volume zone name
229 *
230 * \return pointer to (read only) zone structure, or NULL
231 */
232/*----------------------------------------------------------------------------*/
233
234const cs_zone_t *
235cs_volume_zone_by_name_try(const char *name);
236
237/*----------------------------------------------------------------------------*/
238/*
239 * \brief Retrieve the volume zone id from its zone name.
240 * If the zone name is equal to NULL or has an empty length, then
241 * the default zone id (=0) corresponding to all entities is returned
242 *
243 * \param[in] z_name name of the zone or NULL or ""
244 *
245 * \return the id of the volume zone
246 */
247/*----------------------------------------------------------------------------*/
248
249int
250cs_volume_zone_id_by_name(const char *z_name);
251
252/*----------------------------------------------------------------------------*/
253/*
254 * \brief Set type flag for a given volume zone.
255 *
256 * \param[in] id volume zone id
257 * \param[in] type_flag volume zone type flag
258 */
259/*----------------------------------------------------------------------------*/
260
261void
263 int type_flag);
264
265/*----------------------------------------------------------------------------*/
266/*
267 * \brief Set time varying behavior for a given volume zone.
268 *
269 * \param[in] id volume zone id
270 * \param[in] time_varying true if the zone's definition varies in time
271 */
272/*----------------------------------------------------------------------------*/
273
274void
276 bool time_varying);
277
278/*----------------------------------------------------------------------------*/
279/*
280 * \brief Set overlay behavior for a given volume zone.
281 *
282 * \param[in] id volume zone id
283 * \param[in] allow_overlay true if the zone may be overlayed by another
284 */
285/*----------------------------------------------------------------------------*/
286
287void
289 bool allow_overlay)
290;
291/*----------------------------------------------------------------------------*/
292/*
293 * \brief Return pointer to zone id associated with each cell.
294 *
295 * In case of overlayed zones, the highest zone id associated with
296 * a given cell is given.
297 */
298/*----------------------------------------------------------------------------*/
299
300const int *
302
303/*----------------------------------------------------------------------------*/
304/*
305 * \brief Print info relative to a given volume zone to log file.
306 *
307 * \param[in] z pointer to volume zone structure
308 */
309/*----------------------------------------------------------------------------*/
310
311void
313
314/*----------------------------------------------------------------------------*/
315/*
316 * \brief Log setup information relative to defined volume zones.
317 */
318/*----------------------------------------------------------------------------*/
319
320void
322
323/*----------------------------------------------------------------------------*/
324/*
325 * \brief Return number of volume zones associated with a
326 * given zone flag.
327 *
328 * \param[in] type_flag flag to compare to zone type
329 *
330 * \return number of zones matching the given type flag
331 */
332/*----------------------------------------------------------------------------*/
333
334int
335cs_volume_zone_n_type_zones(int type_flag);
336
337/*----------------------------------------------------------------------------*/
338/*
339 * \brief Return number of volume zone cells associated with a
340 * given zone flag.
341 *
342 * Note that in the case of overlapping zones, a cell may be accounted
343 * for multiple times.
344 *
345 * \param[in] type_flag flag to compare to zone type
346 *
347 * \return number of cells in zones matching the given type flag
348 */
349/*----------------------------------------------------------------------------*/
350
352cs_volume_zone_n_type_cells(int type_flag);
353
354/*----------------------------------------------------------------------------*/
355/*
356 * \brief Select cells associated with volume zones of a given type.
357 *
358 * Note that in the case of overlapping zones, a cell may be accounted
359 * for multiple times.
360 *
361 * \param[in] type_flag flag to compare to zone type
362 * \param[out] cell_ids ids of selected cells (size: given by
363 * \ref cs_volume_zone_n_type_cells)
364 */
365/*----------------------------------------------------------------------------*/
366
367void
369 cs_lnum_t cell_ids[]);
370
371/*----------------------------------------------------------------------------*/
372/*
373 * \brief Tag cells of a given zone type
374 *
375 * The tag array should be initialized. The given tag_value is associted
376 * to cells of the given zone type using a logical "or", so multiple flag
377 * bits can be handled using the same array if necessary.
378 *
379 * \param[in] zone_type_flag zone types to tag
380 * \param[in] tag_value tag value to add to cells of matching zones
381 * \param[in, out] tag tag value for each cell
382 */
383/*----------------------------------------------------------------------------*/
384
385void
386cs_volume_zone_tag_cell_type(int zone_type_flag,
387 int tag_value,
388 int tag[]);
389
390/*----------------------------------------------------------------------------*/
391/*
392 * \brief Print volume zones information to listing file
393 */
394/*----------------------------------------------------------------------------*/
395
396void
398
399/*----------------------------------------------------------------------------*/
400
401#endif /* CS_VOLUME_ZONE_H */
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
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
int cs_volume_zone_n_zones_time_varying(void)
Return number of volume zones which may vary in time.
Definition: cs_volume_zone.cpp:430
void cs_volume_zone_tag_cell_type(int zone_type_flag, int tag_value, int tag[])
Tag cells of a given zone type.
Definition: cs_volume_zone.cpp:1029
void cs_volume_zone_finalize(void)
Free all volume zone structures.
Definition: cs_volume_zone.cpp:392
void cs_volume_zone_set_type(int id, int type_flag)
Set type flag for a given volume zone.
Definition: cs_volume_zone.cpp:744
int cs_volume_zone_id_by_name(const char *z_name)
Retrieve the volume zone id from its zone name. If the zone name is equal to nullptr or has an empty ...
Definition: cs_volume_zone.cpp:715
void cs_volume_zone_set_time_varying(int id, bool time_varying)
Set time varying behavior for a given volume zone.
Definition: cs_volume_zone.cpp:762
cs_lnum_t cs_volume_zone_n_type_cells(int type_flag)
Return number of volume zone cells associated with a given zone flag.
Definition: cs_volume_zone.cpp:962
const int * cs_volume_zone_cell_zone_id(void)
Return pointer to zone id associated with each cell.
Definition: cs_volume_zone.cpp:798
int cs_volume_zone_define(const char *name, const char *criteria, int type_flag)
Define a new volume zone using a selection criteria string.
Definition: cs_volume_zone.cpp:562
const cs_zone_t * cs_volume_zone_by_name_try(const char *name)
Return a pointer to a volume zone based on its name if present.
Definition: cs_volume_zone.cpp:691
void cs_volume_zone_initialize(void)
Initialize volume zone structures.
Definition: cs_volume_zone.cpp:366
const cs_zone_t * cs_volume_zone_by_id(int id)
Return a pointer to a volume zone based on its id.
Definition: cs_volume_zone.cpp:641
int cs_volume_zone_n_type_zones(int type_flag)
Return number of volume zones associated with a given zone flag.
Definition: cs_volume_zone.cpp:935
void cs_volume_zone_log_info(const cs_zone_t *z)
Print info relative to a given volume zone to log file.
Definition: cs_volume_zone.cpp:812
int cs_volume_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_volume_zone.cpp:606
void cs_volume_zone_log_setup(void)
Log setup information relative to defined volume zones.
Definition: cs_volume_zone.cpp:909
void cs_volume_zone_select_type_cells(int type_flag, cs_lnum_t cell_ids[])
Select cells associated with volume zones of a given type.
Definition: cs_volume_zone.cpp:988
void cs_volume_zone_set_overlay(int id, bool allow_overlay)
Set overlay behavior for a given volume zone.
Definition: cs_volume_zone.cpp:780
int cs_volume_zone_n_zones(void)
Return number of volume zones defined.
Definition: cs_volume_zone.cpp:416
const cs_zone_t * cs_volume_zone_by_name(const char *name)
Return a pointer to a volume zone based on its name if present.
Definition: cs_volume_zone.cpp:665
void cs_volume_zone_print_info(void)
Print volume zones information to listing file.
Definition: cs_volume_zone.cpp:1059
void cs_volume_zone_build_all(bool mesh_modified)
Update association of volume zones with a mesh.
Definition: cs_volume_zone.cpp:453
Definition: cs_zone.h:51