programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cs_mesh_adjacencies.h
Go to the documentation of this file.
1 #ifndef __CS_MESH_ADJACENCIES_H__
2 #define __CS_MESH_ADJACENCIES_H__
3 
4 /*============================================================================
5  * Additional mesh adjacencies.
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_halo.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*=============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
52 #define CS_ADJACENCY_SHARED (1 << 0)
53 
54 #define CS_ADJACENCY_STRIDE (1 << 1)
55 
56 #define CS_ADJACENCY_SIGNED (1 << 2)
57 
60 /*============================================================================
61  * Type definition
62  *============================================================================*/
63 
64 typedef struct {
65 
66  /* metadata */
67 
68  bool single_faces_to_cells; /* true if a single face is adjacent
69  to 2 given cells */
70 
71  /* cells -> cells connectivity (standard) */
72 
73  cs_lnum_t *cell_cells_idx; /* indexes (shared) */
74  cs_lnum_t *cell_cells; /* adjacency (shared) */
75 
76  /* cells -> cells connectivity (extended) */
77 
78  const cs_lnum_t *cell_cells_e_idx; /* indexes (shared) */
79  const cs_lnum_t *cell_cells_e; /* adjacency (shared) */
80 
81  /* cells -> boundary faces connectivity */
82 
85 
87 
88 
89 typedef struct {
90 
91  cs_flag_t flag; /* Compact way to store metadata */
92  int stride;
93 
95  cs_lnum_t *idx; /* size = n_elts + 1 */
96  cs_lnum_t *ids; /* ids from 0 to n-1 (there is no multifold entry) */
97  short int *sgn; /* +/- 1 according to the orientation of the element */
98 
100 
101 /*============================================================================
102  * Global variables
103  *============================================================================*/
104 
105 /* Read-only pointer to global mesh additional adjacencies structure */
106 
108 
109 /*=============================================================================
110  * Public function prototypes
111  *============================================================================*/
112 
113 /*----------------------------------------------------------------------------*/
117 /*----------------------------------------------------------------------------*/
118 
119 void
121 
122 /*----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------*/
127 
128 void
130 
131 /*----------------------------------------------------------------------------*/
135 /*----------------------------------------------------------------------------*/
136 
137 void
139 
140 /*----------------------------------------------------------------------------*/
145 /*----------------------------------------------------------------------------*/
146 
147 void
149 
150 /*----------------------------------------------------------------------------*/
160 /*----------------------------------------------------------------------------*/
161 
164  int stride,
165  cs_lnum_t n_elts);
166 
167 /*----------------------------------------------------------------------------*/
179 /*----------------------------------------------------------------------------*/
180 
183  int stride,
184  cs_lnum_t *ids,
185  short int *sgn);
186 
187 /*----------------------------------------------------------------------------*/
199 /*----------------------------------------------------------------------------*/
200 
203  cs_lnum_t *idx,
204  cs_lnum_t *ids,
205  short int *sgn);
206 
207 /*----------------------------------------------------------------------------*/
213 /*----------------------------------------------------------------------------*/
214 
215 void
217 
218 /*----------------------------------------------------------------------------*/
231 /*----------------------------------------------------------------------------*/
232 
234 cs_adjacency_compose(int n_c_elts,
235  const cs_adjacency_t *a2b,
236  const cs_adjacency_t *b2c);
237 
238 /*----------------------------------------------------------------------------*/
248 /*----------------------------------------------------------------------------*/
249 
251 cs_adjacency_transpose(int n_b_elts,
252  const cs_adjacency_t *a2b);
253 
254 /*----------------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------------*/
262 
263 void
265 
266 /*----------------------------------------------------------------------------*/
275 /*----------------------------------------------------------------------------*/
276 
277 void
278 cs_adjacency_dump(const char *name,
279  FILE *_f,
280  cs_adjacency_t *adj);
281 
282 /*----------------------------------------------------------------------------*/
283 
285 
286 #endif /* __CS_MESH_ADJACENCIES__ */
cs_lnum_t n_elts
Definition: cs_mesh_adjacencies.h:94
bool single_faces_to_cells
Definition: cs_mesh_adjacencies.h:68
short int * sgn
Definition: cs_mesh_adjacencies.h:97
cs_adjacency_t * cs_adjacency_create_from_s_arrays(cs_lnum_t n_elts, int stride, cs_lnum_t *ids, short int *sgn)
Create a cs_adjacency_t structure sharing arrays scanned with a stride.
Definition: cs_mesh_adjacencies.c:418
cs_adjacency_t * cs_adjacency_create_from_i_arrays(cs_lnum_t n_elts, cs_lnum_t *idx, cs_lnum_t *ids, short int *sgn)
Create a cs_adjacency_t structure sharing arrays scanned with a stride.
Definition: cs_mesh_adjacencies.c:464
Definition: cs_mesh_adjacencies.h:89
Definition: cs_mesh_adjacencies.h:64
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
cs_lnum_t * cell_b_faces_idx
Definition: cs_mesh_adjacencies.h:83
void cs_mesh_adjacencies_initialize(void)
Initialize mesh adjacencies helper API.
Definition: cs_mesh_adjacencies.c:267
void cs_adjacency_sort(cs_adjacency_t *adj)
Sort each sub-list related to an entry in a cs_adjacency_t structure.
Definition: cs_mesh_adjacencies.c:886
const cs_lnum_t * cell_cells_e_idx
Definition: cs_mesh_adjacencies.h:78
int stride
Definition: cs_mesh_adjacencies.h:92
cs_lnum_t * ids
Definition: cs_mesh_adjacencies.h:96
cs_adjacency_t * cs_adjacency_compose(int n_c_elts, const cs_adjacency_t *a2b, const cs_adjacency_t *b2c)
Create a new cs_adjacency_t structure from the composition of two cs_adjacency_t structures: (1) A ->...
Definition: cs_mesh_adjacencies.c:544
void cs_adjacency_dump(const char *name, FILE *_f, cs_adjacency_t *adj)
Dump a cs_adjacency_t structure to a file or into the standard output.
Definition: cs_mesh_adjacencies.c:938
const cs_mesh_adjacencies_t * cs_glob_mesh_adjacencies
cs_adjacency_t * cs_adjacency_transpose(int n_b_elts, const cs_adjacency_t *a2b)
Create a new cs_adjacency_t structure from a one corresponding to A -> B. The resulting structure dea...
Definition: cs_mesh_adjacencies.c:758
void cs_mesh_adjacencies_update_mesh(void)
Update mesh adjacencies helper API relative to mesh.
Definition: cs_mesh_adjacencies.c:310
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_lnum_t * cell_cells
Definition: cs_mesh_adjacencies.h:74
void cs_mesh_adjacencies_finalize(void)
Finalize mesh adjacencies helper API.
Definition: cs_mesh_adjacencies.c:290
#define END_C_DECLS
Definition: cs_defs.h:454
cs_flag_t flag
Definition: cs_mesh_adjacencies.h:91
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_mesh_adjacencies_update_cell_cells_e(void)
Update extended cell -> cell connectivites in mesh adjacencies helper API relative to mesh...
Definition: cs_mesh_adjacencies.c:335
cs_lnum_t * cell_b_faces
Definition: cs_mesh_adjacencies.h:84
cs_lnum_t * cell_cells_idx
Definition: cs_mesh_adjacencies.h:73
void cs_adjacency_free(cs_adjacency_t **p_adj)
Destroy a cs_adjacency_t structure.
Definition: cs_mesh_adjacencies.c:506
cs_adjacency_t * cs_adjacency_create(cs_flag_t flag, int stride, cs_lnum_t n_elts)
Create a cs_adjacency_t structure of size n_elts.
Definition: cs_mesh_adjacencies.c:358
const cs_lnum_t * cell_cells_e
Definition: cs_mesh_adjacencies.h:79
cs_lnum_t * idx
Definition: cs_mesh_adjacencies.h:95