9.2
general documentation
cs_renumber.h
Go to the documentation of this file.
1#ifndef CS_RENUMBER_H
2#define CS_RENUMBER_H
3
4/*============================================================================
5 * Optional mesh renumbering
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 "base/cs_base.h"
35#include "mesh/cs_mesh.h"
36
37/*============================================================================
38 * Macro definitions
39 *============================================================================*/
40
41/*============================================================================
42 * Type definitions
43 *============================================================================*/
44
45/* Renumbering algorithms */
46
48typedef enum {
49
67
69typedef enum {
70
85
87typedef enum {
88
97
99typedef enum {
100
106
107/* Ordering options for adjacency arrays */
108
110typedef enum {
116
117/*=============================================================================
118 * Public function prototypes
119 *============================================================================*/
120
121/*----------------------------------------------------------------------------
122 * Set the target number of threads for mesh renumbering.
123 *
124 * By default, the target number of threads is set to cs_glob_n_threads,
125 * but the value may be forced using this function. This is mainly useful
126 * for testing purposes.
127 *
128 * parameters:
129 * n_threads <-- target number of threads for mesh numbering
130 *----------------------------------------------------------------------------*/
131
132void
133cs_renumber_set_n_threads(int n_threads);
134
135/*----------------------------------------------------------------------------
136 * Return the target number of threads for mesh renumbering.
137 *
138 * returns:
139 * the target number of threads for mesh numbering
140 *----------------------------------------------------------------------------*/
141
142int
144
145/*----------------------------------------------------------------------------
146 * Set the minimum sunset sizes when renumbering for threads.
147 *
148 * parameters:
149 * min_i_subset_size <-- minimum number of interior faces per
150 * thread per group
151 * min_b_subset_size <-- minimum number of boundary faces per
152 * thread per group
153 *----------------------------------------------------------------------------*/
154
155void
157 cs_lnum_t min_b_subset_size);
158
159/*----------------------------------------------------------------------------
160 * Get the minimum sunset sizes when renumbering for threads.
161 *
162 * min_i_subset_size --> minimum number of interior faces per
163 * thread per group, or NULL
164 * min_b_subset_size --> minimum number of boundary faces per
165 * thread per group, or NULL
166 *----------------------------------------------------------------------------*/
167
168void
170 cs_lnum_t *min_b_subset_size);
171
172/*----------------------------------------------------------------------------*/
173/*
174 * \brief Set the relaxtion factor for rebalancing with the
175 * multipass algorithm.
176 *
177 * A relaxation factor of 0 disables rebalancing.
178 *
179 * Depending on the mesh numbering, rebalancing may interfere with the
180 * multigrid algorithm's coarsening, especially in the presence of
181 * cell renumbering. In some cases, the coarsening will be less constrained
182 * and lead to better aggregation (and performance) when combining
183 * cells renumbering and multipass interior faces renumbering with no
184 * reblancing (i. e. with a relaxation factor of 0).
185 *
186 * \param[in] relaxation factor multipass renumbering rebalance step
187 * relaxation factor.
188 */
189/*----------------------------------------------------------------------------*/
190
191void
192cs_renumber_set_multipass_rebalance_factor(float relaxation_factor);
193
194/*----------------------------------------------------------------------------*/
201/*----------------------------------------------------------------------------*/
202
203float
205
206/*----------------------------------------------------------------------------*/
207/*
208 * \brief Select the algorithm for mesh renumbering.
209 *
210 * \param[in] halo_adjacent_cells_last if true, cells adjacent to ghost cells
211 * will be placed last
212 * (after pre-numbering)
213 * \param[in] halo_adjacent_faces_last if true, interior faces adjacent to
214 * ghost cells will be placed last
215 * (after pre-numbering)
216 * \param[in] i_faces_base_ordering pre-ordering of interior faces by
217 * lowest or highest adjacent cell id
218 * \param[in] cells_pre_numbering algorithm for cells pre-numbering
219 * \param[in] cells_numbering algorithm for cells numbering
220 * \param[in] i_faces_numbering algorithm for interior faces numbering
221 * \param[in] b_faces_numbering algorithm for boundary faces numbering
222 * \param[in] vertices_numbering algorithm for vertices numbering
223 */
224/*----------------------------------------------------------------------------*/
225
226void
227cs_renumber_set_algorithm(bool halo_adjacent_cells_last,
228 bool halo_adjacent_faces_last,
229 cs_renumber_ordering_t i_faces_base_ordering,
230 cs_renumber_cells_type_t cells_pre_numbering,
231 cs_renumber_cells_type_t cells_numbering,
232 cs_renumber_i_faces_type_t i_faces_numbering,
233 cs_renumber_b_faces_type_t b_faces_numbering,
234 cs_renumber_vertices_type_t vertices_numbering);
235
236/*----------------------------------------------------------------------------*/
237/*
238 * \brief Return the algorithms for mesh renumbering.
239 *
240 * Any argument may be passed NULL if this option is not queried.
241 *
242 * \param[out] halo_adjacent_cells_last if true, cells adjacent to ghost cells
243 * will be placed last
244 * (after pre-numbering)
245 * \param[out] halo_adjacent_faces_last if true, interior faces adjacent to
246 * ghost cells will be placed last
247 * (after pre-numbering)
248 * \param[out] i_faces_base_ordering pre-ordering of interior faces by
249 * lowest or highest adjacent cell id
250 * \param[out] cells_pre_numbering algorithm for cells pre-numbering
251 * \param[out] cells_numbering algorithm for cells numbering
252 * \param[out] i_faces_numbering algorithm for interior faces numbering
253 * \param[out] b_faces_numbering algorithm for boundary faces numbering
254 * \param[out] vertices_numbering algorithm for vertices numbering
255 */
256/*----------------------------------------------------------------------------*/
257
258void
259cs_renumber_get_algorithm(bool *halo_adjacent_cells_last,
260 bool *halo_adjacent_faces_last,
261 cs_renumber_ordering_t *i_faces_base_ordering,
262 cs_renumber_cells_type_t *cells_pre_numbering,
263 cs_renumber_cells_type_t *cells_numbering,
264 cs_renumber_i_faces_type_t *i_faces_numbering,
265 cs_renumber_b_faces_type_t *b_faces_numbering,
266 cs_renumber_vertices_type_t *vertices_numbering);
267
268/*----------------------------------------------------------------------------
269 * Renumber mesh elements for vectorization or threading depending on code
270 * options and target machine.
271 *
272 * Renumbering cells may also allow improving locality (and favor faces
273 * renumbering).
274 * It is also possible to place cells connected to ghost cells last,
275 * which may be useful to enable computation/communication overlap.
276 *
277 * If new_to_old pointers are provided, the new to old mappings will
278 * be passed to this pointer. The caller then takes ownership and is
279 * responsible for freeing them
280 *
281 * parameters:
282 * mesh <-> pointer to global mesh structure
283 * cell_n2o <-> pointer to new to old cells array, or nullptr
284 * i_face_n2o <-> pointer to new to old interior faces array, or nullptr
285 * b_face_n2o <-> pointer to new to old boundary faces array, or nullptr
286 * vtx_n2o <-> pointer to new to old vertices array, or nullptr
287 *----------------------------------------------------------------------------*/
288
289void
291 cs_lnum_t **cell_n2o,
292 cs_lnum_t **i_face_n2o,
293 cs_lnum_t **b_face_n2o,
294 cs_lnum_t **vtx_n2o);
295
296/*----------------------------------------------------------------------------*/
305/*----------------------------------------------------------------------------*/
306
307void
309
310/*----------------------------------------------------------------------------
311 * Renumber interior faces for vectorization or threading depending on code
312 * options and target machine.
313 *
314 * parameters:
315 * mesh <-> pointer to global mesh structure
316 *----------------------------------------------------------------------------*/
317
318void
320
321/*----------------------------------------------------------------------------
322 * Renumber interior faces by global number.
323 *
324 * This effectively resets the interior faces to their initial numbering.
325 *
326 * parameters:
327 * mesh <-> pointer to global mesh structure
328 *----------------------------------------------------------------------------*/
329
330void
332
333/*----------------------------------------------------------------------------
334 * Renumber boundary faces for vectorization or threading depending on code
335 * options and target machine.
336 *
337 * parameters:
338 * mesh <-> pointer to global mesh structure
339 *----------------------------------------------------------------------------*/
340
341void
343
344/*----------------------------------------------------------------------------
345 * Renumber boundary faces by global number.
346 *
347 * This effectively resets the boundary faces to their initial numbering.
348 *
349 * parameters:
350 * mesh <-> pointer to global mesh structure
351 *----------------------------------------------------------------------------*/
352
353void
355
356/*----------------------------------------------------------------------------*/
369/*----------------------------------------------------------------------------*/
370
371void
373 cs_lnum_t n_faces,
374 const cs_lnum_t face_ids[]);
375
376/*----------------------------------------------------------------------------*/
385/*----------------------------------------------------------------------------*/
386
387void
389
390/*----------------------------------------------------------------------------*/
391
392#endif /* CS_RENUMBER_H */
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
void cs_renumber_mesh(cs_mesh_t *mesh, cs_lnum_t **cell_n2o, cs_lnum_t **i_face_n2o, cs_lnum_t **b_face_n2o, cs_lnum_t **vtx_n2o)
Renumber mesh elements for vectorization or threading depending on code options and target machine.
Definition: cs_renumber.cpp:5925
void cs_renumber_get_min_subset_size(cs_lnum_t *min_i_subset_size, cs_lnum_t *min_b_subset_size)
Get the minimum sunset sizes when renumbering for threads.
Definition: cs_renumber.cpp:5759
void cs_renumber_set_n_threads(int n_threads)
Set the target number of threads for mesh renumbering.
Definition: cs_renumber.cpp:5699
void cs_renumber_b_faces(cs_mesh_t *mesh)
Renumber boundary faces for vectorization or threading depending on code options and target machine.
Definition: cs_renumber.cpp:6089
cs_renumber_i_faces_type_t
Definition: cs_renumber.h:69
@ CS_RENUMBER_I_FACES_BLOCK
Definition: cs_renumber.h:71
@ CS_RENUMBER_I_FACES_SIMD
Definition: cs_renumber.h:78
@ CS_RENUMBER_I_FACES_NONE
Definition: cs_renumber.h:82
@ CS_RENUMBER_I_FACES_MULTIPASS
Definition: cs_renumber.h:74
void cs_renumber_set_algorithm(bool halo_adjacent_cells_last, bool halo_adjacent_faces_last, cs_renumber_ordering_t i_faces_base_ordering, cs_renumber_cells_type_t cells_pre_numbering, cs_renumber_cells_type_t cells_numbering, cs_renumber_i_faces_type_t i_faces_numbering, cs_renumber_b_faces_type_t b_faces_numbering, cs_renumber_vertices_type_t vertices_numbering)
Select the algorithm for mesh renumbering.
Definition: cs_renumber.cpp:5829
void cs_renumber_b_faces_select_ignore(cs_mesh_t *mesh, cs_lnum_t n_faces, const cs_lnum_t face_ids[])
Renumber boundary faces such that selected faces appear last and will be ignored.
Definition: cs_renumber.cpp:6177
void cs_renumber_set_multipass_rebalance_factor(float relaxation_factor)
Set the relaxtion factor for rebalancing with the multipass algorithm.
Definition: cs_renumber.cpp:5788
void cs_renumber_i_faces_by_gnum(cs_mesh_t *mesh)
Definition: cs_renumber.cpp:6053
cs_renumber_ordering_t
Definition: cs_renumber.h:110
@ CS_RENUMBER_ADJACENT_HIGH
Definition: cs_renumber.h:113
@ CS_RENUMBER_ADJACENT_LOW
Definition: cs_renumber.h:111
cs_renumber_cells_type_t
Definition: cs_renumber.h:48
@ CS_RENUMBER_CELLS_SCOTCH_ORDER
Definition: cs_renumber.h:52
@ CS_RENUMBER_CELLS_SCOTCH_PART
Definition: cs_renumber.h:50
@ CS_RENUMBER_CELLS_METIS_PART
Definition: cs_renumber.h:54
@ CS_RENUMBER_CELLS_HILBERT
Definition: cs_renumber.h:60
@ CS_RENUMBER_CELLS_METIS_ORDER
Definition: cs_renumber.h:56
@ CS_RENUMBER_CELLS_RCM
Definition: cs_renumber.h:62
@ CS_RENUMBER_CELLS_NONE
Definition: cs_renumber.h:64
@ CS_RENUMBER_CELLS_MORTON
Definition: cs_renumber.h:58
cs_renumber_vertices_type_t
Definition: cs_renumber.h:99
@ CS_RENUMBER_VERTICES_NONE
Definition: cs_renumber.h:103
@ CS_RENUMBER_VERTICES_BY_FACE_ADJ
Definition: cs_renumber.h:102
@ CS_RENUMBER_VERTICES_BY_CELL_ADJ
Definition: cs_renumber.h:101
float cs_renumber_get_multipass_rebalance_factor(void)
Get the relaxtion factor for rebalancing with the multipass algorithm.
Definition: cs_renumber.cpp:5803
cs_renumber_b_faces_type_t
Definition: cs_renumber.h:87
@ CS_RENUMBER_B_FACES_NONE
Definition: cs_renumber.h:94
@ CS_RENUMBER_B_FACES_SIMD
Definition: cs_renumber.h:92
@ CS_RENUMBER_B_FACES_THREAD
Definition: cs_renumber.h:89
void cs_renumber_b_faces_by_gnum(cs_mesh_t *mesh)
Definition: cs_renumber.cpp:6135
void cs_renumber_cells(cs_mesh_t *mesh)
Renumber cells depending on code options and target machine.
Definition: cs_renumber.cpp:5957
void cs_renumber_get_algorithm(bool *halo_adjacent_cells_last, bool *halo_adjacent_faces_last, cs_renumber_ordering_t *i_faces_base_ordering, cs_renumber_cells_type_t *cells_pre_numbering, cs_renumber_cells_type_t *cells_numbering, cs_renumber_i_faces_type_t *i_faces_numbering, cs_renumber_b_faces_type_t *b_faces_numbering, cs_renumber_vertices_type_t *vertices_numbering)
Return the algorithms for mesh renumbering.
Definition: cs_renumber.cpp:5872
void cs_renumber_set_min_subset_size(cs_lnum_t min_i_subset_size, cs_lnum_t min_b_subset_size)
Set the minimum sunset sizes when renumbering for threads.
Definition: cs_renumber.cpp:5740
int cs_renumber_get_n_threads(void)
Return the target number of threads for mesh renumbering.
Definition: cs_renumber.cpp:5720
void cs_renumber_vertices(cs_mesh_t *mesh)
Renumber vertices depending on code options and target machine.
Definition: cs_renumber.cpp:6325
void cs_renumber_i_faces(cs_mesh_t *mesh)
Renumber interior faces for vectorization or threading depending on code options and target machine.
Definition: cs_renumber.cpp:6007
Definition: mesh.f90:26
Definition: cs_mesh.h:85