7.0
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-2021 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 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 
319 void CS_PROCF(mestcr, MESTCR)
320 (
321  const char *name,
322  const int *lname,
323  const int *idim,
324  const int *ilved,
325  int *imeset);
326 
327 /*----------------------------------------------------------------------------
328  * Define a grid.
329  *
330  * Fortran interface
331  *
332  * subroutine gridcr (name, lname, igrid)
333  * *****************
334  *
335  * character* name : <-- : Measure set name
336  * integer lname : <-- : Measure set name length
337  * integer igrid : --> : id of defined grid
338  *----------------------------------------------------------------------------*/
339 
340 void CS_PROCF(gridcr, GRIDCR)
341 (
342  const char *name,
343  const int *lname,
344  int *igrid);
345 
346 /*----------------------------------------------------------------------------
347  * (re)Allocate and map values to a measure set.
348  *
349  * Fortran interface
350  *
351  * subroutine mesmap (imeset, inbmes, meset, coords, cressm, interp)
352  * *****************
353  *
354  * integer imeset : <-- : Measures set id
355  * integer inbmes : <-- : Number of measures
356  * cs_real_t* meset : <-- : Pointer to measures values array
357  * cs_real_t* coords : <-- : Pointer to measures coordonates array
358  * integer* cressm : <-- : Pointer to Cressman interpolation flag
359  * integer* interp : <-- : Pointer to interpolation flag
360  * integer* infrad : <-- : Influence radius for interpolation
361  *----------------------------------------------------------------------------*/
362 
363 void CS_PROCF(mesmap, MESMAP)
364 (
365  const int *imeset,
366  const int *inbmes,
367  const cs_real_t *meset,
368  const cs_real_t *coords,
369  const int *cressm,
370  const int *interp,
371  const cs_real_t *infrad
372 );
373 
374 /*----------------------------------------------------------------------------
375  * Map a grid grid.
376  *
377  * Fortran interface
378  *
379  * subroutine gridmap (name, lname, igrid)
380  * *****************
381  *
382  * integer igrid : <-- : Measures set id
383  * integer inpts : <-- : Number of measures
384  * cs_real_t* coords : <-- : Pointer to measures coordonates array
385  *----------------------------------------------------------------------------*/
386 
387 void CS_PROCF(grimap, GRIMAP)
388 (
389  const int *igrid,
390  const int *inpts,
391  const cs_real_t *coords
392 );
393 
394 /*----------------------------------------------------------------------------
395  * Add values to a measure set.
396  *
397  * Fortran interface
398  *
399  * subroutine mesadd (imeset, inbmes, meset, coords, cressm, interp)
400  * *****************
401  *
402  * integer imeset : <-- : Measures set id
403  * integer inbmes : <-- : Number of measures to add
404  * cs_real_t* meset : <-- : Pointer to measures values array
405  * cs_real_t* coords : <-- : Pointer to measures coordonates array
406  * integer* cressm : <-- : Pointer to Cressman interpolation flag
407  * integer* interp : <-- : Pointer to interpolation flag
408  * integer* infrad : <-- : Influence radius for interpolation
409  *----------------------------------------------------------------------------*/
410 
411 void CS_PROCF(mesadd, MESADD)
412 (
413  const int *imeset,
414  const int *inbmes,
415  const cs_real_t *meset,
416  const cs_real_t *coords,
417  const int *cressm,
418  const int *interp,
419  const cs_real_t *infrad
420 );
421 
422 /*----------------------------------------------------------------------------
423  * Compute a Cressman interpolation on the global mesh.
424  *
425  * Fortran interface
426  *
427  * subroutine mscrss (imeset, type, pldval)
428  * *****************
429  *
430  * integer imeset : <-- : Measures set id
431  * integer type : <-- : Parameter:
432  * 1: interpolation on volumes
433  * 2: interpolation on boundary faces
434  * cs_real_t* pldval : --> : Interpolated values on the global mesh
435  *----------------------------------------------------------------------------*/
436 
437 void CS_PROCF(mscrss, MSCRSS)
438 (
439  const int *imeset,
440  const int *type,
441  cs_real_t *pldval
442 );
443 
444 /*----------------------------------------------------------------------------
445  * Interpolate calculed field on a grid.
446  *
447  * Fortran interface
448  *
449  * subroutine gripol (igrid, inval, pldval)
450  * *****************
451  *
452  * integer igrid : <-- : Measures set id
453  * cs_real_t* inval : <-- : Values to interpolate
454  * cs_real_t* pldval : --> : Interpolated values on the grid
455  *----------------------------------------------------------------------------*/
456 
457 void CS_PROCF(gripol, GRIPOL)
458 (
459  const int *igrid,
460  const cs_real_t *inval,
461  cs_real_t *pldval
462 );
463 
464 /*----------------------------------------------------------------------------
465  * Destroy measures sets.
466  *
467  * Fortran interface
468  *
469  * subroutine mestde (void)
470  * *****************
471  *----------------------------------------------------------------------------*/
472 
473 void CS_PROCF(mestde, MESTDE)(void);
474 
475 /*----------------------------------------------------------------------------
476  * Destroy grids.
477  *
478  * Fortran interface
479  *
480  * subroutine grides (void)
481  * *****************
482  *----------------------------------------------------------------------------*/
483 
484 void CS_PROCF(grides, GRIDES)(void);
485 
487 
488 #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:1053
cs_interpol_grid_t * cs_interpol_grid_by_id(int id)
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
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:1080
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:1015
int id
Definition: cs_measures_util.h:50
void mestde(void)
Definition: cs_measures_util.c:1102
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:307
int * comp_ids
Definition: cs_measures_util.h:54
void gridcr(const char *name, const int *lname, int *igrid)
Definition: cs_measures_util.c:911
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)
void mestcr(const char *name, const int *lname, const int *idim, const int *ilved, int *imeset)
Definition: cs_measures_util.c:872
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:301
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:1116
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:496
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:509
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:984
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:947