programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cs_mesh_quantities.h
Go to the documentation of this file.
1 #ifndef __CS_MESH_QUANTITIES_H__
2 #define __CS_MESH_QUANTITIES_H__
3 
4 /*============================================================================
5  * Management of mesh quantities
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2013 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  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_mesh.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*=============================================================================
42  * Local Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definition
47  *============================================================================*/
48 
49 /* Structure associated to mesh quantities management */
50 
51 typedef struct {
52 
53  cs_real_t *cell_cen; /* Cell center coordinates */
54  cs_real_t *cell_vol; /* Cell volume */
55 
56  cs_real_t *i_face_normal; /* Surface normal of interior faces.
57  (L2 norm equals area of the face) */
58  cs_real_t *b_face_normal; /* Surface normal of border faces.
59  (L2 norm equals area of the face) */
60  cs_real_t *i_face_cog; /* Center of gravity of interior faces */
61  cs_real_t *b_face_cog; /* Center of gravity of border faces */
62 
63  cs_real_t *i_face_surf; /* Surface of interior faces. */
64  cs_real_t *b_face_surf; /* Surface of boundary faces. */
65 
66  cs_real_t *dijpf; /* Vector I'J' for interior faces */
67  cs_real_t *diipb; /* Vector II' for border faces */
68  cs_real_t *dofij; /* Vector OF for interior faces */
69  cs_real_t *diipf; /* Vector II' for interior faces */
70  cs_real_t *djjpf; /* Vector JJ' for interior faces */
71 
72  cs_real_t *i_dist; /* Distance between the cell center and
73  the center of gravity of interior faces */
74  cs_real_t *b_dist; /* Distance between the cell center and
75  the center of gravity of border faces */
76 
77  cs_real_t *weight; /* Interior faces weighting factor */
78 
79  cs_real_t min_vol; /* Minimum cell volume */
80  cs_real_t max_vol; /* Maximum cell volume */
81  cs_real_t tot_vol; /* Total volume */
82 
83  cs_real_33_t *cocgb_s_it; /* coupling of gradient compponents for
84  iterative reconstruction at boundary */
85  cs_real_33_t *cocg_s_it; /* coupling of gradient compponents for
86  iterative reconstruction */
87  cs_real_33_t *cocgb_s_lsq; /* coupling of gradient compponents for
88  least-square reconstruction at boundary */
89  cs_real_33_t *cocg_s_lsq; /* coupling of gradient compponents for
90  least-square reconstruction */
91 
92  cs_real_33_t *cocg_it; /* Interleaved cocg matrix
93  for iterative gradients */
94  cs_real_33_t *cocg_lsq; /* Interleaved cocg matrix
95  for least square gradients */
96 
97  cs_int_t *b_sym_flag; /* Symmetry flag for boundary faces */
98  unsigned *bad_cell_flag; /* Flag (mask) for bad cells detected */
99 
101 
102 /*============================================================================
103  * Static global variables
104  *============================================================================*/
105 
106 /* Pointer to mesh quantities structure associated to the main mesh */
107 
109 
110 /*============================================================================
111  * Public function prototypes for API Fortran
112  *============================================================================*/
113 
114 /*----------------------------------------------------------------------------
115  * Query or modification of the option for computing cell centers.
116  *
117  * This function returns 1 or 2 according to the selected algorithm.
118  *
119  * Fortran interface :
120  *
121  * SUBROUTINE ALGCEN (IOPT)
122  * *****************
123  *
124  * INTEGER IOPT : <-> : Choice of the algorithm
125  * < 0 : query
126  * 0 : computation based
127  * on faces (default choice)
128  * 1 : computation based
129  * on vertices
130  *----------------------------------------------------------------------------*/
131 
132 void
133 CS_PROCF (algcen, ALGCEN) (cs_int_t *const iopt);
134 
135 /*----------------------------------------------------------------------------
136  * Set behavior for computing the cocg matrixes for the iterative algo
137  * and for the Least square method for scalar and vector gradients.
138  *
139  * Fortran interface :
140  *
141  * subroutine comcoc (imrgra)
142  * *****************
143  *
144  * integer imrgra : <-- : gradient reconstruction option
145  *----------------------------------------------------------------------------*/
146 
147 void
148 CS_PROCF (comcoc, COMCOC) (const cs_int_t *const imrgra);
149 
150 /*=============================================================================
151  * Public function prototypes
152  *============================================================================*/
153 
154 /*----------------------------------------------------------------------------
155  * Query or modification of the option for computing cell centers.
156  *
157  * < 0 : query
158  * 0 : computation based on faces (default choice)
159  * 1 : computation based on vertices
160  *
161  * algo_choice <-- choice of algorithm to compute cell centers.
162  *
163  * returns:
164  * 1 or 2 according to the selected algorithm.
165  *----------------------------------------------------------------------------*/
166 
167 int
168 cs_mesh_quantities_cell_cen_choice(const int algo_choice);
169 
170 /*----------------------------------------------------------------------------
171  * Compute cocg for iterative gradient reconstruction for scalars.
172  *
173  * parameters:
174  * gradient_option <-- gradient option (Fortran IMRGRA)
175  *----------------------------------------------------------------------------*/
176 
177 void
178 cs_mesh_quantities_set_cocg_options(int gradient_option);
179 
180 /*----------------------------------------------------------------------------
181  * Create a mesh quantities structure.
182  *
183  * returns:
184  * pointer to created cs_mesh_quantities_t structure
185  *----------------------------------------------------------------------------*/
186 
189 
190 /*----------------------------------------------------------------------------
191  * Destroy a mesh quantities structure
192  *
193  * parameters:
194  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
195  *
196  * returns:
197  * NULL
198  *----------------------------------------------------------------------------*/
199 
202 
203 /*----------------------------------------------------------------------------
204  * Compute mesh quantities
205  *
206  * parameters:
207  * mesh <-- pointer to a cs_mesh_t structure
208  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
209  *----------------------------------------------------------------------------*/
210 
211 void
213  cs_mesh_quantities_t *mesh_quantities);
214 
215 /*----------------------------------------------------------------------------
216  * Compute mesh quantities
217  *
218  * parameters:
219  * mesh <-- pointer to a cs_mesh_t structure
220  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
221  *----------------------------------------------------------------------------*/
222 
223 void
225  cs_mesh_quantities_t *mesh_quantities);
226 
227 /*----------------------------------------------------------------------------
228  * Compute internal and border face normal.
229  *
230  * parameters:
231  * mesh <-- pointer to a cs_mesh_t structure
232  * p_i_face_normal <-> pointer to the internal face normal array
233  * p_b_face_normal <-> pointer to the border face normal array
234  *----------------------------------------------------------------------------*/
235 
236 void
238  cs_real_t *p_i_face_normal[],
239  cs_real_t *p_b_face_normal[]);
240 
241 /*----------------------------------------------------------------------------
242  * Compute interior face centers and normals.
243  *
244  * The corresponding arrays are allocated by this function, and it is the
245  * caller's responsibility to free them when they are no longer needed.
246  *
247  * parameters:
248  * mesh <-- pointer to a cs_mesh_t structure
249  * p_i_face_cog <-> pointer to the interior face center array
250  * p_i_face_normal <-> pointer to the interior face normal array
251  *----------------------------------------------------------------------------*/
252 
253 void
255  cs_real_t *p_i_face_cog[],
256  cs_real_t *p_i_face_normal[]);
257 
258 /*----------------------------------------------------------------------------
259  * Compute border face centers and normals.
260  *
261  * The corresponding arrays are allocated by this function, and it is the
262  * caller's responsibility to free them when they are no longer needed.
263  *
264  * parameters:
265  * mesh <-- pointer to a cs_mesh_t structure
266  * p_b_face_cog <-> pointer to the border face center array
267  * p_b_face_normal <-> pointer to the border face normal array
268  *----------------------------------------------------------------------------*/
269 
270 void
272  cs_real_t *p_b_face_cog[],
273  cs_real_t *p_b_face_normal[]);
274 
275 /*----------------------------------------------------------------------------
276  * Check that no negative volumes are present, and exit on error otherwise.
277  *
278  * parameters:
279  * mesh <-- pointer to mesh structure
280  * mesh_quantities <-- pointer to mesh quantities structure
281  * allow_error <-- 1 if errors are allowed, 0 otherwise
282  *----------------------------------------------------------------------------*/
283 
284 void
286  const cs_mesh_quantities_t *mesh_quantities,
287  int allow_error);
288 
289 /*----------------------------------------------------------------------------
290  * Update mesh quantities relative to extended ghost cells when the
291  * neighborhood is reduced.
292  *
293  * parameters:
294  * mesh <-- pointer to a cs_mesh_t structure
295  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
296  *----------------------------------------------------------------------------*/
297 
298 void
300  cs_mesh_quantities_t *mesh_quantities);
301 
302 /*----------------------------------------------------------------------------
303  * Return the number of times mesh quantities have been computed.
304  *
305  * returns:
306  * number of times mesh quantities have been computed
307  *----------------------------------------------------------------------------*/
308 
309 int
311 
312 /*----------------------------------------------------------------------------
313  * Dump a cs_mesh_quantities_t structure
314  *
315  * parameters:
316  * mesh <-- pointer to a cs_mesh_t structure
317  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
318  *----------------------------------------------------------------------------*/
319 
320 void
322  const cs_mesh_quantities_t *mesh_quantities);
323 
324 /*----------------------------------------------------------------------------*/
325 
327 
328 #endif /* __CS_MESH_QUANTITIES_H__ */