programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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-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 #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  * Transfer an existing global numbering structure to a nodal mesh.
184  *
185  * This assumes the local number of vertices is identical to that of
186  * the numberign structure.
187  *
188  * The argument pointer to the global numbering structure is set to NULL
189  * so the caller does not spuriously modify the structure after this call.
190  *
191  * A call to this function may be used instead of fvm_nodal_init_io_num
192  * (for vertices only).
193  *
194  * parameters:
195  * this_nodal <-- nodal mesh structure
196  * io_num <-> pointer to external numbering structure
197  * whose property is transferred to the mesh
198  * independent) parent entity numbers
199  *----------------------------------------------------------------------------*/
200 
201 void
202 fvm_nodal_transfer_vertex_io_num(fvm_nodal_t *this_nodal,
203  fvm_io_num_t **io_num);
204 
205 /*----------------------------------------------------------------------------
206  * Set entity tags (for non-vertex entities).
207  *
208  * The number of entities of the given dimension may be obtained
209  * through fvm_nodal_get_n_entities(), the tag[] array is populated
210  * in local section order, section by section).
211  *
212  * parameters:
213  * this_nodal <-- nodal mesh structure
214  * tag <-- tag values to assign
215  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges
216  *----------------------------------------------------------------------------*/
217 
218 void
219 fvm_nodal_set_tag(fvm_nodal_t *this_nodal,
220  const int tag[],
221  int entity_dim);
222 
223 /*----------------------------------------------------------------------------
224  * Remove entity tags.
225  *
226  * parameters:
227  * this_nodal <-- nodal mesh structure
228  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges
229  *----------------------------------------------------------------------------*/
230 
231 void
232 fvm_nodal_remove_tag(fvm_nodal_t *this_nodal,
233  int entity_dim);
234 
235 /*----------------------------------------------------------------------------
236  * Preset number and list of vertices to assign to a nodal mesh.
237  *
238  * If the parent_vertex_num argument is NULL, the list is assumed to
239  * be {1, 2, ..., n}. If parent_vertex_num is given, it specifies a
240  * list of n vertices from a larger set (1 to n numbering).
241  *
242  * Ownership of the given parent vertex numbering array is
243  * transferred to the nodal mesh representation structure.
244  *
245  * This function should be called before fvm_nodal_set_shared_vertices()
246  * or fvm_nodal_transfer_vertices() if we want to force certain
247  * vertices to appear in the mesh (especially if we want to define
248  * a mesh containing only vertices).
249  *
250  * parameters:
251  * this_nodal <-> nodal mesh structure
252  * n_vertices <-- number of vertices to assign
253  * parent_vertex_num <-- parent numbers of vertices to assign
254  *----------------------------------------------------------------------------*/
255 
256 void
257 fvm_nodal_define_vertex_list(fvm_nodal_t *this_nodal,
260 
261 /*----------------------------------------------------------------------------
262  * Assign shared vertex coordinates to an extracted nodal mesh,
263  * renumbering vertex numbers based on those really referenced,
264  * and updating connectivity arrays in accordance.
265  *
266  * This function should be called once all element sections have
267  * been added to a nodal mesh representation.
268  *
269  * parameters:
270  * this_nodal <-> nodal mesh structure
271  * vertex_coords <-- coordinates of parent vertices (interlaced)
272  *----------------------------------------------------------------------------*/
273 
274 void
275 fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal,
276  const cs_coord_t vertex_coords[]);
277 
278 /*----------------------------------------------------------------------------
279  * Assign private vertex coordinates to a nodal mesh,
280  * renumbering vertex numbers based on those really referenced,
281  * and updating connectivity arrays in accordance.
282  *
283  * Ownership of the given coordinates array is transferred to
284  * the nodal mesh representation structure.
285  *
286  * This function should only be called once all element sections
287  * have been added to a nodal mesh representation.
288  *
289  * parameters:
290  * this_nodal <-> nodal mesh structure
291  * vertex_coords <-- coordinates of parent vertices (interlaced)
292  *
293  * returns:
294  * updated pointer to vertex_coords (may be different from initial
295  * argument if vertices were renumbered).
296  *----------------------------------------------------------------------------*/
297 
298 cs_coord_t *
299 fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal,
301 
302 /*----------------------------------------------------------------------------
303  * Make vertex coordinates of a nodal mesh private.
304  *
305  * If vertex coordinates were previously shared, those coordinates that
306  * are actually references are copied, and the relation to parent vertices
307  * is discarded.
308  *
309  * If vertices were already private, the mesh is not modified.
310  *
311  * parameters:
312  * this_nodal <-> nodal mesh structure
313  *----------------------------------------------------------------------------*/
314 
315 void
316 fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal);
317 
318 /*----------------------------------------------------------------------------
319  * Assign group class set descriptions to a nodal mesh.
320  *
321  * The structure builds its own copy of the group class sets,
322  * renumbering them so as to discard those not referenced.
323  * Empty group classes are also renumbered to zero.
324  *
325  * This function should only be called once all element sections
326  * have been added to a nodal mesh representation.
327  *
328  * parameters:
329  * this_nodal <-> nodal mesh structure
330  * gc_set <-- group class set descriptions
331  *----------------------------------------------------------------------------*/
332 
333 void
334 fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal,
336 
337 /*----------------------------------------------------------------------------
338  * Assign global vertex labels to a nodal mesh.
339  *
340  * As these are expected to be used only for small sets (i.e. probes)
341  * where the point set is built from a global definition and data movement
342  * would add complexity and overhead, the labels refer to a global view
343  * on rank 0.
344  *
345  * The size of the labels pointers array should be the same as that
346  * returned by fvm_nodal_n_g_vertices();
347  *
348  * This function should only be called once the nodal mesh representation
349  * has been completed, as most functions modifying its vertex definitions
350  * will remove these labels.
351  *
352  * parameters:
353  * this_nodal <-> nodal mesh structure
354  * g_labels <-- global vertex labels, or NULL
355  *----------------------------------------------------------------------------*/
356 
357 void
358 fvm_nodal_transfer_global_vertex_labels(fvm_nodal_t *this_nodal,
359  char *g_labels[]);
360 
361 /*----------------------------------------------------------------------------
362  * Obtain the name of a nodal mesh.
363  *
364  * parameters:
365  * this_nodal <-- pointer to nodal mesh structure
366  *
367  * returns:
368  * pointer to constant string containing the mesh name
369  *----------------------------------------------------------------------------*/
370 
371 const char *
372 fvm_nodal_get_name(const fvm_nodal_t *this_nodal);
373 
374 /*----------------------------------------------------------------------------
375  * Return spatial dimension of the nodal mesh.
376  *
377  * parameters:
378  * this_nodal <-- pointer to nodal mesh structure
379  *
380  * returns:
381  * spatial dimension
382  *----------------------------------------------------------------------------*/
383 
384 int
385 fvm_nodal_get_dim(const fvm_nodal_t *this_nodal);
386 
387 /*----------------------------------------------------------------------------
388  * Return maximum dimension of entities in a nodal mesh.
389  *
390  * parameters:
391  * this_nodal <-- pointer to nodal mesh structure
392  *
393  * returns:
394  * maximum dimension of entities in mesh (0 to 3)
395  *----------------------------------------------------------------------------*/
396 
397 int
398 fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal);
399 
400 /*----------------------------------------------------------------------------
401  * Return number of entities of a given dimension in a nodal mesh.
402  *
403  * parameters:
404  * this_nodal <-- pointer to nodal mesh structure
405  * entity_dim <-- dimension of entities we want to count (0 to 3)
406  *
407  * returns:
408  * number of entities of given dimension in mesh
409  *----------------------------------------------------------------------------*/
410 
411 cs_lnum_t
412 fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal,
413  int entity_dim);
414 
415 /*----------------------------------------------------------------------------
416  * Return global number of vertices associated with nodal mesh.
417  *
418  * parameters:
419  * this_nodal <-- pointer to nodal mesh structure
420  *
421  * returns:
422  * global number of vertices associated with nodal mesh
423  *----------------------------------------------------------------------------*/
424 
425 cs_gnum_t
426 fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal);
427 
428 /*----------------------------------------------------------------------------
429  * Return global number of elements of a given type associated with nodal mesh.
430  *
431  * parameters:
432  * this_nodal <-- pointer to nodal mesh structure
433  * element_type <-- type of elements for query
434  *
435  * returns:
436  * global number of elements of the given type associated with nodal mesh
437  *----------------------------------------------------------------------------*/
438 
439 cs_gnum_t
440 fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal,
441  fvm_element_t element_type);
442 
443 /*----------------------------------------------------------------------------
444  * Return local number of elements of a given type associated with nodal mesh.
445  *
446  * parameters:
447  * this_nodal <-- pointer to nodal mesh structure
448  * element_type <-- type of elements for query
449  *
450  * returns:
451  * local number of elements of the given type associated with nodal mesh
452  *----------------------------------------------------------------------------*/
453 
454 cs_lnum_t
455 fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal,
456  fvm_element_t element_type);
457 
458 /*----------------------------------------------------------------------------
459  * Return local parent numbering array for all entities of a given
460  * dimension in a nodal mesh.
461  *
462  * The number of entities of the given dimension may be obtained
463  * through fvm_nodal_get_n_entities(), the parent_num[] array is populated
464  * with the parent entity numbers of those entities, in order (i.e. in
465  * local section order, section by section).
466  *
467  * parameters:
468  * this_nodal <-- pointer to nodal mesh structure
469  * entity_dim <-- dimension of entities we are interested in (0 to 3)
470  * parent_num --> entity parent numbering (array must be pre-allocated)
471  *----------------------------------------------------------------------------*/
472 
473 void
474 fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal,
475  int entity_dim,
476  cs_lnum_t parent_num[]);
477 
478 /*----------------------------------------------------------------------------
479  * Return pointer to global vertex labels of a nodal mesh.
480  *
481  * As these are expected to be used only for small sets (i.e. probes)
482  * where the point set is built from a global definition and data movement
483  * would adds complexity and overhead, the labels refer to a global view
484  * on rank 0; for the same reason, only shared labels are needed.
485  *
486  * The size of the labels pointers array returned should be the same
487  * as that returned by fvm_nodal_n_g_vertices();
488  *
489  * parameters:
490  * this_nodal <-> nodal mesh structure
491  *
492  * returns:
493  * pointer to global vertex labels, or NULL
494  *----------------------------------------------------------------------------*/
495 
496 const char **
497 fvm_nodal_get_global_vertex_labels(const fvm_nodal_t *this_nodal);
498 
499 /*----------------------------------------------------------------------------
500  * Compute tesselation a a nodal mesh's sections of a given type, and add the
501  * corresponding structure to the mesh representation.
502  *
503  * If global element numbers are used (i.e. in parallel mode), this function
504  * should be only be used after calling fvm_nodal_init_io_num().
505  *
506  * If some mesh sections have already been tesselated, their tesselation
507  * is unchanged.
508  *
509  * parameters:
510  * this_nodal <-> pointer to nodal mesh structure
511  * type <-> element type that should be tesselated
512  * error_count --> number of elements with a tesselation error
513  * counter (optional)
514  *----------------------------------------------------------------------------*/
515 
516 void
517 fvm_nodal_tesselate(fvm_nodal_t *this_nodal,
518  fvm_element_t type,
519  cs_lnum_t *error_count);
520 
521 /*----------------------------------------------------------------------------
522  * Build a nodal representation structure based on extraction of a
523  * mesh's edges.
524  *
525  * parameters:
526  * name <-- name to assign to extracted mesh
527  * this_nodal <-> pointer to nodal mesh structure
528  *----------------------------------------------------------------------------*/
529 
530 fvm_nodal_t *
531 fvm_nodal_copy_edges(const char *name,
532  const fvm_nodal_t *this_nodal);
533 
534 /*----------------------------------------------------------------------------
535  * Dump printout of a nodal representation structure.
536  *
537  * parameters:
538  * this_nodal <-- pointer to structure that should be dumped
539  *----------------------------------------------------------------------------*/
540 
541 void
542 fvm_nodal_dump(const fvm_nodal_t *this_nodal);
543 
544 /*----------------------------------------------------------------------------*/
545 
547 
548 #endif /* __FVM_NODAL_H__ */
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
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:1963
void fvm_nodal_remove_tag(fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1502
void fvm_nodal_transfer_vertex_io_num(fvm_nodal_t *this_nodal, fvm_io_num_t **io_num)
Definition: fvm_nodal.c:1455
Definition: fvm_nodal_priv.h:153
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
cs_coord_t * fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal, cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1614
void fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal, const fvm_group_class_set_t *gc_set)
Definition: fvm_nodal.c:1730
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:1534
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:1992
double cs_coord_t
Definition: cs_defs.h:294
void fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal, int entity_dim, cs_lnum_t parent_num[])
Definition: fvm_nodal.c:2025
void fvm_nodal_dump(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2461
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:1908
void fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal, const cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1568
void fvm_nodal_transfer_global_vertex_labels(fvm_nodal_t *this_nodal, char *g_labels[])
Definition: fvm_nodal.c:1825
void fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1673
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:1880
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:293
int fvm_nodal_get_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1864
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
struct _fvm_io_num_t fvm_io_num_t
Definition: fvm_io_num.h:72
fvm_nodal_t * fvm_nodal_create(const char *name, int dim)
Definition: fvm_nodal.c:1059
#define END_C_DECLS
Definition: cs_defs.h:454
const char * fvm_nodal_get_name(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1846
void fvm_nodal_tesselate(fvm_nodal_t *this_nodal, fvm_element_t type, cs_lnum_t *error_count)
Definition: fvm_nodal.c:2117
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:1477
cs_gnum_t fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1946
fvm_nodal_t * fvm_nodal_copy_edges(const char *name, const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2166
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:2092
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