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-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  * 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  * Local Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definition
48  *============================================================================*/
49 
50 /* Structure associated to mesh quantities management */
51 
52 typedef struct {
53 
54  cs_real_t *cell_cen; /* Cell center coordinates */
55  cs_real_t *cell_vol; /* Cell volume */
56  cs_real_t *cell_f_vol; /* Cell fluid volume */
57 
58  cs_real_t *i_face_normal; /* Surface normal of interior faces.
59  (L2 norm equals area of the face) */
60  cs_real_t *b_face_normal; /* Surface normal of border faces.
61  (L2 norm equals area of the face) */
62  cs_real_t *i_f_face_normal;/* Fluid Surface normal of interior faces.
63  (L2 norm equals area of the face) */
64  cs_real_t *b_f_face_normal;/* Fluid Surface normal of border faces.
65  (L2 norm equals area of the face) */
66  cs_real_t *i_face_cog; /* Center of gravity of interior faces */
67  cs_real_t *b_face_cog; /* Center of gravity of border faces */
68 
69  cs_real_t *i_face_surf; /* Surface of interior faces. */
70  cs_real_t *b_face_surf; /* Surface of boundary faces. */
71 
72  cs_real_t *i_f_face_surf; /* Fluid surface of interior faces. */
73  cs_real_t *b_f_face_surf; /* Fluid surface of boundary faces. */
74 
75  cs_real_t *dijpf; /* Vector I'J' for interior faces */
76  cs_real_t *diipb; /* Vector II' for border faces */
77  cs_real_t *dofij; /* Vector OF for interior faces */
78  cs_real_t *diipf; /* Vector II' for interior faces */
79  cs_real_t *djjpf; /* Vector JJ' for interior faces */
80 
81  cs_real_t *i_dist; /* Distance between the cell center and
82  the center of gravity of interior faces */
83  cs_real_t *b_dist; /* Distance between the cell center and
84  the center of gravity of border faces */
85 
86  cs_real_t *weight; /* Interior faces weighting factor */
87 
88  cs_real_t min_vol; /* Minimum cell volume */
89  cs_real_t max_vol; /* Maximum cell volume */
90  cs_real_t tot_vol; /* Total volume */
91 
92  cs_real_33_t *cocgb_s_it; /* coupling of gradient components for
93  iterative reconstruction at boundary */
94  cs_real_33_t *cocg_s_it; /* coupling of gradient components for
95  iterative reconstruction */
96  cs_real_33_t *cocgb_s_lsq; /* coupling of gradient components for
97  least-square reconstruction at boundary */
98 
99  cs_real_33_t *cocg_it; /* Interleaved cocg matrix
100  for iterative gradients */
101  cs_real_33_t *cocg_lsq; /* Interleaved cocg matrix
102  for least square gradients */
103 
104  cs_int_t *b_sym_flag; /* Symmetry flag for boundary faces */
105  cs_int_t *c_solid_flag; /* Is the fluid volume 0 flag */
106  unsigned *bad_cell_flag; /* Flag (mask) for bad cells detected */
107 
109 
110 /*============================================================================
111  * Static global variables
112  *============================================================================*/
113 
114 /* Pointer to mesh quantities structure associated to the main mesh */
115 
117 
118 /* Choice of the porous model */
119 extern int cs_glob_porous_model;
120 
121 /*============================================================================
122  * Public function prototypes for API Fortran
123  *============================================================================*/
124 
125 /*----------------------------------------------------------------------------
126  * Query or modification of the option for computing cell centers.
127  *
128  * This function returns 1 or 2 according to the selected algorithm.
129  *
130  * Fortran interface :
131  *
132  * SUBROUTINE ALGCEN (IOPT)
133  * *****************
134  *
135  * INTEGER IOPT : <-> : Choice of the algorithm
136  * < 0 : query
137  * 0 : computation based
138  * on faces (default choice)
139  * 1 : computation based
140  * on vertices
141  *----------------------------------------------------------------------------*/
142 
143 void
144 CS_PROCF (algcen, ALGCEN) (cs_int_t *const iopt);
145 
146 /*----------------------------------------------------------------------------
147  * Set behavior for computing the cocg matrixes for the iterative algo
148  * and for the Least square method for scalar and vector gradients.
149  *
150  * Fortran interface :
151  *
152  * subroutine comcoc (imrgra)
153  * *****************
154  *
155  * integer imrgra : <-- : gradient reconstruction option
156  *----------------------------------------------------------------------------*/
157 
158 void
159 CS_PROCF (comcoc, COMCOC) (const cs_int_t *const imrgra);
160 
161 /*----------------------------------------------------------------------------
162  * Set porous model
163  *
164  * Fortran interface :
165  *
166  * subroutine compor (iporos)
167  * *****************
168  *
169  * integer iporos : <-- : porous model
170  *----------------------------------------------------------------------------*/
171 
172 void
173 CS_PROCF (compor, COMPOR) (const cs_int_t *const iporos);
174 
175 /*=============================================================================
176  * Public function prototypes
177  *============================================================================*/
178 
179 /*----------------------------------------------------------------------------
180  * Query or modification of the option for computing cell centers.
181  *
182  * < 0 : query
183  * 0 : computation based on faces (default choice)
184  * 1 : computation based on vertices
185  *
186  * algo_choice <-- choice of algorithm to compute cell centers.
187  *
188  * returns:
189  * 1 or 2 according to the selected algorithm.
190  *----------------------------------------------------------------------------*/
191 
192 int
193 cs_mesh_quantities_cell_cen_choice(const int algo_choice);
194 
195 /*----------------------------------------------------------------------------
196  * Compute cocg for iterative gradient reconstruction for scalars.
197  *
198  * parameters:
199  * gradient_option <-- gradient option (Fortran IMRGRA)
200  *----------------------------------------------------------------------------*/
201 
202 void
203 cs_mesh_quantities_set_cocg_options(int gradient_option);
204 
205 /*----------------------------------------------------------------------------
206  * Compute Fluid volumes and fluid surface in addition to cell volume and surfaces.
207  *
208  * parameters:
209  * porous_model <-- gradient option (Fortran iporos)
210  *----------------------------------------------------------------------------*/
211 
212 void
213 cs_mesh_quantities_set_porous_model(int porous_model);
214 
215 /*----------------------------------------------------------------------------
216  * Create a mesh quantities structure.
217  *
218  * returns:
219  * pointer to created cs_mesh_quantities_t structure
220  *----------------------------------------------------------------------------*/
221 
224 
225 /*----------------------------------------------------------------------------
226  * Destroy a mesh quantities structure
227  *
228  * parameters:
229  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
230  *
231  * returns:
232  * NULL
233  *----------------------------------------------------------------------------*/
234 
237 
238 /*----------------------------------------------------------------------------
239  * Compute mesh quantities
240  *
241  * parameters:
242  * mesh <-- pointer to a cs_mesh_t structure
243  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
244  *----------------------------------------------------------------------------*/
245 
246 void
248  cs_mesh_quantities_t *mesh_quantities);
249 
250 /*----------------------------------------------------------------------------
251  * Compute fluid section mesh quantities at the initial step
252  *
253  * parameters:
254  * mesh <-- pointer to a cs_mesh_t structure
255  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
256  *----------------------------------------------------------------------------*/
257 
258 void
260  cs_mesh_quantities_t *mesh_quantities);
261 
262 /*----------------------------------------------------------------------------
263  * Compute mesh quantities
264  *
265  * parameters:
266  * mesh <-- pointer to a cs_mesh_t structure
267  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
268  *----------------------------------------------------------------------------*/
269 
270 void
272  cs_mesh_quantities_t *mesh_quantities);
273 
274 /*----------------------------------------------------------------------------
275  * Compute internal and border face normal.
276  *
277  * parameters:
278  * mesh <-- pointer to a cs_mesh_t structure
279  * p_i_face_normal <-> pointer to the internal face normal array
280  * p_b_face_normal <-> pointer to the border face normal array
281  *----------------------------------------------------------------------------*/
282 
283 void
285  cs_real_t *p_i_face_normal[],
286  cs_real_t *p_b_face_normal[]);
287 
288 /*----------------------------------------------------------------------------
289  * Compute interior face centers and normals.
290  *
291  * The corresponding arrays are allocated by this function, and it is the
292  * caller's responsibility to free them when they are no longer needed.
293  *
294  * parameters:
295  * mesh <-- pointer to a cs_mesh_t structure
296  * p_i_face_cog <-> pointer to the interior face center array
297  * p_i_face_normal <-> pointer to the interior face normal array
298  *----------------------------------------------------------------------------*/
299 
300 void
302  cs_real_t *p_i_face_cog[],
303  cs_real_t *p_i_face_normal[]);
304 
305 /*----------------------------------------------------------------------------
306  * Compute border face centers and normals.
307  *
308  * The corresponding arrays are allocated by this function, and it is the
309  * caller's responsibility to free them when they are no longer needed.
310  *
311  * parameters:
312  * mesh <-- pointer to a cs_mesh_t structure
313  * p_b_face_cog <-> pointer to the border face center array
314  * p_b_face_normal <-> pointer to the border face normal array
315  *----------------------------------------------------------------------------*/
316 
317 void
319  cs_real_t *p_b_face_cog[],
320  cs_real_t *p_b_face_normal[]);
321 
322 /*----------------------------------------------------------------------------
323  * Compute cell centers.
324  *
325  * The corresponding array is allocated by this function, and it is the
326  * caller's responsibility to free it when they are no longer needed.
327  *
328  * parameters:
329  * mesh <-- pointer to a cs_mesh_t structure
330  * p_cell_cen <-> pointer to the cell centers array
331  *----------------------------------------------------------------------------*/
332 
333 void
335  cs_real_t *cell_cen[]);
336 
337 /*----------------------------------------------------------------------------
338  * Check that no negative volumes are present, and exit on error otherwise.
339  *
340  * parameters:
341  * mesh <-- pointer to mesh structure
342  * mesh_quantities <-- pointer to mesh quantities structure
343  * allow_error <-- 1 if errors are allowed, 0 otherwise
344  *----------------------------------------------------------------------------*/
345 
346 void
348  const cs_mesh_quantities_t *mesh_quantities,
349  int allow_error);
350 
351 /*----------------------------------------------------------------------------
352  * Update mesh quantities relative to extended ghost cells when the
353  * neighborhood is reduced.
354  *
355  * parameters:
356  * mesh <-- pointer to a cs_mesh_t structure
357  * mesh_quantities <-> pointer to a cs_mesh_quantities_t structure
358  *----------------------------------------------------------------------------*/
359 
360 void
362  cs_mesh_quantities_t *mesh_quantities);
363 
364 /*----------------------------------------------------------------------------
365  * Return the number of times mesh quantities have been computed.
366  *
367  * returns:
368  * number of times mesh quantities have been computed
369  *----------------------------------------------------------------------------*/
370 
371 int
373 
374 /*----------------------------------------------------------------------------
375  * Dump a cs_mesh_quantities_t structure
376  *
377  * parameters:
378  * mesh <-- pointer to a cs_mesh_t structure
379  * mesh_quantities <-- pointer to a cs_mesh_quantities_t structure
380  *----------------------------------------------------------------------------*/
381 
382 void
384  const cs_mesh_quantities_t *mesh_quantities);
385 
386 /*----------------------------------------------------------------------------
387  * Compute 3x3 matrix cocg for the scalar gradient least squares algorithm
388  * adapted for internal coupling.
389  *
390  * parameters:
391  * m <-- mesh
392  * fvq <-> mesh quantities
393  * ce <-> coupling
394  *----------------------------------------------------------------------------*/
395 
396 void
400 
401 /*----------------------------------------------------------------------------
402  * Compute 3x3 matrix cocg for the scalar gradient iterative algorithm
403  * adapted for internal coupling.
404  *
405  * parameters:
406  * m <-- mesh
407  * fvq <-> mesh quantities
408  * ce <-> coupling
409  *----------------------------------------------------------------------------*/
410 
411 void
415 
416 /*----------------------------------------------------------------------------*/
417 
419 
420 #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:2611
cs_real_33_t * cocgb_s_lsq
Definition: cs_mesh_quantities.h:96
void cs_mesh_quantities_reduce_extended(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2663
void cs_mesh_quantities_dump(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2692
cs_real_t * b_dist
Definition: cs_mesh_quantities.h:83
integer, save iporos
Definition: optcal.f90:1135
cs_real_t * cell_f_vol
Definition: cs_mesh_quantities.h:56
cs_real_t * b_face_surf
Definition: cs_mesh_quantities.h:70
cs_real_t * djjpf
Definition: cs_mesh_quantities.h:79
cs_int_t * c_solid_flag
Definition: cs_mesh_quantities.h:105
Definition: cs_internal_coupling.h:59
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
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:2807
void algcen(cs_int_t *const iopt)
Definition: cs_mesh_quantities.c:1813
cs_mesh_quantities_t * cs_mesh_quantities_destroy(cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2014
cs_real_t * diipf
Definition: cs_mesh_quantities.h:78
cs_real_t * dofij
Definition: cs_mesh_quantities.h:77
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:67
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:2433
cs_real_t max_vol
Definition: cs_mesh_quantities.h:89
unsigned * bad_cell_flag
Definition: cs_mesh_quantities.h:106
Definition: cs_mesh.h:63
cs_real_33_t * cocg_s_it
Definition: cs_mesh_quantities.h:94
cs_real_t * i_f_face_normal
Definition: cs_mesh_quantities.h:62
void cs_mesh_init_fluid_sections(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2359
cs_real_t tot_vol
Definition: cs_mesh_quantities.h:90
void cs_mesh_quantities_set_cocg_options(int gradient_option)
Definition: cs_mesh_quantities.c:1898
cs_real_t * dijpf
Definition: cs_mesh_quantities.h:75
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:2519
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:54
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_t * i_dist
Definition: cs_mesh_quantities.h:81
cs_real_t * i_face_normal
Definition: cs_mesh_quantities.h:58
Definition: cs_mesh_quantities.h:52
void cs_mesh_quantities_cell_cen(const cs_mesh_t *mesh, cs_real_t *cell_cen[])
Definition: cs_mesh_quantities.c:2553
cs_real_33_t * cocgb_s_it
Definition: cs_mesh_quantities.h:92
int cs_glob_porous_model
cs_mesh_quantities_t * cs_mesh_quantities_create(void)
Definition: cs_mesh_quantities.c:1965
int cs_mesh_quantities_cell_cen_choice(const int algo_choice)
Definition: cs_mesh_quantities.c:1873
void comcoc(const cs_int_t *const imrgra)
Definition: cs_mesh_quantities.c:1833
cs_real_t * b_f_face_surf
Definition: cs_mesh_quantities.h:73
cs_real_t * weight
Definition: cs_mesh_quantities.h:86
cs_real_t min_vol
Definition: cs_mesh_quantities.h:88
#define END_C_DECLS
Definition: cs_defs.h:452
cs_real_33_t * cocg_it
Definition: cs_mesh_quantities.h:99
cs_real_t * i_f_face_surf
Definition: cs_mesh_quantities.h:72
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:2789
#define CS_PROCF(x, y)
Definition: cs_defs.h:465
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:60
cs_real_t * diipb
Definition: cs_mesh_quantities.h:76
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:55
void cs_mesh_quantities_compute(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2066
void cs_mesh_quantities_sup_vectors(const cs_mesh_t *mesh, cs_mesh_quantities_t *mesh_quantities)
Definition: cs_mesh_quantities.c:2400
void compor(const cs_int_t *const iporos)
Definition: cs_mesh_quantities.c:1850
cs_real_t * i_face_surf
Definition: cs_mesh_quantities.h:69
int cs_mesh_quantities_compute_count(void)
Definition: cs_mesh_quantities.c:2678
cs_real_t * i_face_cog
Definition: cs_mesh_quantities.h:66
cs_int_t * b_sym_flag
Definition: cs_mesh_quantities.h:104
Definition: mesh.f90:26
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:353
cs_real_33_t * cocg_lsq
Definition: cs_mesh_quantities.h:101
cs_real_t * b_f_face_normal
Definition: cs_mesh_quantities.h:64
void cs_mesh_quantities_set_porous_model(int porous_model)
Definition: cs_mesh_quantities.c:1952
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:2484