programmer's documentation
cs_cdo_quantities.h
Go to the documentation of this file.
1 #ifndef __CS_CDO_QUANTITIES_H__
2 #define __CS_CDO_QUANTITIES_H__
3 
4 /*============================================================================
5  * Manage geometrical quantities needed in CDO schemes
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_cdo_connect.h"
36 #include "cs_flag.h"
37 #include "cs_math.h"
38 #include "cs_mesh.h"
39 #include "cs_mesh_quantities.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /* Information useful to get simpler algo. */
50 #define CS_CDO_ORTHO (1 << 0) // Orthogonality condition is checked
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 /* Type of algorithm used to compute the cell center */
57 typedef enum {
58 
59  /* Center is computed as the mean of cell vertices */
61 
62  /* Center is computed as the real cell barycenter */
64 
65  /* Use the cell center computed in cs_mesh_quantities.c (Default behavior) */
67 
69 
71 
72 /* Structure storing information about variation of entities accros the
73  mesh for a given type of entity (cell, face and edge) */
74 typedef struct {
75 
76  /* Measure is either a volume for cells, a surface for faces or a length
77  for edges */
78  double meas_min; // Min. value of the entity measure
79  double meas_max; // Max. value of the entity measure
80  double h_min; // Estimation of the min. value of the diameter
81  double h_max; // Estimation of the max. value of the diameter
82 
84 
85 /* For primal vector quantities (edge or face) */
86 typedef struct {
87 
88  double meas; /* length or area */
89  double unitv[3]; /* unitary vector: tangent or normal to the element */
90  double center[3];
91 
92 } cs_quant_t;
93 
94 typedef struct { /* Specific mesh quantities */
95 
96  /* Global mesh quantities */
97  double vol_tot;
98 
99  /* Cell-based quantities */
100  /* ===================== */
101 
102  cs_lnum_t n_cells; /* Local number of cells */
103  cs_gnum_t n_g_cells; /* Global number of cells */
106  cs_flag_t *cell_flag; /* Flag attached to cell to associate
107  metadata like boundary cell or
108  orthogonality */
109 
111 
112  /* Face-based quantities */
113  /* ===================== */
114 
115  cs_lnum_t n_i_faces; // Local number of interior faces
116  const cs_real_t *i_face_normal; // Shared with cs_mesh_quantities_t
117  const cs_real_t *i_face_center; // Shared with cs_mesh_quantities_t
118  const cs_real_t *i_face_surf; // Shared with cs_mesh_quantities_t
119 
120  cs_lnum_t n_b_faces; // Local number of border faces
121  const cs_real_t *b_face_normal; // Shared with cs_mesh_quantities_t
122  const cs_real_t *b_face_center; // Shared with cs_mesh_quantities_t
123  const cs_real_t *b_face_surf; // Shared with cs_mesh_quantities_t
124 
125  cs_lnum_t n_faces; /* n_i_faces + n_b_faces */
126  cs_gnum_t n_g_faces; /* Global number of faces */
127 
128  /* cs_quant_t structure attached to a face (interior or border) is build
129  on-the-fly cs_quant_get(flag, f_id, quant) */
130 
132 
133  /* cs_nvec3_t structure attached to a dual edge is build on-the-fly
134  Dual edge quantities (length and unit vector)
135  Scan with the c2f connectivity
136  */
137 
139 
140  /* Edge-based quantities */
141  /* ===================== */
142 
143  cs_lnum_t n_edges; /* Local number of edges */
144  cs_gnum_t n_g_edges; /* Global number of edges */
145 
146  cs_real_t *edge_vector; /* norm of the vector is equal to the
147  distance between two vertices.
148  unit vector is the tangential direction
149  attached to the edge */
150 
151  /* For each edge belonging to a cell, two contributions coming from 2
152  triangles s(x_cell, x_face, x_edge) for face in Face_edge are considered.
153  Scan with the c2e connectivity */
154 
155  cs_real_t *sface_normal; /* 2 triangle-face normals by edge in a
156  cell */
157 
159 
160  /* Vertex-based quantities */
161  /* ======================= */
162 
163  cs_lnum_t n_vertices; /* Local number of vertices */
164  cs_gnum_t n_g_vertices; /* Global number of vertices */
165 
166  cs_real_t *dcell_vol; /* Dual volume related to each vertex.
167  Scan with the c2v connectivity */
168  const cs_real_t *vtx_coord; /* Shared with the cs_mesh_t structure */
169 
171 
172 /*============================================================================
173  * Global variables
174  *============================================================================*/
175 
176 /*============================================================================
177  * Public function prototypes
178  *============================================================================*/
179 
180 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 double
194  const cs_real_t *xb);
195 
196 /*----------------------------------------------------------------------------*/
202 /*----------------------------------------------------------------------------*/
203 
204 void
206 
207 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 
221  const cs_mesh_quantities_t *mq,
222  const cs_cdo_connect_t *topo);
223 
224 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
236 
237 /*----------------------------------------------------------------------------*/
244 /*----------------------------------------------------------------------------*/
245 
246 void
248 
249 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 void
260 
261 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
274  const cs_cdo_quantities_t *cdoq);
275 
276 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 inline static const cs_real_t *
289  const cs_cdo_quantities_t *cdoq)
290 {
291  const cs_lnum_t bf_id = f_id - cdoq->n_i_faces;
292  if (bf_id > -1) // Border face
293  return cdoq->b_face_center + 3*bf_id;
294  else // Interior face
295  return cdoq->i_face_center + 3*f_id;
296 }
297 
298 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
312  const cs_cdo_quantities_t *cdoq);
313 
314 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
327  const cs_cdo_quantities_t *cdoq);
328 
329 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
342  const cs_cdo_quantities_t *cdoq);
343 
344 /*----------------------------------------------------------------------------*/
352 /*----------------------------------------------------------------------------*/
353 
354 void
355 cs_quant_dump(FILE *f,
356  cs_lnum_t num,
357  const cs_quant_t q);
358 
359 /*----------------------------------------------------------------------------*/
360 
362 
363 #endif /* __CS_CDO_QUANTITIES_H__ */
const cs_real_t * b_face_center
Definition: cs_cdo_quantities.h:122
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
cs_real_t * dedge_vector
Definition: cs_cdo_quantities.h:131
cs_gnum_t n_g_cells
Definition: cs_cdo_quantities.h:103
Definition: cs_cdo_quantities.h:63
cs_cdo_quantities_t * cs_cdo_quantities_build(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, const cs_cdo_connect_t *topo)
Build a cs_cdo_quantities_t structure.
Definition: cs_cdo_quantities.c:919
Definition: cs_cdo_quantities.h:66
cs_real_t * cell_centers
Definition: cs_cdo_quantities.h:104
cs_cdo_quantities_t * cs_cdo_quantities_free(cs_cdo_quantities_t *q)
Destroy a cs_cdo_quantities_t structure.
Definition: cs_cdo_quantities.c:1132
const cs_real_t * i_face_normal
Definition: cs_cdo_quantities.h:116
void cs_quant_dump(FILE *f, cs_lnum_t num, const cs_quant_t q)
Dump a cs_quant_t structure.
Definition: cs_cdo_quantities.c:1414
cs_quant_info_t edge_info
Definition: cs_cdo_quantities.h:158
cs_real_t * dcell_vol
Definition: cs_cdo_quantities.h:166
void cs_cdo_quantities_set_algo_ccenter(cs_cdo_quantities_algo_ccenter_t algo)
Set the type of algorithm to use for computing the cell center.
Definition: cs_cdo_quantities.c:901
double h_max
Definition: cs_cdo_quantities.h:81
double meas_min
Definition: cs_cdo_quantities.h:78
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
static const cs_real_t * cs_quant_set_face_center(cs_lnum_t f_id, const cs_cdo_quantities_t *cdoq)
Retrieve the face center for a primal face (interior or border)
Definition: cs_cdo_quantities.h:288
cs_lnum_t n_edges
Definition: cs_cdo_quantities.h:143
double meas
Definition: cs_cdo_quantities.h:88
Definition: cs_cdo_quantities.h:74
Definition: cs_cdo_quantities.h:68
double h_min
Definition: cs_cdo_quantities.h:80
Definition: cs_cdo_connect.h:69
double vol_tot
Definition: cs_cdo_quantities.h:97
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:94
Definition: cs_defs.h:337
double cs_compute_area_from_quant(const cs_quant_t qa, const cs_real_t *xb)
Compute the area of the triangle of base given by q (related to a segment) with apex located at xa...
Definition: cs_cdo_quantities.c:871
Definition: cs_mesh.h:63
cs_lnum_t n_faces
Definition: cs_cdo_quantities.h:125
cs_real_t * edge_vector
Definition: cs_cdo_quantities.h:146
const cs_real_t * i_face_surf
Definition: cs_cdo_quantities.h:118
cs_nvec3_t cs_quant_set_dedge_nvec(cs_lnum_t f_shift, const cs_cdo_quantities_t *cdoq)
Get the two normalized vector associated to a dual edge.
Definition: cs_cdo_quantities.c:1394
void cs_cdo_quantities_dump(const cs_cdo_quantities_t *cdoq)
Dump a cs_cdo_quantities_t structure.
Definition: cs_cdo_quantities.c:1217
Definition: cs_mesh_quantities.h:85
cs_quant_info_t face_info
Definition: cs_cdo_quantities.h:138
cs_lnum_t n_b_faces
Definition: cs_cdo_quantities.h:120
cs_gnum_t n_g_edges
Definition: cs_cdo_quantities.h:144
double meas_max
Definition: cs_cdo_quantities.h:79
void cs_cdo_quantities_summary(const cs_cdo_quantities_t *quant)
Summarize generic information about the cdo mesh quantities.
Definition: cs_cdo_quantities.c:1168
const cs_real_t * i_face_center
Definition: cs_cdo_quantities.h:117
cs_lnum_t n_vertices
Definition: cs_cdo_quantities.h:163
cs_gnum_t n_g_faces
Definition: cs_cdo_quantities.h:126
Definition: cs_cdo_quantities.h:86
cs_real_t * cell_vol
Definition: cs_cdo_quantities.h:105
Definition: cs_cdo_quantities.h:60
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
const cs_real_t * b_face_normal
Definition: cs_cdo_quantities.h:121
cs_cdo_quantities_algo_ccenter_t
Definition: cs_cdo_quantities.h:57
cs_lnum_t n_i_faces
Definition: cs_cdo_quantities.h:115
const cs_real_t * b_face_surf
Definition: cs_cdo_quantities.h:123
#define END_C_DECLS
Definition: cs_defs.h:462
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_lnum_t n_cells
Definition: cs_cdo_quantities.h:102
cs_quant_t cs_quant_set_face(cs_lnum_t f_id, const cs_cdo_quantities_t *cdoq)
Define a cs_quant_t structure for a primal face (interior or border)
Definition: cs_cdo_quantities.c:1296
const cs_real_t * vtx_coord
Definition: cs_cdo_quantities.h:168
cs_nvec3_t cs_quant_set_edge_nvec(cs_lnum_t e_id, const cs_cdo_quantities_t *cdoq)
Get the two normalized vector associated to a primal edge.
Definition: cs_cdo_quantities.c:1373
cs_flag_t * cell_flag
Definition: cs_cdo_quantities.h:106
cs_real_t * sface_normal
Definition: cs_cdo_quantities.h:155
cs_nvec3_t cs_quant_set_face_nvec(cs_lnum_t f_id, const cs_cdo_quantities_t *cdoq)
Retrieve the face surface and its unit normal vector for a primal face (interior or border) ...
Definition: cs_cdo_quantities.c:1348
cs_gnum_t n_g_vertices
Definition: cs_cdo_quantities.h:164
cs_quant_info_t cell_info
Definition: cs_cdo_quantities.h:110