programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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-2017 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 #include "cs_internal_coupling.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*=============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
52 /*
53  * Field property type
54  */
55 
57 #define CS_BAD_CELLS_WARPED_CORRECTION (1 << 0)
58 
60 #define CS_BAD_CELLS_REGULARISATION (1 << 1)
61 
63 #define CS_CELL_FACE_CENTER_CORRECTION (1 << 2)
64 
66 #define CS_CELL_CENTER_CORRECTION (1 << 3)
67 
69 #define CS_FACE_DISTANCE_CLIP (1 << 4)
70 
72 #define CS_FACE_RECONSTRUCTION_CLIP (1 << 5)
73 
76 /*============================================================================
77  * Type definition
78  *============================================================================*/
79 
80 /* Structure associated to mesh quantities management */
81 
82 typedef struct {
83 
84  cs_real_t *cell_cen; /* Cell center coordinates */
85  cs_real_t *cell_vol; /* Cell volume */
86  cs_real_t *cell_f_vol; /* Cell fluid volume */
87 
88  cs_real_t *i_face_normal; /* Surface normal of interior faces.
89  (L2 norm equals area of the face) */
90  cs_real_t *b_face_normal; /* Surface normal of border faces.
91  (L2 norm equals area of the face) */
92  cs_real_t *i_f_face_normal;/* Fluid Surface normal of interior faces.
93  (L2 norm equals area of the face) */
94  cs_real_t *b_f_face_normal;/* Fluid Surface normal of border faces.
95  (L2 norm equals area of the face) */
96  cs_real_t *i_face_cog; /* Center of gravity of interior faces */
97  cs_real_t *b_face_cog; /* Center of gravity of border faces */
98 
99  cs_real_t *i_face_surf; /* Surface of interior faces. */
100  cs_real_t *b_face_surf; /* Surface of boundary faces. */
101 
102  cs_real_t *i_f_face_surf; /* Fluid surface of interior faces. */
103  cs_real_t *b_f_face_surf; /* Fluid surface of boundary faces. */
104 
105  cs_real_t *dijpf; /* Vector I'J' for interior faces */
106  cs_real_t *diipb; /* Vector II' for border faces */
107  cs_real_t *dofij; /* Vector OF for interior faces */
108  cs_real_t *diipf; /* Vector II' for interior faces */
109  cs_real_t *djjpf; /* Vector JJ' for interior faces */
110 
111  cs_real_t *i_dist; /* Distance between the cell center and
112  the center of gravity of interior faces */
113  cs_real_t *b_dist; /* Distance between the cell center and
114  the center of gravity of border faces */
115 
116  cs_real_t *weight; /* Interior faces weighting factor */
117 
118  cs_real_t min_vol; /* Minimum cell volume */
119  cs_real_t max_vol; /* Maximum cell volume */
120  cs_real_t tot_vol; /* Total volume */
121 
122  cs_real_t min_f_vol; /* Minimum cell volume */
123  cs_real_t max_f_vol; /* Maximum cell volume */
124  cs_real_t tot_f_vol; /* Total volume */
125 
126  cs_real_33_t *cocgb_s_it; /* coupling of gradient components for
127  iterative reconstruction at boundary */
128  cs_real_33_t *cocg_s_it; /* coupling of gradient components for
129  iterative reconstruction */
130  cs_real_33_t *cocgb_s_lsq; /* coupling of gradient components for
131  least-square reconstruction at boundary */
132 
133  cs_real_33_t *cocg_it; /* Interleaved cocg matrix
134  for iterative gradients */
135  cs_real_33_t *cocg_lsq; /* Interleaved cocg matrix
136  for least square gradients */
137 
138  cs_real_t *corr_grad_lin_det; /* Determinant of geometrical matrix linear gradient correction */
139  cs_real_33_t *corr_grad_lin; /* Geometrical matrix linear gradient correction */
140 
141  cs_int_t *b_sym_flag; /* Symmetry flag for boundary faces */
142  cs_int_t *c_solid_flag; /* Is the fluid volume 0 flag */
143  unsigned *bad_cell_flag; /* Flag (mask) for bad cells detected */
144 
146 
147 /*============================================================================
148  * Static global variables
149  *============================================================================*/
150 
151 /* Pointer to mesh quantities structure associated to the main mesh */
152 
154 
155 /* Flag (mask) to activate bad cells correction */
156 extern unsigned cs_glob_mesh_quantities_flag;
157 
158 /* Choice of the porous model */
159 extern int cs_glob_porous_model;
160 
161 /*============================================================================
162  * Public function prototypes for API Fortran
163  *============================================================================*/
164 
165 /*----------------------------------------------------------------------------
166  * Query or modification of the option for computing cell centers.
167  *
168  * This function returns 1 or 2 according to the selected algorithm.
169  *
170  * Fortran interface :
171  *
172  * SUBROUTINE ALGCEN (IOPT)
173  * *****************
174  *
175  * INTEGER IOPT : <-> : Choice of the algorithm
176  * < 0 : query
177  * 0 : computation based
178  * on faces (default choice)
179  * 1 : computation based
180  * on vertices
181  *----------------------------------------------------------------------------*/
182 
183 void
184 CS_PROCF (algcen, ALGCEN) (cs_int_t *const iopt);
185 
186 /*----------------------------------------------------------------------------
187  * Set behavior for computing the cocg matrixes for the iterative algo
188  * and for the Least square method for scalar and vector gradients.
189  *
190  * Fortran interface :
191  *
192  * subroutine comcoc (imrgra)
193  * *****************
194  *
195  * integer imrgra : <-- : gradient reconstruction option
196  *----------------------------------------------------------------------------*/
197 
198 void
199 CS_PROCF (comcoc, COMCOC) (const cs_int_t *const imrgra);
200 
201 /*----------------------------------------------------------------------------
202  * Set porous model
203  *
204  * Fortran interface :
205  *
206  * subroutine compor (iporos)
207  * *****************
208  *
209  * integer iporos : <-- : porous model
210  *----------------------------------------------------------------------------*/
211 
212 void
213 CS_PROCF (compor, COMPOR) (const cs_int_t *const iporos);
214 
215 /*=============================================================================
216  * Public function prototypes
217  *============================================================================*/
218 
219 /*----------------------------------------------------------------------------
220  * Query or modification of the option for computing cell centers.
221  *
222  * < 0 : query
223  * 0 : computation based on faces (default choice)
224  * 1 : computation based on vertices
225  *
226  * algo_choice <-- choice of algorithm to compute cell centers.
227  *
228  * returns:
229  * 1 or 2 according to the selected algorithm.
230  *----------------------------------------------------------------------------*/
231 
232 int
233 cs_mesh_quantities_cell_cen_choice(const int algo_choice);
234 
235 /*----------------------------------------------------------------------------
236  * Compute cocg for iterative gradient reconstruction for scalars.
237  *
238  * parameters:
239  * gradient_option <-- gradient option (Fortran IMRGRA)
240  *----------------------------------------------------------------------------*/
241 
242 void
243 cs_mesh_quantities_set_cocg_options(int gradient_option);
244 
245 /*----------------------------------------------------------------------------
246  * Compute Fluid volumes and fluid surface in addition to cell volume and surfaces.
247  *
248  * parameters:
249  * porous_model <-- gradient option (Fortran iporos)
250  *----------------------------------------------------------------------------*/
251 
252 void
253 cs_mesh_quantities_set_porous_model(int porous_model);
254 
255 /*----------------------------------------------------------------------------
256  * Create a mesh quantities structure.
257  *
258  * returns:
259  * pointer to created cs_mesh_quantities_t structure
260  *----------------------------------------------------------------------------*/
261 
264 
265 /*----------------------------------------------------------------------------
266  * Destroy a mesh quantities structure
267  *
268  * parameters:
269  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
270  *
271  * returns:
272  * NULL
273  *----------------------------------------------------------------------------*/
274 
277 
278 /*----------------------------------------------------------------------------
279  * Compute mesh quantities
280  *
281  * parameters:
282  * mesh <-- pointer to a cs_mesh_t structure
283  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
284  *----------------------------------------------------------------------------*/
285 
286 void
288  cs_mesh_quantities_t *mesh_quantities);
289 
290 /*----------------------------------------------------------------------------
291  * Compute fluid mesh quantities
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  * Compute fluid section mesh quantities at the initial step
304  *
305  * parameters:
306  * mesh <-- pointer to a cs_mesh_t structure
307  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
308  *----------------------------------------------------------------------------*/
309 
310 void
312  cs_mesh_quantities_t *mesh_quantities);
313 
314 /*----------------------------------------------------------------------------
315  * Compute mesh quantities
316  *
317  * parameters:
318  * mesh <-- pointer to a cs_mesh_t structure
319  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
320  *----------------------------------------------------------------------------*/
321 
322 void
324  cs_mesh_quantities_t *mesh_quantities);
325 
326 /*----------------------------------------------------------------------------
327  * Compute internal and border face normal.
328  *
329  * parameters:
330  * mesh <-- pointer to a cs_mesh_t structure
331  * p_i_face_normal <-> pointer to the internal face normal array
332  * p_b_face_normal <-> pointer to the border face normal array
333  *----------------------------------------------------------------------------*/
334 
335 void
337  cs_real_t *p_i_face_normal[],
338  cs_real_t *p_b_face_normal[]);
339 
340 /*----------------------------------------------------------------------------
341  * Compute interior face centers and normals.
342  *
343  * The corresponding arrays are allocated by this function, and it is the
344  * caller's responsibility to free them when they are no longer needed.
345  *
346  * parameters:
347  * mesh <-- pointer to a cs_mesh_t structure
348  * p_i_face_cog <-> pointer to the interior face center array
349  * p_i_face_normal <-> pointer to the interior face normal array
350  *----------------------------------------------------------------------------*/
351 
352 void
354  cs_real_t *p_i_face_cog[],
355  cs_real_t *p_i_face_normal[]);
356 
357 /*----------------------------------------------------------------------------
358  * Compute border face centers and normals.
359  *
360  * The corresponding arrays are allocated by this function, and it is the
361  * caller's responsibility to free them when they are no longer needed.
362  *
363  * parameters:
364  * mesh <-- pointer to a cs_mesh_t structure
365  * p_b_face_cog <-> pointer to the border face center array
366  * p_b_face_normal <-> pointer to the border face normal array
367  *----------------------------------------------------------------------------*/
368 
369 void
371  cs_real_t *p_b_face_cog[],
372  cs_real_t *p_b_face_normal[]);
373 
374 /*----------------------------------------------------------------------------
375  * Compute cell centers.
376  *
377  * The corresponding array is allocated by this function, and it is the
378  * caller's responsibility to free it when they are no longer needed.
379  *
380  * parameters:
381  * mesh <-- pointer to a cs_mesh_t structure
382  * p_cell_cen <-> pointer to the cell centers array
383  *----------------------------------------------------------------------------*/
384 
385 void
387  cs_real_t *cell_cen[]);
388 
389 /*----------------------------------------------------------------------------
390  * Check that no negative volumes are present, and exit on error otherwise.
391  *
392  * parameters:
393  * mesh <-- pointer to mesh structure
394  * mesh_quantities <-- pointer to mesh quantities structure
395  * allow_error <-- 1 if errors are allowed, 0 otherwise
396  *----------------------------------------------------------------------------*/
397 
398 void
400  const cs_mesh_quantities_t *mesh_quantities,
401  int allow_error);
402 
403 /*----------------------------------------------------------------------------
404  * Update mesh quantities relative to extended ghost cells when the
405  * neighborhood is reduced.
406  *
407  * parameters:
408  * mesh <-- pointer to a cs_mesh_t structure
409  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
410  *----------------------------------------------------------------------------*/
411 
412 void
414  cs_mesh_quantities_t *mesh_quantities);
415 
416 /*----------------------------------------------------------------------------
417  * Return the number of times mesh quantities have been computed.
418  *
419  * returns:
420  * number of times mesh quantities have been computed
421  *----------------------------------------------------------------------------*/
422 
423 int
425 
426 /*----------------------------------------------------------------------------
427  * Dump a cs_mesh_quantities_t structure
428  *
429  * parameters:
430  * mesh <-- pointer to a cs_mesh_t structure
431  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
432  *----------------------------------------------------------------------------*/
433 
434 void
436  const cs_mesh_quantities_t *mesh_quantities);
437 
438 /*----------------------------------------------------------------------------
439  * Compute 3x3 matrix cocg for the scalar gradient least squares algorithm
440  * adapted for internal coupling.
441  *
442  * parameters:
443  * m <-- mesh
444  * fvq <-> mesh quantities
445  * ce <-> coupling
446  *----------------------------------------------------------------------------*/
447 
448 void
452 
453 /*----------------------------------------------------------------------------
454  * Compute 3x3 matrix cocg for the scalar gradient iterative algorithm
455  * adapted for internal coupling.
456  *
457  * parameters:
458  * m <-- mesh
459  * fvq <-> mesh quantities
460  * ce <-> coupling
461  *----------------------------------------------------------------------------*/
462 
463 void
467 
468 /*----------------------------------------------------------------------------*/
469 
471 
472 #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:3211
cs_real_33_t * cocgb_s_lsq
Definition: cs_mesh_quantities.h:130
void cs_mesh_quantities_reduce_extended(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:3263
void cs_mesh_quantities_dump(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:3292
cs_real_t * b_dist
Definition: cs_mesh_quantities.h:113
cs_real_t * corr_grad_lin_det
Definition: cs_mesh_quantities.h:138
cs_real_t * cell_f_vol
Definition: cs_mesh_quantities.h:86
cs_real_t * b_face_surf
Definition: cs_mesh_quantities.h:100
cs_real_t * djjpf
Definition: cs_mesh_quantities.h:109
cs_real_t min_f_vol
Definition: cs_mesh_quantities.h:122
cs_int_t * c_solid_flag
Definition: cs_mesh_quantities.h:142
Definition: cs_internal_coupling.h:59
cs_real_t max_f_vol
Definition: cs_mesh_quantities.h:123
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:296
void cs_compute_cell_cocg_it_coupling(const cs_mesh_t *m, cs_mesh_quantities_t *fvq, cs_internal_coupling_t *ce)
Definition: cs_mesh_quantities.c:3407
cs_real_33_t * corr_grad_lin
Definition: cs_mesh_quantities.h:139
void algcen(cs_int_t *const iopt)
Definition: cs_mesh_quantities.c:2340
cs_mesh_quantities_t * cs_mesh_quantities_destroy(cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2543
cs_real_t * diipf
Definition: cs_mesh_quantities.h:108
cs_real_t * dofij
Definition: cs_mesh_quantities.h:107
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:97
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
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:3033
cs_real_t max_vol
Definition: cs_mesh_quantities.h:119
unsigned * bad_cell_flag
Definition: cs_mesh_quantities.h:143
Definition: cs_mesh.h:63
cs_real_33_t * cocg_s_it
Definition: cs_mesh_quantities.h:128
cs_real_t * i_f_face_normal
Definition: cs_mesh_quantities.h:92
void cs_mesh_init_fluid_sections(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2958
cs_real_t tot_vol
Definition: cs_mesh_quantities.h:120
cs_real_t tot_f_vol
Definition: cs_mesh_quantities.h:124
void cs_mesh_quantities_set_cocg_options(int gradient_option)
Definition: cs_mesh_quantities.c:2425
cs_real_t * dijpf
Definition: cs_mesh_quantities.h:105
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:3119
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:84
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_t * i_dist
Definition: cs_mesh_quantities.h:111
cs_real_t * i_face_normal
Definition: cs_mesh_quantities.h:88
Definition: cs_mesh_quantities.h:82
void cs_mesh_quantities_cell_cen(const cs_mesh_t *mesh, cs_real_t *cell_cen[])
Definition: cs_mesh_quantities.c:3153
cs_real_33_t * cocgb_s_it
Definition: cs_mesh_quantities.h:126
int cs_glob_porous_model
cs_mesh_quantities_t * cs_mesh_quantities_create(void)
Definition: cs_mesh_quantities.c:2492
int cs_mesh_quantities_cell_cen_choice(const int algo_choice)
Definition: cs_mesh_quantities.c:2400
void comcoc(const cs_int_t *const imrgra)
Definition: cs_mesh_quantities.c:2360
unsigned cs_glob_mesh_quantities_flag
cs_real_t * b_f_face_surf
Definition: cs_mesh_quantities.h:103
cs_real_t * weight
Definition: cs_mesh_quantities.h:116
cs_real_t min_vol
Definition: cs_mesh_quantities.h:118
#define END_C_DECLS
Definition: cs_defs.h:454
cs_real_33_t * cocg_it
Definition: cs_mesh_quantities.h:133
cs_real_t * i_f_face_surf
Definition: cs_mesh_quantities.h:102
void cs_compute_cell_cocg_lsq_coupling(const cs_mesh_t *m, cs_mesh_quantities_t *fvq, cs_internal_coupling_t *ce)
Definition: cs_mesh_quantities.c:3389
#define CS_PROCF(x, y)
Definition: cs_defs.h:467
void cs_mesh_quantities_fluid_compute(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2944
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:315
cs_real_t * b_face_normal
Definition: cs_mesh_quantities.h:90
cs_real_t * diipb
Definition: cs_mesh_quantities.h:106
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:85
void cs_mesh_quantities_compute(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2597
void cs_mesh_quantities_sup_vectors(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2999
void compor(const cs_int_t *const iporos)
Definition: cs_mesh_quantities.c:2377
cs_real_t * i_face_surf
Definition: cs_mesh_quantities.h:99
int cs_mesh_quantities_compute_count(void)
Definition: cs_mesh_quantities.c:3278
cs_real_t * i_face_cog
Definition: cs_mesh_quantities.h:96
cs_int_t * b_sym_flag
Definition: cs_mesh_quantities.h:141
cs_real_33_t * cocg_lsq
Definition: cs_mesh_quantities.h:135
cs_real_t * b_f_face_normal
Definition: cs_mesh_quantities.h:94
void cs_mesh_quantities_set_porous_model(int porous_model)
Definition: cs_mesh_quantities.c:2479
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:3084