My Project
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  * Note: if the input pointer is non-NULL, it must point to valid data
87  * when the selection function is called, so that value or structure should
88  * not be temporary (i.e. local);
89  *
90  * parameters:
91  * input <-- pointer to optional (untyped) value or structure.
92  * m <-- pointer to associated mesh structure.
93  * location_id <-- id of associated location.
94  * n_elts --> number of selected elements
95  * elt_ids --> list of selected elements (0 to n-1 numbering).
96  *----------------------------------------------------------------------------*/
97 
98 typedef void
100  const cs_mesh_t *m,
101  int location_id,
102  cs_lnum_t *n_elts,
103  cs_lnum_t **elt_ids);
104 
105 /*=============================================================================
106  * Global variables
107  *============================================================================*/
108 
109 /* Names associated with location types */
110 
111 extern const char *cs_mesh_location_type_name[];
112 
113 /*=============================================================================
114  * Public function prototypes
115  *============================================================================*/
116 
117 /*----------------------------------------------------------------------------
118  * Return number of mesh locations defined.
119  *----------------------------------------------------------------------------*/
120 
121 int
123 
124 /*----------------------------------------------------------------------------
125  * Initialize mesh location API.
126  *
127  * By default, 7 mesh locations are built, matching the 7 first values of
128  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
129  * values, CS_MESH_LOCATION_CELLS for the cells of the (default) global mesh,
130  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
131  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
132  * CS_MESH_LOCATION_FACES and a placeholder for CS_MESH_LOCATION_EDGES are
133  * also added for CDO discretizations.
134  *
135  * Locations should then be built once the global mesh is complete, and
136  * its halo structures completed.
137  *----------------------------------------------------------------------------*/
138 
139 void
141 
142 /*----------------------------------------------------------------------------
143  * Finalize mesh location API.
144  *----------------------------------------------------------------------------*/
145 
146 void
148 
149 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 
159 int
160 cs_mesh_location_get_id_by_name(const char *ref_name);
161 
162 /*----------------------------------------------------------------------------
163  * Associate mesh locations with a mesh.
164  *
165  * If mesh_id is negative, all defined mesh locations are associated
166  * (which is useful for the common case where only one mesh is present).
167  * If mesh_id is non-negative, only the location with the matching
168  * id is associated (which may be useful when multiple meshes are defined).
169  *
170  * The number of elements are computed based on the underlying mesh,
171  * and element lists are built for mesh subset locations.
172  *
173  * parameters:
174  * mesh <-- pointer to associated mesh structure
175  * id <-- id of mesh location
176  *----------------------------------------------------------------------------*/
177 
178 void
180  int id);
181 
182 /*----------------------------------------------------------------------------
183  * Define a new mesh location.
184  *
185  * So as to define a subset of mesh entities of a given type, an optional
186  * selection criteria may be given.
187  *
188  * parameters:
189  * name <-- name of location to define
190  * type <-- type of location to define
191  * criteria <-- selection criteria for associated elements, or NULL
192  *
193  * returns:
194  * id of newly created mesh location
195  *----------------------------------------------------------------------------*/
196 
197 int
198 cs_mesh_location_add(const char *name,
200  const char *criteria);
201 
202 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 int
224 cs_mesh_location_add_by_func(const char *name,
227  void *input);
228 
229 /*----------------------------------------------------------------------------*/
244 /*----------------------------------------------------------------------------*/
245 
246 int
247 cs_mesh_location_add_by_union(const char *name,
249  int n_ml_ids,
250  const int *ml_ids,
251  bool complement);
252 
253 /*----------------------------------------------------------------------------
254  * Get a mesh location's name.
255  *
256  * parameters:
257  * id <-- id of mesh location
258  *
259  * returns:
260  * pointer to mesh location name
261  *----------------------------------------------------------------------------*/
262 
263 const char *
265 
266 /*----------------------------------------------------------------------------
267  * Get a mesh location's type.
268  *
269  * parameters:
270  * id <-- id of mesh location
271  *
272  * returns:
273  * mesh location type
274  *----------------------------------------------------------------------------*/
275 
278 
279 /*----------------------------------------------------------------------------
280  * Get a mesh location's number of elements.
281  *
282  * A pointer to a array of 3 values is returned:
283  * 0: local number of elements
284  * 1: with standard ghost elements (if applicable)
285  * 2: with extended ghost elements (if applicable)
286  *
287  * parameters:
288  * id <-- id of mesh location
289  *
290  * returns:
291  * array of numbers of elements.
292  *----------------------------------------------------------------------------*/
293 
294 const cs_lnum_t *
296 
297 /*----------------------------------------------------------------------------
298  * Get a mesh location's elements list, if present.
299  *
300  * A list of elements is defined if the location is a subset of a main
301  * location type.
302  *
303  * \deprecated Use \ref cs_mesh_location_get_elt_ids_try or
304  * \ref cs_mesh_location_get_elt_ids instead.
305  *
306  * parameters:
307  * id <-- id of mesh location
308  *
309  * returns:
310  * pointer to elements list (0 to n-1 numbering).
311  *----------------------------------------------------------------------------*/
312 
313 const cs_lnum_t *
315 
316 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
330 const cs_lnum_t *
332 
333 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 const cs_lnum_t *
349 
350 /*----------------------------------------------------------------------------*/
358 /*----------------------------------------------------------------------------*/
359 
360 const char *
362 
363 /*----------------------------------------------------------------------------*/
371 /*----------------------------------------------------------------------------*/
372 
375 
376 /*----------------------------------------------------------------------------*/
385 /*----------------------------------------------------------------------------*/
386 
387 bool
389 
390 /*----------------------------------------------------------------------------*/
398 /*----------------------------------------------------------------------------*/
399 
400 void
402  bool explicit_elt_ids);
403 
404 /*----------------------------------------------------------------------------*/
405 
407 
408 #endif /* __CS_MESH_LOCATION_H__ */
cs_mesh_location_type_t
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
input
static int input(void)
cs_defs.h
CS_MESH_LOCATION_BOUNDARY_FACES
Definition: cs_mesh_location.h:65
CS_MESH_LOCATION_NONE
Definition: cs_mesh_location.h:62
cs_mesh_location_get_selection_function
cs_mesh_location_select_t * cs_mesh_location_get_selection_function(int id)
Get a mesh location's selection function pointer.
Definition: cs_mesh_location.c:938
CS_MESH_LOCATION_VERTICES
Definition: cs_mesh_location.h:66
cs_mesh_location_add_by_func
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
cs_mesh_location_select_t
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:99
cs_mesh_location_get_selection_string
const char * cs_mesh_location_get_selection_string(int id)
Get a mesh location's selection criteria string.
Definition: cs_mesh_location.c:920
cs_mesh_location_get_elt_ids
const cs_lnum_t * cs_mesh_location_get_elt_ids(int id)
Get a mesh location's element ids.
Definition: cs_mesh_location.c:891
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_mesh_location_get_elt_ids_try
const cs_lnum_t * cs_mesh_location_get_elt_ids_try(int id)
Get a mesh location's element ids, if present.
Definition: cs_mesh_location.c:869
cs_mesh_location_n_locations
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition: cs_mesh_location.c:435
cs_mesh_location_type_name
const char * cs_mesh_location_type_name[]
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_mesh_location_add
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
cs_mesh_location_initialize
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition: cs_mesh_location.c:458
cs_mesh_location_get_n_elts
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:823
cs_mesh_location_add_by_union
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
mesh
Definition: mesh.f90:26
cs_mesh.h
CS_MESH_LOCATION_FACES
Definition: cs_mesh_location.h:67
CS_MESH_LOCATION_PARTICLES
Definition: cs_mesh_location.h:69
cs_mesh_location_t
struct _cs_mesh_location_t cs_mesh_location_t
Definition: cs_mesh_location.h:76
cs_mesh_location_get_name
const char * cs_mesh_location_get_name(int id)
Get a mesh location's name.
Definition: cs_mesh_location.c:782
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
CS_MESH_LOCATION_OTHER
Definition: cs_mesh_location.h:70
cs_mesh_location_get_explicit_ids
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
CS_MESH_LOCATION_EDGES
Definition: cs_mesh_location.h:68
cs_mesh_location_get_elt_list
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:847
cs_mesh_location_get_type
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location's type.
Definition: cs_mesh_location.c:800
cs_mesh_location_build
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition: cs_mesh_location.c:528
type
void const cs_int_t * type
Definition: cs_measures_util.h:425
CS_MESH_LOCATION_CELLS
Definition: cs_mesh_location.h:63
cs_mesh_t
Definition: cs_mesh.h:63
cs_mesh_location_set_explicit_ids
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
CS_MESH_LOCATION_INTERIOR_FACES
Definition: cs_mesh_location.h:64
cs_mesh_location_finalize
void cs_mesh_location_finalize(void)
Finalize mesh location API.
Definition: cs_mesh_location.c:490
cs_mesh_location_get_id_by_name
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