My Project
programmer's documentation
Loading...
Searching...
No Matches
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-2019 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 "cs_defs.h"
39
40/*----------------------------------------------------------------------------*/
41
43/*----------------------------------------------------------------------------
44 * Definition of the measures set structure
45 *----------------------------------------------------------------------------*/
46
47typedef struct _cs_measures_set_t {
48
49 const char *name; /* Name */
50 int id; /* Measures set id */
51 int type; /* Measures set type flag
52 not yet used */
53 int dim; /* Measures set dimension */
54 int *comp_ids; /* index of components of measures if
55 dim > 1 */
56 cs_lnum_t nb_measures; /* Number of measures */
57 cs_lnum_t nb_measures_max; /* Dynamic reallocation parameter */
58 bool interleaved; /* Is measures set interleaved ? */
59 int *is_cressman; /* Is measure cressman interpolated?
60 0: no
61 1: yes */
62 int *is_interpol; /* Is measure taken into account for
63 interpolation ?
64 0: no
65 1: yes */
66 cs_real_t *coords; /* measures coordinates */
67 cs_real_t *measures; /* measures values */
68 cs_real_t *inf_radius; /* influence radius */
69
71
72typedef struct _cs_interpol_grid_t {
73
74 const char *name; /* Name */
75 int id; /* Grid id */
76 cs_lnum_t nb_points; /* Number of grid points */
77 bool is_connect; /* Is connectivity computed? */
78 cs_real_t *coords; /* measures coordinates */
79 cs_lnum_t *cell_connect; /* Mesh -> grid connectivity */
80 int *rank_connect; /* Rank location */
81
83
84/*----------------------------------------------------------------------------
85 * Interpolate mesh field on interpol grid structure.
86 *
87 * parameters:
88 * ig <-- pointer to the interpolation grid structure
89 * values_to_interpol <-- field on mesh (size = n_cells)
90 * interpolated_values --> interpolated values on the interpolation grid
91 * structure (size = ig->nb_point)
92 *----------------------------------------------------------------------------*/
93
94void
96 const cs_real_t *values_to_interpol,
97 cs_real_t *interpoled_values);
98
99/*----------------------------------------------------------------------------
100 * Create an interpolation grid descriptor.
101 *
102 * For measures set with a dimension greater than 1, components are interleaved.
103 *
104 * parameters:
105 * name <-- grid name
106 *
107 * returns:
108 * pointer to new interpolation grid.
109 *
110 *----------------------------------------------------------------------------*/
111
113cs_interpol_grid_create(const char *name);
114
115/*----------------------------------------------------------------------------
116 * Create interpolation grid.
117 *
118 * parameters:
119 * ig <-- pointer to an interpol grid strcuture
120 * nb_points <-- number of considered points
121 * coord <-- coordonates of considered points
122 *----------------------------------------------------------------------------*/
123
124void
126 const cs_lnum_t nb_points,
127 const cs_real_t *coords);
128
129/*----------------------------------------------------------------------------
130 * Create a measures set descriptor.
131 *
132 * For measures set with a dimension greater than 1, components are interleaved.
133 *
134 * parameters:
135 * name <-- measures set name
136 * type_flag <-- mask of field property and category values (not used yet)
137 * dim <-- measure set dimension (number of components)
138 * interleaved <-- if dim > 1, indicate if field is interleaved
139 *
140 * returns:
141 * pointer to new measures set.
142 *
143 *----------------------------------------------------------------------------*/
144
146cs_measures_set_create(const char *name,
147 int type_flag,
148 int dim,
149 bool interleaved);
150
151/*----------------------------------------------------------------------------
152 * (re)Allocate and fill in a measures set structure with an array of measures.
153 *
154 * parameters:
155 * ms <-- pointer to the measures set
156 * nb_measures <-- number of measures
157 * is_cressman <-- for each measure cressman interpolation is:
158 * 0: not used
159 * 1: used
160 * is_interpol <-- for the interpolation on mesh, each measure is
161 * 0: not taken into account
162 * 1: taken into account
163 * measures_coords <-- measures spaces coordonates
164 * measures <-- measures values (associated to coordonates)
165 * influence_radius <-- influence radius for interpolation (xyz interleaved)
166 *----------------------------------------------------------------------------*/
167
168void
170 const cs_lnum_t nb_measures,
171 const int *is_cressman,
172 const int *is_interpol,
173 const cs_real_t *measures_coords,
174 const cs_real_t *measures,
175 const cs_real_t *influence_radius);
176
177/*----------------------------------------------------------------------------
178 * Add new measures to an existing measures set (already declared and
179 * allocated).
180 *
181 * parameters:
182 * ms <-- pointer to the existing measures set
183 * nb_measures <-- number of new measures
184 * is_cressman <-- for each new measure cressman interpolation is:
185 * 0: not used
186 * 1: used
187 * is_interpol <-- for the interpolation on mesh, each new measure is
188 * 0: not taken into account
189 * 1: taken into account
190 * measures_coords <-- new measures spaces coordonates
191 * measures <-- new measures values (associated to coordonates)
192 * influence_radius <-- influence radius for interpolation (xyz interleaved)
193 *----------------------------------------------------------------------------*/
194
195void
197 const cs_lnum_t nb_measures,
198 const int *is_cressman,
199 const int *is_interpol,
200 const cs_real_t *measures_coords,
201 const cs_real_t *measures,
202 const cs_real_t *influence_radius);
203
204/*----------------------------------------------------------------------------
205 * Compute a Cressman interpolation on the global mesh.
206 *
207 * parameters:
208 * ms <-- pointer to the measures set structure
209 * (values to interpolate)
210 * interpolated_values --> interpolated values on the global mesh
211 * (size = n_cells or nb_faces)
212 * id_type <-- parameter:
213 * 1: interpolation on volumes
214 * 2: interpolation on boundary faces
215 *----------------------------------------------------------------------------*/
216
217void
219 cs_real_t *interpolated_values,
220 int id_type);
221
222/*----------------------------------------------------------------------------
223 * Return a pointer to a measures set based on its id.
224 *
225 * This function requires that a measures set of the given id is defined.
226 *
227 * parameters:
228 * id <-- measures set id
229 *
230 * return:
231 * pointer to the measures set structure
232 *
233 *----------------------------------------------------------------------------*/
234
237
238/*----------------------------------------------------------------------------
239 * Return a pointer to a grid based on its id.
240 *
241 * This function requires that a grid of the given id is defined.
242 *
243 * parameters:
244 * id <-- grid id
245 *
246 * return:
247 * pointer to the grid structure
248 *
249 *----------------------------------------------------------------------------*/
250
253
254/*----------------------------------------------------------------------------
255 * Return a pointer to a measures set based on its name.
256 *
257 * This function requires that a measure set of the given name is defined.
258 *
259 * parameters:
260 * name <-- measure set name
261 *
262 * return:
263 * pointer to the measures set structure
264 *----------------------------------------------------------------------------*/
265
267cs_measures_set_by_name(const char *name);
268
269/*----------------------------------------------------------------------------
270 * Return a pointer to a grid based on its name.
271 *
272 * This function requires that a grid of the given name is defined.
273 *
274 * parameters:
275 * name <-- grid name
276 *
277 * return:
278 * pointer to the grid structure
279 *----------------------------------------------------------------------------*/
280
282cs_interpol_grid_by_name(const char *name);
283
284
285/*----------------------------------------------------------------------------
286 * Destroy all defined measures sets.
287 *----------------------------------------------------------------------------*/
288
289void
291
292/*----------------------------------------------------------------------------
293 * Destroy all defined grids.
294 *----------------------------------------------------------------------------*/
295
296void
298
299
300/*============================================================================
301 * Public function definitions for Fortran API
302 *============================================================================*/
303
304/*----------------------------------------------------------------------------
305 * Define a measures set.
306 *
307 * Fortran interface; use mestcr;
308 *
309 * subroutine mestcr (name, lname, idim, ilved, imeset)
310 * *****************
311 *
312 * character* name : <-- : Measure set name
313 * integer lname : <-- : Measure set name length
314 * integer idim : <-- : Measures set dimension
315 * integer ilved : <-- : 0: not intereaved; 1: interleaved
316 * integer imesset : --> : id of defined measures set
317 *----------------------------------------------------------------------------*/
318
319void CS_PROCF(mestcr, MESTCR)(const char *name,
320 const cs_int_t *lname,
321 const cs_int_t *idim,
322 const cs_int_t *ilved,
323 cs_int_t *imeset);
324
325/*----------------------------------------------------------------------------
326 * Define a grid.
327 *
328 * Fortran interface
329 *
330 * subroutine gridcr (name, lname, igrid)
331 * *****************
332 *
333 * character* name : <-- : Measure set name
334 * integer lname : <-- : Measure set name length
335 * integer igrid : --> : id of defined grid
336 *----------------------------------------------------------------------------*/
337
338void CS_PROCF(gridcr, GRIDCR)(const char *name,
339 const cs_int_t *lname,
340 cs_int_t *igrid);
341
342/*----------------------------------------------------------------------------
343 * (re)Allocate and map values to a measure set.
344 *
345 * Fortran interface
346 *
347 * subroutine mesmap (imeset, inbmes, meset, coords, cressm, interp)
348 * *****************
349 *
350 * integer imeset : <-- : Measures set id
351 * integer inbmes : <-- : Number of measures
352 * cs_real_t* meset : <-- : Pointer to measures values array
353 * cs_real_t* coords : <-- : Pointer to measures coordonates array
354 * integer* cressm : <-- : Pointer to Cressman interpolation flag
355 * integer* interp : <-- : Pointer to interpolation flag
356 * integer* infrad : <-- : Influence radius for interpolation
357 *----------------------------------------------------------------------------*/
358
359void CS_PROCF(mesmap, MESMAP)(const cs_int_t *imeset,
360 const cs_int_t *inbmes,
361 const cs_real_t *meset,
362 const cs_real_t *coords,
363 const cs_int_t *cressm,
364 const cs_int_t *interp,
365 const cs_real_t *infrad);
366
367/*----------------------------------------------------------------------------
368 * Map a grid grid.
369 *
370 * Fortran interface
371 *
372 * subroutine gridmap (name, lname, igrid)
373 * *****************
374 *
375 * integer igrid : <-- : Measures set id
376 * integer inpts : <-- : Number of measures
377 * cs_real_t* coords : <-- : Pointer to measures coordonates array
378 *----------------------------------------------------------------------------*/
379
380void CS_PROCF(grimap, GRIMAP)(const cs_int_t *igrid,
381 const cs_int_t *inpts,
382 const cs_real_t *coords);
383
384/*----------------------------------------------------------------------------
385 * Add values to a measure set.
386 *
387 * Fortran interface
388 *
389 * subroutine mesadd (imeset, inbmes, meset, coords, cressm, interp)
390 * *****************
391 *
392 * integer imeset : <-- : Measures set id
393 * integer inbmes : <-- : Number of measures to add
394 * cs_real_t* meset : <-- : Pointer to measures values array
395 * cs_real_t* coords : <-- : Pointer to measures coordonates array
396 * integer* cressm : <-- : Pointer to Cressman interpolation flag
397 * integer* interp : <-- : Pointer to interpolation flag
398 * integer* infrad : <-- : Influence radius for interpolation
399 *----------------------------------------------------------------------------*/
400
401void CS_PROCF(mesadd, MESADD)(const cs_int_t *imeset,
402 const cs_int_t *inbmes,
403 const cs_real_t *meset,
404 const cs_real_t *coords,
405 const cs_int_t *cressm,
406 const cs_int_t *interp,
407 const cs_real_t *infrad);
408
409/*----------------------------------------------------------------------------
410 * Compute a Cressman interpolation on the global mesh.
411 *
412 * Fortran interface
413 *
414 * subroutine mscrss (imeset, type, pldval)
415 * *****************
416 *
417 * integer imeset : <-- : Measures set id
418 * integer type : <-- : Parameter:
419 * 1: interpolation on volumes
420 * 2: interpolation on boundary faces
421 * cs_real_t* pldval : --> : Interpolated values on the global mesh
422 *----------------------------------------------------------------------------*/
423
424void CS_PROCF(mscrss, MSCRSS)(const cs_int_t *imeset,
425 const cs_int_t *type,
426 cs_real_t *pldval);
427
428/*----------------------------------------------------------------------------
429 * Interpolate calculed field on a grid.
430 *
431 * Fortran interface
432 *
433 * subroutine gripol (igrid, inval, pldval)
434 * *****************
435 *
436 * integer igrid : <-- : Measures set id
437 * cs_real_t* inval : <-- : Values to interpolate
438 * cs_real_t* pldval : --> : Interpolated values on the grid
439 *----------------------------------------------------------------------------*/
440
441void CS_PROCF(gripol, GRIPOL)(const cs_int_t *igrid,
442 const cs_real_t *inval,
443 cs_real_t *pldval);
444
445/*----------------------------------------------------------------------------
446 * Destroy measures sets.
447 *
448 * Fortran interface
449 *
450 * subroutine mestde (void)
451 * *****************
452 *----------------------------------------------------------------------------*/
453
454void CS_PROCF(mestde, MESTDE)(void);
455
456/*----------------------------------------------------------------------------
457 * Destroy grids.
458 *
459 * Fortran interface
460 *
461 * subroutine grides (void)
462 * *****************
463 *----------------------------------------------------------------------------*/
464
465void CS_PROCF(grides, GRIDES)(void);
466
468
469#endif /* __CS_MEASURES_H__ */
#define BEGIN_C_DECLS
Definition cs_defs.h:467
double cs_real_t
Floating-point value.
Definition cs_defs.h:302
int cs_int_t
Fortran-compatible integer.
Definition cs_defs.h:301
#define CS_PROCF(x, y)
Definition cs_defs.h:481
#define END_C_DECLS
Definition cs_defs.h:468
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:298
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)
void mesmap(const cs_int_t *imeset, const cs_int_t *inbmes, const cs_real_t *meset, const cs_real_t *coords, const cs_int_t *cressm, const cs_int_t *interp, const cs_real_t *infrad)
Definition cs_measures_util.c:946
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 grides(void)
Definition cs_measures_util.c:1115
void gridcr(const char *name, const cs_int_t *lname, cs_int_t *igrid)
Definition cs_measures_util.c:910
void cs_cressman_interpol(cs_measures_set_t *ms, cs_real_t *interpolated_values, int id_type)
void gripol(const cs_int_t *igrid, const cs_real_t *inval, cs_real_t *pldval)
Definition cs_measures_util.c:1079
void mestcr(const char *name, const cs_int_t *lname, const cs_int_t *idim, const cs_int_t *ilved, cs_int_t *imeset)
Definition cs_measures_util.c:871
void mscrss(const cs_int_t *imeset, const cs_int_t *type, cs_real_t *pldval)
Definition cs_measures_util.c:1052
cs_interpol_grid_t * cs_interpol_grid_by_id(int id)
void grimap(const cs_int_t *igrid, const cs_int_t *inpts, const cs_real_t *coords)
Definition cs_measures_util.c:983
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 mestde(void)
Definition cs_measures_util.c:1101
void cs_interpol_grids_destroy(void)
void mesadd(const cs_int_t *imeset, const cs_int_t *inbmes, const cs_real_t *meset, const cs_real_t *coords, const cs_int_t *cressm, const cs_int_t *interp, const cs_real_t *infrad)
Definition cs_measures_util.c:1014
void cs_measures_sets_destroy(void)
Definition cs_measures_util.h:72
cs_real_t * coords
Definition cs_measures_util.h:78
cs_lnum_t nb_points
Definition cs_measures_util.h:76
int * rank_connect
Definition cs_measures_util.h:80
bool is_connect
Definition cs_measures_util.h:77
cs_lnum_t * cell_connect
Definition cs_measures_util.h:79
int id
Definition cs_measures_util.h:75
const char * name
Definition cs_measures_util.h:74
Definition cs_measures_util.h:47
cs_lnum_t nb_measures
Definition cs_measures_util.h:56
int * is_cressman
Definition cs_measures_util.h:59
cs_real_t * coords
Definition cs_measures_util.h:66
cs_lnum_t nb_measures_max
Definition cs_measures_util.h:57
int dim
Definition cs_measures_util.h:53
cs_real_t * measures
Definition cs_measures_util.h:67
int id
Definition cs_measures_util.h:50
int * is_interpol
Definition cs_measures_util.h:62
int * comp_ids
Definition cs_measures_util.h:54
const char * name
Definition cs_measures_util.h:49
cs_real_t * inf_radius
Definition cs_measures_util.h:68
int type
Definition cs_measures_util.h:51
bool interleaved
Definition cs_measures_util.h:58