8.0
general documentation
Loading...
Searching...
No Matches
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-2023 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 "cs_base.h"
33#include "cs_cdo_quantities.h"
34#include "cs_param_types.h"
35#include "cs_time_step.h"
36#include "cs_xdef.h"
37
38/*----------------------------------------------------------------------------*/
39
41
42/*============================================================================
43 * Macro definitions
44 *============================================================================*/
45
46#define CS_CDO_BC_DEFAULT_DEF -1
47
58
60
61#define CS_CDO_BC_NEUMANN (1 << 0)
62
64
65#define CS_CDO_BC_FULL_NEUMANN (1 << 1)
66
68
69#define CS_CDO_BC_HMG_NEUMANN (1 << 2)
70
72
73#define CS_CDO_BC_DIRICHLET (1 << 3)
74
76
77#define CS_CDO_BC_HMG_DIRICHLET (1 << 4)
78
80
81#define CS_CDO_BC_ROBIN (1 << 5)
82
84
85#define CS_CDO_BC_SLIDING (1 << 6)
86
88
89#define CS_CDO_BC_TANGENTIAL_DIRICHLET (1 << 7)
90
92
93#define CS_CDO_BC_WALL_PRESCRIBED (1 << 8)
94
96
97/*============================================================================
98 * Type definitions
99 *============================================================================*/
100
101/* Structure specific to store data related to the definition of boundary
102 * conditions on boundary faces.
103 *
104 * For of scalar-valued equations, only some the classical (Dirichlet, Neumann
105 * and Robin types are available. Other types of boundary conditions are
106 * possible for vector-valued equations.
107 */
108
109typedef struct {
110
111 bool is_steady; /* Do we need to update BC faces during the
112 computation */
113 cs_lnum_t n_b_faces; /* Number of boundary faces */
114
115 /* Type of boundary conditions associated to a face. Size: n_b_faces */
116
118
119 /* Id of the boundary condition definition or CS_BC_DEFAULT (=-1) if this face
120 is related to the default boundary condition. Size = n_b_faces */
121
122 short int *def_ids;
123
124 /* List of face ids by type of boundary conditions. Homogeneous types don't
125 * need to rely on a definition since it can be the default bc. Moreover, some
126 * optimizations can be performed that's why they are stored separately
127 */
128
129 /* Dirichlet */
130
135
136 /* Neumann */
137
142
143 /* Robin */
144
147
148 /* Sliding wall */
149
152
153 /* Circulation */
154
157
159
160/*============================================================================
161 * Global variables
162 *============================================================================*/
163
164/*============================================================================
165 * Public function prototypes
166 *============================================================================*/
167
168/*----------------------------------------------------------------------------*/
175/*----------------------------------------------------------------------------*/
176
177static inline void
179 char *desc)
180{
181 if (desc == NULL)
182 bft_error(__FILE__, __LINE__, 0,
183 " %s: Empty desciption buffer.", __func__);
184
185 switch (bc_flag) {
186
188 sprintf(desc, "%s", "Homogenous Dirichlet");
189 break;
191 sprintf(desc, "%s", "Dirichlet");
192 break;
194 sprintf(desc, "%s", "Homogeneous Neumann");
195 break;
197 sprintf(desc, "%s", "Neumann");
198 break;
200 sprintf(desc, "%s", "Full Neumann");
201 break;
202 case CS_CDO_BC_ROBIN:
203 sprintf(desc, "%s", "Robin");
204 break;
206 sprintf(desc, "%s", "Sliding");
207 break;
209 sprintf(desc, "%s", "Dirichlet on the tangential component");
210 break;
211
212 default:
213 bft_error(__FILE__, __LINE__, 0,
214 "%s: Invalid case. Please contact the support.\n", __func__);
215 break;
216 }
217}
218
219/*----------------------------------------------------------------------------*/
228/*----------------------------------------------------------------------------*/
229
230static inline cs_flag_t
232{
233 cs_flag_t ret_flag;
234
235 switch (bc_type) {
236
238 ret_flag = CS_CDO_BC_HMG_DIRICHLET;
239 break;
241 ret_flag = CS_CDO_BC_DIRICHLET;
242 break;
244 ret_flag = CS_CDO_BC_HMG_NEUMANN;
245 break;
247 ret_flag = CS_CDO_BC_NEUMANN;
248 break;
250 ret_flag = CS_CDO_BC_FULL_NEUMANN;
251 break;
253 ret_flag = CS_CDO_BC_ROBIN;
254 break;
256 ret_flag = CS_CDO_BC_SLIDING;
257 break;
260 break;
262 ret_flag = CS_CDO_BC_WALL_PRESCRIBED; /* TO BE CHECKED */
263 break;
264
265 default:
266 ret_flag = 0; /* Not handle automatically */
267 break;
268 }
269
270 return ret_flag;
271}
272
273/*----------------------------------------------------------------------------*/
282/*----------------------------------------------------------------------------*/
283
284static inline bool
286{
287 if (flag & CS_CDO_BC_DIRICHLET)
288 return true;
289 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
290 return true;
291 else
292 return false;
293}
294
295/*----------------------------------------------------------------------------*/
303/*----------------------------------------------------------------------------*/
304
305static inline bool
307{
308 if (flag & CS_CDO_BC_NEUMANN)
309 return true;
310 else if (flag & CS_CDO_BC_HMG_NEUMANN)
311 return true;
312 else
313 return false;
314}
315
316/*----------------------------------------------------------------------------*/
324/*----------------------------------------------------------------------------*/
325
326static inline bool
328{
329 if (flag & CS_CDO_BC_SLIDING)
330 return true;
331 else
332 return false;
333}
334
335/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345
346static inline bool
348{
349 if (flag & CS_CDO_BC_DIRICHLET)
350 return true;
351 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
352 return true;
353 else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
354 return true;
355 else
356 return false;
357}
358
359/*----------------------------------------------------------------------------*/
374/*----------------------------------------------------------------------------*/
375
378 bool is_steady,
379 int dim,
380 int n_defs,
381 cs_xdef_t **defs,
382 cs_lnum_t n_b_faces);
383
384/*----------------------------------------------------------------------------*/
392/*----------------------------------------------------------------------------*/
393
396
397/*----------------------------------------------------------------------------*/
398
400
401#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.c:193
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:178
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.c:349
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:347
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:231
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:306
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:285
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:327
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.c:150
#define BEGIN_C_DECLS
Definition cs_defs.h:509
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
unsigned short int cs_flag_t
Definition cs_defs.h:321
cs_param_bc_type_t
Definition cs_param_types.h:475
@ CS_PARAM_BC_HMG_DIRICHLET
Definition cs_param_types.h:477
@ CS_PARAM_BC_WALL_PRESCRIBED
Definition cs_param_types.h:485
@ CS_PARAM_BC_DIRICHLET
Definition cs_param_types.h:478
@ CS_PARAM_BC_NEUMANN
Definition cs_param_types.h:480
@ CS_PARAM_BC_NEUMANN_FULL
Definition cs_param_types.h:481
@ CS_PARAM_BC_CIRCULATION
Definition cs_param_types.h:484
@ CS_PARAM_BC_SLIDING
Definition cs_param_types.h:483
@ CS_PARAM_BC_ROBIN
Definition cs_param_types.h:482
@ CS_PARAM_BC_HMG_NEUMANN
Definition cs_param_types.h:479
#define CS_CDO_BC_WALL_PRESCRIBED
Definition cs_cdo_bc.h:93
#define CS_CDO_BC_HMG_DIRICHLET
Definition cs_cdo_bc.h:77
#define CS_CDO_BC_ROBIN
Definition cs_cdo_bc.h:81
#define CS_CDO_BC_FULL_NEUMANN
Definition cs_cdo_bc.h:65
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition cs_cdo_bc.h:89
#define CS_CDO_BC_NEUMANN
Definition cs_cdo_bc.h:61
#define CS_CDO_BC_SLIDING
Definition cs_cdo_bc.h:85
#define CS_CDO_BC_DIRICHLET
Definition cs_cdo_bc.h:73
#define CS_CDO_BC_HMG_NEUMANN
Definition cs_cdo_bc.h:69
Definition cs_cdo_bc.h:109
cs_lnum_t * hmg_dir_ids
Definition cs_cdo_bc.h:132
cs_lnum_t n_robin_faces
Definition cs_cdo_bc.h:145
cs_lnum_t n_sliding_faces
Definition cs_cdo_bc.h:150
cs_flag_t * flag
Definition cs_cdo_bc.h:117
cs_lnum_t n_nhmg_neu_faces
Definition cs_cdo_bc.h:140
cs_lnum_t n_b_faces
Definition cs_cdo_bc.h:113
cs_lnum_t * nhmg_neu_ids
Definition cs_cdo_bc.h:141
cs_lnum_t n_hmg_neu_faces
Definition cs_cdo_bc.h:138
cs_lnum_t * sliding_ids
Definition cs_cdo_bc.h:151
cs_lnum_t n_circulation_faces
Definition cs_cdo_bc.h:155
cs_lnum_t n_nhmg_dir_faces
Definition cs_cdo_bc.h:133
cs_lnum_t * robin_ids
Definition cs_cdo_bc.h:146
bool is_steady
Definition cs_cdo_bc.h:111
cs_lnum_t * nhmg_dir_ids
Definition cs_cdo_bc.h:134
cs_lnum_t * circulation_ids
Definition cs_cdo_bc.h:156
cs_lnum_t * hmg_neu_ids
Definition cs_cdo_bc.h:139
short int * def_ids
Definition cs_cdo_bc.h:122
cs_lnum_t n_hmg_dir_faces
Definition cs_cdo_bc.h:131
Structure storing medata for defining a quantity in a very flexible way.
Definition cs_xdef.h:160