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-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 
69 extern const int *cs_glob_bc_face_zone;
70 
71 /*============================================================================
72  * Public function prototypes
73  *============================================================================*/
74 
75 /*----------------------------------------------------------------------------
76  * Handling of boundary condition definition errors and associated output.
77  *
78  * This function checks for errors, and simply returns if no errors are
79  * encountered. In case of error, it outputs helpful information so as to
80  * make it easier to locate the matching faces.
81  *
82  * For each boundary face, bc_type defines the boundary condition type.
83  * As a convention here, zero values correspond to undefined types,
84  * positive values to defined types (with no error), and negative values
85  * to defined types with inconsistent or incompatible values, the
86  * absolute value indicating the original boundary condition type.
87  *
88  * An optional label may be used if the error is related to another
89  * attribute than the boundary type, for appropriate error reporting.
90  *
91  * parameters:
92  * bc_flag <-- array of BC type ids
93  * type_name <-- name of attribute in error, or NULL
94  *----------------------------------------------------------------------------*/
95 
96 void
97 cs_boundary_conditions_error(const int *bc_type,
98  const char *type_name);
99 
100 /*----------------------------------------------------------------------------
101  * Locate shifted boundary face coordinates on possibly filtered
102  * cells or boundary faces for later interpolation.
103  *
104  * parameters:
105  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS
106  * or CS_MESH_LOCATION_BOUNDARY_FACES)
107  * n_location_elts <-- number of selected location elements
108  * n_faces <-- number of selected boundary faces
109  * location_elts <-- list of selected location elements (0 to n-1),
110  * or NULL if no indirection is needed
111  * faces <-- list of selected boundary faces (0 to n-1),
112  * or NULL if no indirection is needed
113  * coord_shift <-- array of coordinates shift relative to selected
114  * boundary faces
115  * coord_stride <-- access stride in coord_shift: 0 for uniform
116  * shift, 1 for "per face" shift.
117  * tolerance <-- relative tolerance for point location.
118  *
119  * returns:
120  * associated locator structure
121  *----------------------------------------------------------------------------*/
122 
123 ple_locator_t *
125  cs_lnum_t n_location_elts,
126  cs_lnum_t n_faces,
127  const cs_lnum_t *location_elts,
128  const cs_lnum_t *faces,
129  cs_real_3_t *coord_shift,
130  int coord_stride,
131  double tolerance);
132 
133 /*----------------------------------------------------------------------------
134  * Set mapped boundary conditions for a given field and mapping locator.
135  *
136  * parameters:
137  * field <-- field whose boundary conditions are set
138  * locator <-- associated mapping locator, as returned
139  * by cs_boundary_conditions_map().
140  * location_type <-- matching values location (CS_MESH_LOCATION_CELLS or
141  * CS_MESH_LOCATION_BOUNDARY_FACES)
142  * normalize <-- normalization option:
143  * 0: values are simply mapped
144  * 1: values are mapped, then multiplied
145  * by a constant factor so that their
146  * surface integral on selected faces
147  * is preserved (relative to the
148  * input values)
149  * 2: as 1, but with a boundary-defined
150  * weight, defined by balance_w
151  * 3: as 1, but with a cell-defined
152  * weight, defined by balance_w
153  * interpolate <-- interpolation option:
154  * 0: values are simply based on matching
155  * cell or face center values
156  * 1: values are based on matching cell
157  * or face center values, corrected
158  * by gradient interpolation
159  * n_faces <-- number of selected boundary faces
160  * faces <-- list of selected boundary faces (0 to n-1),
161  * or NULL if no indirection is needed
162  * balance_w <-- optional balance weight, or NULL
163  * nvar <-- number of variables requiring BC's
164  * rcodcl <-> boundary condition values
165  *----------------------------------------------------------------------------*/
166 
167 void
169  ple_locator_t *locator,
170  cs_mesh_location_type_t location_type,
171  int normalize,
172  int interpolate,
173  cs_lnum_t n_faces,
174  const cs_lnum_t *faces,
175  cs_real_t *balance_w,
176  int nvar,
177  cs_real_t rcodcl[]);
178 
179 /*----------------------------------------------------------------------------
180  * Create the boundary conditions face type and face zone arrays
181  *----------------------------------------------------------------------------*/
182 
183 void
185 
186 /*----------------------------------------------------------------------------
187  * Free the boundary conditions face type and face zone arrays
188  *----------------------------------------------------------------------------*/
189 
190 void
192 
193 /*----------------------------------------------------------------------------*/
204 /*----------------------------------------------------------------------------*/
205 
206 inline static void
208  cs_real_t *af,
209  cs_real_t *b,
210  cs_real_t *bf,
211  cs_real_t qimp,
212  cs_real_t hint)
213 {
214  /* Gradient BCs */
215  *a = -qimp/hint;
216  *b = 1.;
217 
218  /* Flux BCs */
219  *af = qimp;
220  *bf = 0.;
221 }
222 
223 /*----------------------------------------------------------------------------*/
236 /*----------------------------------------------------------------------------*/
237 
238 inline static void
240  cs_real_t *af,
241  cs_real_t *b,
242  cs_real_t *bf,
243  cs_real_t pimp,
244  cs_real_t hint,
245  cs_real_t hext)
246 {
247  if (hext < 0.) {
248 
249  /* Gradient BCs */
250  *a = pimp;
251  *b = 0.;
252 
253  /* Flux BCs */
254  *af = -hint*pimp;
255  *bf = hint;
256 
257  }
258  else {
259 
260  /* Gradient BCs */
261  *a = hext*pimp/(hint + hext);
262  *b = hint /(hint + hext);
263 
264  /* Flux BCs */
265  cs_real_t heq = hint*hext/(hint + hext);
266  *af = -heq*pimp;
267  *bf = heq;
268 
269  }
270 }
271 
272 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 
287  cs_real_t *cofaf,
288  cs_real_t *coefb,
289  cs_real_t *cofbf,
290  cs_real_t pimp,
291  cs_real_t cfl,
292  cs_real_t hint);
293 
294 /*----------------------------------------------------------------------------*/
295 
297 
298 #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:451
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:239
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:797
double precision, save a
Definition: cs_fuel_incl.f90:146
integer, save nvar
number of solved variables (must be lower than nvarmx)
Definition: dimens.f90:42
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:452
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: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:207
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:393
const int * cs_glob_bc_type
double precision, save b
Definition: cs_fuel_incl.f90:146