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-2019 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_ids --> list of selected elements (0 to n-1 numbering).
91  *----------------------------------------------------------------------------*/
92 
93 typedef void
95  const cs_mesh_t *m,
96  int location_id,
97  cs_lnum_t *n_elts,
98  cs_lnum_t **elt_ids);
99 
100 /*=============================================================================
101  * Global variables
102  *============================================================================*/
103 
104 /* Names associated with location types */
105 
106 extern const char *cs_mesh_location_type_name[];
107 
108 /*=============================================================================
109  * Public function prototypes
110  *============================================================================*/
111 
112 /*----------------------------------------------------------------------------
113  * Return number of mesh locations defined.
114  *----------------------------------------------------------------------------*/
115 
116 int
118 
119 /*----------------------------------------------------------------------------
120  * Initialize mesh location API.
121  *
122  * By default, 7 mesh locations are built, matching the 7 first values of
123  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
124  * values, CS_MESH_LOCATION_CELLS for the cells of the (default) global mesh,
125  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
126  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
127  * CS_MESH_LOCATION_FACES and a placeholder for CS_MESH_LOCATION_EDGES are
128  * also added for CDO discretizations.
129  *
130  * Locations should then be built once the global mesh is complete, and
131  * its halo structures completed.
132  *----------------------------------------------------------------------------*/
133 
134 void
136 
137 /*----------------------------------------------------------------------------
138  * Finalize mesh location API.
139  *----------------------------------------------------------------------------*/
140 
141 void
143 
144 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 int
155 cs_mesh_location_get_id_by_name(const char *ref_name);
156 
157 /*----------------------------------------------------------------------------
158  * Associate mesh locations with a mesh.
159  *
160  * If mesh_id is negative, all defined mesh locations are associated
161  * (which is useful for the common case where only one mesh is present).
162  * If mesh_id is non-negative, only the location with the matching
163  * id is associated (which may be useful when multiple meshes are defined).
164  *
165  * The number of elements are computed based on the underlying mesh,
166  * and element lists are built for mesh subset locations.
167  *
168  * parameters:
169  * mesh <-- pointer to associated mesh structure
170  * id <-- id of mesh location
171  *----------------------------------------------------------------------------*/
172 
173 void
175  int id);
176 
177 /*----------------------------------------------------------------------------
178  * Define a new mesh location.
179  *
180  * So as to define a subset of mesh entities of a given type, an optional
181  * selection criteria may be given.
182  *
183  * parameters:
184  * name <-- name of location to define
185  * type <-- type of location to define
186  * criteria <-- selection criteria for associated elements, or NULL
187  *
188  * returns:
189  * id of newly created mesh location
190  *----------------------------------------------------------------------------*/
191 
192 int
193 cs_mesh_location_add(const char *name,
195  const char *criteria);
196 
197 /*----------------------------------------------------------------------------*/
216 /*----------------------------------------------------------------------------*/
217 
218 int
219 cs_mesh_location_add_by_func(const char *name,
222  void *input);
223 
224 /*----------------------------------------------------------------------------*/
239 /*----------------------------------------------------------------------------*/
240 
241 int
242 cs_mesh_location_add_by_union(const char *name,
244  int n_ml_ids,
245  const int *ml_ids,
246  bool complement);
247 
248 /*----------------------------------------------------------------------------
249  * Get a mesh location's name.
250  *
251  * parameters:
252  * id <-- id of mesh location
253  *
254  * returns:
255  * pointer to mesh location name
256  *----------------------------------------------------------------------------*/
257 
258 const char *
260 
261 /*----------------------------------------------------------------------------
262  * Get a mesh location's type.
263  *
264  * parameters:
265  * id <-- id of mesh location
266  *
267  * returns:
268  * mesh location type
269  *----------------------------------------------------------------------------*/
270 
273 
274 /*----------------------------------------------------------------------------
275  * Get a mesh location's number of elements.
276  *
277  * A pointer to a array of 3 values is returned:
278  * 0: local number of elements
279  * 1: with standard ghost elements (if applicable)
280  * 2: with extended ghost elements (if applicable)
281  *
282  * parameters:
283  * id <-- id of mesh location
284  *
285  * returns:
286  * array of numbers of elements.
287  *----------------------------------------------------------------------------*/
288 
289 const cs_lnum_t *
291 
292 /*----------------------------------------------------------------------------
293  * Get a mesh location's elements list, if present.
294  *
295  * A list of elements is defined if the location is a subset of a main
296  * location type.
297  *
298  * \deprecated Use \ref cs_mesh_location_get_elt_ids_try or
299  * \ref cs_mesh_location_get_elt_ids instead.
300  *
301  * parameters:
302  * id <-- id of mesh location
303  *
304  * returns:
305  * pointer to elements list (0 to n-1 numbering).
306  *----------------------------------------------------------------------------*/
307 
308 const cs_lnum_t *
310 
311 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 const cs_lnum_t *
327 
328 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 const cs_lnum_t *
344 
345 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 const char *
357 
358 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 
370 
371 /*----------------------------------------------------------------------------*/
380 /*----------------------------------------------------------------------------*/
381 
382 bool
384 
385 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
395 void
397  bool explicit_elt_ids);
398 
399 /*----------------------------------------------------------------------------*/
400 
402 
403 #endif /* __CS_MESH_LOCATION_H__ */
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition: cs_mesh_location.c:458
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition: cs_mesh_location.c:435
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:766
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:735
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition: cs_mesh_location.c:528
void cs_mesh_location_set_explicit_ids(int id, bool explicit_elt_ids)
Set behavior of cs_mesh_location_get_elt_ids for a given mesh location and locations based on it...
Definition: cs_mesh_location.c:974
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
void() cs_mesh_location_select_t(void *input, const cs_mesh_t *m, int location_id, cs_lnum_t *n_elts, cs_lnum_t **elt_ids)
Definition: cs_mesh_location.h:94
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
Definition: cs_mesh_location.h:68
void cs_mesh_location_finalize(void)
Finalize mesh location API.
Definition: cs_mesh_location.c:490
const cs_lnum_t * cs_mesh_location_get_elt_ids(int id)
Get a mesh location&#39;s element ids.
Definition: cs_mesh_location.c:891
Definition: cs_mesh_location.h:66
const cs_lnum_t * cs_mesh_location_get_elt_ids_try(int id)
Get a mesh location&#39;s element ids, if present.
Definition: cs_mesh_location.c:869
const char * cs_mesh_location_type_name[]
Definition: cs_mesh.h:63
const cs_lnum_t * cs_mesh_location_get_n_elts(int id)
Get a mesh location&#39;s number of elements.
Definition: cs_mesh_location.c:823
int cs_mesh_location_add_by_func(const char *name, cs_mesh_location_type_t type, cs_mesh_location_select_t *func, void *input)
Define a new mesh location with an associated selection function.
Definition: cs_mesh_location.c:703
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&#39;s elements list, if present.
Definition: cs_mesh_location.c:847
cs_mesh_location_select_t * cs_mesh_location_get_selection_function(int id)
Get a mesh location&#39;s selection function pointer.
Definition: cs_mesh_location.c:938
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:666
const char * cs_mesh_location_get_selection_string(int id)
Get a mesh location&#39;s selection criteria string.
Definition: cs_mesh_location.c:920
static int input(void)
const char * cs_mesh_location_get_name(int id)
Get a mesh location&#39;s name.
Definition: cs_mesh_location.c:782
Definition: cs_mesh_location.h:63
Definition: cs_mesh_location.h:69
bool cs_mesh_location_get_explicit_ids(int id)
Check if cs_mesh_location_get_elt_ids always returns explicit element ids for a given mesh location...
Definition: cs_mesh_location.c:957
Definition: cs_mesh_location.h:62
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
#define END_C_DECLS
Definition: cs_defs.h:468
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location&#39;s type.
Definition: cs_mesh_location.c:800
Definition: cs_mesh_location.h:67
Definition: mesh.f90:26