programmer's documentation
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-2015 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  cs_real_t *cell_f_vol; /* Cell fluid volume */
56 
57  cs_real_t *i_face_normal; /* Surface normal of interior faces.
58  (L2 norm equals area of the face) */
59  cs_real_t *b_face_normal; /* Surface normal of border faces.
60  (L2 norm equals area of the face) */
61  cs_real_t *i_f_face_normal;/* Fluid Surface normal of interior faces.
62  (L2 norm equals area of the face) */
63  cs_real_t *b_f_face_normal;/* Fluid Surface normal of border faces.
64  (L2 norm equals area of the face) */
65  cs_real_t *i_face_cog; /* Center of gravity of interior faces */
66  cs_real_t *b_face_cog; /* Center of gravity of border faces */
67 
68  cs_real_t *i_face_surf; /* Surface of interior faces. */
69  cs_real_t *b_face_surf; /* Surface of boundary faces. */
70 
71  cs_real_t *i_f_face_surf; /* Fluid surface of interior faces. */
72  cs_real_t *b_f_face_surf; /* Fluid surface of boundary faces. */
73 
74  cs_real_t *dijpf; /* Vector I'J' for interior faces */
75  cs_real_t *diipb; /* Vector II' for border faces */
76  cs_real_t *dofij; /* Vector OF for interior faces */
77  cs_real_t *diipf; /* Vector II' for interior faces */
78  cs_real_t *djjpf; /* Vector JJ' for interior faces */
79 
80  cs_real_t *i_dist; /* Distance between the cell center and
81  the center of gravity of interior faces */
82  cs_real_t *b_dist; /* Distance between the cell center and
83  the center of gravity of border faces */
84 
85  cs_real_t *weight; /* Interior faces weighting factor */
86 
87  cs_real_t min_vol; /* Minimum cell volume */
88  cs_real_t max_vol; /* Maximum cell volume */
89  cs_real_t tot_vol; /* Total volume */
90 
91  cs_real_33_t *cocgb_s_it; /* coupling of gradient compponents for
92  iterative reconstruction at boundary */
93  cs_real_33_t *cocg_s_it; /* coupling of gradient compponents for
94  iterative reconstruction */
95  cs_real_33_t *cocgb_s_lsq; /* coupling of gradient compponents for
96  least-square reconstruction at boundary */
97  cs_real_33_t *cocg_s_lsq; /* coupling of gradient compponents for
98  least-square reconstruction */
99 
100  cs_real_33_t *cocg_it; /* Interleaved cocg matrix
101  for iterative gradients */
102  cs_real_33_t *cocg_lsq; /* Interleaved cocg matrix
103  for least square gradients */
104 
105  cs_int_t *b_sym_flag; /* Symmetry flag for boundary faces */
106  cs_int_t *c_solid_flag; /* Is the fluid volume 0 flag */
107  unsigned *bad_cell_flag; /* Flag (mask) for bad cells detected */
108 
110 
111 /*============================================================================
112  * Static global variables
113  *============================================================================*/
114 
115 /* Pointer to mesh quantities structure associated to the main mesh */
116 
118 
119 /* Choice of the porous model */
120 extern int cs_glob_porous_model;
121 
122 /*============================================================================
123  * Public function prototypes for API Fortran
124  *============================================================================*/
125 
126 /*----------------------------------------------------------------------------
127  * Query or modification of the option for computing cell centers.
128  *
129  * This function returns 1 or 2 according to the selected algorithm.
130  *
131  * Fortran interface :
132  *
133  * SUBROUTINE ALGCEN (IOPT)
134  * *****************
135  *
136  * INTEGER IOPT : <-> : Choice of the algorithm
137  * < 0 : query
138  * 0 : computation based
139  * on faces (default choice)
140  * 1 : computation based
141  * on vertices
142  *----------------------------------------------------------------------------*/
143 
144 void
145 CS_PROCF (algcen, ALGCEN) (cs_int_t *const iopt);
146 
147 /*----------------------------------------------------------------------------
148  * Set behavior for computing the cocg matrixes for the iterative algo
149  * and for the Least square method for scalar and vector gradients.
150  *
151  * Fortran interface :
152  *
153  * subroutine comcoc (imrgra)
154  * *****************
155  *
156  * integer imrgra : <-- : gradient reconstruction option
157  *----------------------------------------------------------------------------*/
158 
159 void
160 CS_PROCF (comcoc, COMCOC) (const cs_int_t *const imrgra);
161 
162 /*----------------------------------------------------------------------------
163  * Set porous model
164  *
165  * Fortran interface :
166  *
167  * subroutine compor (iporos)
168  * *****************
169  *
170  * integer iporos : <-- : porous model
171  *----------------------------------------------------------------------------*/
172 
173 void
174 CS_PROCF (compor, COMPOR) (const cs_int_t *const iporos);
175 
176 /*=============================================================================
177  * Public function prototypes
178  *============================================================================*/
179 
180 /*----------------------------------------------------------------------------
181  * Query or modification of the option for computing cell centers.
182  *
183  * < 0 : query
184  * 0 : computation based on faces (default choice)
185  * 1 : computation based on vertices
186  *
187  * algo_choice <-- choice of algorithm to compute cell centers.
188  *
189  * returns:
190  * 1 or 2 according to the selected algorithm.
191  *----------------------------------------------------------------------------*/
192 
193 int
194 cs_mesh_quantities_cell_cen_choice(const int algo_choice);
195 
196 /*----------------------------------------------------------------------------
197  * Compute cocg for iterative gradient reconstruction for scalars.
198  *
199  * parameters:
200  * gradient_option <-- gradient option (Fortran IMRGRA)
201  *----------------------------------------------------------------------------*/
202 
203 void
204 cs_mesh_quantities_set_cocg_options(int gradient_option);
205 
206 /*----------------------------------------------------------------------------
207  * Compute Fluid volumes and fluid surface in addition to cell volume and surfaces.
208  *
209  * parameters:
210  * porous_model <-- gradient option (Fortran iporos)
211  *----------------------------------------------------------------------------*/
212 
213 void
214 cs_mesh_quantities_set_porous_model(int porous_model);
215 
216 /*----------------------------------------------------------------------------
217  * Create a mesh quantities structure.
218  *
219  * returns:
220  * pointer to created cs_mesh_quantities_t structure
221  *----------------------------------------------------------------------------*/
222 
225 
226 /*----------------------------------------------------------------------------
227  * Destroy a mesh quantities structure
228  *
229  * parameters:
230  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
231  *
232  * returns:
233  * NULL
234  *----------------------------------------------------------------------------*/
235 
238 
239 /*----------------------------------------------------------------------------
240  * Compute mesh quantities
241  *
242  * parameters:
243  * mesh <-- pointer to a cs_mesh_t structure
244  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
245  *----------------------------------------------------------------------------*/
246 
247 void
249  cs_mesh_quantities_t *mesh_quantities);
250 
251 /*----------------------------------------------------------------------------
252  * Compute mesh quantities
253  *
254  * parameters:
255  * mesh <-- pointer to a cs_mesh_t structure
256  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
257  *----------------------------------------------------------------------------*/
258 
259 void
261  cs_mesh_quantities_t *mesh_quantities);
262 
263 /*----------------------------------------------------------------------------
264  * Compute internal and border face normal.
265  *
266  * parameters:
267  * mesh <-- pointer to a cs_mesh_t structure
268  * p_i_face_normal <-> pointer to the internal face normal array
269  * p_b_face_normal <-> pointer to the border face normal array
270  *----------------------------------------------------------------------------*/
271 
272 void
274  cs_real_t *p_i_face_normal[],
275  cs_real_t *p_b_face_normal[]);
276 
277 /*----------------------------------------------------------------------------
278  * Compute interior face centers and normals.
279  *
280  * The corresponding arrays are allocated by this function, and it is the
281  * caller's responsibility to free them when they are no longer needed.
282  *
283  * parameters:
284  * mesh <-- pointer to a cs_mesh_t structure
285  * p_i_face_cog <-> pointer to the interior face center array
286  * p_i_face_normal <-> pointer to the interior face normal array
287  *----------------------------------------------------------------------------*/
288 
289 void
291  cs_real_t *p_i_face_cog[],
292  cs_real_t *p_i_face_normal[]);
293 
294 /*----------------------------------------------------------------------------
295  * Compute border face centers and normals.
296  *
297  * The corresponding arrays are allocated by this function, and it is the
298  * caller's responsibility to free them when they are no longer needed.
299  *
300  * parameters:
301  * mesh <-- pointer to a cs_mesh_t structure
302  * p_b_face_cog <-> pointer to the border face center array
303  * p_b_face_normal <-> pointer to the border face normal array
304  *----------------------------------------------------------------------------*/
305 
306 void
308  cs_real_t *p_b_face_cog[],
309  cs_real_t *p_b_face_normal[]);
310 
311 /*----------------------------------------------------------------------------
312  * Check that no negative volumes are present, and exit on error otherwise.
313  *
314  * parameters:
315  * mesh <-- pointer to mesh structure
316  * mesh_quantities <-- pointer to mesh quantities structure
317  * allow_error <-- 1 if errors are allowed, 0 otherwise
318  *----------------------------------------------------------------------------*/
319 
320 void
322  const cs_mesh_quantities_t *mesh_quantities,
323  int allow_error);
324 
325 /*----------------------------------------------------------------------------
326  * Update mesh quantities relative to extended ghost cells when the
327  * neighborhood is reduced.
328  *
329  * parameters:
330  * mesh <-- pointer to a cs_mesh_t structure
331  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
332  *----------------------------------------------------------------------------*/
333 
334 void
336  cs_mesh_quantities_t *mesh_quantities);
337 
338 /*----------------------------------------------------------------------------
339  * Return the number of times mesh quantities have been computed.
340  *
341  * returns:
342  * number of times mesh quantities have been computed
343  *----------------------------------------------------------------------------*/
344 
345 int
347 
348 /*----------------------------------------------------------------------------
349  * Dump a cs_mesh_quantities_t structure
350  *
351  * parameters:
352  * mesh <-- pointer to a cs_mesh_t structure
353  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
354  *----------------------------------------------------------------------------*/
355 
356 void
358  const cs_mesh_quantities_t *mesh_quantities);
359 
360 /*----------------------------------------------------------------------------*/
361 
363 
364 #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:2640
cs_real_33_t * cocgb_s_lsq
Definition: cs_mesh_quantities.h:95
void cs_mesh_quantities_reduce_extended(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2692
void cs_mesh_quantities_dump(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2723
cs_real_t * b_dist
Definition: cs_mesh_quantities.h:82
integer, save iporos
take the porosity fomulation into account
Definition: optcal.f90:855
cs_real_t * cell_f_vol
Definition: cs_mesh_quantities.h:55
cs_real_t * b_face_surf
Definition: cs_mesh_quantities.h:69
cs_real_t * djjpf
Definition: cs_mesh_quantities.h:78
cs_int_t * c_solid_flag
Definition: cs_mesh_quantities.h:106
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
void algcen(cs_int_t *const iopt)
Definition: cs_mesh_quantities.c:1937
cs_mesh_quantities_t * cs_mesh_quantities_destroy(cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2141
cs_real_t * diipf
Definition: cs_mesh_quantities.h:77
cs_real_t * dofij
Definition: cs_mesh_quantities.h:76
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:66
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:2522
cs_real_t max_vol
Definition: cs_mesh_quantities.h:88
unsigned * bad_cell_flag
Definition: cs_mesh_quantities.h:107
Definition: cs_mesh.h:62
cs_real_33_t * cocg_s_it
Definition: cs_mesh_quantities.h:93
cs_real_t * i_f_face_normal
Definition: cs_mesh_quantities.h:61
cs_real_t tot_vol
Definition: cs_mesh_quantities.h:89
void cs_mesh_quantities_set_cocg_options(int gradient_option)
Definition: cs_mesh_quantities.c:2022
cs_real_t * dijpf
Definition: cs_mesh_quantities.h:74
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:2608
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:53
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_t * i_dist
Definition: cs_mesh_quantities.h:80
cs_real_t * i_face_normal
Definition: cs_mesh_quantities.h:57
Definition: cs_mesh_quantities.h:51
cs_real_33_t * cocgb_s_it
Definition: cs_mesh_quantities.h:91
int cs_glob_porous_model
cs_mesh_quantities_t * cs_mesh_quantities_create(void)
Definition: cs_mesh_quantities.c:2091
int cs_mesh_quantities_cell_cen_choice(const int algo_choice)
Definition: cs_mesh_quantities.c:1997
void comcoc(const cs_int_t *const imrgra)
Definition: cs_mesh_quantities.c:1957
cs_real_33_t * cocg_s_lsq
Definition: cs_mesh_quantities.h:97
cs_real_t * b_f_face_surf
Definition: cs_mesh_quantities.h:72
cs_real_t * weight
Definition: cs_mesh_quantities.h:85
cs_real_t min_vol
Definition: cs_mesh_quantities.h:87
#define END_C_DECLS
Definition: cs_defs.h:430
double cs_real_t
Definition: cs_defs.h:296
cs_real_33_t * cocg_it
Definition: cs_mesh_quantities.h:100
cs_real_t * i_f_face_surf
Definition: cs_mesh_quantities.h:71
#define CS_PROCF(x, y)
Definition: cs_defs.h:453
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:311
cs_real_t * b_face_normal
Definition: cs_mesh_quantities.h:59
cs_real_t * diipb
Definition: cs_mesh_quantities.h:75
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:54
void cs_mesh_quantities_compute(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2194
void cs_mesh_quantities_sup_vectors(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2489
void compor(const cs_int_t *const iporos)
Definition: cs_mesh_quantities.c:1974
cs_real_t * i_face_surf
Definition: cs_mesh_quantities.h:68
int cs_mesh_quantities_compute_count(void)
Definition: cs_mesh_quantities.c:2709
cs_real_t * i_face_cog
Definition: cs_mesh_quantities.h:65
cs_int_t * b_sym_flag
Definition: cs_mesh_quantities.h:105
Definition: mesh.f90:26
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:266
cs_real_33_t * cocg_lsq
Definition: cs_mesh_quantities.h:102
cs_real_t * b_f_face_normal
Definition: cs_mesh_quantities.h:63
void cs_mesh_quantities_set_porous_model(int porous_model)
Definition: cs_mesh_quantities.c:2078
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:2573