7.2
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-2022 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 
47 typedef 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 
72 typedef 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 
94 void
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 
113 cs_interpol_grid_create(const char *name);
114 
115 /*----------------------------------------------------------------------------
116  * Create interpolation grid.
117  *
118  * parameters:
119  * ig <-- pointer to an interpol grid structure
120  * nb_points <-- number of considered points
121  * coord <-- coordonates of considered points
122  *----------------------------------------------------------------------------*/
123 
124 void
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 
146 cs_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 coordinates)
165  * influence_radius <-- influence radius for interpolation (xyz interleaved)
166  *----------------------------------------------------------------------------*/
167 
168 void
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 
195 void
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 
217 void
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 
236 cs_measures_set_by_id(int id);
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 
252 cs_interpol_grid_by_id(int id);
253 
254 /*----------------------------------------------------------------------------
255  * Return a pointer to a measure 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 
267 cs_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 
282 cs_interpol_grid_by_name(const char *name);
283 
284 
285 /*----------------------------------------------------------------------------
286  * Destroy all defined measures sets.
287  *----------------------------------------------------------------------------*/
288 
289 void
291 
292 /*----------------------------------------------------------------------------
293  * Destroy all defined grids.
294  *----------------------------------------------------------------------------*/
295 
296 void
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 idim : <-- : Measures set dimension
314  * integer ilved : <-- : 0: not intereaved; 1: interleaved
315  * integer imesset : --> : id of defined measures set
316  *----------------------------------------------------------------------------*/
317 
318 void CS_PROCF(mestcr, MESTCR)
319 (
320  const char *name,
321  const int *idim,
322  const int *ilved,
323  int *imeset);
324 
325 /*----------------------------------------------------------------------------
326  * Define a grid.
327  *
328  * Fortran interface
329  *
330  * subroutine gridcr (name, igrid)
331  * *****************
332  *
333  * character* name : <-- : Measure set name
334  * integer igrid : --> : id of defined grid
335  *----------------------------------------------------------------------------*/
336 
337 void CS_PROCF(gridcr, GRIDCR)
338 (
339  const char *name,
340  int *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 
359 void CS_PROCF(mesmap, MESMAP)
360 (
361  const int *imeset,
362  const int *inbmes,
363  const cs_real_t *meset,
364  const cs_real_t *coords,
365  const int *cressm,
366  const int *interp,
367  const cs_real_t *infrad
368 );
369 
370 /*----------------------------------------------------------------------------
371  * Map a grid grid.
372  *
373  * Fortran interface
374  *
375  * subroutine gridmap (name, lname, igrid)
376  * *****************
377  *
378  * integer igrid : <-- : Measures set id
379  * integer inpts : <-- : Number of measures
380  * cs_real_t* coords : <-- : Pointer to measures coordonates array
381  *----------------------------------------------------------------------------*/
382 
383 void CS_PROCF(grimap, GRIMAP)
384 (
385  const int *igrid,
386  const int *inpts,
387  const cs_real_t *coords
388 );
389 
390 /*----------------------------------------------------------------------------
391  * Add values to a measure set.
392  *
393  * Fortran interface
394  *
395  * subroutine mesadd (imeset, inbmes, meset, coords, cressm, interp)
396  * *****************
397  *
398  * integer imeset : <-- : Measures set id
399  * integer inbmes : <-- : Number of measures to add
400  * cs_real_t* meset : <-- : Pointer to measures values array
401  * cs_real_t* coords : <-- : Pointer to measures coordonates array
402  * integer* cressm : <-- : Pointer to Cressman interpolation flag
403  * integer* interp : <-- : Pointer to interpolation flag
404  * integer* infrad : <-- : Influence radius for interpolation
405  *----------------------------------------------------------------------------*/
406 
407 void CS_PROCF(mesadd, MESADD)
408 (
409  const int *imeset,
410  const int *inbmes,
411  const cs_real_t *meset,
412  const cs_real_t *coords,
413  const int *cressm,
414  const int *interp,
415  const cs_real_t *infrad
416 );
417 
418 /*----------------------------------------------------------------------------
419  * Compute a Cressman interpolation on the global mesh.
420  *
421  * Fortran interface
422  *
423  * subroutine mscrss (imeset, type, pldval)
424  * *****************
425  *
426  * integer imeset : <-- : Measures set id
427  * integer type : <-- : Parameter:
428  * 1: interpolation on volumes
429  * 2: interpolation on boundary faces
430  * cs_real_t* pldval : --> : Interpolated values on the global mesh
431  *----------------------------------------------------------------------------*/
432 
433 void CS_PROCF(mscrss, MSCRSS)
434 (
435  const int *imeset,
436  const int *type,
437  cs_real_t *pldval
438 );
439 
440 /*----------------------------------------------------------------------------
441  * Interpolate calculed field on a grid.
442  *
443  * Fortran interface
444  *
445  * subroutine gripol (igrid, inval, pldval)
446  * *****************
447  *
448  * integer igrid : <-- : Measures set id
449  * cs_real_t* inval : <-- : Values to interpolate
450  * cs_real_t* pldval : --> : Interpolated values on the grid
451  *----------------------------------------------------------------------------*/
452 
453 void CS_PROCF(gripol, GRIPOL)
454 (
455  const int *igrid,
456  const cs_real_t *inval,
457  cs_real_t *pldval
458 );
459 
460 /*----------------------------------------------------------------------------
461  * Destroy measures sets.
462  *
463  * Fortran interface
464  *
465  * subroutine mestde (void)
466  * *****************
467  *----------------------------------------------------------------------------*/
468 
469 void CS_PROCF(mestde, MESTDE)(void);
470 
471 /*----------------------------------------------------------------------------
472  * Destroy grids.
473  *
474  * Fortran interface
475  *
476  * subroutine grides (void)
477  * *****************
478  *----------------------------------------------------------------------------*/
479 
480 void CS_PROCF(grides, GRIDES)(void);
481 
483 
484 #endif /* __CS_MEASURES_H__ */
cs_lnum_t nb_points
Definition: cs_measures_util.h:76
cs_lnum_t nb_measures_max
Definition: cs_measures_util.h:57
Definition: cs_measures_util.h:72
Definition: cs_measures_util.h:47
void mscrss(const int *imeset, const int *type, cs_real_t *pldval)
Definition: cs_measures_util.c:1039
cs_interpol_grid_t * cs_interpol_grid_by_id(int id)
void mestcr(const char *name, const int *idim, const int *ilved, int *imeset)
Definition: cs_measures_util.c:871
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
int * is_cressman
Definition: cs_measures_util.h:59
void cs_interpol_field_on_grid(cs_interpol_grid_t *ig, const cs_real_t *values_to_interpol, cs_real_t *interpoled_values)
void gripol(const int *igrid, const cs_real_t *inval, cs_real_t *pldval)
Definition: cs_measures_util.c:1066
void mesadd(const int *imeset, const int *inbmes, const cs_real_t *meset, const cs_real_t *coords, const int *cressm, const int *interp, const cs_real_t *infrad)
Definition: cs_measures_util.c:1001
int id
Definition: cs_measures_util.h:50
void mestde(void)
Definition: cs_measures_util.c:1088
const char * name
Definition: cs_measures_util.h:74
cs_real_t * coords
Definition: cs_measures_util.h:66
int * rank_connect
Definition: cs_measures_util.h:80
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
int * comp_ids
Definition: cs_measures_util.h:54
cs_interpol_grid_t * cs_interpol_grid_by_name(const char *name)
bool is_connect
Definition: cs_measures_util.h:77
cs_real_t * coords
Definition: cs_measures_util.h:78
void cs_interpol_grid_init(cs_interpol_grid_t *ig, const cs_lnum_t nb_points, const cs_real_t *coords)
void cs_interpol_grids_destroy(void)
integer, save igrid
grid formed by 1D profiles
Definition: atincl.f90:269
const char * name
Definition: cs_measures_util.h:49
cs_measures_set_t * cs_measures_set_by_name(const char *name)
cs_real_t * inf_radius
Definition: cs_measures_util.h:68
bool interleaved
Definition: cs_measures_util.h:58
cs_lnum_t nb_measures
Definition: cs_measures_util.h:56
cs_real_t * measures
Definition: cs_measures_util.h:67
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
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:1102
void cs_cressman_interpol(cs_measures_set_t *ms, cs_real_t *interpolated_values, int id_type)
void cs_measures_sets_destroy(void)
#define END_C_DECLS
Definition: cs_defs.h:511
int * is_interpol
Definition: cs_measures_util.h:62
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)
#define CS_PROCF(x, y)
Definition: cs_defs.h:524
cs_measures_set_t * cs_measures_set_create(const char *name, int type_flag, int dim, bool interleaved)
int type
Definition: cs_measures_util.h:51
int dim
Definition: cs_measures_util.h:53
cs_measures_set_t * cs_measures_set_by_id(int id)
int id
Definition: cs_measures_util.h:75
cs_lnum_t * cell_connect
Definition: cs_measures_util.h:79
cs_interpol_grid_t * cs_interpol_grid_create(const char *name)
void grimap(const int *igrid, const int *inpts, const cs_real_t *coords)
Definition: cs_measures_util.c:970
void gridcr(const char *name, int *igrid)
Definition: cs_measures_util.c:903
void mesmap(const int *imeset, const int *inbmes, const cs_real_t *meset, const cs_real_t *coords, const int *cressm, const int *interp, const cs_real_t *infrad)
Definition: cs_measures_util.c:933