src/mesh/cs_mesh_location.h Source File

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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-2013 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
48 BEGIN_C_DECLS
49
50 /*=============================================================================
51 * Macro definitions
52 *============================================================================*/
53
54 /*============================================================================
55 * Type definitions
56 *============================================================================*/
57
58 /* Mesh location types */
59
60 typedef enum {
61
62 CS_MESH_LOCATION_NONE,
63 CS_MESH_LOCATION_CELLS,
64 CS_MESH_LOCATION_INTERIOR_FACES,
65 CS_MESH_LOCATION_BOUNDARY_FACES,
66 CS_MESH_LOCATION_VERTICES,
67 CS_MESH_LOCATION_PARTICLES,
68 CS_MESH_LOCATION_OTHER
69
70 } cs_mesh_location_type_t;
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
92 (cs_mesh_location_select_t) (const cs_mesh_t *m,
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
106 cs_mesh_location_n_locations(void);
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
122 cs_mesh_location_initialize(void);
123
124 /*----------------------------------------------------------------------------
125 * Finalize mesh location API.
126 *----------------------------------------------------------------------------*/
127
128 void
129 cs_mesh_location_finalize(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
148 cs_mesh_location_build(cs_mesh_t *mesh,
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,
168 cs_mesh_location_type_t type,
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,
191 cs_mesh_location_type_t type,
192 cs_mesh_location_select_t *func);
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 *
205 cs_mesh_location_get_name(int id);
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
217 cs_mesh_location_type_t
218 cs_mesh_location_get_type(int id);
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 *
236 cs_mesh_location_get_n_elts(int id);
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 *
252 cs_mesh_location_get_elt_list(int id);
253
254 /*----------------------------------------------------------------------------*/
255
256 END_C_DECLS
257
258 #endif /* __CS_MESH_LOCATION_H__ */