9.1
general documentation
cs_measures_util.h
Go to the documentation of this file.
1#ifndef __CS_MEASURES_H__
2#define __CS_MEASURES_H__
3
4/*============================================================================
5 * Field management.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30#if defined(HAVE_MPI)
31#include <mpi.h>
32#endif
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "base/cs_defs.h"
39
40/*----------------------------------------------------------------------------*/
41
43
44/*----------------------------------------------------------------------------
45 * Definition of the measures set structure
46 *----------------------------------------------------------------------------*/
47
48typedef struct {
49
50 const char *name; /* Name */
51 int id; /* Measures set id */
52 int type; /* Measures set type flag
53 not yet used */
54 int dim; /* Measures set dimension */
55 int *comp_ids; /* index of components of measures if
56 dim > 1 */
57 cs_lnum_t nb_measures; /* Number of measures */
58 cs_lnum_t nb_measures_max; /* Dynamic reallocation parameter */
59 bool interleaved; /* Is measures set interleaved ? */
60 int *is_cressman; /* Is measure cressman interpolated?
61 0: no
62 1: yes */
63 int *is_interpol; /* Is measure taken into account for
64 interpolation ?
65 0: no
66 1: yes */
67 cs_real_t *coords; /* measures coordinates */
68 cs_real_t *measures; /* measures values */
69 cs_real_t *inf_radius; /* influence radius */
70
72
73typedef struct {
74
75 const char *name; /* Name */
76 int id; /* Grid id */
77 cs_lnum_t nb_points; /* Number of grid points */
78 bool is_connect; /* Is connectivity computed? */
79 cs_real_t *coords; /* measures coordinates */
80 cs_lnum_t *cell_connect; /* Mesh -> grid connectivity */
81 int *rank_connect; /* Rank location */
82
84
85/*----------------------------------------------------------------------------
86 * Interpolate mesh field on interpol grid structure.
87 *
88 * This function is deprecated because it take 1 value of the 3D field to
89 * the 1D grid...
90 *
91 * parameters:
92 * ig <-- pointer to the interpolation grid structure
93 * values_to_interpol <-- field on mesh (size = n_cells)
94 * interpolated_values --> interpolated values on the interpolation grid
95 * structure (size = ig->nb_point)
96 *----------------------------------------------------------------------------*/
97
98void
100 const cs_real_t *values_to_interpol,
101 cs_real_t *interpoled_values);
102
103/*----------------------------------------------------------------------------
104 * Interpolate mesh field on interpol grid structure.
105 *
106 * parameters:
107 * ig <-- pointer to the interpolation grid structure
108 * values_to_interpol <-- field on mesh (size = n_cells)
109 * interpolated_values --> interpolated values on the interpolation grid
110 * structure (size = ig->nb_point)
111 *----------------------------------------------------------------------------*/
112
113void
115 const cs_real_t *values_to_interpol,
116 cs_real_t *interpoled_values);
117
118/*----------------------------------------------------------------------------
119 * Create an interpolation grid descriptor.
120 *
121 * For measures set with a dimension greater than 1, components are interleaved.
122 *
123 * parameters:
124 * name <-- grid name
125 *
126 * returns:
127 * pointer to new interpolation grid.
128 *
129 *----------------------------------------------------------------------------*/
130
132cs_interpol_grid_create(const char *name);
133
134/*----------------------------------------------------------------------------
135 * Create interpolation grid.
136 *
137 * parameters:
138 * ig <-- pointer to an interpol grid structure
139 * nb_points <-- number of considered points
140 * coord <-- coordonates of considered points
141 *----------------------------------------------------------------------------*/
142
143void
145 const cs_lnum_t nb_points,
146 const cs_real_t *coords);
147
148/*----------------------------------------------------------------------------
149 * Create a measures set descriptor.
150 *
151 * For measures set with a dimension greater than 1, components are interleaved.
152 *
153 * parameters:
154 * name <-- measures set name
155 * type_flag <-- mask of field property and category values (not used yet)
156 * dim <-- measure set dimension (number of components)
157 * interleaved <-- if dim > 1, indicate if field is interleaved
158 *
159 * returns:
160 * pointer to new measures set.
161 *
162 *----------------------------------------------------------------------------*/
163
165cs_measures_set_create(const char *name,
166 int type_flag,
167 int dim,
168 bool interleaved);
169
170/*----------------------------------------------------------------------------
171 * (re)Allocate and fill in a measures set structure with an array of measures.
172 *
173 * parameters:
174 * ms <-- pointer to the measures set
175 * nb_measures <-- number of measures
176 * is_cressman <-- for each measure cressman interpolation is:
177 * 0: not used
178 * 1: used
179 * is_interpol <-- for the interpolation on mesh, each measure is
180 * 0: not taken into account
181 * 1: taken into account
182 * measures_coords <-- measures spaces coordonates
183 * measures <-- measures values (associated to coordinates)
184 * influence_radius <-- influence radius for interpolation (xyz interleaved)
185 *----------------------------------------------------------------------------*/
186
187void
189 const cs_lnum_t nb_measures,
190 const int *is_cressman,
191 const int *is_interpol,
192 const cs_real_t *measures_coords,
193 const cs_real_t *measures,
194 const cs_real_t *influence_radius);
195
196/*----------------------------------------------------------------------------
197 * Add new measures to an existing measures set (already declared and
198 * allocated).
199 *
200 * parameters:
201 * ms <-- pointer to the existing measures set
202 * nb_measures <-- number of new measures
203 * is_cressman <-- for each new measure cressman interpolation is:
204 * 0: not used
205 * 1: used
206 * is_interpol <-- for the interpolation on mesh, each new measure is
207 * 0: not taken into account
208 * 1: taken into account
209 * measures_coords <-- new measures spaces coordonates
210 * measures <-- new measures values (associated to coordonates)
211 * influence_radius <-- influence radius for interpolation (xyz interleaved)
212 *----------------------------------------------------------------------------*/
213
214void
216 const cs_lnum_t nb_measures,
217 const int *is_cressman,
218 const int *is_interpol,
219 const cs_real_t *measures_coords,
220 const cs_real_t *measures,
221 const cs_real_t *influence_radius);
222
223/*----------------------------------------------------------------------------
224 * Compute a Cressman interpolation on the global mesh.
225 *
226 * parameters:
227 * ms <-- pointer to the measures set structure
228 * (values to interpolate)
229 * interpolated_values --> interpolated values on the global mesh
230 * (size = n_cells or nb_faces)
231 * id_type <-- parameter:
232 * 1: interpolation on volumes
233 * 2: interpolation on boundary faces
234 *----------------------------------------------------------------------------*/
235
236void
238 cs_real_t *interpolated_values,
239 int id_type);
240
241/*----------------------------------------------------------------------------
242 * Return a pointer to a measures set based on its id.
243 *
244 * This function requires that a measures set of the given id is defined.
245 *
246 * parameters:
247 * id <-- measures set id
248 *
249 * return:
250 * pointer to the measures set structure
251 *
252 *----------------------------------------------------------------------------*/
253
256
257/*----------------------------------------------------------------------------
258 * Return a pointer to a grid based on its id.
259 *
260 * This function requires that a grid of the given id is defined.
261 *
262 * parameters:
263 * id <-- grid id
264 *
265 * return:
266 * pointer to the grid structure
267 *
268 *----------------------------------------------------------------------------*/
269
272
273/*----------------------------------------------------------------------------
274 * Return a pointer to a measure set based on its name.
275 *
276 * This function requires that a measure set of the given name is defined.
277 *
278 * parameters:
279 * name <-- measure set name
280 *
281 * return:
282 * pointer to the measures set structure
283 *----------------------------------------------------------------------------*/
284
286cs_measures_set_by_name(const char *name);
287
288/*----------------------------------------------------------------------------
289 * Return a pointer to a grid based on its name.
290 *
291 * This function requires that a grid of the given name is defined.
292 *
293 * parameters:
294 * name <-- grid name
295 *
296 * return:
297 * pointer to the grid structure
298 *----------------------------------------------------------------------------*/
299
301cs_interpol_grid_by_name(const char *name);
302
303/*----------------------------------------------------------------------------
304 * Destroy all defined measures sets.
305 *----------------------------------------------------------------------------*/
306
307void
309
310/*----------------------------------------------------------------------------
311 * Destroy all defined grids.
312 *----------------------------------------------------------------------------*/
313
314void
316
317/*----------------------------------------------------------------------------*/
318
320
321#endif /* __CS_MEASURES_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define END_C_DECLS
Definition: cs_defs.h:555
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
void cs_interpol_field_on_grid(cs_interpol_grid_t *ig, const cs_real_t *values_to_interpol, cs_real_t *interpoled_values)
cs_interpol_grid_t * cs_interpol_grid_by_name(const char *name)
cs_measures_set_t * cs_measures_set_by_id(int id)
void cs_measures_set_map_values(cs_measures_set_t *ms, const cs_lnum_t nb_measures, const int *is_cressman, const int *is_interpol, const cs_real_t *measures_coords, const cs_real_t *measures, const cs_real_t *influence_radius)
void cs_interpol_grid_init(cs_interpol_grid_t *ig, const cs_lnum_t nb_points, const cs_real_t *coords)
cs_interpol_grid_t * cs_interpol_grid_create(const char *name)
void cs_measures_set_add_values(cs_measures_set_t *ms, const cs_lnum_t nb_measures, const int *is_cressman, const int *is_interpol, const cs_real_t *measures_coords, const cs_real_t *measures, const cs_real_t *influence_radius)
void cs_cressman_interpol(cs_measures_set_t *ms, cs_real_t *interpolated_values, int id_type)
cs_interpol_grid_t * cs_interpol_grid_by_id(int id)
cs_measures_set_t * cs_measures_set_create(const char *name, int type_flag, int dim, bool interleaved)
cs_measures_set_t * cs_measures_set_by_name(const char *name)
void cs_interpol_grids_destroy(void)
void cs_interpol_field_on_grid_deprecated(cs_interpol_grid_t *ig, const cs_real_t *values_to_interpol, cs_real_t *interpoled_values)
void cs_measures_sets_destroy(void)
Definition: cs_measures_util.h:73
cs_real_t * coords
Definition: cs_measures_util.h:79
cs_lnum_t nb_points
Definition: cs_measures_util.h:77
int * rank_connect
Definition: cs_measures_util.h:81
bool is_connect
Definition: cs_measures_util.h:78
cs_lnum_t * cell_connect
Definition: cs_measures_util.h:80
int id
Definition: cs_measures_util.h:76
const char * name
Definition: cs_measures_util.h:75
Definition: cs_measures_util.h:48
cs_lnum_t nb_measures
Definition: cs_measures_util.h:57
int * is_cressman
Definition: cs_measures_util.h:60
cs_real_t * coords
Definition: cs_measures_util.h:67
cs_lnum_t nb_measures_max
Definition: cs_measures_util.h:58
int dim
Definition: cs_measures_util.h:54
cs_real_t * measures
Definition: cs_measures_util.h:68
int id
Definition: cs_measures_util.h:51
int * is_interpol
Definition: cs_measures_util.h:63
int * comp_ids
Definition: cs_measures_util.h:55
const char * name
Definition: cs_measures_util.h:50
cs_real_t * inf_radius
Definition: cs_measures_util.h:69
int type
Definition: cs_measures_util.h:52
bool interleaved
Definition: cs_measures_util.h:59