8.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-2024 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
70#define CS_CDO_BC_SYMMETRY (1 << 2)
71
74#define CS_CDO_BC_DIRICHLET (1 << 3)
75
78#define CS_CDO_BC_HMG_DIRICHLET (1 << 4)
79
82#define CS_CDO_BC_ROBIN (1 << 5)
83
86#define CS_CDO_BC_TANGENTIAL_DIRICHLET (1 << 6)
87
90#define CS_CDO_BC_WALL_PRESCRIBED (1 << 7)
91
94/*============================================================================
95 * Type definitions
96 *============================================================================*/
97
98/* Structure specific to store data related to the definition of boundary
99 * conditions on boundary faces.
100 *
101 * For of scalar-valued equations, only some the classical (Dirichlet, Neumann
102 * and Robin types are available. Other types of boundary conditions are
103 * possible for vector-valued equations.
104 */
105
106typedef struct {
107
108 bool is_steady; /* Do we need to update BC faces during the
109 computation */
110 cs_lnum_t n_b_faces; /* Number of boundary faces */
111
112 /* Type of boundary conditions associated to a face. Size: n_b_faces */
113
115
116 /* Id of the boundary condition definition or CS_BC_DEFAULT (=-1) if this face
117 is related to the default boundary condition. Size = n_b_faces */
118
119 short int *def_ids;
120
121 /* List of face ids by type of boundary conditions. Homogeneous types don't
122 * need to rely on a definition since it can be the default bc. Moreover, some
123 * optimizations can be performed that's why they are stored separately
124 */
125
126 /* Dirichlet */
127
132
133 /* Neumann */
134
139
140 /* Robin */
141
144
145 /* Sliding wall */
146
149
150 /* Circulation */
151
154
156
157/*============================================================================
158 * Global variables
159 *============================================================================*/
160
161/*============================================================================
162 * Public function prototypes
163 *============================================================================*/
164
165/*----------------------------------------------------------------------------*/
172/*----------------------------------------------------------------------------*/
173
174static inline void
176 char *desc)
177{
178 if (desc == NULL)
179 bft_error(__FILE__, __LINE__, 0,
180 " %s: Empty desciption buffer.", __func__);
181
182 switch (bc_flag) {
183
185 sprintf(desc, "%s", "Homogenous Dirichlet");
186 break;
188 sprintf(desc, "%s", "Dirichlet");
189 break;
191 sprintf(desc, "%s", "Homogeneous Neumann or Sliding for vectors");
192 break;
194 sprintf(desc, "%s", "Neumann");
195 break;
197 sprintf(desc, "%s", "Full Neumann");
198 break;
199 case CS_CDO_BC_ROBIN:
200 sprintf(desc, "%s", "Robin");
201 break;
203 sprintf(desc, "%s", "Dirichlet on the tangential component");
204 break;
205
206 default:
207 bft_error(__FILE__, __LINE__, 0,
208 "%s: Invalid case. Please contact the support.\n", __func__);
209 break;
210 }
211}
212
213/*----------------------------------------------------------------------------*/
222/*----------------------------------------------------------------------------*/
223
224static inline cs_flag_t
226{
227 cs_flag_t ret_flag;
228
229 switch (bc_type) {
230
232 ret_flag = CS_CDO_BC_HMG_DIRICHLET;
233 break;
234 case CS_BC_DIRICHLET:
235 ret_flag = CS_CDO_BC_DIRICHLET;
236 break;
237 case CS_BC_SYMMETRY:
238 ret_flag = CS_CDO_BC_SYMMETRY;
239 break;
240 case CS_BC_NEUMANN:
241 ret_flag = CS_CDO_BC_NEUMANN;
242 break;
244 ret_flag = CS_CDO_BC_FULL_NEUMANN;
245 break;
247 bft_error(__FILE__, __LINE__, 0,
248 _("invalid boundary condition CS_BC_GENERALIZED_SYM for CDO"));
249 ret_flag = 0;
250 break;
251 case CS_BC_ROBIN:
252 ret_flag = CS_CDO_BC_ROBIN;
253 break;
256 break;
258 ret_flag = CS_CDO_BC_WALL_PRESCRIBED; /* TO BE CHECKED */
259 break;
260
261 default:
262 ret_flag = 0; /* Not handle automatically */
263 break;
264 }
265
266 return ret_flag;
267}
268
269/*----------------------------------------------------------------------------*/
278/*----------------------------------------------------------------------------*/
279
280static inline bool
282{
283 if (flag & CS_CDO_BC_DIRICHLET)
284 return true;
285 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
286 return true;
287 else
288 return false;
289}
290
291/*----------------------------------------------------------------------------*/
299/*----------------------------------------------------------------------------*/
300
301static inline bool
303{
304 if (flag & CS_CDO_BC_NEUMANN)
305 return true;
306 else if (flag & CS_CDO_BC_SYMMETRY)
307 return true;
308 else
309 return false;
310}
311
312/*----------------------------------------------------------------------------*/
320/*----------------------------------------------------------------------------*/
321
322static inline bool
324{
325 if (flag & CS_CDO_BC_SYMMETRY)
326 return true;
327 else
328 return false;
329}
330
331/*----------------------------------------------------------------------------*/
340/*----------------------------------------------------------------------------*/
341
342static inline bool
344{
345 if (flag & CS_CDO_BC_DIRICHLET)
346 return true;
347 else if (flag & CS_CDO_BC_HMG_DIRICHLET)
348 return true;
349 else if (flag & CS_CDO_BC_TANGENTIAL_DIRICHLET)
350 return true;
351 else
352 return false;
353}
354
355/*----------------------------------------------------------------------------*/
370/*----------------------------------------------------------------------------*/
371
374 bool is_steady,
375 int dim,
376 int n_defs,
377 cs_xdef_t **defs,
378 cs_lnum_t n_b_faces);
379
380/*----------------------------------------------------------------------------*/
388/*----------------------------------------------------------------------------*/
389
392
393/*----------------------------------------------------------------------------*/
394
396
397#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: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:175
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:352
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:343
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:225
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:302
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:281
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:323
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:150
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define _(String)
Definition: cs_defs.h:67
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
unsigned short int cs_flag_t
Definition: cs_defs.h:344
cs_param_bc_type_t
Definition: cs_param_types.h:481
@ CS_BC_GENERALIZED_SYM
Definition: cs_param_types.h:494
@ CS_BC_NEUMANN_FULL
Definition: cs_param_types.h:490
@ CS_BC_CIRCULATION
Definition: cs_param_types.h:492
@ CS_BC_NEUMANN
Definition: cs_param_types.h:486
@ CS_BC_SYMMETRY
Definition: cs_param_types.h:487
@ CS_BC_DIRICHLET
Definition: cs_param_types.h:484
@ CS_BC_HMG_DIRICHLET
Definition: cs_param_types.h:483
@ CS_BC_WALL_MODELLED
Definition: cs_param_types.h:488
@ CS_BC_ROBIN
Definition: cs_param_types.h:491
#define CS_CDO_BC_WALL_PRESCRIBED
Definition: cs_cdo_bc.h:90
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:78
#define CS_CDO_BC_SYMMETRY
Definition: cs_cdo_bc.h:70
#define CS_CDO_BC_ROBIN
Definition: cs_cdo_bc.h:82
#define CS_CDO_BC_FULL_NEUMANN
Definition: cs_cdo_bc.h:65
#define CS_CDO_BC_TANGENTIAL_DIRICHLET
Definition: cs_cdo_bc.h:86
#define CS_CDO_BC_NEUMANN
Definition: cs_cdo_bc.h:61
#define CS_CDO_BC_DIRICHLET
Definition: cs_cdo_bc.h:74
Definition: cs_cdo_bc.h:106
cs_lnum_t * hmg_dir_ids
Definition: cs_cdo_bc.h:129
cs_lnum_t n_robin_faces
Definition: cs_cdo_bc.h:142
cs_lnum_t n_sliding_faces
Definition: cs_cdo_bc.h:147
cs_flag_t * flag
Definition: cs_cdo_bc.h:114
cs_lnum_t n_nhmg_neu_faces
Definition: cs_cdo_bc.h:137
cs_lnum_t n_b_faces
Definition: cs_cdo_bc.h:110
cs_lnum_t * nhmg_neu_ids
Definition: cs_cdo_bc.h:138
cs_lnum_t n_hmg_neu_faces
Definition: cs_cdo_bc.h:135
cs_lnum_t * sliding_ids
Definition: cs_cdo_bc.h:148
cs_lnum_t n_circulation_faces
Definition: cs_cdo_bc.h:152
cs_lnum_t n_nhmg_dir_faces
Definition: cs_cdo_bc.h:130
cs_lnum_t * robin_ids
Definition: cs_cdo_bc.h:143
bool is_steady
Definition: cs_cdo_bc.h:108
cs_lnum_t * nhmg_dir_ids
Definition: cs_cdo_bc.h:131
cs_lnum_t * circulation_ids
Definition: cs_cdo_bc.h:153
cs_lnum_t * hmg_neu_ids
Definition: cs_cdo_bc.h:136
short int * def_ids
Definition: cs_cdo_bc.h:119
cs_lnum_t n_hmg_dir_faces
Definition: cs_cdo_bc.h:128
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:160