Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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-2012 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_defs.h"
35 #include "fvm_group.h"
36 #include "fvm_io_num.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #if 0
43 } /* Fake brace to force back Emacs auto-indentation back to column 0 */
44 #endif
45 #endif /* __cplusplus */
46 
47 /*=============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Type definitions
53  *============================================================================*/
54 
55 /*----------------------------------------------------------------------------
56  * Structure defining a mesh in nodal definition
57  *----------------------------------------------------------------------------*/
58 
59 typedef struct _fvm_nodal_t fvm_nodal_t;
60 
61 /*=============================================================================
62  * Static global variables
63  *============================================================================*/
64 
65 /* Number of vertices associated with each "nodal" element type */
66 
67 extern const int fvm_nodal_n_vertices_element[];
68 
69 /*=============================================================================
70  * Public function prototypes
71  *============================================================================*/
72 
73 /*----------------------------------------------------------------------------
74  * Creation of a nodal mesh representation structure.
75  *
76  * parameters:
77  * name <-- name that should be assigned to the nodal mesh
78  * dim <-- spatial dimension
79  *
80  * returns:
81  * pointer to created nodal mesh representation structure
82  *----------------------------------------------------------------------------*/
83 
85 fvm_nodal_create(const char *name,
86  int dim);
87 
88 /*----------------------------------------------------------------------------
89  * Destruction of a nodal mesh representation structure.
90  *
91  * parameters:
92  * this_nodal <-> pointer to structure that should be destroyed
93  *
94  * returns:
95  * NULL pointer
96  *----------------------------------------------------------------------------*/
97 
99 fvm_nodal_destroy(fvm_nodal_t *this_nodal);
100 
101 /*----------------------------------------------------------------------------
102  * Copy a nodal mesh representation structure, sharing arrays with the
103  * original structure.
104  *
105  * parameters:
106  * this_nodal <-> pointer to structure that should be copied
107  *
108  * returns:
109  * pointer to created nodal mesh representation structure
110  *----------------------------------------------------------------------------*/
111 
112 fvm_nodal_t *
113 fvm_nodal_copy(const fvm_nodal_t *this_nodal);
114 
115 /*----------------------------------------------------------------------------
116  * Reduction of a nodal mesh representation structure: only the associations
117  * (numberings) necessary to redistribution of fields for output are
118  * conserved, the full connectivity being in many cases no longer useful
119  * once it has been output. If the del_vertex_num value is set
120  * to true, vertex-based values may not be output in parallel mode
121  * after this function is called.
122  *
123  * parameters:
124  * this_nodal <-> pointer to structure that should be reduced
125  * del_vertex_num <-- indicates if vertex parent indirection and
126  * I/O numbering are destroyed (1) or not (0)
127  *----------------------------------------------------------------------------*/
128 
129 void
130 fvm_nodal_reduce(fvm_nodal_t *this_nodal,
131  int del_vertex_num);
132 
133 /*----------------------------------------------------------------------------
134  * Change entity parent numbering; this is useful when entities of the
135  * parent mesh have been renumbered after a nodal mesh representation
136  * structure's creation.
137  *
138  * parameters:
139  * this_nodal <-- nodal mesh structure
140  * new_parent_num <-- pointer to local parent renumbering array
141  * ({1, ..., n} <-- {1, ..., n})
142  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
143  * and 0 for vertices
144  *----------------------------------------------------------------------------*/
145 
146 void
148  const cs_lnum_t new_parent_num[],
149  int entity_dim);
150 
151 /*----------------------------------------------------------------------------
152  * Remove entity parent numbering; this is useful for example when we
153  * want to assign coordinates or fields to an extracted mesh using
154  * arrays relative to the mesh, and not to its parent.
155  *
156  * This is equivalent to calling fvm_nodal_change_parent_num(), with
157  * 'trivial' (1 o n) new_parent_num[] values.
158  *
159  * parameters:
160  * this_nodal <-- nodal mesh structure
161  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
162  * and 0 for vertices
163  *----------------------------------------------------------------------------*/
164 
165 void
167  int entity_dim);
168 
169 /*----------------------------------------------------------------------------
170  * Build external numbering for entities based on global numbers.
171  *
172  * parameters:
173  * this_nodal <-- nodal mesh structure
174  * parent_global_number <-- pointer to list of global (i.e. domain splitting
175  * independent) parent entity numbers
176  * entity_dim <-- 3 for cells, 2 for faces, 1 for edges,
177  * and 0 for vertices
178  *----------------------------------------------------------------------------*/
179 
180 void
182  const cs_gnum_t parent_global_numbers[],
183  int entity_dim);
184 
185 /*----------------------------------------------------------------------------
186  * Preset number and list of vertices to assign to a nodal mesh.
187  *
188  * If the parent_vertex_num argument is NULL, the list is assumed to
189  * be {1, 2, ..., n}. If parent_vertex_num is given, it specifies a
190  * list of n vertices from a larger set (1 to n numbering).
191  *
192  * Ownership of the given parent vertex numbering array is
193  * transferred to the nodal mesh representation structure.
194  *
195  * This function should be called before fvm_nodal_set_shared_vertices()
196  * or fvm_nodal_transfer_vertices() if we want to force certain
197  * vertices to appear in the mesh (especially if we want to define
198  * a mesh containing only vertices).
199  *
200  * parameters:
201  * this_nodal <-> nodal mesh structure
202  * n_vertices <-- number of vertices to assign
203  * parent_vertex_num <-- parent numbers of vertices to assign
204  *----------------------------------------------------------------------------*/
205 
206 void
210 
211 /*----------------------------------------------------------------------------
212  * Assign shared vertex coordinates to an extracted nodal mesh,
213  * renumbering vertex numbers based on those really referenced,
214  * and updating connectivity arrays in accordance.
215  *
216  * This function should be called once all element sections have
217  * been added to a nodal mesh representation.
218  *
219  * parameters:
220  * this_nodal <-> nodal mesh structure
221  * vertex_coords <-- coordinates of parent vertices (interlaced)
222  *----------------------------------------------------------------------------*/
223 
224 void
226  const cs_coord_t vertex_coords[]);
227 
228 /*----------------------------------------------------------------------------
229  * Assign private vertex coordinates to a nodal mesh,
230  * renumbering vertex numbers based on those really referenced,
231  * and updating connectivity arrays in accordance.
232  *
233  * Ownership of the given coordinates array is transferred to
234  * the nodal mesh representation structure.
235  *
236  * This function should only be called once all element sections
237  * have been added to a nodal mesh representation.
238  *
239  * parameters:
240  * this_nodal <-> nodal mesh structure
241  * vertex_coords <-- coordinates of parent vertices (interlaced)
242  *
243  * returns:
244  * updated pointer to vertex_coords (may be different from initial
245  * argument if vertices were renumbered).
246  *----------------------------------------------------------------------------*/
247 
248 cs_coord_t *
251 
252 /*----------------------------------------------------------------------------
253  * Make vertex coordinates of a nodal mesh private.
254  *
255  * If vertex coordinates were previously shared, those coordinates that
256  * are actually refernces are copied, and the relation to parent vertices
257  * is discarded.
258  *
259  * If vertices were already private, the mesh is not modified.
260  *
261  * parameters:
262  * this_nodal <-> nodal mesh structure
263  *----------------------------------------------------------------------------*/
264 
265 void
267 
268 /*----------------------------------------------------------------------------
269  * Assign group class set descriptions to a nodal mesh.
270  *
271  * The structure builds its own copy of the group class sets,
272  * renumbering them so as to discard those not referenced.
273  * Empty group classes are also renumbered to zero.
274  *
275  * This function should only be called once all element sections
276  * have been added to a nodal mesh representation.
277  *
278  * parameters:
279  * this_nodal <-> nodal mesh structure
280  * gc_set <-- group class set descriptions
281  *----------------------------------------------------------------------------*/
282 
283 void
286 
287 /*----------------------------------------------------------------------------
288  * Obtain the name of a nodal mesh.
289  *
290  * parameters:
291  * this_nodal <-- pointer to nodal mesh structure
292  *
293  * returns:
294  * pointer to constant string containing the mesh name
295  *----------------------------------------------------------------------------*/
296 
297 const char *
298 fvm_nodal_get_name(const fvm_nodal_t *this_nodal);
299 
300 /*----------------------------------------------------------------------------
301  * Return spatial dimension of the nodal mesh.
302  *
303  * parameters:
304  * this_nodal <-- pointer to nodal mesh structure
305  *
306  * returns:
307  * spatial dimension
308  *----------------------------------------------------------------------------*/
309 
310 int
311 fvm_nodal_get_dim(const fvm_nodal_t *this_nodal);
312 
313 /*----------------------------------------------------------------------------
314  * Return maximum dimension of entities in a nodal mesh.
315  *
316  * parameters:
317  * this_nodal <-- pointer to nodal mesh structure
318  *
319  * returns:
320  * maximum dimension of entities in mesh (0 to 3)
321  *----------------------------------------------------------------------------*/
322 
323 int
324 fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal);
325 
326 /*----------------------------------------------------------------------------
327  * Return number of entities of a given dimension in a nodal mesh.
328  *
329  * parameters:
330  * this_nodal <-- pointer to nodal mesh structure
331  * entity_dim <-- dimension of entities we want to count (0 to 3)
332  *
333  * returns:
334  * number of entities of given dimension in mesh
335  *----------------------------------------------------------------------------*/
336 
337 cs_lnum_t
338 fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal,
339  int entity_dim);
340 
341 /*----------------------------------------------------------------------------
342  * Return global number of vertices associated with nodal mesh.
343  *
344  * parameters:
345  * this_nodal <-- pointer to nodal mesh structure
346  *
347  * returns:
348  * global number of vertices associated with nodal mesh
349  *----------------------------------------------------------------------------*/
350 
351 cs_gnum_t
352 fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal);
353 
354 /*----------------------------------------------------------------------------
355  * Return global number of elements of a given type associated with nodal mesh.
356  *
357  * parameters:
358  * this_nodal <-- pointer to nodal mesh structure
359  * element_type <-- type of elements for query
360  *
361  * returns:
362  * global number of elements of the given type associated with nodal mesh
363  *----------------------------------------------------------------------------*/
364 
365 cs_gnum_t
366 fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal,
367  fvm_element_t element_type);
368 
369 /*----------------------------------------------------------------------------
370  * Return local number of elements of a given type associated with nodal mesh.
371  *
372  * parameters:
373  * this_nodal <-- pointer to nodal mesh structure
374  * element_type <-- type of elements for query
375  *
376  * returns:
377  * local number of elements of the given type associated with nodal mesh
378  *----------------------------------------------------------------------------*/
379 
380 cs_lnum_t
381 fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal,
382  fvm_element_t element_type);
383 
384 /*----------------------------------------------------------------------------
385  * Return local parent numbering array for all entities of a given
386  * dimension in a nodal mesh.
387  *
388  * The number of entities of the given dimension may be obtained
389  * through fvm_nodal_get_n_entities(), the parent_num[] array is populated
390  * with the parent entity numbers of those entities, in order (i.e. in
391  * local section order, section by section).
392  *
393  * parameters:
394  * this_nodal <-- pointer to nodal mesh structure
395  * entity_dim <-- dimension of entities we are interested in (0 to 3)
396  * parent_num --> entity parent numbering (array must be pre-allocated)
397  *----------------------------------------------------------------------------*/
398 
399 void
400 fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal,
401  int entity_dim,
402  cs_lnum_t parent_num[]);
403 
404 /*----------------------------------------------------------------------------
405  * Compute tesselation a a nodal mesh's sections of a given type, and add the
406  * corresponding structure to the mesh representation.
407  *
408  * If global element numbers are used (i.e. in parallel mode), this function
409  * should be only be used after calling fvm_nodal_init_io_num().
410  *
411  * If some mesh sections have already been tesselated, their tesselation
412  * is unchanged.
413  *
414  * parameters:
415  * this_nodal <-> pointer to nodal mesh structure
416  * type <-> element type that should be tesselated
417  * error_count --> number of elements with a tesselation error
418  * counter (optional)
419  *----------------------------------------------------------------------------*/
420 
421 void
422 fvm_nodal_tesselate(fvm_nodal_t *this_nodal,
423  fvm_element_t type,
424  cs_lnum_t *error_count);
425 
426 /*----------------------------------------------------------------------------
427  * Build a nodal representation structure based on extraction of a
428  * mesh's edges.
429  *
430  * parameters:
431  * name <-- name to assign to extracted mesh
432  * this_nodal <-> pointer to nodal mesh structure
433  *----------------------------------------------------------------------------*/
434 
435 fvm_nodal_t *
436 fvm_nodal_copy_edges(const char *name,
437  const fvm_nodal_t *this_nodal);
438 
439 /*----------------------------------------------------------------------------
440  * Dump printout of a nodal representation structure.
441  *
442  * parameters:
443  * this_nodal <-- pointer to structure that should be dumped
444  *----------------------------------------------------------------------------*/
445 
446 void
447 fvm_nodal_dump(const fvm_nodal_t *this_nodal);
448 
449 /*----------------------------------------------------------------------------*/
450 
451 #ifdef __cplusplus
452 }
453 #endif /* __cplusplus */
454 
455 #endif /* __FVM_NODAL_H__ */
void fvm_nodal_reduce(fvm_nodal_t *this_nodal, int del_vertex_num)
Definition: fvm_nodal.c:1206
fvm_nodal_t * fvm_nodal_copy(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1130
cs_gnum_t fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal, fvm_element_t element_type)
Definition: fvm_nodal.c:1804
Definition: fvm_nodal_priv.h:152
cs_coord_t * fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal, cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1488
void fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal, const fvm_group_class_set_t *gc_set)
Definition: fvm_nodal.c:1602
const cs_coord_t * vertex_coords
Definition: fvm_nodal_priv.h:176
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:1411
char * name
Definition: fvm_nodal_priv.h:157
cs_lnum_t fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal, fvm_element_t element_type)
Definition: fvm_nodal.c:1833
double cs_coord_t
Definition: cs_defs.h:261
void fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal, int entity_dim, cs_lnum_t parent_num[])
Definition: fvm_nodal.c:1866
void fvm_nodal_dump(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2276
fvm_nodal_t * fvm_nodal_destroy(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1079
fvm_element_t
Definition: fvm_defs.h:49
cs_lnum_t fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1749
void fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal, const cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1443
int cs_lnum_t
Definition: cs_defs.h:260
unsigned cs_gnum_t
Definition: cs_defs.h:255
Definition: fvm_group.c:83
void fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1545
cs_lnum_t n_vertices
Definition: fvm_nodal_priv.h:171
void fvm_nodal_remove_parent_num(fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1317
int fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1721
fvm_group_class_set_t * gc_set
Definition: fvm_nodal_priv.h:209
int fvm_nodal_get_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1705
const cs_lnum_t * parent_vertex_num
Definition: fvm_nodal_priv.h:182
const int fvm_nodal_n_vertices_element[]
Definition: fvm_nodal.c:77
fvm_nodal_t * fvm_nodal_create(const char *name, int dim)
Definition: fvm_nodal.c:1023
const char * fvm_nodal_get_name(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1687
void fvm_nodal_tesselate(fvm_nodal_t *this_nodal, fvm_element_t type, cs_lnum_t *error_count)
Definition: fvm_nodal.c:1932
cs_gnum_t fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1787
fvm_nodal_t * fvm_nodal_copy_edges(const char *name, const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1981
int dim
Definition: fvm_nodal_priv.h:159
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:1360
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:1262