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-2016 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_mesh_quantities.h"
37 #include "cs_cdo.h"
38 #include "cs_cdo_connect.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /* Type of algorithm to compute geometrical quantities */
53 typedef enum {
54 
55  CS_CDO_CC_MEANV, // Cell center is computed as the mean of cell vertices
56  CS_CDO_CC_BARYC, // Cell center is computed as the real cell barycenter
57  CS_CDO_CC_SATURNE, // Cell center is given by Code_Saturne
58  CS_CDO_CC_ORTHO, /* Cell center is optimized to enforce orthogonality
59  between cell-face edge and face plane */
61 
63 
64 /* Structure storing information about variation of entities accros the
65  mesh for a given type of entity (cell, face and edge) */
66 typedef struct {
67 
68  double meas_min; // Min. value of the entity measure (vol, surf or lenght)
69  double meas_max; // Max. value of the entity measure (vol, surf or lenght)
70  double h_min; // Estimation of the min. value of the diameter
71  double h_max; // Estimation of the max. value of the diameter
72 
73  cs_lnum_t min_id; // Entity if related to the min. value
74  cs_lnum_t max_id; // Entity if related to the max. value
75 
77 
78 /* For primal vector quantities (edge or face) */
79 typedef struct {
80 
81  double meas; /* length or area */
82  double unitv[3]; /* unitary vector: tangent or normal to the element */
83  double center[3];
84 
85 } cs_quant_t;
86 
87 /* For dual face quantities. Add also a link to entity id related to this dual
88  quantities */
89 
90 typedef struct { /* TODO: remove what is the less necessary in order to
91  save memory comsumption */
92 
93  cs_lnum_t parent_id[2]; /* parent entity id of (primal) faces f0 and f1 */
94  cs_nvec3_t sface[2]; /* area and unit normal vector for each
95  triangle s(e,f,c) for f in {f0, f1} */
96  double vect[3]; /* dual face vector */
97 
98 } cs_dface_t;
99 
100 typedef struct { /* Specific mesh quantities */
101 
102  /* Global mesh quantities */
103  double vol_tot;
104 
105  /* Cell-based quantities */
110 
111  /* Face-based quantities */
114  cs_lnum_t n_faces; /* n_i_faces + n_b_faces */
115  cs_quant_t *face; /* Face quantities */
116  cs_nvec3_t *dedge; /* Dual edge quantities (length and unit vector)
117  Scan with the c2f connectivity */
119 
120  /* Edge-based quantities */
122  cs_quant_t *edge; /* Edge quantities */
123  cs_dface_t *dface; /* For each edge belonging to a cell, two
124  contributions coming from 2 triangles
125  s(x_cell, x_face, x_edge) for face in Face_edge
126  are considered.
127  Scan with the c2e connectivity */
129 
130  /* Vertex-based quantities */
132  double *dcell_vol; /* Dual volume related to each vertex.
133  Scan with the c2v connectivity */
134  const cs_real_t *vtx_coord; /* Pointer to the one stored in cs_mesh_t */
135 
136 
138 
139 /*============================================================================
140  * Global variables
141  *============================================================================*/
142 
143 /*============================================================================
144  * Public function prototypes
145  *============================================================================*/
146 
147 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 
161  const cs_mesh_quantities_t *mq,
162  const cs_cdo_connect_t *topo);
163 
164 /*----------------------------------------------------------------------------*/
172 /*----------------------------------------------------------------------------*/
173 
176 
177 /*----------------------------------------------------------------------------*/
184 /*----------------------------------------------------------------------------*/
185 
186 void
188 
189 /*----------------------------------------------------------------------------*/
196 /*----------------------------------------------------------------------------*/
197 
198 void
200 
201 /*----------------------------------------------------------------------------*/
209 /*----------------------------------------------------------------------------*/
210 
211 void
212 cs_quant_dump(FILE *f,
213  cs_lnum_t num,
214  const cs_quant_t q);
215 
216 /*----------------------------------------------------------------------------*/
227 /*----------------------------------------------------------------------------*/
228 
229 void
231  const cs_cdo_quantities_t *quant,
232  double *p_pvol[]);
233 
234 /*----------------------------------------------------------------------------*/
243 /*----------------------------------------------------------------------------*/
244 
245 void
247  const cs_cdo_quantities_t *quant,
248  double *p_pvol[]);
249 
250 /*----------------------------------------------------------------------------*/
259 /*----------------------------------------------------------------------------*/
260 
261 void
263  const cs_cdo_quantities_t *quant,
264  double *p_pvol[]);
265 
266 /*----------------------------------------------------------------------------*/
267 
269 
270 #endif /* __CS_CDO_QUANTITIES_H__ */
Definition: cs_cdo_quantities.h:55
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:870
cs_real_t * cell_centers
Definition: cs_cdo_quantities.h:107
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:1001
Definition: cs_cdo_quantities.h:58
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:1112
cs_quant_info_t edge_info
Definition: cs_cdo_quantities.h:128
void cs_compute_pvol_vtx(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, double *p_pvol[])
Compute for each vertex the dual cell volume which is also.
Definition: cs_cdo_quantities.c:1140
double h_max
Definition: cs_cdo_quantities.h:71
double meas_min
Definition: cs_cdo_quantities.h:68
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
cs_cdo_cc_algo_t
Definition: cs_cdo_quantities.h:53
cs_lnum_t n_edges
Definition: cs_cdo_quantities.h:121
double meas
Definition: cs_cdo_quantities.h:81
Definition: cs_cdo_quantities.h:66
cs_dface_t * dface
Definition: cs_cdo_quantities.h:123
double h_min
Definition: cs_cdo_quantities.h:70
Definition: cs_cdo_connect.h:67
double vol_tot
Definition: cs_cdo_quantities.h:103
Definition: cs_cdo_quantities.h:56
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_cdo_quantities.h:100
Definition: cs_cdo.h:121
Definition: cs_mesh.h:62
cs_lnum_t n_faces
Definition: cs_cdo_quantities.h:114
Definition: cs_cdo_quantities.h:60
void cs_cdo_quantities_dump(const cs_cdo_quantities_t *cdoq)
Dump a cs_cdo_quantities_t structure.
Definition: cs_cdo_quantities.c:1057
Definition: cs_mesh_quantities.h:51
cs_lnum_t min_id
Definition: cs_cdo_quantities.h:73
cs_quant_t * face
Definition: cs_cdo_quantities.h:115
cs_quant_info_t face_info
Definition: cs_cdo_quantities.h:118
cs_lnum_t n_b_faces
Definition: cs_cdo_quantities.h:113
double meas_max
Definition: cs_cdo_quantities.h:69
double * dcell_vol
Definition: cs_cdo_quantities.h:132
void cs_cdo_quantities_summary(const cs_cdo_quantities_t *quant)
Summarize generic information about the cdo mesh quantities.
Definition: cs_cdo_quantities.c:1034
Definition: cs_cdo_quantities.h:90
cs_lnum_t n_vertices
Definition: cs_cdo_quantities.h:131
Definition: cs_cdo_quantities.h:79
cs_real_t * cell_vol
Definition: cs_cdo_quantities.h:108
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
Definition: cs_cdo_quantities.h:57
void cs_compute_pvol_face(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, double *p_pvol[])
Compute for each face a related volume pvol_f which constitutes a partition of unity.
Definition: cs_cdo_quantities.c:1223
cs_lnum_t n_i_faces
Definition: cs_cdo_quantities.h:112
#define END_C_DECLS
Definition: cs_defs.h:449
cs_lnum_t n_cells
Definition: cs_cdo_quantities.h:106
const cs_real_t * vtx_coord
Definition: cs_cdo_quantities.h:134
void cs_compute_pvol_edge(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, double *p_pvol[])
Compute for each edge a related volume pvol_e which constitutes a partition of unity.
Definition: cs_cdo_quantities.c:1177
cs_lnum_t max_id
Definition: cs_cdo_quantities.h:74
cs_quant_info_t cell_info
Definition: cs_cdo_quantities.h:109
cs_quant_t * edge
Definition: cs_cdo_quantities.h:122
cs_nvec3_t * dedge
Definition: cs_cdo_quantities.h:116