programmer's documentation
fvm_nodal.h
Go to the documentation of this file.
1 #ifndef __FVM_NODAL_H__
2 #define __FVM_NODAL_H__
3 
4 /*============================================================================
5  * Main structure for a nodal representation associated with a mesh
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2016 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 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *----------------------------------------------------------------------------*/
35 
36 #include "fvm_defs.h"
37 #include "fvm_group.h"
38 #include "fvm_io_num.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*=============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*----------------------------------------------------------------------------
53  * Structure defining a mesh in nodal definition
54  *----------------------------------------------------------------------------*/
55 
56 typedef struct _fvm_nodal_t fvm_nodal_t;
57 
58 /*=============================================================================
59  * Static global variables
60  *============================================================================*/
61 
62 /* Number of vertices associated with each "nodal" element type */
63 
64 extern const int fvm_nodal_n_vertices_element[];
65 
66 /*=============================================================================
67  * Public function prototypes
68  *============================================================================*/
69 
70 /*----------------------------------------------------------------------------
71  * Creation of a nodal mesh representation structure.
72  *
73  * parameters:
74  * name <-- name that should be assigned to the nodal mesh
75  * dim <-- spatial dimension
76  *
77  * returns:
78  * pointer to created nodal mesh representation structure
79  *----------------------------------------------------------------------------*/
80 
81 fvm_nodal_t *
82 fvm_nodal_create(const char *name,
83  int dim);
84 
85 /*----------------------------------------------------------------------------
86  * Destruction of a nodal mesh representation structure.
87  *
88  * parameters:
89  * this_nodal <-> pointer to structure that should be destroyed
90  *
91  * returns:
92  * NULL pointer
93  *----------------------------------------------------------------------------*/
94 
95 fvm_nodal_t *
96 fvm_nodal_destroy(fvm_nodal_t *this_nodal);
97 
98 /*----------------------------------------------------------------------------
99  * Copy a nodal mesh representation structure, sharing arrays with the
100  * original structure.
101  *
102  * parameters:
103  * this_nodal <-> pointer to structure that should be copied
104  *
105  * returns:
106  * pointer to created nodal mesh representation structure
107  *----------------------------------------------------------------------------*/
108 
109 fvm_nodal_t *
110 fvm_nodal_copy(const fvm_nodal_t *this_nodal);
111 
112 /*----------------------------------------------------------------------------
113  * Reduction of a nodal mesh representation structure: only the associations
114  * (numberings) necessary to redistribution of fields for output are
115  * conserved, the full connectivity being in many cases no longer useful
116  * once it has been output. If the del_vertex_num value is set
117  * to true, vertex-based values may not be output in parallel mode
118  * after this function is called.
119  *
120  * parameters:
121  * this_nodal <-> pointer to structure that should be reduced
122  * del_vertex_num <-- indicates if vertex parent indirection and
123  * I/O numbering are destroyed (1) or not (0)
124  *----------------------------------------------------------------------------*/
125 
126 void
127 fvm_nodal_reduce(fvm_nodal_t *this_nodal,
128  int del_vertex_num);
129 
130 /*----------------------------------------------------------------------------
131  * Change entity parent numbering; this is useful when entities of the
132  * parent mesh have been renumbered after a nodal mesh representation
133  * structure's creation.
134  *
135  * parameters:
136  * this_nodal <-- nodal mesh structure
137  * new_parent_num <-- pointer to local parent renumbering array
138  * ({1, ..., n} <-- {1, ..., n})
139  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
140  * and 0 for vertices
141  *----------------------------------------------------------------------------*/
142 
143 void
144 fvm_nodal_change_parent_num(fvm_nodal_t *this_nodal,
145  const cs_lnum_t new_parent_num[],
146  int entity_dim);
147 
148 /*----------------------------------------------------------------------------
149  * Remove entity parent numbering; this is useful for example when we
150  * want to assign coordinates or fields to an extracted mesh using
151  * arrays relative to the mesh, and not to its parent.
152  *
153  * This is equivalent to calling fvm_nodal_change_parent_num(), with
154  * 'trivial' (1 o n) new_parent_num[] values.
155  *
156  * parameters:
157  * this_nodal <-- nodal mesh structure
158  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
159  * and 0 for vertices
160  *----------------------------------------------------------------------------*/
161 
162 void
163 fvm_nodal_remove_parent_num(fvm_nodal_t *this_nodal,
164  int entity_dim);
165 
166 /*----------------------------------------------------------------------------
167  * Build external numbering for entities based on global numbers.
168  *
169  * parameters:
170  * this_nodal <-- nodal mesh structure
171  * parent_global_number <-- pointer to list of global (i.e. domain splitting
172  * independent) parent entity numbers
173  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
174  * and 0 for vertices
175  *----------------------------------------------------------------------------*/
176 
177 void
178 fvm_nodal_init_io_num(fvm_nodal_t *this_nodal,
179  const cs_gnum_t parent_global_numbers[],
180  int entity_dim);
181 
182 /*----------------------------------------------------------------------------
183  * Set entity tags (for non-vertex entities).
184  *
185  * The number of entities of the given dimension may be obtained
186  * through fvm_nodal_get_n_entities(), the tag[] array is populated
187  * in local section order, section by section).
188  *
189  * parameters:
190  * this_nodal <-- nodal mesh structure
191  * tag <-- tag values to assign
192  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges
193  *----------------------------------------------------------------------------*/
194 
195 void
196 fvm_nodal_set_tag(fvm_nodal_t *this_nodal,
197  const int tag[],
198  int entity_dim);
199 
200 /*----------------------------------------------------------------------------
201  * Remove entity tags.
202  *
203  * parameters:
204  * this_nodal <-- nodal mesh structure
205  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges
206  *----------------------------------------------------------------------------*/
207 
208 void
209 fvm_nodal_remove_tag(fvm_nodal_t *this_nodal,
210  int entity_dim);
211 
212 /*----------------------------------------------------------------------------
213  * Preset number and list of vertices to assign to a nodal mesh.
214  *
215  * If the parent_vertex_num argument is NULL, the list is assumed to
216  * be {1, 2, ..., n}. If parent_vertex_num is given, it specifies a
217  * list of n vertices from a larger set (1 to n numbering).
218  *
219  * Ownership of the given parent vertex numbering array is
220  * transferred to the nodal mesh representation structure.
221  *
222  * This function should be called before fvm_nodal_set_shared_vertices()
223  * or fvm_nodal_transfer_vertices() if we want to force certain
224  * vertices to appear in the mesh (especially if we want to define
225  * a mesh containing only vertices).
226  *
227  * parameters:
228  * this_nodal <-> nodal mesh structure
229  * n_vertices <-- number of vertices to assign
230  * parent_vertex_num <-- parent numbers of vertices to assign
231  *----------------------------------------------------------------------------*/
232 
233 void
234 fvm_nodal_define_vertex_list(fvm_nodal_t *this_nodal,
237 
238 /*----------------------------------------------------------------------------
239  * Assign shared vertex coordinates to an extracted nodal mesh,
240  * renumbering vertex numbers based on those really referenced,
241  * and updating connectivity arrays in accordance.
242  *
243  * This function should be called once all element sections have
244  * been added to a nodal mesh representation.
245  *
246  * parameters:
247  * this_nodal <-> nodal mesh structure
248  * vertex_coords <-- coordinates of parent vertices (interlaced)
249  *----------------------------------------------------------------------------*/
250 
251 void
252 fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal,
253  const cs_coord_t vertex_coords[]);
254 
255 /*----------------------------------------------------------------------------
256  * Assign private vertex coordinates to a nodal mesh,
257  * renumbering vertex numbers based on those really referenced,
258  * and updating connectivity arrays in accordance.
259  *
260  * Ownership of the given coordinates array is transferred to
261  * the nodal mesh representation structure.
262  *
263  * This function should only be called once all element sections
264  * have been added to a nodal mesh representation.
265  *
266  * parameters:
267  * this_nodal <-> nodal mesh structure
268  * vertex_coords <-- coordinates of parent vertices (interlaced)
269  *
270  * returns:
271  * updated pointer to vertex_coords (may be different from initial
272  * argument if vertices were renumbered).
273  *----------------------------------------------------------------------------*/
274 
275 cs_coord_t *
276 fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal,
278 
279 /*----------------------------------------------------------------------------
280  * Make vertex coordinates of a nodal mesh private.
281  *
282  * If vertex coordinates were previously shared, those coordinates that
283  * are actually references are copied, and the relation to parent vertices
284  * is discarded.
285  *
286  * If vertices were already private, the mesh is not modified.
287  *
288  * parameters:
289  * this_nodal <-> nodal mesh structure
290  *----------------------------------------------------------------------------*/
291 
292 void
293 fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal);
294 
295 /*----------------------------------------------------------------------------
296  * Assign group class set descriptions to a nodal mesh.
297  *
298  * The structure builds its own copy of the group class sets,
299  * renumbering them so as to discard those not referenced.
300  * Empty group classes are also renumbered to zero.
301  *
302  * This function should only be called once all element sections
303  * have been added to a nodal mesh representation.
304  *
305  * parameters:
306  * this_nodal <-> nodal mesh structure
307  * gc_set <-- group class set descriptions
308  *----------------------------------------------------------------------------*/
309 
310 void
311 fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal,
313 
314 /*----------------------------------------------------------------------------
315  * Assign global vertex labels to a nodal mesh.
316  *
317  * As these are expected to be used only for small sets (i.e. probes)
318  * where the point set is built from a global definition and data movement
319  * would add complexity and overhead, the labels refer to a global view
320  * on rank 0.
321  *
322  * The size of the labels pointers array should be the same as that
323  * returned by fvm_nodal_n_g_vertices();
324  *
325  * This function should only be called once the nodal mesh representation
326  * has been completed, as most functions modifying its vertex definitions
327  * will remove these labels.
328  *
329  * parameters:
330  * this_nodal <-> nodal mesh structure
331  * g_labels <-- global vertex labels, or NULL
332  *----------------------------------------------------------------------------*/
333 
334 void
335 fvm_nodal_transfer_global_vertex_labels(fvm_nodal_t *this_nodal,
336  char *g_labels[]);
337 
338 /*----------------------------------------------------------------------------
339  * Obtain the name of a nodal mesh.
340  *
341  * parameters:
342  * this_nodal <-- pointer to nodal mesh structure
343  *
344  * returns:
345  * pointer to constant string containing the mesh name
346  *----------------------------------------------------------------------------*/
347 
348 const char *
349 fvm_nodal_get_name(const fvm_nodal_t *this_nodal);
350 
351 /*----------------------------------------------------------------------------
352  * Return spatial dimension of the nodal mesh.
353  *
354  * parameters:
355  * this_nodal <-- pointer to nodal mesh structure
356  *
357  * returns:
358  * spatial dimension
359  *----------------------------------------------------------------------------*/
360 
361 int
362 fvm_nodal_get_dim(const fvm_nodal_t *this_nodal);
363 
364 /*----------------------------------------------------------------------------
365  * Return maximum dimension of entities in a nodal mesh.
366  *
367  * parameters:
368  * this_nodal <-- pointer to nodal mesh structure
369  *
370  * returns:
371  * maximum dimension of entities in mesh (0 to 3)
372  *----------------------------------------------------------------------------*/
373 
374 int
375 fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal);
376 
377 /*----------------------------------------------------------------------------
378  * Return number of entities of a given dimension in a nodal mesh.
379  *
380  * parameters:
381  * this_nodal <-- pointer to nodal mesh structure
382  * entity_dim <-- dimension of entities we want to count (0 to 3)
383  *
384  * returns:
385  * number of entities of given dimension in mesh
386  *----------------------------------------------------------------------------*/
387 
388 cs_lnum_t
389 fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal,
390  int entity_dim);
391 
392 /*----------------------------------------------------------------------------
393  * Return global number of vertices associated with nodal mesh.
394  *
395  * parameters:
396  * this_nodal <-- pointer to nodal mesh structure
397  *
398  * returns:
399  * global number of vertices associated with nodal mesh
400  *----------------------------------------------------------------------------*/
401 
402 cs_gnum_t
403 fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal);
404 
405 /*----------------------------------------------------------------------------
406  * Return global number of elements of a given type associated with nodal mesh.
407  *
408  * parameters:
409  * this_nodal <-- pointer to nodal mesh structure
410  * element_type <-- type of elements for query
411  *
412  * returns:
413  * global number of elements of the given type associated with nodal mesh
414  *----------------------------------------------------------------------------*/
415 
416 cs_gnum_t
417 fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal,
418  fvm_element_t element_type);
419 
420 /*----------------------------------------------------------------------------
421  * Return local number of elements of a given type associated with nodal mesh.
422  *
423  * parameters:
424  * this_nodal <-- pointer to nodal mesh structure
425  * element_type <-- type of elements for query
426  *
427  * returns:
428  * local number of elements of the given type associated with nodal mesh
429  *----------------------------------------------------------------------------*/
430 
431 cs_lnum_t
432 fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal,
433  fvm_element_t element_type);
434 
435 /*----------------------------------------------------------------------------
436  * Return local parent numbering array for all entities of a given
437  * dimension in a nodal mesh.
438  *
439  * The number of entities of the given dimension may be obtained
440  * through fvm_nodal_get_n_entities(), the parent_num[] array is populated
441  * with the parent entity numbers of those entities, in order (i.e. in
442  * local section order, section by section).
443  *
444  * parameters:
445  * this_nodal <-- pointer to nodal mesh structure
446  * entity_dim <-- dimension of entities we are interested in (0 to 3)
447  * parent_num --> entity parent numbering (array must be pre-allocated)
448  *----------------------------------------------------------------------------*/
449 
450 void
451 fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal,
452  int entity_dim,
453  cs_lnum_t parent_num[]);
454 
455 /*----------------------------------------------------------------------------
456  * Return pointer to global vertex labels of a nodal mesh.
457  *
458  * As these are expected to be used only for small sets (i.e. probes)
459  * where the point set is built from a global definition and data movement
460  * would adds complexity and overhead, the labels refer to a global view
461  * on rank 0; for the same reason, only shared labels are needed.
462  *
463  * The size of the labels pointers array returned should be the same
464  * as that returned by fvm_nodal_n_g_vertices();
465  *
466  * parameters:
467  * this_nodal <-> nodal mesh structure
468  *
469  * returns:
470  * pointer to global vertex labels, or NULL
471  *----------------------------------------------------------------------------*/
472 
473 const char **
474 fvm_nodal_get_global_vertex_labels(const fvm_nodal_t *this_nodal);
475 
476 /*----------------------------------------------------------------------------
477  * Compute tesselation a a nodal mesh's sections of a given type, and add the
478  * corresponding structure to the mesh representation.
479  *
480  * If global element numbers are used (i.e. in parallel mode), this function
481  * should be only be used after calling fvm_nodal_init_io_num().
482  *
483  * If some mesh sections have already been tesselated, their tesselation
484  * is unchanged.
485  *
486  * parameters:
487  * this_nodal <-> pointer to nodal mesh structure
488  * type <-> element type that should be tesselated
489  * error_count --> number of elements with a tesselation error
490  * counter (optional)
491  *----------------------------------------------------------------------------*/
492 
493 void
494 fvm_nodal_tesselate(fvm_nodal_t *this_nodal,
495  fvm_element_t type,
496  cs_lnum_t *error_count);
497 
498 /*----------------------------------------------------------------------------
499  * Build a nodal representation structure based on extraction of a
500  * mesh's edges.
501  *
502  * parameters:
503  * name <-- name to assign to extracted mesh
504  * this_nodal <-> pointer to nodal mesh structure
505  *----------------------------------------------------------------------------*/
506 
507 fvm_nodal_t *
508 fvm_nodal_copy_edges(const char *name,
509  const fvm_nodal_t *this_nodal);
510 
511 /*----------------------------------------------------------------------------
512  * Dump printout of a nodal representation structure.
513  *
514  * parameters:
515  * this_nodal <-- pointer to structure that should be dumped
516  *----------------------------------------------------------------------------*/
517 
518 void
519 fvm_nodal_dump(const fvm_nodal_t *this_nodal);
520 
521 /*----------------------------------------------------------------------------*/
522 
524 
525 #endif /* __FVM_NODAL_H__ */
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:280
void fvm_nodal_reduce(fvm_nodal_t *this_nodal, int del_vertex_num)
Definition: fvm_nodal.c:1250
fvm_nodal_t * fvm_nodal_copy(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1173
cs_gnum_t fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal, fvm_element_t element_type)
Definition: fvm_nodal.c:1935
void fvm_nodal_remove_tag(fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1474
Definition: fvm_nodal_priv.h:153
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
cs_coord_t * fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal, cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1586
void fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal, const fvm_group_class_set_t *gc_set)
Definition: fvm_nodal.c:1702
const cs_coord_t * vertex_coords
Definition: fvm_nodal_priv.h:177
void fvm_nodal_define_vertex_list(fvm_nodal_t *this_nodal, cs_lnum_t n_vertices, cs_lnum_t parent_vertex_num[])
Definition: fvm_nodal.c:1506
char * name
Definition: fvm_nodal_priv.h:158
cs_lnum_t fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal, fvm_element_t element_type)
Definition: fvm_nodal.c:1964
double cs_coord_t
Definition: cs_defs.h:293
void fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal, int entity_dim, cs_lnum_t parent_num[])
Definition: fvm_nodal.c:1997
void fvm_nodal_dump(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2433
fvm_nodal_t * fvm_nodal_destroy(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1117
fvm_element_t
Definition: fvm_defs.h:48
cs_lnum_t fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1880
void fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal, const cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1540
void fvm_nodal_transfer_global_vertex_labels(fvm_nodal_t *this_nodal, char *g_labels[])
Definition: fvm_nodal.c:1797
void fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1645
cs_lnum_t n_vertices
Definition: fvm_nodal_priv.h:172
void fvm_nodal_remove_parent_num(fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1361
int fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1852
fvm_group_class_set_t * gc_set
Definition: fvm_nodal_priv.h:213
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
int fvm_nodal_get_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1836
const cs_lnum_t * parent_vertex_num
Definition: fvm_nodal_priv.h:183
const int fvm_nodal_n_vertices_element[]
Definition: fvm_nodal.c:68
fvm_nodal_t * fvm_nodal_create(const char *name, int dim)
Definition: fvm_nodal.c:1059
#define END_C_DECLS
Definition: cs_defs.h:449
const char * fvm_nodal_get_name(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1818
void fvm_nodal_tesselate(fvm_nodal_t *this_nodal, fvm_element_t type, cs_lnum_t *error_count)
Definition: fvm_nodal.c:2089
struct _fvm_group_class_set_t fvm_group_class_set_t
Definition: fvm_group.h:60
void fvm_nodal_set_tag(fvm_nodal_t *this_nodal, const int tag[], int entity_dim)
Definition: fvm_nodal.c:1449
cs_gnum_t fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1918
fvm_nodal_t * fvm_nodal_copy_edges(const char *name, const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2138
int dim
Definition: fvm_nodal_priv.h:160
const char ** fvm_nodal_get_global_vertex_labels(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2064
void fvm_nodal_init_io_num(fvm_nodal_t *this_nodal, const cs_gnum_t parent_global_numbers[], int entity_dim)
Definition: fvm_nodal.c:1404
void fvm_nodal_change_parent_num(fvm_nodal_t *this_nodal, const cs_lnum_t new_parent_num[], int entity_dim)
Definition: fvm_nodal.c:1306