Code_Saturne
CFD tool
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-2012 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  unsigned *bad_cell_flag; /* Flag (mask) for bad cells detected */
97 
99 
100 /*============================================================================
101  * Static global variables
102  *============================================================================*/
103 
104 /* Pointer to mesh quantities structure associated to the main mesh */
105 
107 
108 /*============================================================================
109  * Public function prototypes for API Fortran
110  *============================================================================*/
111 
112 /*----------------------------------------------------------------------------
113  * Query or modification of the option for computing cell centers.
114  *
115  * This function returns 1 or 2 according to the selected algorithm.
116  *
117  * Fortran interface :
118  *
119  * SUBROUTINE ALGCEN (IOPT)
120  * *****************
121  *
122  * INTEGER IOPT : <-> : Choice of the algorithm
123  * < 0 : query
124  * 0 : computation based
125  * on faces (default choice)
126  * 1 : computation based
127  * on vertices
128  *----------------------------------------------------------------------------*/
129 
130 void
131 CS_PROCF (algcen, ALGCEN) (cs_int_t *const iopt);
132 
133 /*----------------------------------------------------------------------------
134  * Query of the option for computing cocg matrix for the iterative algo
135  * and for the Least square method.
136  *
137  * This function returns 0 or 1 according to the selected option.
138  *
139  * Fortran interface :
140  *
141  * SUBROUTINE COMCOC (IOPTIT, IOPLSQ)
142  * *****************
143  *
144  * INTEGER IOPTIT : <-> : Choice of the algorithm
145  * < 0 : query
146  * 0 : No computation
147  * 1 : computation of the
148  * 3x3 dimensionless matrix cocg_it
149  * INTEGER IOPTLSQ : <-> : Choice of the algorithm
150  * < 0 : query
151  * 0 : No computation
152  * 1 : computation of the
153  * 3x3 dimensionless matrix cocg_lsq
154  *----------------------------------------------------------------------------*/
155 
156 void
157 CS_PROCF (comcoc, COMCOC) (cs_int_t *const ioptit, cs_int_t *const ioplsq);
158 
159 /*=============================================================================
160  * Public function prototypes
161  *============================================================================*/
162 
163 /*----------------------------------------------------------------------------
164  * Query or modification of the option for computing cell centers.
165  *
166  * < 0 : query
167  * 0 : computation based on faces (default choice)
168  * 1 : computation based on vertices
169  *
170  * algo_choice <-- choice of algorithm to compute cell centers.
171  *
172  * returns:
173  * 1 or 2 according to the selected algorithm.
174  *----------------------------------------------------------------------------*/
175 
176 int
177 cs_mesh_quantities_cell_cen_choice(const int algo_choice);
178 
179 /*----------------------------------------------------------------------------
180  * Query or modification of the option for computing cocg for the iterative
181  * algorithm.
182  *
183  * < 0 : query
184  * 0 : Not compute cocg (default choice)
185  * 1 : compute the dimensionless cocg matrix
186  *
187  * algo_choice <-- choice of the option.
188  *
189  * returns:
190  * 0 or 1 according to the selected option.
191  *----------------------------------------------------------------------------*/
192 
193 int
194 cs_mesh_quantities_compute_cocg_it(const int algo_choice);
195 
196 /*----------------------------------------------------------------------------
197  * Query or modification of the option for computing cocg for the Least
198  * square method.
199  *
200  * < 0 : query
201  * 0 : Not compute cocg (default choice)
202  * 1 : compute the dimensionless cocg matrix
203  *
204  * algo_choice <-- choice of the option.
205  *
206  * returns:
207  * 0 or 1 according to the selected option.
208  *----------------------------------------------------------------------------*/
209 
210 int
211 cs_mesh_quantities_compute_cocg_lsq(const int algo_choice);
212 
213 /*----------------------------------------------------------------------------
214  * Create a mesh quantities structure.
215  *
216  * returns:
217  * pointer to created cs_mesh_quantities_t structure
218  *----------------------------------------------------------------------------*/
219 
222 
223 /*----------------------------------------------------------------------------
224  * Destroy a mesh quantities structure
225  *
226  * parameters:
227  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
228  *
229  * returns:
230  * NULL
231  *----------------------------------------------------------------------------*/
232 
235 
236 /*----------------------------------------------------------------------------
237  * Compute mesh quantities
238  *
239  * parameters:
240  * mesh <-- pointer to a cs_mesh_t structure
241  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
242  *----------------------------------------------------------------------------*/
243 
244 void
246  cs_mesh_quantities_t *mesh_quantities);
247 
248 /*----------------------------------------------------------------------------
249  * Compute mesh quantities
250  *
251  * parameters:
252  * mesh <-- pointer to a cs_mesh_t structure
253  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
254  *----------------------------------------------------------------------------*/
255 
256 void
258  cs_mesh_quantities_t *mesh_quantities);
259 
260 /*----------------------------------------------------------------------------
261  * Compute internal and border face normal.
262  *
263  * parameters:
264  * mesh <-- pointer to a cs_mesh_t structure
265  * p_i_face_normal <-> pointer to the internal face normal array
266  * p_b_face_normal <-> pointer to the border face normal array
267  *----------------------------------------------------------------------------*/
268 
269 void
271  cs_real_t *p_i_face_normal[],
272  cs_real_t *p_b_face_normal[]);
273 
274 /*----------------------------------------------------------------------------
275  * Compute interior face centers and normals.
276  *
277  * The corresponding arrays are allocated by this function, and it is the
278  * caller's responsibility to free them when they are no longer needed.
279  *
280  * parameters:
281  * mesh <-- pointer to a cs_mesh_t structure
282  * p_i_face_cog <-> pointer to the interior face center array
283  * p_i_face_normal <-> pointer to the interior face normal array
284  *----------------------------------------------------------------------------*/
285 
286 void
288  cs_real_t *p_i_face_cog[],
289  cs_real_t *p_i_face_normal[]);
290 
291 /*----------------------------------------------------------------------------
292  * Compute border face centers and normals.
293  *
294  * The corresponding arrays are allocated by this function, and it is the
295  * caller's responsibility to free them when they are no longer needed.
296  *
297  * parameters:
298  * mesh <-- pointer to a cs_mesh_t structure
299  * p_b_face_cog <-> pointer to the border face center array
300  * p_b_face_normal <-> pointer to the border face normal array
301  *----------------------------------------------------------------------------*/
302 
303 void
305  cs_real_t *p_b_face_cog[],
306  cs_real_t *p_b_face_normal[]);
307 
308 /*----------------------------------------------------------------------------
309  * Check that no negative volumes are present, and exit on error otherwise.
310  *
311  * parameters:
312  * mesh <-- pointer to mesh structure
313  * mesh_quantities <-- pointer to mesh quantities structure
314  * allow_error <-- 1 if errors are allowed, 0 otherwise
315  *----------------------------------------------------------------------------*/
316 
317 void
319  const cs_mesh_quantities_t *mesh_quantities,
320  int allow_error);
321 
322 /*----------------------------------------------------------------------------
323  * Dump a cs_mesh_quantities_t structure
324  *
325  * parameters:
326  * mesh <-- pointer to a cs_mesh_t structure
327  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
328  *----------------------------------------------------------------------------*/
329 
330 void
332  const cs_mesh_quantities_t *mesh_quantities);
333 
334 /*----------------------------------------------------------------------------*/
335 
337 
338 #endif /* __CS_MESH_QUANTITIES_H__ */
void cs_mesh_quantities_check_vol(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, int allow_error)
Definition: cs_mesh_quantities.c:2187
cs_real_33_t * cocgb_s_lsq
Definition: cs_mesh_quantities.h:87
void cs_mesh_quantities_dump(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2238
cs_real_t * b_dist
Definition: cs_mesh_quantities.h:74
cs_real_t * b_face_surf
Definition: cs_mesh_quantities.h:64
cs_real_t * djjpf
Definition: cs_mesh_quantities.h:70
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
int cs_mesh_quantities_compute_cocg_it(const int algo_choice)
Definition: cs_mesh_quantities.c:1660
void algcen(cs_int_t *const iopt)
Definition: cs_mesh_quantities.c:1571
cs_mesh_quantities_t * cs_mesh_quantities_destroy(cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:1758
cs_real_t * diipf
Definition: cs_mesh_quantities.h:69
cs_real_t * dofij
Definition: cs_mesh_quantities.h:68
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:61
int cs_int_t
Definition: cs_defs.h:263
void cs_mesh_quantities_face_normal(const cs_mesh_t *mesh, cs_real_t *p_i_face_normal[], cs_real_t *p_b_face_normal[])
Definition: cs_mesh_quantities.c:2069
cs_real_t max_vol
Definition: cs_mesh_quantities.h:80
unsigned * bad_cell_flag
Definition: cs_mesh_quantities.h:96
Definition: cs_mesh.h:62
cs_real_33_t * cocg_s_it
Definition: cs_mesh_quantities.h:85
cs_real_t tot_vol
Definition: cs_mesh_quantities.h:81
cs_real_t * dijpf
Definition: cs_mesh_quantities.h:66
void cs_mesh_quantities_b_faces(const cs_mesh_t *mesh, cs_real_t *p_b_face_cog[], cs_real_t *p_b_face_normal[])
Definition: cs_mesh_quantities.c:2155
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:53
cs_mesh_quantities_t * cs_glob_mesh_quantities
Definition: cs_mesh_quantities.c:93
cs_real_t * i_dist
Definition: cs_mesh_quantities.h:72
cs_real_t * i_face_normal
Definition: cs_mesh_quantities.h:56
Definition: cs_mesh_quantities.h:51
cs_real_33_t * cocgb_s_it
Definition: cs_mesh_quantities.h:83
cs_mesh_quantities_t * cs_mesh_quantities_create(void)
Definition: cs_mesh_quantities.c:1715
int cs_mesh_quantities_cell_cen_choice(const int algo_choice)
Definition: cs_mesh_quantities.c:1629
int cs_mesh_quantities_compute_cocg_lsq(const int algo_choice)
Definition: cs_mesh_quantities.c:1691
cs_real_33_t * cocg_s_lsq
Definition: cs_mesh_quantities.h:89
cs_real_t * weight
Definition: cs_mesh_quantities.h:77
cs_real_t min_vol
Definition: cs_mesh_quantities.h:79
#define END_C_DECLS
Definition: cs_defs.h:366
double cs_real_t
Definition: cs_defs.h:264
cs_real_33_t * cocg_it
Definition: cs_mesh_quantities.h:92
#define CS_PROCF(x, y)
Definition: cs_defs.h:379
cs_real_t * b_face_normal
Definition: cs_mesh_quantities.h:58
cs_real_t * diipb
Definition: cs_mesh_quantities.h:67
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:54
void comcoc(cs_int_t *const ioptit, cs_int_t *const ioplsq)
Definition: cs_mesh_quantities.c:1602
void cs_mesh_quantities_compute(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:1799
void cs_mesh_quantities_sup_vectors(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2036
cs_real_t * i_face_surf
Definition: cs_mesh_quantities.h:63
cs_real_t * i_face_cog
Definition: cs_mesh_quantities.h:60
cs_real_t cs_real_33_t[3][3]
Definition: cs_defs.h:273
Definition: mesh.f90:25
cs_real_33_t * cocg_lsq
Definition: cs_mesh_quantities.h:94
void cs_mesh_quantities_i_faces(const cs_mesh_t *mesh, cs_real_t *p_i_face_cog[], cs_real_t *p_i_face_normal[])
Definition: cs_mesh_quantities.c:2120