programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2014 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 
69 
71 
72 /* Opaque mesh location object */
73 
74 typedef struct _cs_mesh_location_t cs_mesh_location_t;
75 
76 /*----------------------------------------------------------------------------
77  * Function pointer to mesh location elements selection definition.
78  *
79  * If non-empty and not containing all elements, a list of elements
80  * of the parent mesh belonging to the location should be allocated
81  * (using BFT_MALLOC) and defined by this function when called.
82  * This list's lifecycle is then managed by the mesh location object.
83  *
84  * parameters:
85  * m <-- pointer to associated mesh structure.
86  * location_id <-- id of associated location.
87  * n_elts --> number of selected elements
88  * elt_list --> list of selected elements (0 to n-1 numbering).
89  *----------------------------------------------------------------------------*/
90 
91 typedef void
93  int location_id,
94  cs_lnum_t *n_elts,
95  cs_lnum_t **elt_list);
96 
97 /*=============================================================================
98  * Global variables
99  *============================================================================*/
100 
101 /* Names associated with location types */
102 
103 extern const char *cs_mesh_location_type_name[];
104 
105 /*=============================================================================
106  * Public function prototypes
107  *============================================================================*/
108 
109 /*----------------------------------------------------------------------------
110  * Return number of mesh locations defined.
111  *----------------------------------------------------------------------------*/
112 
113 int
115 
116 /*----------------------------------------------------------------------------
117  * Initialize mesh location API.
118  *
119  * By default, 5 mesh locations are built, matching the 5 first values of
120  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
121  * values, CS_MESH_LOCCATION_CELLS for the cellsof the (default) global mesh,
122  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
123  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
124  *
125  * Locations should then be built once the global mesh is complete, and
126  * its halo structures completed.
127  *----------------------------------------------------------------------------*/
128 
129 void
131 
132 /*----------------------------------------------------------------------------
133  * Finalize mesh location API.
134  *----------------------------------------------------------------------------*/
135 
136 void
138 
139 /*----------------------------------------------------------------------------
140  * Associate mesh locations with a mesh.
141  *
142  * If mesh_id is negative, all defined mesh locations are associated
143  * (which is useful for the common case where only one mesh is present).
144  * If mesh_id is non-negative, only the location with the matching
145  * id is associated (which may be useful when multiple meshes are defined).
146  *
147  * The number of elements are computed based on the underlying mesh,
148  * and element lists are built for mesh subset locations.
149  *
150  * parameters:
151  * mesh <-- pointer to associated mesh structure
152  * id <-- id of mesh location
153  *----------------------------------------------------------------------------*/
154 
155 void
157  int id);
158 
159 /*----------------------------------------------------------------------------
160  * Define a new mesh location.
161  *
162  * So as to define a subset of mesh entities of a given type, an optional
163  * selection criteria may be given.
164  *
165  * parameters:
166  * name <-- name of location to define
167  * type <-- type of location to define
168  * criteria <-- selection criteria for associated elements, or NULL
169  *
170  * returns:
171  * id of newly defined created mesh location
172  *----------------------------------------------------------------------------*/
173 
174 int
175 cs_mesh_location_define(const char *name,
177  const char *criteria);
178 
179 /*----------------------------------------------------------------------------
180  * Define a new mesh location.
181  *
182  * So as to define a subset of mesh entities of a given type, a pointer
183  * to a selection function may be given.
184  *
185  * This requires more programming but allows finer control than selection
186  * criteria, as the function has access to the complete mesh structure.
187  *
188  * parameters:
189  * name <-- name of location to define
190  * type <-- type of location to define
191  * func <-- pointer to selection function for associated elements, or NULL
192  *
193  * returns:
194  * id of newly defined created mesh location
195  *----------------------------------------------------------------------------*/
196 
197 int
198 cs_mesh_location_define_by_func(const char *name,
201 
202 /*----------------------------------------------------------------------------
203  * Get a mesh location's name.
204  *
205  * parameters:
206  * id <-- id of mesh location
207  *
208  * returns:
209  * pointer to mesh location name
210  *----------------------------------------------------------------------------*/
211 
212 const char *
214 
215 /*----------------------------------------------------------------------------
216  * Get a mesh location's type.
217  *
218  * parameters:
219  * id <-- id of mesh location
220  *
221  * returns:
222  * mesh location type
223  *----------------------------------------------------------------------------*/
224 
227 
228 /*----------------------------------------------------------------------------
229  * Get a mesh location's number of elements.
230  *
231  * A pointer to a array of 3 values is returned:
232  * 0: local number of elements
233  * 1: with standard ghost elements (if applicable)
234  * 2: with extended ghost elements (if applicable)
235  *
236  * parameters:
237  * id <-- id of mesh location
238  *
239  * returns:
240  * array of numbers of elements.
241  *----------------------------------------------------------------------------*/
242 
243 const cs_lnum_t *
245 
246 /*----------------------------------------------------------------------------
247  * Get a mesh location's elements list, if present.
248  *
249  * A list of elements is defined if the location is a subset of a main
250  * location type.
251  *
252  * parameters:
253  * id <-- id of mesh location
254  *
255  * returns:
256  * pointer to elements list (0 to n-1 numbering).
257  *----------------------------------------------------------------------------*/
258 
259 const cs_lnum_t *
261 
262 /*----------------------------------------------------------------------------*/
263 
265 
266 #endif /* __CS_MESH_LOCATION_H__ */
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition: cs_mesh_location.c:267
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition: cs_mesh_location.c:246
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition: cs_mesh_location.c:327
void( cs_mesh_location_select_t)(const cs_mesh_t *m, int location_id, cs_lnum_t *n_elts, cs_lnum_t **elt_list)
Function pointer to mesh location elements selection definition.
Definition: cs_mesh_location.h:92
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:74
#define BEGIN_C_DECLS
Definition: cs_defs.h:405
void cs_mesh_location_finalize(void)
Finalize mesh location API.
Definition: cs_mesh_location.c:293
int cs_mesh_location_define(const char *name, cs_mesh_location_type_t type, const char *criteria)
Define a new mesh location.
Definition: cs_mesh_location.c:442
Definition: cs_mesh_location.h:66
const char * cs_mesh_location_type_name[]
Definition: cs_mesh_location.c:129
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:543
Definition: mesh.f90:26
Definition: cs_mesh_location.h:68
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:564
const char * cs_mesh_location_get_name(int id)
Get a mesh location's name.
Definition: cs_mesh_location.c:502
Definition: cs_mesh_location.h:63
Definition: cs_mesh_location.h:67
int cs_mesh_location_define_by_func(const char *name, cs_mesh_location_type_t type, cs_mesh_location_select_t *func)
Define a new mesh location with a associated selection function.
Definition: cs_mesh_location.c:478
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:406
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location's type.
Definition: cs_mesh_location.c:520