7.1
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-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  * 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 
60 #define CS_CDO_BC_NEUMANN (1 << 0)
61 
62 #define CS_CDO_BC_HMG_NEUMANN (1 << 1)
63 
64 #define CS_CDO_BC_DIRICHLET (1 << 2)
65 
66 #define CS_CDO_BC_HMG_DIRICHLET (1 << 3)
67 
68 #define CS_CDO_BC_ROBIN (1 << 4)
69 
70 #define CS_CDO_BC_SLIDING (1 << 5)
71 
72 #define CS_CDO_BC_TANGENTIAL_DIRICHLET (1 << 6)
73 
76 /*============================================================================
77  * Type definitions
78  *============================================================================*/
79 
80 /* Structure specific to store data related to the definition of boundary
81  * conditions on boundary faces.
82  *
83  * For of scalar-valued equations, only some the classical (Dirichlet, Neumann
84  * and Robin types are available. Other types of boundary conditions are
85  * possible for vector-valued equations
86  */
87 
88 typedef struct {
89 
90  bool is_steady; /* Do we need to update BC faces during the
91  computation */
92  cs_lnum_t n_b_faces; /* Number of boundary faces */
93 
94  /* Type of boundary conditions associated to a face. Size: n_b_faces */
96 
97  /* Id of the boundary condition definition or CS_BC_DEFAULT (=-1) if this face
98  is related to the default boundary condition. Size = n_b_faces */
99  short int *def_ids;
100 
101  /* List of face ids by type of boundary conditions. Homogeneous types don't
102  * need to rely on a definition since it can be the default bc. Moreover, some
103  * optimizations can be performed that's why they are stored separately
104  */
105 
106  /* Dirichlet */
111 
112  /* Neumann */
117 
118  /* Robin */
121 
122  /* Sliding wall */
125 
126  /* Circulation */
129 
131 
132 /*============================================================================
133  * Global variables
134  *============================================================================*/
135 
136 /*============================================================================
137  * Public function prototypes
138  *============================================================================*/
139 
140 /*----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------*/
148 
149 static inline void
150 cs_cdo_bc_get_desc(cs_flag_t bc_flag,
151  char *desc)
152 {
153  if (desc == NULL)
154  bft_error(__FILE__, __LINE__, 0,
155  " %s: Empty desciption buffer.", __func__);
156 
157  switch (bc_flag) {
158 
160  sprintf(desc, "%s", "Homogenous Dirichlet");
161  break;
162  case CS_CDO_BC_DIRICHLET:
163  sprintf(desc, "%s", "Dirichlet");
164  break;
166  sprintf(desc, "%s", "Homogeneous Neumann");
167  break;
168  case CS_CDO_BC_NEUMANN:
169  sprintf(desc, "%s", "Neumann");
170  break;
171  case CS_CDO_BC_ROBIN:
172  sprintf(desc, "%s", "Robin");
173  break;
174  case CS_CDO_BC_SLIDING:
175  sprintf(desc, "%s", "Sliding");
176  break;
178  sprintf(desc, "%s", "Dirichlet on the tangential component");
179  break;
180 
181  default:
182  bft_error(__FILE__, __LINE__, 0,
183  "%s: Invalid case. Please contact the support.\n", __func__);
184  break;
185  }
186 }
187 
188 /*----------------------------------------------------------------------------*/
197 /*----------------------------------------------------------------------------*/
198 
199 static inline cs_flag_t
200 cs_cdo_bc_get_flag(cs_param_bc_type_t bc_type)
201 {
202  cs_flag_t ret_flag;
203 
204  switch (bc_type) {
206  ret_flag = CS_CDO_BC_HMG_DIRICHLET;
207  break;
209  ret_flag = CS_CDO_BC_DIRICHLET;
210  break;
212  ret_flag = CS_CDO_BC_HMG_NEUMANN;
213  break;
214  case CS_PARAM_BC_NEUMANN:
215  ret_flag = CS_CDO_BC_NEUMANN;
216  break;
218  ret_flag = CS_CDO_BC_NEUMANN;
219  break;
220  case CS_PARAM_BC_ROBIN:
221  ret_flag = CS_CDO_BC_ROBIN;
222  break;
223  case CS_PARAM_BC_SLIDING:
224  ret_flag = CS_CDO_BC_SLIDING;
225  break;
228  break;
229 
230  default:
231  ret_flag = 0; /* Not handle automatically */
232  break;
233  }
234  return ret_flag;
235 }
236 
237 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
248 static inline bool
249 cs_cdo_bc_is_dirichlet(cs_flag_t flag)
250 {
251  if (flag & CS_CDO_BC_DIRICHLET)
252  return true;
253  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
254  return true;
255  else
256  return false;
257 }
258 
259 /*----------------------------------------------------------------------------*/
267 /*----------------------------------------------------------------------------*/
268 
269 static inline bool
270 cs_cdo_bc_is_neumann(cs_flag_t flag)
271 {
272  if (flag & CS_CDO_BC_NEUMANN)
273  return true;
274  else if (flag & CS_CDO_BC_HMG_NEUMANN)
275  return true;
276  else
277  return false;
278 }
279 
280 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 static inline bool
291 cs_cdo_bc_is_sliding(cs_flag_t flag)
292 {
293  if (flag & CS_CDO_BC_SLIDING)
294  return true;
295  else
296  return false;
297 }
298 
299 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 static inline bool
311 cs_cdo_bc_is_circulation(cs_flag_t flag)
312 {
313  if (flag & CS_CDO_BC_DIRICHLET)
314  return true;
315  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
316  return true;
317  else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
318  return true;
319  else
320  return false;
321 }
322 
323 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
342  bool is_steady,
343  int dim,
344  int n_defs,
345  cs_xdef_t **defs,
346  cs_lnum_t n_b_faces);
347 
348 /*----------------------------------------------------------------------------*/
356 /*----------------------------------------------------------------------------*/
357 
360 
361 /*----------------------------------------------------------------------------*/
362 
364 
365 #endif /* __CS_CDO_BC_H__ */
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:66
Definition: cs_param_types.h:447
cs_lnum_t n_hmg_neu_faces
Definition: cs_cdo_bc.h:113
Definition: cs_param_types.h:442
Definition: cs_param_types.h:445
cs_lnum_t * circulation_ids
Definition: cs_cdo_bc.h:128
Definition: cs_param_types.h:443
cs_lnum_t * hmg_neu_ids
Definition: cs_cdo_bc.h:114
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
Definition: cs_param_types.h:446
cs_lnum_t * nhmg_dir_ids
Definition: cs_cdo_bc.h:110
cs_lnum_t n_nhmg_neu_faces
Definition: cs_cdo_bc.h:115
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
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:334
cs_lnum_t n_robin_faces
Definition: cs_cdo_bc.h:119
#define CS_CDO_BC_ROBIN
Definition: cs_cdo_bc.h:68
#define CS_CDO_BC_DIRICHLET
Definition: cs_cdo_bc.h:64
cs_flag_t * flag
Definition: cs_cdo_bc.h:95
cs_lnum_t n_sliding_faces
Definition: cs_cdo_bc.h:123
cs_lnum_t n_b_faces
Definition: cs_cdo_bc.h:92
Definition: cs_cdo_bc.h:88
#define CS_CDO_BC_NEUMANN
Definition: cs_cdo_bc.h:60
#define CS_CDO_BC_HMG_NEUMANN
Definition: cs_cdo_bc.h:62
short int * def_ids
Definition: cs_cdo_bc.h:99
bool is_steady
Definition: cs_cdo_bc.h:90
cs_lnum_t n_circulation_faces
Definition: cs_cdo_bc.h:127
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:154
cs_lnum_t n_hmg_dir_faces
Definition: cs_cdo_bc.h:107
cs_lnum_t * hmg_dir_ids
Definition: cs_cdo_bc.h:108
Definition: cs_param_types.h:448
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition: cs_cdo_bc.h:72
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
cs_param_bc_type_t
Definition: cs_param_types.h:439
cs_lnum_t * robin_ids
Definition: cs_cdo_bc.h:120
cs_lnum_t * sliding_ids
Definition: cs_cdo_bc.h:124
cs_lnum_t * nhmg_neu_ids
Definition: cs_cdo_bc.h:116
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:146
Definition: cs_param_types.h:441
Definition: cs_param_types.h:444
cs_lnum_t n_nhmg_dir_faces
Definition: cs_cdo_bc.h:109
#define CS_CDO_BC_SLIDING
Definition: cs_cdo_bc.h:70