Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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-2012 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.
89  *----------------------------------------------------------------------------*/
90 
91 typedef void
93  int location_id,
94  cs_lnum_t *n_elts,
95  cs_lnum_t **elt_list);
96 
97 /*=============================================================================
98  * Public function prototypes
99  *============================================================================*/
100 
101 /*----------------------------------------------------------------------------
102  * Return number of mesh locations defined.
103  *----------------------------------------------------------------------------*/
104 
105 int
107 
108 /*----------------------------------------------------------------------------
109  * Initialize mesh location API.
110  *
111  * By default, 5 mesh locations are built, matching the 5 first values of
112  * the cs_mesh_location_type_t enum: CS_MESH_LOCATION_NONE for global
113  * values, CS_MESH_LOCCATION_CELLS for the cellsof the (default) global mesh,
114  * CS_MESH_LOCATION_INTERIOR_FACES and CS_MESH_LOCATION_BOUNDARY_FACES for
115  * its faces, and CS_MESH_LOCATION_VERTICES for its vertices.
116  *
117  * Locations should then be built once the global mesh is complete, and
118  * its halo structures completed.
119  *----------------------------------------------------------------------------*/
120 
121 void
123 
124 /*----------------------------------------------------------------------------
125  * Finalize mesh location API.
126  *----------------------------------------------------------------------------*/
127 
128 void
130 
131 /*----------------------------------------------------------------------------
132  * Associate mesh locations with a mesh.
133  *
134  * If mesh_id is negative, all defined mesh locations are associated
135  * (which is useful for the common case where only one mesh is present).
136  * If mesh_id is non-negative, only the location with the matching
137  * id is associated (which may be useful when multiple meshes are defined).
138  *
139  * The number of elements are computed based on the underlying mesh,
140  * and element lists are built for mesh subset locations.
141  *
142  * parameters:
143  * mesh <-- pointer to associated mesh structure
144  * id <-- id of mesh location
145  *----------------------------------------------------------------------------*/
146 
147 void
149  int id);
150 
151 /*----------------------------------------------------------------------------
152  * Define a new mesh location.
153  *
154  * So as to define a subset of mesh entities of a given type, an optional
155  * selection criteria may be given.
156  *
157  * parameters:
158  * name <-- name of location to define
159  * type <-- type of location to define
160  * criteria <-- selection criteria for associated elements, or NULL
161  *
162  * returns:
163  * id of newly defined created mesh location
164  *----------------------------------------------------------------------------*/
165 
166 int
167 cs_mesh_location_define(const char *name,
169  const char *criteria);
170 
171 /*----------------------------------------------------------------------------
172  * Define a new mesh location.
173  *
174  * So as to define a subset of mesh entities of a given type, a pointer
175  * to a selection function may be given.
176  *
177  * This requires more programming but allows finer control than selection
178  * criteria, as the function has access to the complete mesh structure.
179  *
180  * parameters:
181  * name <-- name of location to define
182  * type <-- type of location to define
183  * func <-- pointer to selection function for associated elements, or NULL
184  *
185  * returns:
186  * id of newly defined created mesh location
187  *----------------------------------------------------------------------------*/
188 
189 int
190 cs_mesh_location_define_by_func(const char *name,
193 
194 /*----------------------------------------------------------------------------
195  * Get a mesh location's name.
196  *
197  * parameters:
198  * id <-- id of mesh location
199  *
200  * returns:
201  * pointer to mesh location name
202  *----------------------------------------------------------------------------*/
203 
204 const char *
206 
207 /*----------------------------------------------------------------------------
208  * Get a mesh location's type.
209  *
210  * parameters:
211  * id <-- id of mesh location
212  *
213  * returns:
214  * mesh location type
215  *----------------------------------------------------------------------------*/
216 
219 
220 /*----------------------------------------------------------------------------
221  * Get a mesh location's number of elements.
222  *
223  * A pointer to a array of 3 values is returned:
224  * 0: local number of elements
225  * 1: with standard ghost elements (if applicable)
226  * 2: with extended ghost elements (if applicable)
227  *
228  * parameters:
229  * id <-- id of mesh location
230  *
231  * returns:
232  * array of numbers of elements.
233  *----------------------------------------------------------------------------*/
234 
235 const cs_lnum_t *
237 
238 /*----------------------------------------------------------------------------
239  * Get a mesh location's elements list, if present.
240  *
241  * A list of elements is defined if the location is a subset of a main
242  * location type.
243  *
244  * parameters:
245  * id <-- id of mesh location
246  *
247  * returns:
248  * pointer to elements list.
249  *----------------------------------------------------------------------------*/
250 
251 const cs_lnum_t *
253 
254 /*----------------------------------------------------------------------------*/
255 
257 
258 #endif /* __CS_MESH_LOCATION_H__ */
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition: cs_mesh_location.c:255
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition: cs_mesh_location.c:234
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition: cs_mesh_location.c:315
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:365
void cs_mesh_location_finalize(void)
Finalize mesh location API.
Definition: cs_mesh_location.c:281
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:430
Definition: cs_mesh_location.h:66
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:531
Definition: mesh.f90:25
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:552
int cs_lnum_t
Definition: cs_defs.h:260
const char * cs_mesh_location_get_name(int id)
Get a mesh location's name.
Definition: cs_mesh_location.c:490
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:92
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:466
Definition: cs_mesh_location.h:62
#define END_C_DECLS
Definition: cs_defs.h:366
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location's type.
Definition: cs_mesh_location.c:508