programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cs_boundary_conditions.h
Go to the documentation of this file.
1 #ifndef __CS_BOUNDARY_CONDITIONS_H__
2 #define __CS_BOUNDARY_CONDITIONS_H__
3 
4 /*============================================================================
5  * Boundary condition handling.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 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 
30 /*----------------------------------------------------------------------------
31  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 /*----------------------------------------------------------------------------
35  * Local headers
36  *----------------------------------------------------------------------------*/
37 
38 #include <ple_locator.h>
39 
40 #include "fvm_nodal.h"
41 #include "fvm_writer.h"
42 
43 #include "cs_base.h"
44 #include "cs_field.h"
45 #include "cs_mesh_location.h"
46 
47 /*----------------------------------------------------------------------------*/
48 
50 
51 /*============================================================================
52  * Macro definitions
53  *============================================================================*/
54 
55 /*============================================================================
56  * Local type definitions
57  *============================================================================*/
58 
59 /*=============================================================================
60  * Global variables
61  *============================================================================*/
62 
65 extern const int *cs_glob_bc_type;
66 
70 extern const int *cs_glob_bc_face_zone;
71 
72 /*============================================================================
73  * Public function prototypes
74  *============================================================================*/
75 
76 /*----------------------------------------------------------------------------
77  * Handling of boundary condition definition errors and associated output.
78  *
79  * This function checks for errors, and simply returns if no errors are
80  * encountered. In case of error, it outputs helpful information so as to
81  * make it easier to locate the matching faces.
82  *
83  * For each boundary face, bc_type defines the boundary condition type.
84  * As a convention here, zero values correspond to undefined types,
85  * positive values to defined types (with no error), and negative values
86  * to defined types with inconsistent or incompatible values, the
87  * absolute value indicating the original boundary condition type.
88  *
89  * An optional label may be used if the error is related to another
90  * attribute than the boundary type, for appropriate error reporting.
91  *
92  * parameters:
93  * bc_flag <-- array of BC type ids
94  * type_name <-- name of attribute in error, or NULL
95  *----------------------------------------------------------------------------*/
96 
97 void
98 cs_boundary_conditions_error(const int *bc_type,
99  const char *type_name);
100 
101 /*----------------------------------------------------------------------------
102  * Locate shifted boundary face coordinates on possibly filtered
103  * cells or boundary faces for later interpolation.
104  *
105  * parameters:
106  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS
107  * or CS_MESH_LOCATION_BOUNDARY_FACES)
108  * n_location_elts <-- number of selected location elements
109  * n_faces <-- number of selected boundary faces
110  * location_elts <-- list of selected location elements (0 to n-1),
111  * or NULL if no indirection is needed
112  * faces <-- list of selected boundary faces (0 to n-1),
113  * or NULL if no indirection is needed
114  * coord_shift <-- array of coordinates shift relative to selected
115  * boundary faces
116  * coord_stride <-- access stride in coord_shift: 0 for uniform
117  * shift, 1 for "per face" shift.
118  * tolerance <-- relative tolerance for point location.
119  *
120  * returns:
121  * associated locator structure
122  *----------------------------------------------------------------------------*/
123 
124 ple_locator_t *
126  cs_lnum_t n_location_elts,
127  cs_lnum_t n_faces,
128  const cs_lnum_t *location_elts,
129  const cs_lnum_t *faces,
130  cs_real_3_t *coord_shift,
131  int coord_stride,
132  double tolerance);
133 
134 /*----------------------------------------------------------------------------
135  * Set mapped boundary conditions for a given field and mapping locator.
136  *
137  * parameters:
138  * field <-- field whose boundary conditions are set
139  * locator <-- associated mapping locator, as returned
140  * by cs_boundary_conditions_map().
141  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS or
142  * CS_MESH_LOCATION_BOUNDARY_FACES)
143  * normalize <-- normalization option:
144  * 0: values are simply mapped
145  * 1: values are mapped, then multiplied
146  * by a constant factor so that their
147  * surface integral on selected faces
148  * is preserved (relative to the
149  * input values)
150  * 2: as 1, but with a boundary-defined
151  * weight, defined by balance_w
152  * 3: as 1, but with a cell-defined
153  * weight, defined by balance_w
154  * interpolate <-- interpolation option:
155  * 0: values are simply based on matching
156  * cell or face center values
157  * 1: values are based on matching cell
158  * or face center values, corrected
159  * by gradient interpolation
160  * n_faces <-- number of selected boundary faces
161  * faces <-- list of selected boundary faces (0 to n-1),
162  * or NULL if no indirection is needed
163  * balance_w <-- optional balance weight, or NULL
164  * nvar <-- number of variables requiring BC's
165  * rcodcl <-> boundary condition values
166  *----------------------------------------------------------------------------*/
167 
168 void
170  ple_locator_t *locator,
171  cs_mesh_location_type_t location_type,
172  int normalize,
173  int interpolate,
174  cs_lnum_t n_faces,
175  const cs_lnum_t *faces,
176  cs_real_t *balance_w,
177  int nvar,
178  cs_real_t rcodcl[]);
179 
180 /*----------------------------------------------------------------------------
181  * Create the boundary conditions face type and face zone arrays
182  *----------------------------------------------------------------------------*/
183 
184 void
186 
187 /*----------------------------------------------------------------------------
188  * Free the boundary conditions face type and face zone arrays
189  *----------------------------------------------------------------------------*/
190 
191 void
193 
194 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 inline static void
209  cs_real_t *af,
210  cs_real_t *b,
211  cs_real_t *bf,
212  cs_real_t qimp,
213  cs_real_t hint)
214 {
215  /* Gradient BCs */
216  *a = -qimp/hint;
217  *b = 1.;
218 
219  /* Flux BCs */
220  *af = qimp;
221  *bf = 0.;
222 }
223 
224 /*----------------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------------*/
238 
239 inline static void
241  cs_real_t *af,
242  cs_real_t *b,
243  cs_real_t *bf,
244  cs_real_t pimp,
245  cs_real_t hint,
246  cs_real_t hext)
247 {
248  if (hext < 0.) {
249 
250  /* Gradient BCs */
251  *a = pimp;
252  *b = 0.;
253 
254  /* Flux BCs */
255  *af = -hint*pimp;
256  *bf = hint;
257 
258  }
259  else {
260 
261  /* Gradient BCs */
262  *a = hext*pimp/(hint + hext);
263  *b = hint /(hint + hext);
264 
265  /* Flux BCs */
266  cs_real_t heq = hint*hext/(hint + hext);
267  *af = -heq*pimp;
268  *bf = heq;
269 
270  }
271 }
272 
273 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 void
290  cs_real_t *cofaf,
291  cs_real_t *coefb,
292  cs_real_t *cofbf,
293  cs_real_t pimp,
294  cs_real_t cfl,
295  cs_real_t hint);
296 
297 /*----------------------------------------------------------------------------*/
298 
300 
301 #endif /* __CS_BOUNDARY_CONDITIONS_H__ */
Field descriptor.
Definition: cs_field.h:124
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
void cs_boundary_conditions_free(void)
Definition: cs_boundary_conditions.c:773
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
void cs_boundary_conditions_create(void)
Definition: cs_boundary_conditions.c:743
void cs_boundary_conditions_mapped_set(const cs_field_t *f, ple_locator_t *locator, cs_mesh_location_type_t location_type, int normalize, int interpolate, cs_lnum_t n_faces, const cs_lnum_t *faces, cs_real_t *balance_w, int nvar, cs_real_t rcodcl[])
Set mapped boundary conditions for a given field and mapping locator.
Definition: cs_boundary_conditions.c:553
const int * cs_glob_bc_face_zone
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
static void cs_boundary_conditions_set_dirichlet_scalar(cs_real_t *a, cs_real_t *af, cs_real_t *b, cs_real_t *bf, cs_real_t pimp, cs_real_t hint, cs_real_t hext)
Set Dirichlet BC for a scalar for a given face.
Definition: cs_boundary_conditions.h:240
void cs_boundary_conditions_set_convective_outlet_scalar(cs_real_t *coefa, cs_real_t *cofaf, cs_real_t *coefb, cs_real_t *cofbf, cs_real_t pimp, cs_real_t cfl, cs_real_t hint)
Set convective oulet boundary condition for a scalar.
Definition: cs_boundary_conditions.c:799
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_boundary_conditions_error(const int *bc_type, const char *type_name)
Handling of boundary condition definition errors and associated output.
Definition: cs_boundary_conditions.c:339
static void cs_boundary_conditions_set_neumann_scalar(cs_real_t *a, cs_real_t *af, cs_real_t *b, cs_real_t *bf, cs_real_t qimp, cs_real_t hint)
Set Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions.h:208
ple_locator_t * cs_boundary_conditions_map(cs_mesh_location_type_t location_type, cs_lnum_t n_location_elts, cs_lnum_t n_faces, const cs_lnum_t *location_elts, const cs_lnum_t *faces, cs_real_3_t *coord_shift, int coord_stride, double tolerance)
Locate shifted boundary face coordinates on possibly filtered cells or boundary faces for later inter...
Definition: cs_boundary_conditions.c:393
const int * cs_glob_bc_type