programmer's documentation
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-2016 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 
67 /*============================================================================
68  * Public function prototypes
69  *============================================================================*/
70 
71 /*----------------------------------------------------------------------------
72  * Handling of boundary condition definition errors and associated output.
73  *
74  * This function checks for errors, and simply returns if no errors are
75  * encountered. In case of error, it outputs helpful information so as to
76  * make it easier to locate the matching faces.
77  *
78  * For each boundary face, bc_type defines the boundary condition type.
79  * As a convention here, zero values correspond to undefined types,
80  * positive values to defined types (with no error), and negative values
81  * to defined types with inconsistent or incompatible values, the
82  * absolute value indicating the original boundary condition type.
83  *
84  * An optional label may be used if the error is related to another
85  * attribute than the boundary type, for appropriate error reporting.
86  *
87  * parameters:
88  * \param[in] bc_type array of BC type ids
89  * type_name <-- name of attribute in error, or NULL
90  *----------------------------------------------------------------------------*/
91 
92 void
93 cs_boundary_conditions_error(const int *bc_type,
94  const char *type_name);
95 
96 /*----------------------------------------------------------------------------
97  * Locate shifted boundary face coordinates on possibly filtered
98  * cells or boundary faces for later interpolation.
99  *
100  * parameters:
101  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS
102  * or CS_MESH_LOCATION_BOUNDARY_FACES)
103  * n_location_elts <-- number of selected location elements
104  * n_faces <-- number of selected boundary faces
105  * location_elts <-- list of selected location elements (0 to n-1),
106  * or NULL if no indirection is needed
107  * faces <-- list of selected boundary faces (0 to n-1),
108  * or NULL if no indirection is needed
109  * coord_shift <-- array of coordinates shift relative to selected
110  * boundary faces
111  * coord_stride <-- access stride in coord_shift: 0 for uniform
112  * shift, 1 for "per face" shift.
113  * tolerance <-- relative tolerance for point location.
114  *
115  * returns:
116  * associated locator structure
117  *----------------------------------------------------------------------------*/
118 
119 ple_locator_t *
121  cs_lnum_t n_location_elts,
122  cs_lnum_t n_faces,
123  const cs_lnum_t *location_elts,
124  const cs_lnum_t *faces,
125  cs_real_3_t *coord_shift,
126  int coord_stride,
127  double tolerance);
128 
129 /*----------------------------------------------------------------------------
130  * Set mapped boundary conditions for a given field and mapping locator.
131  *
132  * parameters:
133  * field <-- field whose boundary conditions are set
134  * locator <-- associated mapping locator, as returned
135  * by cs_boundary_conditions_map().
136  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS or
137  * CS_MESH_LOCATION_BOUNDARY_FACES)
138  * normalize <-- normalization option:
139  * 0: values are simply mapped
140  * 1: values are mapped, then multiplied
141  * by a constant factor so that their
142  * surface integral on selected faces
143  * is preserved (relative to the
144  * input values)
145  * 2: as 1, but with a boundary-defined
146  * weight, defined by balance_w
147  * 3: as 1, but with a cell-defined
148  * weight, defined by balance_w
149  * interpolate <-- interpolation option:
150  * 0: values are simply based on matching
151  * cell or face center values
152  * 1: values are based on matching cell
153  * or face center values, corrected
154  * by gradient interpolation
155  * n_faces <-- number of selected boundary faces
156  * faces <-- list of selected boundary faces (0 to n-1),
157  * or NULL if no indirection is needed
158  * balance_w <-- optional balance weight, or NULL
159  * nvarcl <-- number of variables requiring BC's
160  * rcodcl <-> boundary condition values
161  *----------------------------------------------------------------------------*/
162 
163 void
165  ple_locator_t *locator,
166  cs_mesh_location_type_t location_type,
167  int normalize,
168  int interpolate,
169  cs_lnum_t n_faces,
170  const cs_lnum_t *faces,
171  cs_real_t *balance_w,
172  int nvarcl,
173  cs_real_t rcodcl[]);
174 
175 /*----------------------------------------------------------------------------
176  * Create the boundary conditions type array bc_type
177  *----------------------------------------------------------------------------*/
178 
179 void
181 
182 /*----------------------------------------------------------------------------
183  * Free the boundary conditions type array bc_type
184  *----------------------------------------------------------------------------*/
185 
186 void
188 
189 /*----------------------------------------------------------------------------*/
200 /*----------------------------------------------------------------------------*/
201 
202 inline static void
204  cs_real_t *af,
205  cs_real_t *b,
206  cs_real_t *bf,
207  cs_real_t qimp,
208  cs_real_t hint)
209 {
210  /* Gradient BCs */
211  *a = -qimp/hint;
212  *b = 1.;
213 
214  /* Flux BCs */
215  *af = qimp;
216  *bf = 0.;
217 }
218 
219 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 inline static void
236  cs_real_t *af,
237  cs_real_t *b,
238  cs_real_t *bf,
239  cs_real_t pimp,
240  cs_real_t hint,
241  cs_real_t hext)
242 {
243  if (hext < 0.) {
244 
245  /* Gradient BCs */
246  *a = pimp;
247  *b = 0.;
248 
249  /* Flux BCs */
250  *af = -hint*pimp;
251  *bf = hint;
252 
253  }
254  else {
255 
256  /* Gradient BCs */
257  *a = hext*pimp/(hint + hext);
258  *b = hint /(hint + hext);
259 
260  /* Flux BCs */
261  cs_real_t heq = hint*hext/(hint + hext);
262  *af = -heq*pimp;
263  *bf = heq;
264 
265  }
266 }
267 
279 /*----------------------------------------------------------------------------*/
280 
282  cs_real_t *cofaf,
283  cs_real_t *coefb,
284  cs_real_t *cofbf,
285  cs_real_t pimp,
286  cs_real_t cfl,
287  cs_real_t hint);
288 
289 /*----------------------------------------------------------------------------*/
290 
292 
293 #endif /* __CS_BOUNDARY_CONDITIONS_H__ */
Field descriptor.
Definition: cs_field.h:121
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
void cs_boundary_conditions_type_create(void)
Definition: cs_boundary_conditions.c:1036
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
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:235
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:1072
double precision, save a
Definition: cs_fuel_incl.f90:146
void cs_boundary_conditions_mapped_set(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 nvarcl, cs_real_t rcodcl[])
Set mapped boundary conditions for a given field and mapping locator.
Definition: cs_boundary_conditions.c:851
void cs_boundary_conditions_type_free(void)
Definition: cs_boundary_conditions.c:1053
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:308
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
integer(c_int), pointer, save nvarcl
number of variable plus number of turbulent fluxes (used by the boundary conditions) ...
Definition: optcal.f90:661
#define END_C_DECLS
Definition: cs_defs.h:449
double precision, dimension(nozppm), save qimp
Definition: coincl.f90:103
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:478
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:203
double precision hext
Definition: cs_tagmr.f90:100
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:691
const int * cs_glob_bc_type
double precision, save b
Definition: cs_fuel_incl.f90:146