programmer's documentation
cs_mesh_location.h
Go to the documentation of this file.
1 #ifndef __CS_MESH_LOCATION_H__
2 #define __CS_MESH_LOCATION_H__
3 
4 /*============================================================================
5  * Mesh locations management.
6  *============================================================================*/
7 
8 /*
9  This file is part of the Code_Saturne Kernel, element of the
10  Code_Saturne CFD tool.
11 
12  Copyright (C) 1998-2015 EDF S.A., France
13 
14  contact: saturne-support@edf.fr
15 
16  The Code_Saturne Kernel is free software; you can redistribute it
17  and/or modify it under the terms of the GNU General Public License
18  as published by the Free Software Foundation; either version 2 of
19  the License, or (at your option) any later version.
20 
21  The Code_Saturne Kernel is distributed in the hope that it will be
22  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  GNU General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with the Code_Saturne Kernel; if not, write to the
28  Free Software Foundation, Inc.,
29  51 Franklin St, Fifth Floor,
30  Boston, MA 02110-1301 USA
31 */
32 
33 /*----------------------------------------------------------------------------*/
34 
35 #if defined(HAVE_MPI)
36 #include <mpi.h>
37 #endif
38 
39 /*----------------------------------------------------------------------------
40  * Local headers
41  *----------------------------------------------------------------------------*/
42 
43 #include "cs_defs.h"
44 #include "cs_mesh.h"
45 
46 /*----------------------------------------------------------------------------*/
47 
49 
50 /*=============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
58 /* Mesh location types */
59 
60 typedef enum {
61 
71 
73 
74 /* Opaque mesh location object */
75 
76 typedef struct _cs_mesh_location_t cs_mesh_location_t;
77 
78 /*----------------------------------------------------------------------------
79  * Function pointer to mesh location elements selection definition.
80  *
81  * If non-empty and not containing all elements, a list of elements
82  * of the parent mesh belonging to the location should be allocated
83  * (using BFT_MALLOC) and defined by this function when called.
84  * This list's lifecycle is then managed by the mesh location object.
85  *
86  * parameters:
87  * m <-- pointer to associated mesh structure.
88  * location_id <-- id of associated location.
89  * n_elts --> number of selected elements
90  * elt_list --> list of selected elements (0 to n-1 numbering).
91  *----------------------------------------------------------------------------*/
92 
93 typedef void
95  int location_id,
96  cs_lnum_t *n_elts,
97  cs_lnum_t **elt_list);
98 
99 /*=============================================================================
100  * Global variables
101  *============================================================================*/
102 
103 /* Names associated with location types */
104 
105 extern const char *cs_mesh_location_type_name[];
106 
107 /*=============================================================================
108  * Public function prototypes
109  *============================================================================*/
110 
111 /*----------------------------------------------------------------------------
112  * Return number of mesh locations defined.
113  *----------------------------------------------------------------------------*/
114 
115 int
117 
118 /*----------------------------------------------------------------------------
119  * Initialize mesh location API.
120  *
121  * By default, 7 mesh locations are built, matching the 7 first values of
122  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
123  * values, CS_MESH_LOCATION_CELLS for the cells of the (default) global mesh,
124  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
125  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
126  * CS_MESH_LOCATION_FACES and a placeholder for CS_MESH_LOCATION_EDGES are
127  * also added for CDO discretizations.
128  *
129  * Locations should then be built once the global mesh is complete, and
130  * its halo structures completed.
131  *----------------------------------------------------------------------------*/
132 
133 void
135 
136 /*----------------------------------------------------------------------------
137  * Finalize mesh location API.
138  *----------------------------------------------------------------------------*/
139 
140 void
142 
143 /*----------------------------------------------------------------------------*/
151 /*----------------------------------------------------------------------------*/
152 
153 int
154 cs_mesh_location_get_id_by_name(const char *ref_name);
155 
156 /*----------------------------------------------------------------------------
157  * Associate mesh locations with a mesh.
158  *
159  * If mesh_id is negative, all defined mesh locations are associated
160  * (which is useful for the common case where only one mesh is present).
161  * If mesh_id is non-negative, only the location with the matching
162  * id is associated (which may be useful when multiple meshes are defined).
163  *
164  * The number of elements are computed based on the underlying mesh,
165  * and element lists are built for mesh subset locations.
166  *
167  * parameters:
168  * mesh <-- pointer to associated mesh structure
169  * id <-- id of mesh location
170  *----------------------------------------------------------------------------*/
171 
172 void
174  int id);
175 
176 /*----------------------------------------------------------------------------
177  * Define a new mesh location.
178  *
179  * So as to define a subset of mesh entities of a given type, an optional
180  * selection criteria may be given.
181  *
182  * parameters:
183  * name <-- name of location to define
184  * type <-- type of location to define
185  * criteria <-- selection criteria for associated elements, or NULL
186  *
187  * returns:
188  * id of newly created mesh location
189  *----------------------------------------------------------------------------*/
190 
191 int
192 cs_mesh_location_add(const char *name,
194  const char *criteria);
195 
196 /*----------------------------------------------------------------------------
197  * Define a new mesh location.
198  *
199  * So as to define a subset of mesh entities of a given type, a pointer
200  * to a selection function may be given.
201  *
202  * This requires more programming but allows finer control than selection
203  * criteria, as the function has access to the complete mesh structure.
204  *
205  * parameters:
206  * name <-- name of location to define
207  * type <-- type of location to define
208  * func <-- pointer to selection function for associated elements, or NULL
209  *
210  * returns:
211  * id of newly created mesh location
212  *----------------------------------------------------------------------------*/
213 
214 int
215 cs_mesh_location_add_by_func(const char *name,
218 
219 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 int
237 cs_mesh_location_add_by_union(const char *name,
239  int n_ml_ids,
240  const int *ml_ids,
241  bool complement);
242 
243 /*----------------------------------------------------------------------------
244  * Get a mesh location's name.
245  *
246  * parameters:
247  * id <-- id of mesh location
248  *
249  * returns:
250  * pointer to mesh location name
251  *----------------------------------------------------------------------------*/
252 
253 const char *
255 
256 /*----------------------------------------------------------------------------
257  * Get a mesh location's type.
258  *
259  * parameters:
260  * id <-- id of mesh location
261  *
262  * returns:
263  * mesh location type
264  *----------------------------------------------------------------------------*/
265 
268 
269 /*----------------------------------------------------------------------------
270  * Get a mesh location's number of elements.
271  *
272  * A pointer to a array of 3 values is returned:
273  * 0: local number of elements
274  * 1: with standard ghost elements (if applicable)
275  * 2: with extended ghost elements (if applicable)
276  *
277  * parameters:
278  * id <-- id of mesh location
279  *
280  * returns:
281  * array of numbers of elements.
282  *----------------------------------------------------------------------------*/
283 
284 const cs_lnum_t *
286 
287 /*----------------------------------------------------------------------------
288  * Get a mesh location's elements list, if present.
289  *
290  * A list of elements is defined if the location is a subset of a main
291  * location type.
292  *
293  * parameters:
294  * id <-- id of mesh location
295  *
296  * returns:
297  * pointer to elements list (0 to n-1 numbering).
298  *----------------------------------------------------------------------------*/
299 
300 const cs_lnum_t *
302 
303 /*----------------------------------------------------------------------------*/
304 
306 
307 #endif /* __CS_MESH_LOCATION_H__ */
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition: cs_mesh_location.c:424
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition: cs_mesh_location.c:401
int cs_mesh_location_get_id_by_name(const char *ref_name)
Find the related location id from the location name.
Definition: cs_mesh_location.c:707
int cs_mesh_location_add_by_union(const char *name, cs_mesh_location_type_t type, int n_ml_ids, const int *ml_ids, bool complement)
Define a new mesh location.
Definition: cs_mesh_location.c:676
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition: cs_mesh_location.c:491
Definition: cs_mesh_location.h:65
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
struct _cs_mesh_location_t cs_mesh_location_t
Definition: cs_mesh_location.h:76
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
Definition: cs_mesh_location.h:68
void cs_mesh_location_finalize(void)
Finalize mesh location API.
Definition: cs_mesh_location.c:456
Definition: cs_mesh_location.h:66
const char * cs_mesh_location_type_name[]
Definition: cs_mesh.h:62
const cs_lnum_t * cs_mesh_location_get_n_elts(int id)
Get a mesh location's number of elements.
Definition: cs_mesh_location.c:784
Definition: cs_mesh_location.h:70
Definition: cs_mesh_location.h:64
const cs_lnum_t * cs_mesh_location_get_elt_list(int id)
Get a mesh location's elements list, if present.
Definition: cs_mesh_location.c:805
int cs_mesh_location_add(const char *name, cs_mesh_location_type_t type, const char *criteria)
Define a new mesh location.
Definition: cs_mesh_location.c:611
const char * cs_mesh_location_get_name(int id)
Get a mesh location's name.
Definition: cs_mesh_location.c:743
Definition: cs_mesh_location.h:63
Definition: cs_mesh_location.h:69
int cs_mesh_location_add_by_func(const char *name, cs_mesh_location_type_t type, cs_mesh_location_select_t *func)
Define a new mesh location with an associated selection function.
Definition: cs_mesh_location.c:646
Definition: cs_mesh_location.h:62
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
#define END_C_DECLS
Definition: cs_defs.h:430
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location's type.
Definition: cs_mesh_location.c:761
Definition: cs_mesh_location.h:67
Definition: mesh.f90:26
void( cs_mesh_location_select_t)(const cs_mesh_t *m, int location_id, cs_lnum_t *n_elts, cs_lnum_t **elt_list)
Definition: cs_mesh_location.h:94