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-2015 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 refernces 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  * Obtain the name of a nodal mesh.
316  *
317  * parameters:
318  * this_nodal <-- pointer to nodal mesh structure
319  *
320  * returns:
321  * pointer to constant string containing the mesh name
322  *----------------------------------------------------------------------------*/
323 
324 const char *
325 fvm_nodal_get_name(const fvm_nodal_t *this_nodal);
326 
327 /*----------------------------------------------------------------------------
328  * Return spatial dimension of the nodal mesh.
329  *
330  * parameters:
331  * this_nodal <-- pointer to nodal mesh structure
332  *
333  * returns:
334  * spatial dimension
335  *----------------------------------------------------------------------------*/
336 
337 int
338 fvm_nodal_get_dim(const fvm_nodal_t *this_nodal);
339 
340 /*----------------------------------------------------------------------------
341  * Return maximum dimension of entities in a nodal mesh.
342  *
343  * parameters:
344  * this_nodal <-- pointer to nodal mesh structure
345  *
346  * returns:
347  * maximum dimension of entities in mesh (0 to 3)
348  *----------------------------------------------------------------------------*/
349 
350 int
351 fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal);
352 
353 /*----------------------------------------------------------------------------
354  * Return number of entities of a given dimension in a nodal mesh.
355  *
356  * parameters:
357  * this_nodal <-- pointer to nodal mesh structure
358  * entity_dim <-- dimension of entities we want to count (0 to 3)
359  *
360  * returns:
361  * number of entities of given dimension in mesh
362  *----------------------------------------------------------------------------*/
363 
364 cs_lnum_t
365 fvm_nodal_get_n_entities(const fvm_nodal_t *this_nodal,
366  int entity_dim);
367 
368 /*----------------------------------------------------------------------------
369  * Return global number of vertices associated with nodal mesh.
370  *
371  * parameters:
372  * this_nodal <-- pointer to nodal mesh structure
373  *
374  * returns:
375  * global number of vertices associated with nodal mesh
376  *----------------------------------------------------------------------------*/
377 
378 cs_gnum_t
379 fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal);
380 
381 /*----------------------------------------------------------------------------
382  * Return global number of elements of a given type associated with nodal mesh.
383  *
384  * parameters:
385  * this_nodal <-- pointer to nodal mesh structure
386  * element_type <-- type of elements for query
387  *
388  * returns:
389  * global number of elements of the given type associated with nodal mesh
390  *----------------------------------------------------------------------------*/
391 
392 cs_gnum_t
393 fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal,
394  fvm_element_t element_type);
395 
396 /*----------------------------------------------------------------------------
397  * Return local number of elements of a given type associated with nodal mesh.
398  *
399  * parameters:
400  * this_nodal <-- pointer to nodal mesh structure
401  * element_type <-- type of elements for query
402  *
403  * returns:
404  * local number of elements of the given type associated with nodal mesh
405  *----------------------------------------------------------------------------*/
406 
407 cs_lnum_t
408 fvm_nodal_get_n_elements(const fvm_nodal_t *this_nodal,
409  fvm_element_t element_type);
410 
411 /*----------------------------------------------------------------------------
412  * Return local parent numbering array for all entities of a given
413  * dimension in a nodal mesh.
414  *
415  * The number of entities of the given dimension may be obtained
416  * through fvm_nodal_get_n_entities(), the parent_num[] array is populated
417  * with the parent entity numbers of those entities, in order (i.e. in
418  * local section order, section by section).
419  *
420  * parameters:
421  * this_nodal <-- pointer to nodal mesh structure
422  * entity_dim <-- dimension of entities we are interested in (0 to 3)
423  * parent_num --> entity parent numbering (array must be pre-allocated)
424  *----------------------------------------------------------------------------*/
425 
426 void
427 fvm_nodal_get_parent_num(const fvm_nodal_t *this_nodal,
428  int entity_dim,
429  cs_lnum_t parent_num[]);
430 
431 /*----------------------------------------------------------------------------
432  * Compute tesselation a a nodal mesh's sections of a given type, and add the
433  * corresponding structure to the mesh representation.
434  *
435  * If global element numbers are used (i.e. in parallel mode), this function
436  * should be only be used after calling fvm_nodal_init_io_num().
437  *
438  * If some mesh sections have already been tesselated, their tesselation
439  * is unchanged.
440  *
441  * parameters:
442  * this_nodal <-> pointer to nodal mesh structure
443  * type <-> element type that should be tesselated
444  * error_count --> number of elements with a tesselation error
445  * counter (optional)
446  *----------------------------------------------------------------------------*/
447 
448 void
449 fvm_nodal_tesselate(fvm_nodal_t *this_nodal,
450  fvm_element_t type,
451  cs_lnum_t *error_count);
452 
453 /*----------------------------------------------------------------------------
454  * Build a nodal representation structure based on extraction of a
455  * mesh's edges.
456  *
457  * parameters:
458  * name <-- name to assign to extracted mesh
459  * this_nodal <-> pointer to nodal mesh structure
460  *----------------------------------------------------------------------------*/
461 
462 fvm_nodal_t *
463 fvm_nodal_copy_edges(const char *name,
464  const fvm_nodal_t *this_nodal);
465 
466 /*----------------------------------------------------------------------------
467  * Dump printout of a nodal representation structure.
468  *
469  * parameters:
470  * this_nodal <-- pointer to structure that should be dumped
471  *----------------------------------------------------------------------------*/
472 
473 void
474 fvm_nodal_dump(const fvm_nodal_t *this_nodal);
475 
476 /*----------------------------------------------------------------------------*/
477 
479 
480 #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:1218
fvm_nodal_t * fvm_nodal_copy(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1142
cs_gnum_t fvm_nodal_get_n_g_elements(const fvm_nodal_t *this_nodal, fvm_element_t element_type)
Definition: fvm_nodal.c:1865
void fvm_nodal_remove_tag(fvm_nodal_t *this_nodal, int entity_dim)
Definition: fvm_nodal.c:1440
Definition: fvm_nodal_priv.h:153
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
cs_coord_t * fvm_nodal_transfer_vertices(fvm_nodal_t *this_nodal, cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1549
void fvm_nodal_set_group_class_set(fvm_nodal_t *this_nodal, const fvm_group_class_set_t *gc_set)
Definition: fvm_nodal.c:1663
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:1472
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:1894
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:1927
void fvm_nodal_dump(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2337
fvm_nodal_t * fvm_nodal_destroy(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1091
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:1810
void fvm_nodal_set_shared_vertices(fvm_nodal_t *this_nodal, const cs_coord_t vertex_coords[])
Definition: fvm_nodal.c:1504
void fvm_nodal_make_vertices_private(fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1606
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:1329
int fvm_nodal_get_max_entity_dim(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1782
fvm_group_class_set_t * gc_set
Definition: fvm_nodal_priv.h:210
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:1766
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:1035
#define END_C_DECLS
Definition: cs_defs.h:430
const char * fvm_nodal_get_name(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1748
void fvm_nodal_tesselate(fvm_nodal_t *this_nodal, fvm_element_t type, cs_lnum_t *error_count)
Definition: fvm_nodal.c:1993
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:1415
cs_gnum_t fvm_nodal_get_n_g_vertices(const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:1848
fvm_nodal_t * fvm_nodal_copy_edges(const char *name, const fvm_nodal_t *this_nodal)
Definition: fvm_nodal.c:2042
int dim
Definition: fvm_nodal_priv.h:160
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:1372
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:1274