programmer's documentation
cs_cdo_local.h
Go to the documentation of this file.
1 #ifndef __CS_CDO_LOCAL_H__
2 #define __CS_CDO_LOCAL_H__
3 
4 /*============================================================================
5  * Routines to handle low-level routines related to CDO local quantities:
6  * - local matrices (stored in dense format),
7  * - local quantities related to a cell.
8  *============================================================================*/
9 
10 /*
11  This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13  Copyright (C) 1998-2016 EDF S.A.
14 
15  This program is free software; you can redistribute it and/or modify it under
16  the terms of the GNU General Public License as published by the Free Software
17  Foundation; either version 2 of the License, or (at your option) any later
18  version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23  details.
24 
25  You should have received a copy of the GNU General Public License along with
26  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27  Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_cdo.h"
35 #include "cs_cdo_connect.h"
36 #include "cs_cdo_quantities.h"
37 #include "cs_cdo_toolbox.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
47 #define CS_CDO_LOCAL_V (1 << 0) // 1: local information related to vertices
48 #define CS_CDO_LOCAL_E (1 << 1) // 2: local information related to edges
49 #define CS_CDO_LOCAL_F (1 << 2) // 4: local information related to faces
50 #define CS_CDO_LOCAL_EV (1 << 3) // 8: cell-wise edge --> vertices connect.
51 #define CS_CDO_LOCAL_FE (1 << 4) // 16: cell-wise face --> edges connect.
52 #define CS_CDO_LOCAL_EF (1 << 5) // 32: cell-wise edge --> faces connect.
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
58 /* Structure used to store a local system (cell-wise for instance) */
59 typedef struct {
60 
61  cs_locmat_t *mat; // cell-wise view of the system matrix
62  double *rhs; // cell-wise view of the right-hand side
63  double *dir_bc; // Dirichlet values for boundary degrees of freedom
64 
66 
67 /* Structure used to get a better memory locality. Map existing structure
68  into a more compact one dedicated to a cell.
69  Arrays are allocated to n_max_vbyc or to n_max_ebyc.
70  Cell-wise numbering is based on the c2e and c2v connectivity.
71 */
72 
73 typedef struct {
74 
75  short int n_max_vbyc;
76  short int n_max_ebyc;
77  short int n_max_fbyc;
78 
79  cs_flag_t flag; // indicate which quantities are defined
80  cs_lnum_t c_id; // id of related cell
81  cs_real_t *xc; // pointer to the coordinates of the cell center
82  double vol_c; // volume of the current cell
83 
84  /* Vertex information */
85  short int n_vc; // local number of vertices in a cell
86  cs_lnum_t *v_ids; // vertex ids on this rank
87  double *xv; // local vertex coordinates (copy)
88  short int *vtag; // link between mesh and cell-wise numbering (-1 not set)
89  double *wvc; // weight |vol_dc(v) cap vol_c|/|vol_c for each cell vtx
90 
91  /* Edge information */
92  short int n_ec; // local number of edges in a cell
93  cs_lnum_t *e_ids; // edge ids on this rank
94  short int *etag; // link between mesh and cell-wise numbering (-1 not set)
95  cs_quant_t *edge; // local edge quantities (xe, length and unit vector)
96  cs_nvec3_t *dface; // local dual face quantities (area and unit normal)
97 
98  /* Face information */
99  short int n_fc; // local number of faces in a cell
100  cs_lnum_t *f_ids; // face ids on this rank
101  short int *f_sgn; // incidence number between f and c
102  cs_quant_t *face; // local face quantities (xf, area and unit normal)
103  cs_nvec3_t *dedge; // local dual edge quantities (length and unit vector)
104 
105  /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
106  short int *e2v_ids; // cell-wise edge -> vertices connectivity
107  short int *e2v_sgn; // cell-wise edge -> vertices orientation (-1 or +1)
108 
109  /* Local f2e connectivity: size = n_fc*n_max_ebyf */
110  short int *f2e_idx; // size n_fc + 1
111  short int *f2e_ids; // size f2e_idx[n_fc]
112 
113  /* Local e2f connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
114  short int *e2f_ids; // cell-wise edge -> faces connectivity
115  short int *e2f_sgn; // cell-wise edge -> faces orientation (-1 or +1)
116 
118 
119 /* Structure used to get a better memory locality. Map existing structure
120  into a more compact one dedicated to a face.
121  Arrays are allocated to n_max_vbyf (= n_max_ebyf).
122  Face-wise numbering is based on the f2e connectivity.
123 */
124 
125 typedef struct {
126 
127  short int n_max_vbyf; // = n_max_ebyf
128 
129  cs_lnum_t c_id; // id of related cell
130  cs_real_t *xc; // pointer to the coordinates of the cell center
131 
132  /* Face information */
133  cs_lnum_t f_id; // local mesh face id
134  short int f_sgn; // incidence number between f and c
135  cs_quant_t face; // local face quantities (xf, area and unit normal)
136  cs_nvec3_t dedge; // local dual edge quantities (length and unit vector)
137 
138  /* Vertex information */
139  short int n_vf; // local number of vertices on this face
140  cs_lnum_t *v_ids; // vertex ids on this rank or in the cellwise numbering
141  double *xv; // local vertex coordinates (copy)
142  double *wvf; // weight related to each vertex
143 
144  /* Edge information */
145  short int n_ef; // local number of edges in on this face (= n_vf)
146  cs_lnum_t *e_ids; // edge ids on this rank or in the cellwise numbering
147  cs_quant_t *edge; // local edge quantities (xe, length and unit vector)
148  double *tef; // area of the triangle of base e and apex xf
149 
150  /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyf) */
151  short int *e2v_ids; // face-wise edge -> vertices connectivity
152 
154 
155 /*============================================================================
156  * Global variables
157  *============================================================================*/
158 
161 
162 /*============================================================================
163  * Public function prototypes
164  *============================================================================*/
165 
166 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
177 cs_cdo_locsys_create(int n_max_ent);
178 
179 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 void
189 
190 /*----------------------------------------------------------------------------*/
197 /*----------------------------------------------------------------------------*/
198 
199 void
201 
202 /*----------------------------------------------------------------------------*/
207 /*----------------------------------------------------------------------------*/
208 
209 void
211 
212 /*----------------------------------------------------------------------------*/
220 /*----------------------------------------------------------------------------*/
221 
223 cs_cdo_local_get_cell_mesh(int mesh_id);
224 
225 /*----------------------------------------------------------------------------*/
233 /*----------------------------------------------------------------------------*/
234 
236 cs_cdo_local_get_face_mesh(int mesh_id);
237 
238 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
249 cs_cell_mesh_create(const cs_cdo_connect_t *connect);
250 
251 /*----------------------------------------------------------------------------*/
257 /*----------------------------------------------------------------------------*/
258 
259 void
261 
262 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 void
277  cs_flag_t level,
278  const cs_cdo_connect_t *connect,
279  const cs_cdo_quantities_t *quant,
280  cs_cell_mesh_t *cm);
281 
282 /*----------------------------------------------------------------------------*/
290 /*----------------------------------------------------------------------------*/
291 
293 cs_face_mesh_create(const cs_cdo_connect_t *connect);
294 
295 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 
303 void
305 
306 /*----------------------------------------------------------------------------*/
316 /*----------------------------------------------------------------------------*/
317 
318 void
320  cs_lnum_t f_id,
321  const cs_cdo_connect_t *connect,
322  const cs_cdo_quantities_t *quant,
323  cs_face_mesh_t *fm);
324 
325 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
337 void
339  short int f,
340  cs_face_mesh_t *fm);
341 
342 /*----------------------------------------------------------------------------*/
343 
345 
346 #endif /* __CS_CDO_LOCAL_H__ */
cs_lnum_t * e_ids
Definition: cs_cdo_local.h:146
void cs_cdo_local_initialize(const cs_cdo_connect_t *connect)
Allocate global structures related to a cs_cell_mesh_t and cs_face_mesh_t structures.
Definition: cs_cdo_local.c:142
void cs_cell_mesh_build(cs_lnum_t c_id, cs_flag_t level, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_cell_mesh_t *cm)
Define a cs_cell_mesh_t structure for a given cell id. According to the requested level...
Definition: cs_cdo_local.c:375
short int * e2f_ids
Definition: cs_cdo_local.h:114
double vol_c
Definition: cs_cdo_local.h:82
void cs_cell_mesh_free(cs_cell_mesh_t **p_cm)
Free a cs_cell_mesh_t structure.
Definition: cs_cdo_local.c:326
cs_lnum_t * f_ids
Definition: cs_cdo_local.h:100
cs_lnum_t f_id
Definition: cs_cdo_local.h:133
double * wvc
Definition: cs_cdo_local.h:89
short int n_max_vbyf
Definition: cs_cdo_local.h:127
double * tef
Definition: cs_cdo_local.h:148
short int n_max_vbyc
Definition: cs_cdo_local.h:75
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
short int * e2v_sgn
Definition: cs_cdo_local.h:107
cs_nvec3_t * dface
Definition: cs_cdo_local.h:96
void cs_cdo_local_finalize(void)
Free global structures related to cs_cell_mesh_t and cs_face_mesh_t structures.
Definition: cs_cdo_local.c:177
short int n_vf
Definition: cs_cdo_local.h:139
Definition: cs_cdo_local.h:73
Definition: cs_cdo_connect.h:67
short int * f2e_ids
Definition: cs_cdo_local.h:111
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:140
double * xv
Definition: cs_cdo_local.h:87
short int n_ef
Definition: cs_cdo_local.h:145
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_cdo_quantities.h:100
cs_nvec3_t dedge
Definition: cs_cdo_local.h:136
Definition: cs_cdo.h:121
short int n_max_ebyc
Definition: cs_cdo_local.h:76
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:86
short int * f_sgn
Definition: cs_cdo_local.h:101
double * wvf
Definition: cs_cdo_local.h:142
cs_locmat_t * mat
Definition: cs_cdo_local.h:61
Definition: cs_field_pointer.h:118
cs_lnum_t c_id
Definition: cs_cdo_local.h:80
cs_cell_mesh_t * cs_cdo_local_get_cell_mesh(int mesh_id)
Get a pointer to a cs_cell_mesh_t structure corresponding to mesh id.
Definition: cs_cdo_local.c:214
short int n_max_fbyc
Definition: cs_cdo_local.h:77
void cs_face_mesh_build_from_cell_mesh(const cs_cell_mesh_t *cm, short int f, cs_face_mesh_t *fm)
Define a cs_face_mesh_t structure for a given cell from a cs_cell_mesh_t structure. v_ids and e_ids are defined in the cell numbering given by cm.
Definition: cs_cdo_local.c:789
double * rhs
Definition: cs_cdo_local.h:62
short int n_fc
Definition: cs_cdo_local.h:99
short int f_sgn
Definition: cs_cdo_local.h:134
cs_face_mesh_t * cs_cdo_local_get_face_mesh(int mesh_id)
Get a pointer to a cs_face_mesh_t structure corresponding to mesh id.
Definition: cs_cdo_local.c:233
Definition: cs_cdo_local.h:59
short int * vtag
Definition: cs_cdo_local.h:88
cs_lnum_t * e_ids
Definition: cs_cdo_local.h:93
cs_real_t * xc
Definition: cs_cdo_local.h:130
cs_nvec3_t * dedge
Definition: cs_cdo_local.h:103
cs_quant_t * edge
Definition: cs_cdo_local.h:147
cs_cell_mesh_t ** cs_cdo_local_cell_meshes
Definition: cs_cdo_local.c:64
short int * e2v_ids
Definition: cs_cdo_local.h:151
cs_quant_t * face
Definition: cs_cdo_local.h:102
cs_flag_t flag
Definition: cs_cdo_local.h:79
cs_quant_t face
Definition: cs_cdo_local.h:135
Definition: cs_cdo_quantities.h:79
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
short int n_vc
Definition: cs_cdo_local.h:85
short int * e2f_sgn
Definition: cs_cdo_local.h:115
double * dir_bc
Definition: cs_cdo_local.h:63
#define END_C_DECLS
Definition: cs_defs.h:449
short int * e2v_ids
Definition: cs_cdo_local.h:106
unsigned short int cs_flag_t
Definition: cs_defs.h:298
cs_cell_mesh_t * cs_cell_mesh_create(const cs_cdo_connect_t *connect)
Allocate a cs_cell_mesh_t structure.
Definition: cs_cdo_local.c:252
short int n_ec
Definition: cs_cdo_local.h:92
Definition: cs_cdo_local.h:125
cs_real_t * xc
Definition: cs_cdo_local.h:81
void cs_face_mesh_build(cs_lnum_t c_id, cs_lnum_t f_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_face_mesh_t *fm)
Define a cs_face_mesh_t structure for a given face/cell id.
Definition: cs_cdo_local.c:642
cs_cdo_locsys_t * cs_cdo_locsys_create(int n_max_ent)
Allocate a cs_cdo_locsys_t structure.
Definition: cs_cdo_local.c:88
short int * f2e_idx
Definition: cs_cdo_local.h:110
cs_face_mesh_t ** cs_cdo_local_face_meshes
Definition: cs_cdo_local.c:65
cs_face_mesh_t * cs_face_mesh_create(const cs_cdo_connect_t *connect)
Allocate a cs_face_mesh_t structure.
Definition: cs_cdo_local.c:566
cs_lnum_t c_id
Definition: cs_cdo_local.h:129
void cs_cdo_locsys_free(cs_cdo_locsys_t **p_ls)
Free a cs_cdo_locsys_t structure.
Definition: cs_cdo_local.c:117
Definition: cs_cdo_toolbox.h:71
double * xv
Definition: cs_cdo_local.h:141
cs_quant_t * edge
Definition: cs_cdo_local.h:95
short int * etag
Definition: cs_cdo_local.h:94
void cs_face_mesh_free(cs_face_mesh_t **p_fm)
Free a cs_face_mesh_t structure.
Definition: cs_cdo_local.c:609