programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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-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_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 typedef struct { /* Specific mesh quantities */
90 
91  /* Global mesh quantities */
92  double vol_tot;
93 
94  /* Cell-based quantities */
95  /* ===================== */
96 
97  cs_lnum_t n_cells; /* Local number of cells */
98  cs_gnum_t n_g_cells; /* Global number of cells */
101 
102  /* Type of algorithm used to define the cell center */
104 
105  cs_flag_t *cell_flag; /* Flag attached to cell to associate
106  metadata like boundary cell or
107  orthogonality */
108 
110 
111  /* Face-based quantities */
112  /* ===================== */
113 
114  cs_lnum_t n_i_faces; // Local number of interior faces
115  const cs_real_t *i_face_normal; // Shared with cs_mesh_quantities_t
116  const cs_real_t *i_face_center; // Shared with cs_mesh_quantities_t
117  const cs_real_t *i_face_surf; // Shared with cs_mesh_quantities_t
118 
119  cs_lnum_t n_b_faces; // Local number of border faces
120  const cs_real_t *b_face_normal; // Shared with cs_mesh_quantities_t
121  const cs_real_t *b_face_center; // Shared with cs_mesh_quantities_t
122  const cs_real_t *b_face_surf; // Shared with cs_mesh_quantities_t
123 
124  cs_lnum_t n_faces; /* n_i_faces + n_b_faces */
125  cs_gnum_t n_g_faces; /* Global number of faces */
126 
127  /* cs_quant_t structure attached to a face (interior or border) is build
128  on-the-fly cs_quant_get(flag, f_id, quant) */
129 
131 
132  /* cs_nvec3_t structure attached to a dual edge is build on-the-fly
133  Dual edge quantities (length and unit vector)
134  Scan with the c2f connectivity
135  */
136 
138 
139  /* Edge-based quantities */
140  /* ===================== */
141 
142  cs_lnum_t n_edges; /* Local number of edges */
143  cs_gnum_t n_g_edges; /* Global number of edges */
144 
145  cs_real_t *edge_vector; /* norm of the vector is equal to the
146  distance between two vertices.
147  unit vector is the tangential direction
148  attached to the edge */
149 
150  /* For each edge belonging to a cell, two contributions coming from 2
151  triangles s(x_cell, x_face, x_edge) for face in Face_edge are considered.
152  Scan with the c2e connectivity */
153 
154  cs_real_t *sface_normal; /* 2 triangle-face normals by edge in a
155  cell */
156 
158 
159  /* Vertex-based quantities */
160  /* ======================= */
161 
162  cs_lnum_t n_vertices; /* Local number of vertices */
163  cs_gnum_t n_g_vertices; /* Global number of vertices */
164 
165  cs_real_t *dcell_vol; /* Dual volume related to each vertex.
166  Scan with the c2v connectivity */
167  const cs_real_t *vtx_coord; /* Shared with the cs_mesh_t structure */
168 
170 
171 /*============================================================================
172  * Global variables
173  *============================================================================*/
174 
175 /*============================================================================
176  * Public function prototypes
177  *============================================================================*/
178 
179 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
191 double
193  const cs_real_t *xb);
194 
195 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
210  const cs_mesh_t *m,
211  const cs_mesh_quantities_t *mq,
212  const cs_cdo_connect_t *topo);
213 
214 /*----------------------------------------------------------------------------*/
222 /*----------------------------------------------------------------------------*/
223 
226 
227 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
238 
239 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
248 void
250 
251 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
264  const cs_cdo_quantities_t *cdoq);
265 
266 /*----------------------------------------------------------------------------*/
275 /*----------------------------------------------------------------------------*/
276 
277 inline static const cs_real_t *
279  const cs_cdo_quantities_t *cdoq)
280 {
281  const cs_lnum_t bf_id = f_id - cdoq->n_i_faces;
282  if (bf_id > -1) // Border face
283  return cdoq->b_face_center + 3*bf_id;
284  else // Interior face
285  return cdoq->i_face_center + 3*f_id;
286 }
287 
288 /*----------------------------------------------------------------------------*/
298 /*----------------------------------------------------------------------------*/
299 
302  const cs_cdo_quantities_t *cdoq);
303 
304 /*----------------------------------------------------------------------------*/
313 /*----------------------------------------------------------------------------*/
314 
317  const cs_cdo_quantities_t *cdoq);
318 
319 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
332  const cs_cdo_quantities_t *cdoq);
333 
334 /*----------------------------------------------------------------------------*/
342 /*----------------------------------------------------------------------------*/
343 
344 void
345 cs_quant_dump(FILE *f,
346  cs_lnum_t num,
347  const cs_quant_t q);
348 
349 /*----------------------------------------------------------------------------*/
350 
352 
353 #endif /* __CS_CDO_QUANTITIES_H__ */
const cs_real_t * b_face_center
Definition: cs_cdo_quantities.h:121
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
cs_cdo_cell_center_algo_t cc_algo
Definition: cs_cdo_quantities.h:103
cs_real_t * dedge_vector
Definition: cs_cdo_quantities.h:130
cs_gnum_t n_g_cells
Definition: cs_cdo_quantities.h:98
Definition: cs_cdo_quantities.h:60
cs_real_t * cell_centers
Definition: cs_cdo_quantities.h:99
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:1110
const cs_real_t * i_face_normal
Definition: cs_cdo_quantities.h:115
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:1393
cs_quant_info_t edge_info
Definition: cs_cdo_quantities.h:157
cs_real_t * dcell_vol
Definition: cs_cdo_quantities.h:165
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:453
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:278
cs_lnum_t n_edges
Definition: cs_cdo_quantities.h:142
double meas
Definition: cs_cdo_quantities.h:83
Definition: cs_cdo_quantities.h:69
double h_min
Definition: cs_cdo_quantities.h:75
Definition: cs_cdo_connect.h:55
double vol_tot
Definition: cs_cdo_quantities.h:92
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:89
Definition: cs_cdo.h:130
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:861
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:896
Definition: cs_mesh.h:63
cs_lnum_t n_faces
Definition: cs_cdo_quantities.h:124
cs_real_t * edge_vector
Definition: cs_cdo_quantities.h:145
const cs_real_t * i_face_surf
Definition: cs_cdo_quantities.h:117
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:1373
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:1196
Definition: cs_cdo_quantities.h:61
Definition: cs_mesh_quantities.h:82
cs_quant_info_t face_info
Definition: cs_cdo_quantities.h:137
cs_lnum_t n_b_faces
Definition: cs_cdo_quantities.h:119
cs_gnum_t n_g_edges
Definition: cs_cdo_quantities.h:143
double meas_max
Definition: cs_cdo_quantities.h:74
void cs_cdo_quantities_summary(const cs_cdo_quantities_t *quant)
Summarize generic information about the cdo mesh quantities.
Definition: cs_cdo_quantities.c:1147
const cs_real_t * i_face_center
Definition: cs_cdo_quantities.h:116
cs_lnum_t n_vertices
Definition: cs_cdo_quantities.h:162
cs_gnum_t n_g_faces
Definition: cs_cdo_quantities.h:125
Definition: cs_cdo_quantities.h:81
cs_real_t * cell_vol
Definition: cs_cdo_quantities.h:100
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:120
cs_lnum_t n_i_faces
Definition: cs_cdo_quantities.h:114
const cs_real_t * b_face_surf
Definition: cs_cdo_quantities.h:122
#define END_C_DECLS
Definition: cs_defs.h:454
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:97
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:1275
const cs_real_t * vtx_coord
Definition: cs_cdo_quantities.h:167
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:1352
cs_flag_t * cell_flag
Definition: cs_cdo_quantities.h:105
cs_real_t * sface_normal
Definition: cs_cdo_quantities.h:154
cs_cdo_cell_center_algo_t
Definition: cs_cdo_quantities.h:57
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:1327
cs_gnum_t n_g_vertices
Definition: cs_cdo_quantities.h:163
cs_quant_info_t cell_info
Definition: cs_cdo_quantities.h:109