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-2015 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 /* For primal vector quantities (edge or face) */
65 typedef struct {
66 
67  double meas; /* length or area */
68  double unitv[3]; /* unitary vector: tangent or normal to the element */
69  double center[3];
70 
71 } cs_quant_t;
72 
73 /* For dual face quantities. Add also a link to entity id related to this dual
74  quantities */
75 
76 typedef struct { /* TODO: remove what is the less necessary in order to
77  save memory comsumption */
78 
79  cs_lnum_t parent_id[2]; /* parent entity id of (primal) faces f0 and f1 */
80  cs_nvec3_t sface[2]; /* area and unit normal vector for each
81  triangle s(e,f,c) for f in {f0, f1} */
82  double vect[3]; /* dual face vector */
83 
84 } cs_dface_t;
85 
86 typedef struct { /* Specific mesh quantities */
87 
88  /* Global mesh quantities */
89  double vol_tot;
90 
91  /* Cell-based quantities */
95 
96  /* Face-based quantities */
99  cs_lnum_t n_faces; /* n_i_faces + n_b_faces */
100  cs_quant_t *face; /* Face quantities */
101  cs_nvec3_t *dedge; /* Dual edge quantities (length and unit vector)
102  Scan with the c2f connectivity */
103 
104  /* Edge-based quantities */
106  cs_quant_t *edge; /* Edge quantities */
107  cs_dface_t *dface; /* For each edge belonging to a cell, two
108  contributions coming from 2 triangles
109  s(x_cell, x_face, x_edge) for face in Face_edge
110  are considered.
111  Scan with the c2e connectivity */
112 
113  /* Vertex-based quantities */
115  double *dcell_vol; /* Dual volume related to each vertex.
116  Scan with the c2v connectivity */
117  const cs_real_t *vtx_coord; /* Pointer to the one stored in cs_mesh_t */
118 
119 
121 
122 /*============================================================================
123  * Global variables
124  *============================================================================*/
125 
126 /*============================================================================
127  * Public function prototypes
128  *============================================================================*/
129 
130 /*----------------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------------*/
141 
144  const cs_mesh_quantities_t *mq,
145  const cs_cdo_connect_t *topo);
146 
147 /*----------------------------------------------------------------------------*/
155 /*----------------------------------------------------------------------------*/
156 
159 
160 /*----------------------------------------------------------------------------*/
167 /*----------------------------------------------------------------------------*/
168 
169 void
171 
172 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 
182 void
183 cs_quant_dump(FILE *f,
184  cs_lnum_t num,
185  const cs_quant_t q);
186 
187 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
200 void
202  const cs_cdo_quantities_t *quant,
203  double *p_pvol[]);
204 
205 /*----------------------------------------------------------------------------*/
214 /*----------------------------------------------------------------------------*/
215 
216 void
218  const cs_cdo_quantities_t *quant,
219  double *p_pvol[]);
220 
221 /*----------------------------------------------------------------------------*/
230 /*----------------------------------------------------------------------------*/
231 
232 void
234  const cs_cdo_quantities_t *quant,
235  double *p_pvol[]);
236 
237 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  const cs_cdo_connect_t *connect,
254  const cs_cdo_quantities_t *quant,
255  const short int loc_ids[],
256  double wf[]);
257 
258 /*----------------------------------------------------------------------------*/
259 
261 
262 #endif /* __CS_CDO_QUANTITIES_H__ */
void cs_compute_face_weights(cs_lnum_t f_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const short int loc_ids[], double wf[])
Compute for each face a weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|...
Definition: cs_cdo_quantities.c:1214
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:836
cs_real_t * cell_centers
Definition: cs_cdo_quantities.h:93
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:966
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:1054
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:1082
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
cs_cdo_cc_algo_t
Definition: cs_cdo_quantities.h:53
cs_lnum_t n_edges
Definition: cs_cdo_quantities.h:105
double meas
Definition: cs_cdo_quantities.h:67
cs_dface_t * dface
Definition: cs_cdo_quantities.h:107
Definition: cs_cdo_connect.h:67
double vol_tot
Definition: cs_cdo_quantities.h:89
Definition: cs_cdo_quantities.h:56
Definition: cs_cdo_quantities.h:86
Definition: cs_cdo.h:63
Definition: cs_mesh.h:62
cs_lnum_t n_faces
Definition: cs_cdo_quantities.h:99
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:999
Definition: cs_mesh_quantities.h:51
cs_quant_t * face
Definition: cs_cdo_quantities.h:100
cs_lnum_t n_b_faces
Definition: cs_cdo_quantities.h:98
double * dcell_vol
Definition: cs_cdo_quantities.h:115
Definition: cs_cdo_quantities.h:76
cs_lnum_t n_vertices
Definition: cs_cdo_quantities.h:114
Definition: cs_cdo_quantities.h:65
cs_real_t * cell_vol
Definition: cs_cdo_quantities.h:94
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:1165
cs_lnum_t n_i_faces
Definition: cs_cdo_quantities.h:97
#define END_C_DECLS
Definition: cs_defs.h:430
double cs_real_t
Definition: cs_defs.h:296
cs_lnum_t n_cells
Definition: cs_cdo_quantities.h:92
const cs_real_t * vtx_coord
Definition: cs_cdo_quantities.h:117
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:1119
cs_quant_t * edge
Definition: cs_cdo_quantities.h:106
cs_nvec3_t * dedge
Definition: cs_cdo_quantities.h:101