My Project
programmer's documentation
Loading...
Searching...
No Matches
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
73
74/* Opaque mesh location object */
75
76typedef 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
98typedef 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
111extern 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
121int
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
139void
141
142/*----------------------------------------------------------------------------
143 * Finalize mesh location API.
144 *----------------------------------------------------------------------------*/
145
146void
148
149/*----------------------------------------------------------------------------*/
157/*----------------------------------------------------------------------------*/
158
159int
160cs_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
178void
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
197int
198cs_mesh_location_add(const char *name,
200 const char *criteria);
201
202/*----------------------------------------------------------------------------*/
221/*----------------------------------------------------------------------------*/
222
223int
224cs_mesh_location_add_by_func(const char *name,
227 void *input);
228
229/*----------------------------------------------------------------------------*/
244/*----------------------------------------------------------------------------*/
245
246int
247cs_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
263const 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
294const 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
313const cs_lnum_t *
315
316/*----------------------------------------------------------------------------*/
328/*----------------------------------------------------------------------------*/
329
330const cs_lnum_t *
332
333/*----------------------------------------------------------------------------*/
345/*----------------------------------------------------------------------------*/
346
347const cs_lnum_t *
349
350/*----------------------------------------------------------------------------*/
358/*----------------------------------------------------------------------------*/
359
360const char *
362
363/*----------------------------------------------------------------------------*/
371/*----------------------------------------------------------------------------*/
372
375
376/*----------------------------------------------------------------------------*/
385/*----------------------------------------------------------------------------*/
386
387bool
389
390/*----------------------------------------------------------------------------*/
398/*----------------------------------------------------------------------------*/
399
400void
402 bool explicit_elt_ids);
403
404/*----------------------------------------------------------------------------*/
405
407
408#endif /* __CS_MESH_LOCATION_H__ */
#define BEGIN_C_DECLS
Definition cs_defs.h:467
#define END_C_DECLS
Definition cs_defs.h:468
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:298
const char * cs_mesh_location_type_name[]
void cs_mesh_location_build(cs_mesh_t *mesh, int id)
Associate mesh locations with a mesh.
Definition cs_mesh_location.c:528
cs_mesh_location_type_t
Definition cs_mesh_location.h:60
@ CS_MESH_LOCATION_CELLS
Definition cs_mesh_location.h:63
@ CS_MESH_LOCATION_EDGES
Definition cs_mesh_location.h:68
@ CS_MESH_LOCATION_PARTICLES
Definition cs_mesh_location.h:69
@ CS_MESH_LOCATION_OTHER
Definition cs_mesh_location.h:70
@ CS_MESH_LOCATION_INTERIOR_FACES
Definition cs_mesh_location.h:64
@ CS_MESH_LOCATION_VERTICES
Definition cs_mesh_location.h:66
@ CS_MESH_LOCATION_BOUNDARY_FACES
Definition cs_mesh_location.h:65
@ CS_MESH_LOCATION_FACES
Definition cs_mesh_location.h:67
@ CS_MESH_LOCATION_NONE
Definition cs_mesh_location.h:62
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
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
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
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_select_t * cs_mesh_location_get_selection_function(int id)
Get a mesh location's selection function pointer.
Definition cs_mesh_location.c:938
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
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
const char * cs_mesh_location_get_name(int id)
Get a mesh location's name.
Definition cs_mesh_location.c:782
const char * cs_mesh_location_get_selection_string(int id)
Get a mesh location's selection criteria string.
Definition cs_mesh_location.c:920
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
int cs_mesh_location_n_locations(void)
Return number of mesh locations defined.
Definition cs_mesh_location.c:435
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
void cs_mesh_location_initialize(void)
Initialize mesh location API.
Definition cs_mesh_location.c:458
cs_mesh_location_type_t cs_mesh_location_get_type(int id)
Get a mesh location's type.
Definition cs_mesh_location.c:800
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_try(int id)
Get a mesh location's element ids, if present.
Definition cs_mesh_location.c:869
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
struct _cs_mesh_location_t cs_mesh_location_t
Definition cs_mesh_location.h:76
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
static int input(void)
Definition mesh.f90:26
Definition cs_mesh.h:63