9.2
general documentation
cs_cdo_connect.h
Go to the documentation of this file.
1#ifndef CS_CDO_CONNECT_H
2#define CS_CDO_CONNECT_H
3
4/*============================================================================
5 * Manage connectivity (Topological features of the mesh)
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 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 "fvm/fvm_defs.h"
35
36#include "base/cs_base.h"
37#include "base/cs_param_types.h"
38#include "base/cs_range_set.h"
39#include "cdo/cs_flag.h"
40#include "mesh/cs_mesh.h"
42
43/*============================================================================
44 * Macro definitions
45 *============================================================================*/
46
47/* Additional macros */
48
49#define CS_TRIANGLE_CASE 3 /* Number of vertices in a triangle */
50
51/*============================================================================
52 * Type definitions
53 *============================================================================*/
54
55/* Connectivity structure */
56
57typedef struct {
58
59 /* Periodicity (copy from cs_mesh_t. Stored here to avoid to point to the
60 mesh structure in many functions) */
61
63
64 /* Vertex-related members */
65 /* ---------------------- */
66
68
69 /* range set and interface set structures for scalar-valued vertex DoFs
70 (these structures may be not allocated according to the settings) */
71
74
75
76 /* Edge-related members */
77 /* -------------------- */
78
81
82 cs_adjacency_t *e2v; /* edge --> vertices connectivity */
83 cs_adjacency_t *e2f; /* edge --> faces connectivity */
84
85 /* range set and interface set structures for scalar-valued edge DoFs
86 (these structures may be not allocated according to the settings) */
87
90
91 /* Face-related members */
92 /* -------------------- */
93
94 cs_lnum_t n_faces[3]; /* 0: all, 1: border, 2: interior */
95
96 cs_adjacency_t *f2c; /* face --> cells connectivity */
97 cs_adjacency_t *f2e; /* face --> edges connectivity */
98 cs_adjacency_t *bf2v; /* border face --> vertices connectivity
99 (map from cs_mesh_t) */
100 cs_adjacency_t *if2v; /* interior face --> vertices connectivity
101 (map from cs_mesh_t) */
102
103 /* range set and interface set structures for scalar-valued edge DoFs
104 (these structures may be not allocated according to the settings) */
105
108
109 /* Cell-related members */
110 /* -------------------- */
111
114
115 fvm_element_t *cell_type; /* type of cell */
116 cs_flag_t *cell_flag; /* flag (border/solid) */
117 cs_adjacency_t *c2f; /* cell --> faces connectivity */
118 cs_adjacency_t *c2e; /* cell --> edges connectivity */
119 cs_adjacency_t *c2v; /* cell --> vertices connectivity */
120
121 /* Delta of ids between the min./max. values of entities related to a cell
122 Useful to store compactly the link between mesh ids and cell mesh ids
123 needed during the cell mesh definition */
124
127
128 /* Max. connectitivy size for cells */
129
130 int n_max_vbyc; /* max. number of vertices in a cell */
131 int n_max_ebyc; /* max. number of edges in a cell */
132 int n_max_fbyc; /* max. number of faces in a cell */
133 int n_max_vbyf; /* max. number of vertices in a face */
134 int n_max_v2fc; /* max. number of faces connected to a vertex in a cell */
135 int n_max_v2ec; /* max. number of edges connected to a vertex in a cell */
136
137 /* Adjacency related to linear systems (allocated only if needed) */
138
139 cs_adjacency_t *v2v; /* vertex to vertices through cells */
140 cs_adjacency_t *f2f; /* face to faces through cells */
141 cs_adjacency_t *f2xf; /* face to extended faces through cells + edges
142 * for MAC scheme */
143 cs_adjacency_t *f2f_ed; /* face to faces through edges + same directions
144 * for MAC scheme */
145 cs_adjacency_t *e2e; /* edge to edges through cells */
146
148
149/*============================================================================
150 * Global variables
151 *============================================================================*/
152
153/*============================================================================
154 * Static Inline Public function prototypes
155 *============================================================================*/
156
157/*----------------------------------------------------------------------------*/
169/*----------------------------------------------------------------------------*/
170
171static inline void
173 const cs_lnum_t *e2v_ids,
174 const cs_lnum_t start_idx,
175 cs_lnum_t *v0,
176 cs_lnum_t *v1,
177 cs_lnum_t *v2)
178{
179 const cs_lnum_t _2e0 = 2*f2e_ids[start_idx],
180 _2e1 = 2*f2e_ids[start_idx+1];
181 const cs_lnum_t tmp = e2v_ids[_2e1];
182
183 *v0 = e2v_ids[_2e0];
184 *v1 = e2v_ids[_2e0+1];
185 *v2 = ((tmp != *v0) && (tmp != *v1)) ? tmp : e2v_ids[_2e1+1];
186}
187
188/*============================================================================
189 * Public function prototypes
190 *============================================================================*/
191
192/*----------------------------------------------------------------------------*/
211/*----------------------------------------------------------------------------*/
212
214 cs_flag_t eb_scheme_flag,
215 cs_flag_t fb_scheme_flag,
216 cs_flag_t cb_scheme_flag,
217 cs_flag_t vb_scheme_flag,
218 cs_flag_t vcb_scheme_flag,
219 cs_flag_t hho_scheme_flag,
220 cs_flag_t mac_scheme_flag);
221
222/*----------------------------------------------------------------------------*/
231/*----------------------------------------------------------------------------*/
232
235 cs_cdo_connect_t *connect);
236
237/*----------------------------------------------------------------------------*/
246/*----------------------------------------------------------------------------*/
247
248void
250 cs_flag_t eb_scheme_flag,
251 cs_flag_t vb_scheme_flag,
252 cs_flag_t vcb_scheme_flag);
253
254/*----------------------------------------------------------------------------*/
260/*----------------------------------------------------------------------------*/
261
262void
264
265/*----------------------------------------------------------------------------*/
269/*----------------------------------------------------------------------------*/
270
271void
273
274/*----------------------------------------------------------------------------*/
283/*----------------------------------------------------------------------------*/
284
285double *
287
288/*----------------------------------------------------------------------------*/
294/*----------------------------------------------------------------------------*/
295
296long long
298
299/*----------------------------------------------------------------------------*/
310/*----------------------------------------------------------------------------*/
311
312void
314 int n_vtx_dofs,
315 bool interlaced,
316 cs_interface_set_t **p_ifs,
317 cs_range_set_t **p_rs);
318
319/*----------------------------------------------------------------------------*/
330/*----------------------------------------------------------------------------*/
331
332void
334 cs_lnum_t n_faces,
335 int n_face_dofs,
336 cs_interface_set_t **p_ifs,
337 cs_range_set_t **p_rs);
338
339/*----------------------------------------------------------------------------*/
347/*----------------------------------------------------------------------------*/
348
351
352/*----------------------------------------------------------------------------*/
363/*----------------------------------------------------------------------------*/
364
365void
367 const cs_real_t *edge_values,
368 cs_real_t **p_curl_values);
369
370/*----------------------------------------------------------------------------*/
376/*----------------------------------------------------------------------------*/
377
378void
380
381#endif /* CS_CDO_CONNECT_H */
void cs_cdo_connect_dump(const cs_cdo_connect_t *connect)
Dump a cs_cdo_connect_t structure for debugging purpose.
Definition: cs_cdo_connect.cpp:1633
void cs_cdo_connect_allocate_cw_buffer(const cs_cdo_connect_t *connect)
Allocate and initialize the cell-wise buffer(s)
Definition: cs_cdo_connect.cpp:1424
void cs_cdo_connect_assign_vtx_ifs_rs(const cs_mesh_t *mesh, int n_vtx_dofs, bool interlaced, cs_interface_set_t **p_ifs, cs_range_set_t **p_rs)
Allocate and define a cs_range_set_t structure and a cs_interface_set_t structure for schemes with Do...
Definition: cs_cdo_connect.cpp:1531
cs_cdo_connect_t * cs_cdo_connect_build(cs_mesh_t *mesh, cs_flag_t eb_scheme_flag, cs_flag_t fb_scheme_flag, cs_flag_t cb_scheme_flag, cs_flag_t vb_scheme_flag, cs_flag_t vcb_scheme_flag, cs_flag_t hho_scheme_flag, cs_flag_t mac_scheme_flag)
Allocate and define a new cs_cdo_connect_t structure Range sets and interface sets are allocated and ...
Definition: cs_cdo_connect.cpp:1060
void cs_cdo_connect_assign_face_ifs_rs(const cs_mesh_t *mesh, cs_lnum_t n_faces, int n_face_dofs, cs_interface_set_t **p_ifs, cs_range_set_t **p_rs)
Allocate and define a cs_range_set_t structure and a cs_interface_set_t structure for schemes with Do...
cs_cdo_connect_t * cs_cdo_connect_free(const cs_mesh_t *mesh, cs_cdo_connect_t *connect)
Destroy a cs_cdo_connect_t structure.
Definition: cs_cdo_connect.cpp:1252
void cs_cdo_connect_discrete_curl(const cs_cdo_connect_t *connect, const cs_real_t *edge_values, cs_real_t **p_curl_values)
Compute the discrete curl operator across each primal faces. From an edge-based array (seen as circul...
Definition: cs_cdo_connect.cpp:1591
void cs_cdo_connect_log_summary(const cs_cdo_connect_t *connect, cs_flag_t eb_scheme_flag, cs_flag_t vb_scheme_flag, cs_flag_t vcb_scheme_flag)
Summary of the connectivity information.
Definition: cs_cdo_connect.cpp:1311
void cs_cdo_connect_free_cw_buffer(void)
Free the cell-wise buffer(s)
Definition: cs_cdo_connect.cpp:1465
double * cs_cdo_connect_get_cw_buffer(int thr_id)
Retrieve the cell-wise buffer associated to the current thread. Use cs_get_thread_id when the thread ...
Definition: cs_cdo_connect.cpp:1497
cs_interface_set_t * cs_cdo_connect_define_face_interface(const cs_mesh_t *mesh)
Create and define a new cs_interface_set_t structure on faces.
static void cs_connect_get_next_3_vertices(const cs_lnum_t *f2e_ids, const cs_lnum_t *e2v_ids, const cs_lnum_t start_idx, cs_lnum_t *v0, cs_lnum_t *v1, cs_lnum_t *v2)
Get the next three vertices in a row from a face to edge connectivity and a edge to vertex connectivi...
Definition: cs_cdo_connect.h:172
long long cs_cdo_connect_get_time_perfo(void)
Retrieve the time elapsed to build the cs_cdo_connect_t structure.
Definition: cs_cdo_connect.cpp:1512
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:317
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
struct _cs_interface_set_t cs_interface_set_t
Definition: cs_interface.h:57
fvm_element_t
Definition: fvm_defs.h:44
Definition: mesh.f90:26
Definition: cs_mesh_adjacencies.h:68
Definition: cs_cdo_connect.h:57
cs_lnum_t v_max_cell_range
Definition: cs_cdo_connect.h:126
cs_gnum_t n_g_edges
Definition: cs_cdo_connect.h:80
int n_max_v2fc
Definition: cs_cdo_connect.h:134
cs_flag_t * cell_flag
Definition: cs_cdo_connect.h:116
int n_max_fbyc
Definition: cs_cdo_connect.h:132
cs_adjacency_t * v2v
Definition: cs_cdo_connect.h:139
cs_interface_set_t * vtx_ifs
Definition: cs_cdo_connect.h:73
int n_max_ebyc
Definition: cs_cdo_connect.h:131
int n_max_vbyc
Definition: cs_cdo_connect.h:130
cs_adjacency_t * c2f
Definition: cs_cdo_connect.h:117
int n_max_v2ec
Definition: cs_cdo_connect.h:135
cs_adjacency_t * e2f
Definition: cs_cdo_connect.h:83
int n_max_vbyf
Definition: cs_cdo_connect.h:133
cs_adjacency_t * f2xf
Definition: cs_cdo_connect.h:141
cs_range_set_t * face_rset
Definition: cs_cdo_connect.h:106
cs_range_set_t * edge_rset
Definition: cs_cdo_connect.h:88
cs_lnum_t e_max_cell_range
Definition: cs_cdo_connect.h:125
cs_lnum_t n_cells_with_ghosts
Definition: cs_cdo_connect.h:113
cs_lnum_t n_cells
Definition: cs_cdo_connect.h:112
cs_range_set_t * vtx_rset
Definition: cs_cdo_connect.h:72
cs_adjacency_t * c2v
Definition: cs_cdo_connect.h:119
cs_adjacency_t * e2v
Definition: cs_cdo_connect.h:82
int n_init_perio
Definition: cs_cdo_connect.h:62
cs_lnum_t n_vertices
Definition: cs_cdo_connect.h:67
cs_adjacency_t * f2e
Definition: cs_cdo_connect.h:97
cs_adjacency_t * e2e
Definition: cs_cdo_connect.h:145
fvm_element_t * cell_type
Definition: cs_cdo_connect.h:115
cs_adjacency_t * f2f_ed
Definition: cs_cdo_connect.h:143
cs_lnum_t n_edges
Definition: cs_cdo_connect.h:79
cs_interface_set_t * face_ifs
Definition: cs_cdo_connect.h:107
cs_adjacency_t * if2v
Definition: cs_cdo_connect.h:100
cs_adjacency_t * f2c
Definition: cs_cdo_connect.h:96
cs_adjacency_t * c2e
Definition: cs_cdo_connect.h:118
cs_interface_set_t * edge_ifs
Definition: cs_cdo_connect.h:89
cs_adjacency_t * bf2v
Definition: cs_cdo_connect.h:98
cs_adjacency_t * f2f
Definition: cs_cdo_connect.h:140
Definition: cs_mesh.h:85
Definition: cs_range_set.h:53