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_math.h"
36 #include "cs_mesh.h"
37 #include "cs_mesh_quantities.h"
38 #include "cs_cdo.h"
39 #include "cs_cdo_connect.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  CS_CDO_CCENTER_MEANV, // Center is computed as the mean of cell vertices
60  CS_CDO_CCENTER_BARYC, // Center is computed as the real cell barycenter
61  CS_CDO_CCENTER_SATURNE, // Center is given by Code_Saturne
62 
64 
66 
67 /* Structure storing information about variation of entities accros the
68  mesh for a given type of entity (cell, face and edge) */
69 typedef struct {
70 
71  /* Measure is either a volume for cells, a surface for faces or a length
72  for edges */
73  double meas_min; // Min. value of the entity measure
74  double meas_max; // Max. value of the entity measure
75  double h_min; // Estimation of the min. value of the diameter
76  double h_max; // Estimation of the max. value of the diameter
77 
79 
80 /* For primal vector quantities (edge or face) */
81 typedef struct {
82 
83  double meas; /* length or area */
84  double unitv[3]; /* unitary vector: tangent or normal to the element */
85  double center[3];
86 
87 } cs_quant_t;
88 
89 /* For dual face quantities. Add also a link to entity id related to this dual
90  quantities */
91 
92 typedef struct { /* TODO: remove what is the less necessary in order to
93  save memory comsumption */
94 
95  cs_lnum_t parent_id[2]; /* parent entity id of (primal) faces f0 and f1 */
96  cs_nvec3_t sface[2]; /* area and unit normal vector for each
97  triangle s(e,f,c) for f in {f0, f1} */
98  double vect[3]; /* dual face vector */
99 
100 } cs_dface_t;
101 
102 typedef struct { /* Specific mesh quantities */
103 
104  /* Global mesh quantities */
105  double vol_tot;
106 
107  /* Cell-based quantities */
108  cs_lnum_t n_cells; /* Local number of cells */
109  cs_gnum_t n_g_cells; /* Global number of cells */
114 
115  /* Face-based quantities */
118  cs_lnum_t n_faces; /* n_i_faces + n_b_faces */
119  cs_gnum_t n_g_faces; /* Global number of faces */
120  cs_quant_t *face; /* Face quantities */
121  cs_nvec3_t *dedge; /* Dual edge quantities (length and unit vector)
122  Scan with the c2f connectivity */
124 
125  /* Edge-based quantities */
126  cs_lnum_t n_edges; /* Local number of edges */
127  cs_gnum_t n_g_edges; /* Global number of edges */
128  cs_quant_t *edge; /* Edge quantities */
129  cs_dface_t *dface; /* For each edge belonging to a cell, two
130  contributions coming from 2 triangles
131  s(x_cell, x_face, x_edge) for face in Face_edge
132  are considered.
133  Scan with the c2e connectivity */
135 
136  /* Vertex-based quantities */
137  cs_lnum_t n_vertices; /* Local number of vertices */
138  cs_gnum_t n_g_vertices; /* Global number of vertices */
139  double *dcell_vol; /* Dual volume related to each vertex.
140  Scan with the c2v connectivity */
141  const cs_real_t *vtx_coord; /* Pointer to the one stored in cs_mesh_t */
142 
143 
145 
146 /*============================================================================
147  * Global variables
148  *============================================================================*/
149 
150 /*============================================================================
151  * Public function prototypes
152  *============================================================================*/
153 
154 /*----------------------------------------------------------------------------*/
164 /*----------------------------------------------------------------------------*/
165 
166 double
168  const cs_real_t *xb);
169 
170 /*----------------------------------------------------------------------------*/
181 /*----------------------------------------------------------------------------*/
182 
185  const cs_mesh_t *m,
186  const cs_mesh_quantities_t *mq,
187  const cs_cdo_connect_t *topo);
188 
189 /*----------------------------------------------------------------------------*/
197 /*----------------------------------------------------------------------------*/
198 
201 
202 /*----------------------------------------------------------------------------*/
209 /*----------------------------------------------------------------------------*/
210 
211 void
213 
214 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 void
225 
226 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
237 cs_quant_dump(FILE *f,
238  cs_lnum_t num,
239  const cs_quant_t q);
240 
241 /*----------------------------------------------------------------------------*/
242 
244 
245 #endif /* __CS_CDO_QUANTITIES_H__ */
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
cs_gnum_t n_g_cells
Definition: cs_cdo_quantities.h:109
Definition: cs_cdo_quantities.h:60
cs_real_t * cell_centers
Definition: cs_cdo_quantities.h:110
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:1167
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:1319
cs_quant_info_t edge_info
Definition: cs_cdo_quantities.h:134
double h_max
Definition: cs_cdo_quantities.h:76
double meas_min
Definition: cs_cdo_quantities.h:73
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
cs_lnum_t n_edges
Definition: cs_cdo_quantities.h:126
double meas
Definition: cs_cdo_quantities.h:83
Definition: cs_cdo_quantities.h:69
cs_dface_t * dface
Definition: cs_cdo_quantities.h:129
double h_min
Definition: cs_cdo_quantities.h:75
Definition: cs_cdo_connect.h:56
double vol_tot
Definition: cs_cdo_quantities.h:105
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:102
Definition: cs_cdo.h:129
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:921
cs_cdo_quantities_t * cs_cdo_quantities_build(cs_cdo_cell_center_algo_t cc_algo, 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:956
Definition: cs_mesh.h:63
cs_lnum_t n_faces
Definition: cs_cdo_quantities.h:118
Definition: cs_cdo_quantities.h:63
void cs_cdo_quantities_dump(const cs_cdo_quantities_t *cdoq)
Dump a cs_cdo_quantities_t structure.
Definition: cs_cdo_quantities.c:1254
Definition: cs_cdo_quantities.h:61
Definition: cs_mesh_quantities.h:52
cs_quant_t * face
Definition: cs_cdo_quantities.h:120
cs_quant_info_t face_info
Definition: cs_cdo_quantities.h:123
cs_lnum_t n_b_faces
Definition: cs_cdo_quantities.h:117
cs_gnum_t n_g_edges
Definition: cs_cdo_quantities.h:127
double meas_max
Definition: cs_cdo_quantities.h:74
double * dcell_vol
Definition: cs_cdo_quantities.h:139
void cs_cdo_quantities_summary(const cs_cdo_quantities_t *quant)
Summarize generic information about the cdo mesh quantities.
Definition: cs_cdo_quantities.c:1205
Definition: cs_cdo_quantities.h:92
cs_lnum_t n_vertices
Definition: cs_cdo_quantities.h:137
cs_gnum_t n_g_faces
Definition: cs_cdo_quantities.h:119
Definition: cs_cdo_quantities.h:81
cs_real_t * cell_vol
Definition: cs_cdo_quantities.h:111
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_lnum_t n_i_faces
Definition: cs_cdo_quantities.h:116
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_cdo_quantities.h:59
cs_lnum_t n_cells
Definition: cs_cdo_quantities.h:108
const cs_real_t * vtx_coord
Definition: cs_cdo_quantities.h:141
cs_flag_t * cell_flag
Definition: cs_cdo_quantities.h:113
cs_cdo_cell_center_algo_t
Definition: cs_cdo_quantities.h:57
cs_gnum_t n_g_vertices
Definition: cs_cdo_quantities.h:138
cs_quant_info_t cell_info
Definition: cs_cdo_quantities.h:112
cs_quant_t * edge
Definition: cs_cdo_quantities.h:128
cs_nvec3_t * dedge
Definition: cs_cdo_quantities.h:121