9.2
general documentation
cs_cdo_bc.h
Go to the documentation of this file.
1#ifndef CS_CDO_BC_H
2#define CS_CDO_BC_H
3
4/*============================================================================
5 * Manage the low-level structure dedicated to boundary conditions
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 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "base/cs_base.h"
33#include "base/cs_param_types.h"
34#include "base/cs_time_step.h"
36#include "cdo/cs_xdef.h"
37
38/*============================================================================
39 * Macro definitions
40 *============================================================================*/
41
42#define CS_CDO_BC_DEFAULT_DEF -1
43
57#define CS_CDO_BC_NEUMANN (1 << 0)
58
61#define CS_CDO_BC_FULL_NEUMANN (1 << 1)
62
65#define CS_CDO_BC_HMG_NEUMANN (1 << 2)
66
69#define CS_CDO_BC_DIRICHLET (1 << 3)
70
73#define CS_CDO_BC_HMG_DIRICHLET (1 << 4)
74
77#define CS_CDO_BC_ROBIN (1 << 5)
78
81#define CS_CDO_BC_TANGENTIAL_DIRICHLET (1 << 6)
82
85#define CS_CDO_BC_WALL_PRESCRIBED (1 << 7)
86
89#define CS_CDO_BC_SYMMETRY (1 << 8)
90
93/*============================================================================
94 * Type definitions
95 *============================================================================*/
96
97/* Structure specific to store data related to the definition of boundary
98 * conditions on boundary faces.
99 *
100 * For of scalar-valued equations, only some the classical (Dirichlet, Neumann
101 * and Robin types are available. Other types of boundary conditions are
102 * possible for vector-valued equations.
103 */
104
105typedef struct {
106
107 bool is_steady; /* Do we need to update BC faces during the
108 computation */
109 cs_lnum_t n_b_faces; /* Number of boundary faces */
110
111 /* Type of boundary conditions associated to a face. Size: n_b_faces */
112
114
115 /* Id of the boundary condition definition or CS_BC_DEFAULT (=-1) if this face
116 is related to the default boundary condition. Size = n_b_faces */
117
118 short int *def_ids;
119
120 /* List of face ids by type of boundary conditions. Homogeneous types don't
121 * need to rely on a definition since it can be the default bc. Moreover, some
122 * optimizations can be performed that's why they are stored separately
123 */
124
125 /* Dirichlet */
126
131
132 /* Neumann */
133
138
139 /* Robin */
140
143
144 /* Sliding wall */
145
148
149 /* Circulation */
150
153
155
156/*============================================================================
157 * Global variables
158 *============================================================================*/
159
160/*============================================================================
161 * Public function prototypes
162 *============================================================================*/
163
164/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
173static inline void
175 char *desc)
176{
177 if (desc == NULL)
178 bft_error(__FILE__, __LINE__, 0,
179 " %s: Empty desciption buffer.", __func__);
180
181 switch (bc_flag) {
182
184 sprintf(desc, "%s", "Homogenous Dirichlet");
185 break;
187 sprintf(desc, "%s", "Dirichlet");
188 break;
190 sprintf(desc, "%s", "Sliding for vectors");
191 break;
193 sprintf(desc, "%s", "Homogeneous Neumann");
194 break;
196 sprintf(desc, "%s", "Neumann");
197 break;
199 sprintf(desc, "%s", "Full Neumann");
200 break;
201 case CS_CDO_BC_ROBIN:
202 sprintf(desc, "%s", "Robin");
203 break;
205 sprintf(desc, "%s", "Dirichlet on the tangential component");
206 break;
208 sprintf(desc, "%s", "Prescribed wall with wall functions");
209 break;
210
211 default:
212 bft_error(__FILE__, __LINE__, 0,
213 "%s: Invalid case. Please contact the support.\n", __func__);
214 break;
215 }
216}
217
218/*----------------------------------------------------------------------------*/
227/*----------------------------------------------------------------------------*/
228
229static inline cs_flag_t
231{
232 cs_flag_t ret_flag;
233
234 switch (bc_type) {
235
237 ret_flag = CS_CDO_BC_HMG_DIRICHLET;
238 break;
239 case CS_BC_DIRICHLET:
240 ret_flag = CS_CDO_BC_DIRICHLET;
241 break;
242 case CS_BC_SYMMETRY:
243 ret_flag = CS_CDO_BC_SYMMETRY;
244 break;
245 case CS_BC_NEUMANN:
246 ret_flag = CS_CDO_BC_NEUMANN;
247 break;
249 ret_flag = CS_CDO_BC_FULL_NEUMANN;
250 break;
252 ret_flag = CS_CDO_BC_HMG_NEUMANN;
253 break;
255 bft_error(__FILE__, __LINE__, 0,
256 _("invalid boundary condition CS_BC_GENERALIZED_SYM for CDO"));
257 ret_flag = 0;
258 break;
259 case CS_BC_ROBIN:
260 ret_flag = CS_CDO_BC_ROBIN;
261 break;
264 break;
266 ret_flag = CS_CDO_BC_WALL_PRESCRIBED; /* TO BE CHECKED */
267 break;
268
269 default:
270 ret_flag = 0; /* Not handle automatically */
271 break;
272 }
273
274 return ret_flag;
275}
276
277/*----------------------------------------------------------------------------*/
286/*----------------------------------------------------------------------------*/
287
288static inline bool
290{
291 if (flag & CS_CDO_BC_DIRICHLET)
292 return true;
293 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
294 return true;
295 else
296 return false;
297}
298
299/*----------------------------------------------------------------------------*/
307/*----------------------------------------------------------------------------*/
308
309static inline bool
311{
312 if (flag & CS_CDO_BC_NEUMANN)
313 return true;
314 else if (flag & CS_CDO_BC_HMG_NEUMANN)
315 return true;
316 else if (flag & CS_CDO_BC_FULL_NEUMANN)
317 return true;
318
319 return false;
320}
321
322/*----------------------------------------------------------------------------*/
330/*----------------------------------------------------------------------------*/
331
332static inline bool
334{
335 if (flag & CS_CDO_BC_SYMMETRY)
336 return true;
337 else
338 return false;
339}
340
341/*----------------------------------------------------------------------------*/
350/*----------------------------------------------------------------------------*/
351
352static inline bool
354{
355 if (flag & CS_CDO_BC_DIRICHLET)
356 return true;
357 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
358 return true;
359 else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
360 return true;
361 else
362 return false;
363}
364
365/*----------------------------------------------------------------------------*/
380/*----------------------------------------------------------------------------*/
381
384 bool is_steady,
385 int dim,
386 int n_defs,
387 cs_xdef_t **defs,
388 cs_lnum_t n_b_faces);
389
390/*----------------------------------------------------------------------------*/
398/*----------------------------------------------------------------------------*/
399
402
403#endif /* CS_CDO_BC_H */
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
static void cs_cdo_bc_get_desc(cs_flag_t bc_flag, char *desc)
Convert a flag into a description.
Definition: cs_cdo_bc.h:174
cs_cdo_bc_face_t * cs_cdo_bc_free(cs_cdo_bc_face_t *face_bc)
Free a cs_cdo_bc_face_t structure.
Definition: cs_cdo_bc.cpp:355
static bool cs_cdo_bc_is_circulation(cs_flag_t flag)
Check if a flag is associated to a Dirichlet BC (homogeneous or not)
Definition: cs_cdo_bc.h:353
static cs_flag_t cs_cdo_bc_get_flag(cs_param_bc_type_t bc_type)
Convert a cs_param_bc_type_t into a flag (enable multiple type for a same entity as required for vert...
Definition: cs_cdo_bc.h:230
static bool cs_cdo_bc_is_neumann(cs_flag_t flag)
Check if a flag is associated to a Neumann BC (homogeneous or not)
Definition: cs_cdo_bc.h:310
static bool cs_cdo_bc_is_dirichlet(cs_flag_t flag)
Check if a flag is associated to a Dirichlet BC (homogeneous or not)
Definition: cs_cdo_bc.h:289
static bool cs_cdo_bc_is_sliding(cs_flag_t flag)
Check if a flag is associated to a sliding boundary.
Definition: cs_cdo_bc.h:333
cs_cdo_bc_face_t * cs_cdo_bc_face_define(cs_param_bc_type_t default_bc, bool is_steady, int dim, int n_defs, cs_xdef_t **defs, cs_lnum_t n_b_faces)
Define the structure which translates the BC definitions from the user viewpoint into a ready-to-use ...
Definition: cs_cdo_bc.cpp:143
#define _(String)
Definition: cs_defs.h:61
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
cs_param_bc_type_t
Definition: cs_param_types.h:501
@ CS_BC_GENERALIZED_SYM
Definition: cs_param_types.h:538
@ CS_BC_HMG_NEUMANN
Definition: cs_param_types.h:509
@ CS_BC_NEUMANN_FULL
Definition: cs_param_types.h:512
@ CS_BC_CIRCULATION
Definition: cs_param_types.h:534
@ CS_BC_NEUMANN
Definition: cs_param_types.h:511
@ CS_BC_SYMMETRY
Definition: cs_param_types.h:514
@ CS_BC_DIRICHLET
Definition: cs_param_types.h:506
@ CS_BC_HMG_DIRICHLET
Definition: cs_param_types.h:504
@ CS_BC_WALL_MODELLED
Definition: cs_param_types.h:516
@ CS_BC_ROBIN
Definition: cs_param_types.h:520
#define CS_CDO_BC_WALL_PRESCRIBED
Definition: cs_cdo_bc.h:85
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:73
#define CS_CDO_BC_SYMMETRY
Definition: cs_cdo_bc.h:89
#define CS_CDO_BC_ROBIN
Definition: cs_cdo_bc.h:77
#define CS_CDO_BC_FULL_NEUMANN
Definition: cs_cdo_bc.h:61
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition: cs_cdo_bc.h:81
#define CS_CDO_BC_NEUMANN
Definition: cs_cdo_bc.h:57
#define CS_CDO_BC_DIRICHLET
Definition: cs_cdo_bc.h:69
#define CS_CDO_BC_HMG_NEUMANN
Definition: cs_cdo_bc.h:65
Definition: cs_cdo_bc.h:105
cs_lnum_t * hmg_dir_ids
Definition: cs_cdo_bc.h:128
cs_lnum_t n_robin_faces
Definition: cs_cdo_bc.h:141
cs_lnum_t n_sliding_faces
Definition: cs_cdo_bc.h:146
cs_flag_t * flag
Definition: cs_cdo_bc.h:113
cs_lnum_t n_nhmg_neu_faces
Definition: cs_cdo_bc.h:136
cs_lnum_t n_b_faces
Definition: cs_cdo_bc.h:109
cs_lnum_t * nhmg_neu_ids
Definition: cs_cdo_bc.h:137
cs_lnum_t n_hmg_neu_faces
Definition: cs_cdo_bc.h:134
cs_lnum_t * sliding_ids
Definition: cs_cdo_bc.h:147
cs_lnum_t n_circulation_faces
Definition: cs_cdo_bc.h:151
cs_lnum_t n_nhmg_dir_faces
Definition: cs_cdo_bc.h:129
cs_lnum_t * robin_ids
Definition: cs_cdo_bc.h:142
bool is_steady
Definition: cs_cdo_bc.h:107
cs_lnum_t * nhmg_dir_ids
Definition: cs_cdo_bc.h:130
cs_lnum_t * circulation_ids
Definition: cs_cdo_bc.h:152
cs_lnum_t * hmg_neu_ids
Definition: cs_cdo_bc.h:135
short int * def_ids
Definition: cs_cdo_bc.h:118
cs_lnum_t n_hmg_dir_faces
Definition: cs_cdo_bc.h:127
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:156