9.1
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-2025 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 "cdo/cs_flag.h"
38#include "base/cs_param_types.h"
39#include "mesh/cs_mesh.h"
41#include "base/cs_range_set.h"
42
43/*----------------------------------------------------------------------------*/
44
46
47/*============================================================================
48 * Macro definitions
49 *============================================================================*/
50
51/* Additional macros */
52
53#define CS_TRIANGLE_CASE 3 /* Number of vertices in a triangle */
54
55/*============================================================================
56 * Type definitions
57 *============================================================================*/
58
59/* Connectivity structure */
60
61typedef struct {
62
63 /* Periodicity (copy from cs_mesh_t. Stored here to avoid to point to the
64 mesh structure in many functions) */
65
67
68 /* Vertex-related members */
69 /* ---------------------- */
70
72
73 /* range set and interface set structures for scalar-valued vertex DoFs
74 (these structures may be not allocated according to the settings) */
75
78
79
80 /* Edge-related members */
81 /* -------------------- */
82
85
86 cs_adjacency_t *e2v; /* edge --> vertices connectivity */
87 cs_adjacency_t *e2f; /* edge --> faces connectivity */
88
89 /* range set and interface set structures for scalar-valued edge DoFs
90 (these structures may be not allocated according to the settings) */
91
94
95 /* Face-related members */
96 /* -------------------- */
97
98 cs_lnum_t n_faces[3]; /* 0: all, 1: border, 2: interior */
99
100 cs_adjacency_t *f2c; /* face --> cells connectivity */
101 cs_adjacency_t *f2e; /* face --> edges connectivity */
102 cs_adjacency_t *bf2v; /* border face --> vertices connectivity
103 (map from cs_mesh_t) */
104 cs_adjacency_t *if2v; /* interior face --> vertices connectivity
105 (map from cs_mesh_t) */
106
107 /* range set and interface set structures for scalar-valued edge DoFs
108 (these structures may be not allocated according to the settings) */
109
112
113 /* Cell-related members */
114 /* -------------------- */
115
118
119 fvm_element_t *cell_type; /* type of cell */
120 cs_flag_t *cell_flag; /* flag (border/solid) */
121 cs_adjacency_t *c2f; /* cell --> faces connectivity */
122 cs_adjacency_t *c2e; /* cell --> edges connectivity */
123 cs_adjacency_t *c2v; /* cell --> vertices connectivity */
124
125 /* Delta of ids between the min./max. values of entities related to a cell
126 Useful to store compactly the link between mesh ids and cell mesh ids
127 needed during the cell mesh definition */
128
131
132 /* Max. connectitivy size for cells */
133
134 int n_max_vbyc; /* max. number of vertices in a cell */
135 int n_max_ebyc; /* max. number of edges in a cell */
136 int n_max_fbyc; /* max. number of faces in a cell */
137 int n_max_vbyf; /* max. number of vertices in a face */
138 int n_max_v2fc; /* max. number of faces connected to a vertex in a cell */
139 int n_max_v2ec; /* max. number of edges connected to a vertex in a cell */
140
141 /* Adjacency related to linear systems (allocated only if needed) */
142
143 cs_adjacency_t *v2v; /* vertex to vertices through cells */
144 cs_adjacency_t *f2f; /* face to faces through cells */
145 cs_adjacency_t *f2xf; /* face to extended faces through cells + edges
146 * for MAC scheme */
147 cs_adjacency_t *f2f_ed; /* face to faces through edges + same directions
148 * for MAC scheme */
149 cs_adjacency_t *e2e; /* edge to edges through cells */
150
152
153/*============================================================================
154 * Global variables
155 *============================================================================*/
156
157/*============================================================================
158 * Static Inline Public function prototypes
159 *============================================================================*/
160
161/*----------------------------------------------------------------------------*/
173/*----------------------------------------------------------------------------*/
174
175static inline void
177 const cs_lnum_t *e2v_ids,
178 const cs_lnum_t start_idx,
179 cs_lnum_t *v0,
180 cs_lnum_t *v1,
181 cs_lnum_t *v2)
182{
183 const cs_lnum_t _2e0 = 2*f2e_ids[start_idx],
184 _2e1 = 2*f2e_ids[start_idx+1];
185 const cs_lnum_t tmp = e2v_ids[_2e1];
186
187 *v0 = e2v_ids[_2e0];
188 *v1 = e2v_ids[_2e0+1];
189 *v2 = ((tmp != *v0) && (tmp != *v1)) ? tmp : e2v_ids[_2e1+1];
190}
191
192/*============================================================================
193 * Public function prototypes
194 *============================================================================*/
195
196/*----------------------------------------------------------------------------*/
215/*----------------------------------------------------------------------------*/
216
218 cs_flag_t eb_scheme_flag,
219 cs_flag_t fb_scheme_flag,
220 cs_flag_t cb_scheme_flag,
221 cs_flag_t vb_scheme_flag,
222 cs_flag_t vcb_scheme_flag,
223 cs_flag_t hho_scheme_flag,
224 cs_flag_t mac_scheme_flag);
225
226/*----------------------------------------------------------------------------*/
235/*----------------------------------------------------------------------------*/
236
239 cs_cdo_connect_t *connect);
240
241/*----------------------------------------------------------------------------*/
250/*----------------------------------------------------------------------------*/
251
252void
254 cs_flag_t eb_scheme_flag,
255 cs_flag_t vb_scheme_flag,
256 cs_flag_t vcb_scheme_flag);
257
258/*----------------------------------------------------------------------------*/
264/*----------------------------------------------------------------------------*/
265
266void
268
269/*----------------------------------------------------------------------------*/
273/*----------------------------------------------------------------------------*/
274
275void
277
278/*----------------------------------------------------------------------------*/
287/*----------------------------------------------------------------------------*/
288
289double *
291
292/*----------------------------------------------------------------------------*/
298/*----------------------------------------------------------------------------*/
299
300long long
302
303/*----------------------------------------------------------------------------*/
314/*----------------------------------------------------------------------------*/
315
316void
318 int n_vtx_dofs,
319 bool interlaced,
320 cs_interface_set_t **p_ifs,
321 cs_range_set_t **p_rs);
322
323/*----------------------------------------------------------------------------*/
334/*----------------------------------------------------------------------------*/
335
336void
338 cs_lnum_t n_faces,
339 int n_face_dofs,
340 cs_interface_set_t **p_ifs,
341 cs_range_set_t **p_rs);
342
343/*----------------------------------------------------------------------------*/
351/*----------------------------------------------------------------------------*/
352
355
356/*----------------------------------------------------------------------------*/
367/*----------------------------------------------------------------------------*/
368
369void
371 const cs_real_t *edge_values,
372 cs_real_t **p_curl_values);
373
374/*----------------------------------------------------------------------------*/
380/*----------------------------------------------------------------------------*/
381
382void
384
385/*----------------------------------------------------------------------------*/
386
388
389#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:1637
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:1428
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:1535
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:1064
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:1256
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:1595
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:1315
void cs_cdo_connect_free_cw_buffer(void)
Free the cell-wise buffer(s)
Definition: cs_cdo_connect.cpp:1469
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:1501
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:176
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:1516
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:555
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
unsigned short int cs_flag_t
Definition: cs_defs.h:359
struct _cs_interface_set_t cs_interface_set_t
Definition: cs_interface.h:61
fvm_element_t
Definition: fvm_defs.h:48
Definition: mesh.f90:26
Definition: cs_mesh_adjacencies.h:68
Definition: cs_cdo_connect.h:61
cs_lnum_t v_max_cell_range
Definition: cs_cdo_connect.h:130
cs_gnum_t n_g_edges
Definition: cs_cdo_connect.h:84
int n_max_v2fc
Definition: cs_cdo_connect.h:138
cs_flag_t * cell_flag
Definition: cs_cdo_connect.h:120
int n_max_fbyc
Definition: cs_cdo_connect.h:136
cs_adjacency_t * v2v
Definition: cs_cdo_connect.h:143
cs_interface_set_t * vtx_ifs
Definition: cs_cdo_connect.h:77
int n_max_ebyc
Definition: cs_cdo_connect.h:135
int n_max_vbyc
Definition: cs_cdo_connect.h:134
cs_adjacency_t * c2f
Definition: cs_cdo_connect.h:121
int n_max_v2ec
Definition: cs_cdo_connect.h:139
cs_adjacency_t * e2f
Definition: cs_cdo_connect.h:87
int n_max_vbyf
Definition: cs_cdo_connect.h:137
cs_adjacency_t * f2xf
Definition: cs_cdo_connect.h:145
cs_range_set_t * face_rset
Definition: cs_cdo_connect.h:110
cs_range_set_t * edge_rset
Definition: cs_cdo_connect.h:92
cs_lnum_t e_max_cell_range
Definition: cs_cdo_connect.h:129
cs_lnum_t n_cells_with_ghosts
Definition: cs_cdo_connect.h:117
cs_lnum_t n_cells
Definition: cs_cdo_connect.h:116
cs_range_set_t * vtx_rset
Definition: cs_cdo_connect.h:76
cs_adjacency_t * c2v
Definition: cs_cdo_connect.h:123
cs_adjacency_t * e2v
Definition: cs_cdo_connect.h:86
int n_init_perio
Definition: cs_cdo_connect.h:66
cs_lnum_t n_vertices
Definition: cs_cdo_connect.h:71
cs_adjacency_t * f2e
Definition: cs_cdo_connect.h:101
cs_adjacency_t * e2e
Definition: cs_cdo_connect.h:149
fvm_element_t * cell_type
Definition: cs_cdo_connect.h:119
cs_adjacency_t * f2f_ed
Definition: cs_cdo_connect.h:147
cs_lnum_t n_edges
Definition: cs_cdo_connect.h:83
cs_interface_set_t * face_ifs
Definition: cs_cdo_connect.h:111
cs_adjacency_t * if2v
Definition: cs_cdo_connect.h:104
cs_adjacency_t * f2c
Definition: cs_cdo_connect.h:100
cs_adjacency_t * c2e
Definition: cs_cdo_connect.h:122
cs_interface_set_t * edge_ifs
Definition: cs_cdo_connect.h:93
cs_adjacency_t * bf2v
Definition: cs_cdo_connect.h:102
cs_adjacency_t * f2f
Definition: cs_cdo_connect.h:144
Definition: cs_mesh.h:85
Definition: cs_range_set.h:57