6.3
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-2020 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;
217  case CS_PARAM_BC_ROBIN:
218  ret_flag = CS_CDO_BC_ROBIN;
219  break;
220  case CS_PARAM_BC_SLIDING:
221  ret_flag = CS_CDO_BC_SLIDING;
222  break;
225  break;
226 
227  default:
228  ret_flag = 0; /* Not handle automatically */
229  break;
230  }
231  return ret_flag;
232 }
233 
234 /*----------------------------------------------------------------------------*/
243 /*----------------------------------------------------------------------------*/
244 
245 static inline bool
246 cs_cdo_bc_is_dirichlet(cs_flag_t flag)
247 {
248  if (flag & CS_CDO_BC_DIRICHLET)
249  return true;
250  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
251  return true;
252  else
253  return false;
254 }
255 
256 /*----------------------------------------------------------------------------*/
264 /*----------------------------------------------------------------------------*/
265 
266 static inline bool
267 cs_cdo_bc_is_neumann(cs_flag_t flag)
268 {
269  if (flag & CS_CDO_BC_NEUMANN)
270  return true;
271  else if (flag & CS_CDO_BC_HMG_NEUMANN)
272  return true;
273  else
274  return false;
275 }
276 
277 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 static inline bool
288 cs_cdo_bc_is_sliding(cs_flag_t flag)
289 {
290  if (flag & CS_CDO_BC_SLIDING)
291  return true;
292  else
293  return false;
294 }
295 
296 /*----------------------------------------------------------------------------*/
305 /*----------------------------------------------------------------------------*/
306 
307 static inline bool
308 cs_cdo_bc_is_circulation(cs_flag_t flag)
309 {
310  if (flag & CS_CDO_BC_DIRICHLET)
311  return true;
312  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
313  return true;
314  else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
315  return true;
316  else
317  return false;
318 }
319 
320 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
339  bool is_steady,
340  int dim,
341  int n_defs,
342  cs_xdef_t **defs,
343  cs_lnum_t n_b_faces);
344 
345 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
357 
358 /*----------------------------------------------------------------------------*/
359 
361 
362 #endif /* __CS_CDO_BC_H__ */
CS_PARAM_BC_HMG_NEUMANN
@ CS_PARAM_BC_HMG_NEUMANN
Definition: cs_param_types.h:430
cs_cdo_bc_face_t::nhmg_dir_ids
cs_lnum_t * nhmg_dir_ids
Definition: cs_cdo_bc.h:110
CS_PARAM_BC_ROBIN
@ CS_PARAM_BC_ROBIN
Definition: cs_param_types.h:432
cs_cdo_bc_face_t::n_nhmg_neu_faces
cs_lnum_t n_nhmg_neu_faces
Definition: cs_cdo_bc.h:115
cs_cdo_bc_face_t::hmg_neu_ids
cs_lnum_t * hmg_neu_ids
Definition: cs_cdo_bc.h:114
cs_xdef_t
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:154
CS_PARAM_BC_HMG_DIRICHLET
@ CS_PARAM_BC_HMG_DIRICHLET
Definition: cs_param_types.h:428
CS_CDO_BC_HMG_DIRICHLET
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:66
CS_PARAM_BC_SLIDING
@ CS_PARAM_BC_SLIDING
Definition: cs_param_types.h:433
CS_CDO_BC_ROBIN
#define CS_CDO_BC_ROBIN
Definition: cs_cdo_bc.h:68
cs_cdo_bc_face_t::n_b_faces
cs_lnum_t n_b_faces
Definition: cs_cdo_bc.h:92
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:493
CS_CDO_BC_DIRICHLET
#define CS_CDO_BC_DIRICHLET
Definition: cs_cdo_bc.h:64
cs_cdo_bc_face_t::robin_ids
cs_lnum_t * robin_ids
Definition: cs_cdo_bc.h:120
cs_cdo_bc_face_t::n_circulation_faces
cs_lnum_t n_circulation_faces
Definition: cs_cdo_bc.h:127
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
cs_cdo_quantities.h
bft_error
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_define
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
CS_CDO_BC_TANGENTIAL_DIRICHLET
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition: cs_cdo_bc.h:72
cs_xdef.h
cs_cdo_bc_face_t::is_steady
bool is_steady
Definition: cs_cdo_bc.h:90
cs_cdo_bc_face_t
Definition: cs_cdo_bc.h:88
cs_cdo_bc_face_t::n_hmg_neu_faces
cs_lnum_t n_hmg_neu_faces
Definition: cs_cdo_bc.h:113
cs_cdo_bc_face_t::circulation_ids
cs_lnum_t * circulation_ids
Definition: cs_cdo_bc.h:128
cs_cdo_bc_face_t::sliding_ids
cs_lnum_t * sliding_ids
Definition: cs_cdo_bc.h:124
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_cdo_bc_face_t::n_nhmg_dir_faces
cs_lnum_t n_nhmg_dir_faces
Definition: cs_cdo_bc.h:109
cs_cdo_bc_face_t::nhmg_neu_ids
cs_lnum_t * nhmg_neu_ids
Definition: cs_cdo_bc.h:116
cs_time_step.h
CS_CDO_BC_NEUMANN
#define CS_CDO_BC_NEUMANN
Definition: cs_cdo_bc.h:60
cs_cdo_bc_face_t::hmg_dir_ids
cs_lnum_t * hmg_dir_ids
Definition: cs_cdo_bc.h:108
cs_cdo_bc_face_t::n_sliding_faces
cs_lnum_t n_sliding_faces
Definition: cs_cdo_bc.h:123
cs_param_bc_type_t
cs_param_bc_type_t
Definition: cs_param_types.h:426
cs_cdo_bc_face_t::n_robin_faces
cs_lnum_t n_robin_faces
Definition: cs_cdo_bc.h:119
CS_PARAM_BC_NEUMANN
@ CS_PARAM_BC_NEUMANN
Definition: cs_param_types.h:431
cs_flag_t
unsigned short int cs_flag_t
Definition: cs_defs.h:306
CS_PARAM_BC_CIRCULATION
@ CS_PARAM_BC_CIRCULATION
Definition: cs_param_types.h:434
cs_param_types.h
cs_cdo_bc_face_t::def_ids
short int * def_ids
Definition: cs_cdo_bc.h:99
CS_PARAM_BC_DIRICHLET
@ CS_PARAM_BC_DIRICHLET
Definition: cs_param_types.h:429
cs_cdo_bc_free
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:332
cs_cdo_bc_face_t::flag
cs_flag_t * flag
Definition: cs_cdo_bc.h:95
CS_CDO_BC_SLIDING
#define CS_CDO_BC_SLIDING
Definition: cs_cdo_bc.h:70
cs_base.h
CS_CDO_BC_HMG_NEUMANN
#define CS_CDO_BC_HMG_NEUMANN
Definition: cs_cdo_bc.h:62
cs_cdo_bc_face_t::n_hmg_dir_faces
cs_lnum_t n_hmg_dir_faces
Definition: cs_cdo_bc.h:107