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