7.2
general 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-2022 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 /* Mesh location construction method type */
75 
76 typedef enum {
77 
82 
84 
85 /* Opaque mesh location object */
86 
87 typedef struct _cs_mesh_location_t cs_mesh_location_t;
88 
89 /*----------------------------------------------------------------------------
90  * Function pointer to mesh location elements selection definition.
91  *
92  * If non-empty and not containing all elements, a list of elements
93  * of the parent mesh belonging to the location should be allocated
94  * (using BFT_MALLOC) and defined by this function when called.
95  * This list's lifecycle is then managed by the mesh location object.
96  *
97  * Note: if the input pointer is non-NULL, it must point to valid data
98  * when the selection function is called, so that value or structure should
99  * not be temporary (i.e. local);
100  *
101  * parameters:
102  * input <-- pointer to optional (untyped) value or structure.
103  * m <-- pointer to associated mesh structure.
104  * location_id <-- id of associated location.
105  * n_elts --> number of selected elements
106  * elt_ids --> list of selected elements (0 to n-1 numbering).
107  *----------------------------------------------------------------------------*/
108 
109 typedef void
111  const cs_mesh_t *m,
112  int location_id,
113  cs_lnum_t *n_elts,
114  cs_lnum_t **elt_ids);
115 
116 /*=============================================================================
117  * Global variables
118  *============================================================================*/
119 
120 /* Names associated with location types */
121 
122 extern const char *cs_mesh_location_type_name[];
123 
124 /*=============================================================================
125  * Public function prototypes
126  *============================================================================*/
127 
128 /*----------------------------------------------------------------------------
129  * Return number of mesh locations defined.
130  *----------------------------------------------------------------------------*/
131 
132 int
134 
135 /*----------------------------------------------------------------------------
136  * Initialize mesh location API.
137  *
138  * By default, 7 mesh locations are built, matching the 7 first values of
139  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
140  * values, CS_MESH_LOCATION_CELLS for the cells of the (default) global mesh,
141  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
142  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
143  * CS_MESH_LOCATION_FACES and a placeholder for CS_MESH_LOCATION_EDGES are
144  * also added for CDO discretizations.
145  *
146  * Locations should then be built once the global mesh is complete, and
147  * its halo structures completed.
148  *----------------------------------------------------------------------------*/
149 
150 void
152 
153 /*----------------------------------------------------------------------------
154  * Finalize mesh location API.
155  *----------------------------------------------------------------------------*/
156 
157 void
159 
160 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 int
171 cs_mesh_location_get_id_by_name(const char *ref_name);
172 
173 /*----------------------------------------------------------------------------
174  * Associate mesh locations with a mesh.
175  *
176  * If mesh_id is negative, all defined mesh locations are associated
177  * (which is useful for the common case where only one mesh is present).
178  * If mesh_id is non-negative, only the location with the matching
179  * id is associated (which may be useful when multiple meshes are defined).
180  *
181  * The number of elements are computed based on the underlying mesh,
182  * and element lists are built for mesh subset locations.
183  *
184  * parameters:
185  * mesh <-- pointer to associated mesh structure
186  * id <-- id of mesh location
187  *----------------------------------------------------------------------------*/
188 
189 void
191  int id);
192 
193 /*----------------------------------------------------------------------------
194  * Define a new mesh location.
195  *
196  * So as to define a subset of mesh entities of a given type, an optional
197  * selection criteria may be given.
198  *
199  * parameters:
200  * name <-- name of location to define
201  * type <-- type of location to define
202  * criteria <-- selection criteria for associated elements, or NULL
203  *
204  * returns:
205  * id of newly created mesh location
206  *----------------------------------------------------------------------------*/
207 
208 int
209 cs_mesh_location_add(const char *name,
211  const char *criteria);
212 
213 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 int
235 cs_mesh_location_add_by_func(const char *name,
238  void *input);
239 
240 /*----------------------------------------------------------------------------*/
255 /*----------------------------------------------------------------------------*/
256 
257 int
258 cs_mesh_location_add_by_union(const char *name,
260  int n_ml_ids,
261  const int *ml_ids,
262  bool complement);
263 
264 /*----------------------------------------------------------------------------
265  * Get a mesh location's name.
266  *
267  * parameters:
268  * id <-- id of mesh location
269  *
270  * returns:
271  * pointer to mesh location name
272  *----------------------------------------------------------------------------*/
273 
274 const char *
276 
277 /*----------------------------------------------------------------------------
278  * Get a mesh location's type.
279  *
280  * parameters:
281  * id <-- id of mesh location
282  *
283  * returns:
284  * mesh location type
285  *----------------------------------------------------------------------------*/
286 
289 
290 /*----------------------------------------------------------------------------
291  * Get a mesh location's number of elements.
292  *
293  * A pointer to a array of 3 values is returned:
294  * 0: local number of elements
295  * 1: with standard ghost elements (if applicable)
296  * 2: with extended ghost elements (if applicable)
297  *
298  * parameters:
299  * id <-- id of mesh location
300  *
301  * returns:
302  * array of numbers of elements.
303  *----------------------------------------------------------------------------*/
304 
305 const cs_lnum_t *
307 
308 /*----------------------------------------------------------------------------
309  * Get a mesh location's elements list, if present.
310  *
311  * A list of elements is defined if the location is a subset of a main
312  * location type.
313  *
314  * \deprecated Use \ref cs_mesh_location_get_elt_ids_try or
315  * \ref cs_mesh_location_get_elt_ids instead.
316  *
317  * parameters:
318  * id <-- id of mesh location
319  *
320  * returns:
321  * pointer to elements list (0 to n-1 numbering).
322  *----------------------------------------------------------------------------*/
323 
324 const cs_lnum_t *
326 
327 /*----------------------------------------------------------------------------*/
339 /*----------------------------------------------------------------------------*/
340 
341 const cs_lnum_t *
343 
344 /*----------------------------------------------------------------------------*/
356 /*----------------------------------------------------------------------------*/
357 
358 const cs_lnum_t *
360 
361 /*----------------------------------------------------------------------------*/
369 /*----------------------------------------------------------------------------*/
370 
373 
374 /*----------------------------------------------------------------------------*/
382 /*----------------------------------------------------------------------------*/
383 
384 const char *
386 
387 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
399 
400 /*----------------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------------*/
409 
410 int
412 
413 /*----------------------------------------------------------------------------*/
421 /*----------------------------------------------------------------------------*/
422 
423 int *
425 
426 /*----------------------------------------------------------------------------*/
435 /*----------------------------------------------------------------------------*/
436 
437 bool
439 
440 /*----------------------------------------------------------------------------*/
449 /*----------------------------------------------------------------------------*/
450 
451 bool
453 
454 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 void
466  bool explicit_elt_ids);
467 
468 /*----------------------------------------------------------------------------*/
469 
471 
472 #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_sub_ids(int id)
Get a mesh location&#39;s list of sub ids.
Definition: cs_mesh_location.c:1003
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:1060
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:87
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:110
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
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
Definition: cs_mesh_location.h:81
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[]
cs_mesh_location_def_t
Definition: cs_mesh_location.h:76
Definition: cs_mesh.h:84
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
Definition: cs_mesh_location.h:78
Definition: cs_mesh_location.h:80
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_def_t cs_mesh_location_get_definition_method(int id)
Get a mesh location&#39;s definition method.
Definition: cs_mesh_location.c:920
bool cs_mesh_location_is_complement(int id)
Check if a mesh location is built as a complement of other mesh locations.
Definition: cs_mesh_location.c:1023
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:966
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:948
const char * cs_mesh_location_get_name(int id)
Get a mesh location&#39;s name.
Definition: cs_mesh_location.c:782
int cs_mesh_location_get_n_sub_ids(int id)
Get a mesh location&#39;s number of sub ids.
Definition: cs_mesh_location.c:984
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:1043
Definition: cs_mesh_location.h:62
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define END_C_DECLS
Definition: cs_defs.h:511
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:79
Definition: cs_mesh_location.h:67
Definition: mesh.f90:26