7.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-2022 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 
61 #define CS_CDO_BC_NEUMANN (1 << 0)
62 
65 #define CS_CDO_BC_FULL_NEUMANN (1 << 1)
66 
69 #define CS_CDO_BC_HMG_NEUMANN (1 << 2)
70 
73 #define CS_CDO_BC_DIRICHLET (1 << 3)
74 
77 #define CS_CDO_BC_HMG_DIRICHLET (1 << 4)
78 
81 #define CS_CDO_BC_ROBIN (1 << 5)
82 
85 #define CS_CDO_BC_SLIDING (1 << 6)
86 
89 #define CS_CDO_BC_TANGENTIAL_DIRICHLET (1 << 7)
90 
93 #define CS_CDO_BC_WALL_PRESCRIBED (1 << 8)
94 
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 
109 typedef 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 */
117 
118  /* Id of the boundary condition definition or CS_BC_DEFAULT (=-1) if this face
119  is related to the default boundary condition. Size = n_b_faces */
120  short int *def_ids;
121 
122  /* List of face ids by type of boundary conditions. Homogeneous types don't
123  * need to rely on a definition since it can be the default bc. Moreover, some
124  * optimizations can be performed that's why they are stored separately
125  */
126 
127  /* Dirichlet */
132 
133  /* Neumann */
138 
139  /* Robin */
142 
143  /* Sliding wall */
146 
147  /* Circulation */
150 
152 
153 /*============================================================================
154  * Global variables
155  *============================================================================*/
156 
157 /*============================================================================
158  * Public function prototypes
159  *============================================================================*/
160 
161 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 static inline void
172  char *desc)
173 {
174  if (desc == NULL)
175  bft_error(__FILE__, __LINE__, 0,
176  " %s: Empty desciption buffer.", __func__);
177 
178  switch (bc_flag) {
179 
181  sprintf(desc, "%s", "Homogenous Dirichlet");
182  break;
183  case CS_CDO_BC_DIRICHLET:
184  sprintf(desc, "%s", "Dirichlet");
185  break;
187  sprintf(desc, "%s", "Homogeneous Neumann");
188  break;
189  case CS_CDO_BC_NEUMANN:
190  sprintf(desc, "%s", "Neumann");
191  break;
193  sprintf(desc, "%s", "Full Neumann");
194  break;
195  case CS_CDO_BC_ROBIN:
196  sprintf(desc, "%s", "Robin");
197  break;
198  case CS_CDO_BC_SLIDING:
199  sprintf(desc, "%s", "Sliding");
200  break;
202  sprintf(desc, "%s", "Dirichlet on the tangential component");
203  break;
204 
205  default:
206  bft_error(__FILE__, __LINE__, 0,
207  "%s: Invalid case. Please contact the support.\n", __func__);
208  break;
209  }
210 }
211 
212 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 static inline cs_flag_t
225 {
226  cs_flag_t ret_flag;
227 
228  switch (bc_type) {
229 
231  ret_flag = CS_CDO_BC_HMG_DIRICHLET;
232  break;
234  ret_flag = CS_CDO_BC_DIRICHLET;
235  break;
237  ret_flag = CS_CDO_BC_HMG_NEUMANN;
238  break;
239  case CS_PARAM_BC_NEUMANN:
240  ret_flag = CS_CDO_BC_NEUMANN;
241  break;
243  ret_flag = CS_CDO_BC_FULL_NEUMANN;
244  break;
245  case CS_PARAM_BC_ROBIN:
246  ret_flag = CS_CDO_BC_ROBIN;
247  break;
248  case CS_PARAM_BC_SLIDING:
249  ret_flag = CS_CDO_BC_SLIDING;
250  break;
253  break;
255  ret_flag = CS_CDO_BC_WALL_PRESCRIBED; /* TO BE CHECKED */
256  break;
257 
258  default:
259  ret_flag = 0; /* Not handle automatically */
260  break;
261  }
262 
263  return ret_flag;
264 }
265 
266 /*----------------------------------------------------------------------------*/
275 /*----------------------------------------------------------------------------*/
276 
277 static inline bool
279 {
280  if (flag & CS_CDO_BC_DIRICHLET)
281  return true;
282  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
283  return true;
284  else
285  return false;
286 }
287 
288 /*----------------------------------------------------------------------------*/
296 /*----------------------------------------------------------------------------*/
297 
298 static inline bool
300 {
301  if (flag & CS_CDO_BC_NEUMANN)
302  return true;
303  else if (flag & CS_CDO_BC_HMG_NEUMANN)
304  return true;
305  else
306  return false;
307 }
308 
309 /*----------------------------------------------------------------------------*/
317 /*----------------------------------------------------------------------------*/
318 
319 static inline bool
321 {
322  if (flag & CS_CDO_BC_SLIDING)
323  return true;
324  else
325  return false;
326 }
327 
328 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 static inline bool
341 {
342  if (flag & CS_CDO_BC_DIRICHLET)
343  return true;
344  else if (flag & CS_CDO_BC_HMG_DIRICHLET)
345  return true;
346  else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
347  return true;
348  else
349  return false;
350 }
351 
352 /*----------------------------------------------------------------------------*/
367 /*----------------------------------------------------------------------------*/
368 
371  bool is_steady,
372  int dim,
373  int n_defs,
374  cs_xdef_t **defs,
375  cs_lnum_t n_b_faces);
376 
377 /*----------------------------------------------------------------------------*/
385 /*----------------------------------------------------------------------------*/
386 
389 
390 /*----------------------------------------------------------------------------*/
391 
393 
394 #endif /* __CS_CDO_BC_H__ */
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:77
Definition: cs_param_types.h:478
cs_lnum_t n_hmg_neu_faces
Definition: cs_cdo_bc.h:134
Definition: cs_param_types.h:473
Definition: cs_param_types.h:476
cs_lnum_t * circulation_ids
Definition: cs_cdo_bc.h:149
Definition: cs_param_types.h:474
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:278
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:224
cs_lnum_t * hmg_neu_ids
Definition: cs_cdo_bc.h:135
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
Definition: cs_param_types.h:477
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:299
#define CS_CDO_BC_WALL_PRESCRIBED
Definition: cs_cdo_bc.h:93
cs_lnum_t * nhmg_dir_ids
Definition: cs_cdo_bc.h:131
cs_lnum_t n_nhmg_neu_faces
Definition: cs_cdo_bc.h:136
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:348
cs_lnum_t n_robin_faces
Definition: cs_cdo_bc.h:140
#define CS_CDO_BC_ROBIN
Definition: cs_cdo_bc.h:81
#define CS_CDO_BC_DIRICHLET
Definition: cs_cdo_bc.h:73
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:340
cs_flag_t * flag
Definition: cs_cdo_bc.h:116
cs_lnum_t n_sliding_faces
Definition: cs_cdo_bc.h:144
cs_lnum_t n_b_faces
Definition: cs_cdo_bc.h:113
Definition: cs_cdo_bc.h:109
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:171
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:320
#define CS_CDO_BC_NEUMANN
Definition: cs_cdo_bc.h:61
#define CS_CDO_BC_HMG_NEUMANN
Definition: cs_cdo_bc.h:69
short int * def_ids
Definition: cs_cdo_bc.h:120
bool is_steady
Definition: cs_cdo_bc.h:111
cs_lnum_t n_circulation_faces
Definition: cs_cdo_bc.h:148
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:128
cs_lnum_t * hmg_dir_ids
Definition: cs_cdo_bc.h:129
Definition: cs_param_types.h:479
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition: cs_cdo_bc.h:89
#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:470
Definition: cs_param_types.h:480
#define CS_CDO_BC_FULL_NEUMANN
Definition: cs_cdo_bc.h:65
cs_lnum_t * robin_ids
Definition: cs_cdo_bc.h:141
cs_lnum_t * sliding_ids
Definition: cs_cdo_bc.h:145
cs_lnum_t * nhmg_neu_ids
Definition: cs_cdo_bc.h:137
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:149
Definition: cs_param_types.h:472
Definition: cs_param_types.h:475
cs_lnum_t n_nhmg_dir_faces
Definition: cs_cdo_bc.h:130
#define CS_CDO_BC_SLIDING
Definition: cs_cdo_bc.h:85