programmer's 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-2018 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 strcuture
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  * location_id <-- id of associated location
138  * dim <-- measure set dimension (number of components)
139  * interleaved <-- if dim > 1, indicate if field is interleaved
140  *
141  * returns:
142  * pointer to new measures set.
143  *
144  *----------------------------------------------------------------------------*/
145 
147 cs_measures_set_create(const char *name,
148  int type_flag,
149  int dim,
150  bool interleaved);
151 
152 /*----------------------------------------------------------------------------
153  * (re)Allocate and fill in a measures set structure with an array of measures.
154  *
155  * parameters:
156  * ms <-- pointer to the measures set
157  * nb_measures <-- number of measures
158  * is_cressman <-- for each measure cressman interpolation is:
159  * 0: not used
160  * 1: used
161  * is_interpol <-- for the interpolation on mesh, each measure is
162  * 0: not taken into account
163  * 1: taken into account
164  * measures_coords <-- measures spaces coordonates
165  * measures <-- measures values (associated to coordonates)
166  * influence_radius <-- influence radius for interpolation (xyz interleaved)
167  *----------------------------------------------------------------------------*/
168 
169 void
171  const cs_lnum_t nb_measures,
172  const int *is_cressman,
173  const int *is_interpol,
174  const cs_real_t *measures_coords,
175  const cs_real_t *measures,
176  const cs_real_t *influence_radius);
177 
178 /*----------------------------------------------------------------------------
179  * Add new measures to an existing measures set (already declared and
180  * allocated).
181  *
182  * parameters:
183  * ms <-- pointer to the existing measures set
184  * nb_measures <-- number of new measures
185  * is_cressman <-- for each new measure cressman interpolation is:
186  * 0: not used
187  * 1: used
188  * is_interpol <-- for the interpolation on mesh, each new measure is
189  * 0: not taken into account
190  * 1: taken into account
191  * measures_coords <-- new measures spaces coordonates
192  * measures <-- new measures values (associated to coordonates)
193  * influence_radius <-- influence radius for interpolation (xyz interleaved)
194  *----------------------------------------------------------------------------*/
195 
196 void
198  const cs_lnum_t nb_measures,
199  const int *is_cressman,
200  const int *is_interpol,
201  const cs_real_t *measures_coords,
202  const cs_real_t *measures,
203  const cs_real_t *influence_raidus);
204 
205 /*----------------------------------------------------------------------------
206  * Compute a Cressman interpolation on the global mesh.
207  *
208  * parameters:
209  * ms <-- pointer to the measures set structure
210  * (values to interpolate)
211  * interpolated_values --> interpolated values on the global mesh
212  * (size = n_cells or nb_faces)
213  * id_type <-- parameter:
214  * 1: interpolation on volumes
215  * 2: interpolation on boundary faces
216  *----------------------------------------------------------------------------*/
217 
218 void
220  cs_real_t *interpolated_values,
221  int id_type);
222 
223 /*----------------------------------------------------------------------------
224  * Return a pointer to a measures set based on its id.
225  *
226  * This function requires that a measures set of the given id is defined.
227  *
228  * parameters:
229  * id <-- measures set id
230  *
231  * return:
232  * pointer to the measures set structure
233  *
234  *----------------------------------------------------------------------------*/
235 
237 cs_measures_set_by_id(int id);
238 
239 /*----------------------------------------------------------------------------
240  * Return a pointer to a grid based on its id.
241  *
242  * This function requires that a grid of the given id is defined.
243  *
244  * parameters:
245  * id <-- grid id
246  *
247  * return:
248  * pointer to the grid structure
249  *
250  *----------------------------------------------------------------------------*/
251 
253 cs_interpol_grid_by_id(int id);
254 
255 /*----------------------------------------------------------------------------
256  * Return a pointer to a measures set based on its name.
257  *
258  * This function requires that a measure set of the given name is defined.
259  *
260  * parameters:
261  * name <-- measure set name
262  *
263  * return:
264  * pointer to the measures set structure
265  *----------------------------------------------------------------------------*/
266 
268 cs_measures_set_by_name(const char *name);
269 
270 /*----------------------------------------------------------------------------
271  * Return a pointer to a grid based on its name.
272  *
273  * This function requires that a grid of the given name is defined.
274  *
275  * parameters:
276  * name <-- grid name
277  *
278  * return:
279  * pointer to the grid structure
280  *----------------------------------------------------------------------------*/
281 
283 cs_interpol_grid_by_name(const char *name);
284 
285 
286 /*----------------------------------------------------------------------------
287  * Destroy all defined measures sets.
288  *----------------------------------------------------------------------------*/
289 
290 void
292 
293 /*----------------------------------------------------------------------------
294  * Destroy all defined grids.
295  *----------------------------------------------------------------------------*/
296 
297 void
299 
300 
301 /*============================================================================
302  * Public function definitions for Fortran API
303  *============================================================================*/
304 
305 /*----------------------------------------------------------------------------
306  * Define a measures set.
307  *
308  * Fortran interface; use mestcr;
309  *
310  * subroutine mestcr (name, lname, idim, ilved, imeset)
311  * *****************
312  *
313  * character* name : <-- : Measure set name
314  * integer lname : <-- : Measure set name length
315  * integer idim : <-- : Measures set dimension
316  * integer ilved : <-- : 0: not intereaved; 1: interleaved
317  * integer imesset : --> : id of defined measures set
318  *----------------------------------------------------------------------------*/
319 
320 void CS_PROCF(mestcr, MESTCR)(const char *name,
321  const cs_int_t *lname,
322  const cs_int_t *idim,
323  const cs_int_t *ilved,
324  cs_int_t *imeset);
325 
326 /*----------------------------------------------------------------------------
327  * Define a grid.
328  *
329  * Fortran interface
330  *
331  * subroutine gridcr (name, lname, igrid)
332  * *****************
333  *
334  * character* name : <-- : Measure set name
335  * integer lname : <-- : Measure set name length
336  * integer igrid : --> : id of defined grid
337  *----------------------------------------------------------------------------*/
338 
339 void CS_PROCF(gridcr, GRIDCR)(const char *name,
340  const cs_int_t *lname,
341  cs_int_t *igrid);
342 
343 /*----------------------------------------------------------------------------
344  * (re)Allocate and map values to a measure set.
345  *
346  * Fortran interface
347  *
348  * subroutine mesmap (imeset, inbmes, meset, coords, cressm, interp)
349  * *****************
350  *
351  * integer imeset : <-- : Measures set id
352  * integer inbmes : <-- : Number of measures
353  * cs_real_t* meset : <-- : Pointer to measures values array
354  * cs_real_t* coords : <-- : Pointer to measures coordonates array
355  * integer* cressm : <-- : Pointer to Cressman interpolation flag
356  * integer* interp : <-- : Pointer to interpolation flag
357  * integer* infrad : <-- : Influence radius for interpolation
358  *----------------------------------------------------------------------------*/
359 
360 void CS_PROCF(mesmap, MESMAP)(const cs_int_t *imeset,
361  const cs_int_t *inbmes,
362  const cs_real_t *meset,
363  const cs_real_t *coords,
364  const cs_int_t *cressm,
365  const cs_int_t *interp,
366  const cs_real_t *infrad);
367 
368 /*----------------------------------------------------------------------------
369  * Map a grid grid.
370  *
371  * Fortran interface
372  *
373  * subroutine gridmap (name, lname, igrid)
374  * *****************
375  *
376  * integer igrid : <-- : Measures set id
377  * integer inpts : <-- : Number of measures
378  * cs_real_t* coords : <-- : Pointer to measures coordonates array
379  *----------------------------------------------------------------------------*/
380 
381 void CS_PROCF(grimap, GRIMAP)(const cs_int_t *igrid,
382  const cs_int_t *inpts,
383  const cs_real_t *coords);
384 
385 /*----------------------------------------------------------------------------
386  * Add values to a measure set.
387  *
388  * Fortran interface
389  *
390  * subroutine mesadd (imeset, inbmes, meset, coords, cressm, interp)
391  * *****************
392  *
393  * integer imeset : <-- : Measures set id
394  * integer inbmes : <-- : Number of measures to add
395  * cs_real_t* meset : <-- : Pointer to measures values array
396  * cs_real_t* coords : <-- : Pointer to measures coordonates array
397  * integer* cressm : <-- : Pointer to Cressman interpolation flag
398  * integer* interp : <-- : Pointer to interpolation flag
399  * integer* infrad : <-- : Influence radius for interpolation
400  *----------------------------------------------------------------------------*/
401 
402 void CS_PROCF(mesadd, MESADD)(const cs_int_t *imeset,
403  const cs_int_t *inbmes,
404  const cs_real_t *meset,
405  const cs_real_t *coords,
406  const cs_int_t *cressm,
407  const cs_int_t *interp,
408  const cs_real_t *infrad);
409 
410 /*----------------------------------------------------------------------------
411  * Compute a Cressman interpolation on the global mesh.
412  *
413  * Fortran interface
414  *
415  * subroutine mscrss (imeset, type, pldval)
416  * *****************
417  *
418  * integer imeset : <-- : Measures set id
419  * integer type : <-- : Parameter:
420  * 1: interpolation on volumes
421  * 2: interpolation on boundary faces
422  * cs_real_t* pldval : --> : Interpolated values on the global mesh
423  *----------------------------------------------------------------------------*/
424 
425 void CS_PROCF(mscrss, MSCRSS)(const cs_int_t *imeset,
426  const cs_int_t *type,
427  cs_real_t *pldval);
428 
429 /*----------------------------------------------------------------------------
430  * Interpolate calculed field on a grid.
431  *
432  * Fortran interface
433  *
434  * subroutine gripol (igrid, inval, pldval)
435  * *****************
436  *
437  * integer igrid : <-- : Measures set id
438  * cs_real_t* inval : <-- : Values to interpolate
439  * cs_real_t* pldval : --> : Interpolated values on the grid
440  *----------------------------------------------------------------------------*/
441 
442 void CS_PROCF(gripol, GRIPOL)(const cs_int_t *igrid,
443  const cs_real_t *inval,
444  cs_real_t *pldval);
445 
446 /*----------------------------------------------------------------------------
447  * Destroy measures sets.
448  *
449  * Fortran interface
450  *
451  * subroutine mestde (void)
452  * *****************
453  *----------------------------------------------------------------------------*/
454 
455 void CS_PROCF(mestde, MESTDE)(void);
456 
457 /*----------------------------------------------------------------------------
458  * Destroy grids.
459  *
460  * Fortran interface
461  *
462  * subroutine grides (void)
463  * *****************
464  *----------------------------------------------------------------------------*/
465 
466 void CS_PROCF(grides, GRIDES)(void);
467 
469 
470 #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
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
Definition: cs_measures_util.h:47
cs_interpol_grid_t * cs_interpol_grid_by_id(int id)
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
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_raidus)
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:296
int * is_cressman
Definition: cs_measures_util.h:59
void gripol(const cs_int_t *igrid, const cs_real_t *inval, cs_real_t *pldval)
Definition: cs_measures_util.c:1079
void cs_interpol_field_on_grid(cs_interpol_grid_t *ig, const cs_real_t *values_to_interpol, cs_real_t *interpoled_values)
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
int id
Definition: cs_measures_util.h:50
void mestde(void)
Definition: cs_measures_util.c:1101
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:297
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
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_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:206
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
void gridcr(const char *name, const cs_int_t *lname, cs_int_t *igrid)
Definition: cs_measures_util.c:910
cs_real_t * measures
Definition: cs_measures_util.h:67
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void grides(void)
Definition: cs_measures_util.c:1115
void cs_cressman_interpol(cs_measures_set_t *ms, cs_real_t *interpolated_values, int id_type)
void mscrss(const cs_int_t *imeset, const cs_int_t *type, cs_real_t *pldval)
Definition: cs_measures_util.c:1052
void cs_measures_sets_destroy(void)
#define END_C_DECLS
Definition: cs_defs.h:452
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:465
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
void grimap(const cs_int_t *igrid, const cs_int_t *inpts, const cs_real_t *coords)
Definition: cs_measures_util.c:983
cs_lnum_t * cell_connect
Definition: cs_measures_util.h:79
cs_interpol_grid_t * cs_interpol_grid_create(const char *name)