My Project
programmer's documentation
cs_interface.h
Go to the documentation of this file.
1 #ifndef __CS_INTERFACE_H__
2 #define __CS_INTERFACE_H__
3 
4 /*============================================================================
5  * Main structure for handling of interfaces associating mesh elements
6  * (such as inter-processor or periodic connectivity between cells, faces,
7  * or vertices);
8  *============================================================================*/
9 
10 /*
11  This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13  Copyright (C) 1998-2019 EDF S.A.
14 
15  This program is free software; you can redistribute it and/or modify it under
16  the terms of the GNU General Public License as published by the Free Software
17  Foundation; either version 2 of the License, or (at your option) any later
18  version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23  details.
24 
25  You should have received a copy of the GNU General Public License along with
26  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27  Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------*/
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *----------------------------------------------------------------------------*/
35 
36 #include "fvm_defs.h"
37 #include "fvm_periodicity.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*=============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Type definitions
49  *============================================================================*/
50 
51 /*----------------------------------------------------------------------------
52  * Structure defining an I/O numbering scheme
53  *----------------------------------------------------------------------------*/
54 
55 /*
56  Pointer to structures representing an interface and a list of interfaces.
57  The structures themselves are private, and are defined in cs_interface.c
58 */
59 
60 typedef struct _cs_interface_t cs_interface_t;
61 typedef struct _cs_interface_set_t cs_interface_set_t;
62 
63 /*=============================================================================
64  * Static global variables
65  *============================================================================*/
66 
67 /*=============================================================================
68  * Public function prototypes
69  *============================================================================*/
70 
71 /*----------------------------------------------------------------------------
72  * Return process rank associated with an interface's distant elements.
73  *
74  * parameters:
75  * itf <-- pointer to interface structure
76  *
77  * returns:
78  * process rank associated with the interface's distant elements
79  *----------------------------------------------------------------------------*/
80 
81 int
83 
84 /*----------------------------------------------------------------------------
85  * Return number of local and distant elements defining an interface.
86  *
87  * parameters:
88  * itf <-- pointer to interface structure
89  *
90  * returns:
91  * number of local and distant elements defining the interface
92  *----------------------------------------------------------------------------*/
93 
96 
97 /*----------------------------------------------------------------------------
98  * Return pointer to array of local element ids defining an interface.
99  *
100  * The size of the array may be obtained by cs_interface_size().
101  * The array is owned by the interface structure, and is not copied
102  * (hence the constant qualifier for the return value).
103  *
104  * parameters:
105  * itf <-- pointer to interface structure
106  *
107  * returns:
108  * pointer to array of local element ids (0 to n-1) defining the interface
109  *----------------------------------------------------------------------------*/
110 
111 const cs_lnum_t *
113 
114 /*----------------------------------------------------------------------------
115  * Return pointer to array of matching element ids defining an interface.
116  *
117  * This array is only available if cs_interface_set_add_match_ids() has
118  * been called for the containing interface set.
119  *
120  * The size of the array may be obtained by cs_interface_size().
121  * The array is owned by the interface structure, and is not copied
122  * (hence the constant qualifier for the return value).
123  *
124  * parameters:
125  * itf <-- pointer to interface structure
126  *
127  * returns:
128  * pointer to array of local element ids (0 to n-1) defining the interface
129  *----------------------------------------------------------------------------*/
130 
131 const cs_lnum_t *
133 
134 /*----------------------------------------------------------------------------
135  * Return size of index of sub-sections for different transformations.
136  *
137  * The index is applicable to both local_num and distant_num arrays,
138  * with purely parallel equivalences appearing at position 0, and
139  * equivalences through periodic transform i at position i+1;
140  * Its size should thus be equal to 1 + number of periodic transforms + 1,
141  * In absence of periodicity, it may be 0, as the index is not needed.
142  *
143  * parameters:
144  * itf <-- pointer to interface structure
145  *
146  * returns:
147  * transform index size for the interface
148  *----------------------------------------------------------------------------*/
149 
150 cs_lnum_t
152 
153 /*----------------------------------------------------------------------------
154  * Return pointer to index of sub-sections for different transformations.
155  *
156  * The index is applicable to both local_num and distant_num arrays,
157  * with purely parallel equivalences appearing at position 0, and
158  * equivalences through periodic transform i at position i+1;
159  * In absence of periodicity, it may be NULL, as it is not needed.
160  *
161  * parameters:
162  * itf <-- pointer to interface structure
163  *
164  * returns:
165  * pointer to transform index for the interface
166  *----------------------------------------------------------------------------*/
167 
168 const cs_lnum_t *
170 
171 /*----------------------------------------------------------------------------
172  * Creation of a list of interfaces between elements of a same type.
173  *
174  * These interfaces may be used to identify equivalent vertices or faces using
175  * domain splitting, as well as periodic elements (on the same or on
176  * distant ranks).
177  *
178  * Note that periodicity information will be completed and made consistent
179  * based on the input, so that if a periodic couple is defined on a given rank,
180  * the reverse couple wil be defined, whether it is also defined on the same
181  * or a different rank.
182  *
183  * In addition, multiple periodicity interfaces will be built automatically
184  * if the periodicity structure provides for composed periodicities, so they
185  * need not be defined prior to this function.
186  *
187  * parameters:
188  * n_elts <-- number of local elements considered
189  * (size of parent_element_id[]
190  * parent_element_id <-- pointer to list of selected elements local
191  * numbers (0 to n-1), or NULL if all first n_elts
192  * elements are used
193  * global_number <-- pointer to list of global (i.e. domain splitting
194  * independent) element numbers
195  * periodicity <-- periodicity information (NULL if none)
196  * n_periodic_lists <-- number of periodic lists (may be local)
197  * periodicity_num <-- periodicity number (1 to n) associated with
198  * each periodic list (primary periodicities only)
199  * n_periodic_couples <-- number of periodic couples associated with
200  * each periodic list
201  * periodic_couples <-- array indicating periodic couples (using
202  * global numberings) for each list
203  *
204  * returns:
205  * pointer to list of interfaces (possibly NULL in serial mode)
206  *----------------------------------------------------------------------------*/
207 
210  const cs_lnum_t parent_element_id[],
211  const cs_gnum_t global_number[],
212  const fvm_periodicity_t *periodicity,
213  int n_periodic_lists,
214  const int periodicity_num[],
215  const cs_lnum_t n_periodic_couples[],
216  const cs_gnum_t *const periodic_couples[]);
217 
218 /*----------------------------------------------------------------------------
219  * Destruction of an interface set.
220  *
221  * parameters:
222  * ifs <-> pointer to pointer to structure to destroy
223  *----------------------------------------------------------------------------*/
224 
225 void
227 
228 /*----------------------------------------------------------------------------
229  * Return number of interfaces associated with an interface set.
230  *
231  * parameters:
232  * ifs <-- pointer to interface set structure
233  *
234  * returns:
235  * number of interfaces in set
236  *----------------------------------------------------------------------------*/
237 
238 int
240 
241 /*----------------------------------------------------------------------------
242  * Return total number of elements in interface set.
243  *
244  * This is equal to the sum of cs_interface_size() on the cs_interface_size()
245  * interfaces of a set.
246  *
247  * parameters:
248  * ifs <-- pointer to interface set structure
249  *
250  * returns:
251  * number of interfaces in set
252  *----------------------------------------------------------------------------*/
253 
254 cs_lnum_t
256 
257 /*----------------------------------------------------------------------------
258  * Return pointer to a given interface in an interface set.
259  *
260  * parameters:
261  * ifs <-- pointer to interface set structure
262  * interface_id <-- index of interface in set (0 to n-1)
263  *
264  * returns:
265  * pointer to interface structure
266  *----------------------------------------------------------------------------*/
267 
268 const cs_interface_t *
270  int interface_id);
271 
272 /*----------------------------------------------------------------------------
273  * Return pointer to the periocicity structure associated of an interface set.
274  *
275  * parameters:
276  * ifs <-- pointer to interface set structure
277  *
278  * returns:
279  * pointer to periodicity structure, or NULL
280  *----------------------------------------------------------------------------*/
281 
282 const fvm_periodicity_t *
284 
285 /*----------------------------------------------------------------------------
286  * Apply renumbering of elements referenced by an interface set.
287  *
288  * For any given element i, a negative old_to_new[i] value means that that
289  * element does not appear anymore in the new numbering.
290  *
291  * parameters:
292  * ifs <-> pointer to interface set structure
293  * old_to_new <-- renumbering array (0 to n-1 numbering)
294  *----------------------------------------------------------------------------*/
295 
296 void
298  const cs_lnum_t old_to_new[]);
299 
300 /*----------------------------------------------------------------------------
301  * Add matching element id information to an interface set.
302  *
303  * This information is required by calls to cs_interface_get_dist_ids(),
304  * and may be freed using cs_interface_set_free_match_ids().
305  *
306  * parameters:
307  * ifs <-> pointer to interface set structure
308  *----------------------------------------------------------------------------*/
309 
310 void
312 
313 /*----------------------------------------------------------------------------
314  * Free matching element id information of an interface set.
315  *
316  * This information is used by calls to cs_interface_get_dist_ids(),
317  * and may be defined using cs_interface_set_add_match_ids().
318  *
319  * parameters:
320  * ifs <-> pointer to interface set structure
321  *----------------------------------------------------------------------------*/
322 
323 void
325 
326 /*----------------------------------------------------------------------------
327  * Copy array from distant or matching interface elements to local elements.
328  *
329  * Source and destination arrays define values for all elements in the
330  * interface set (i.e. all elements listed by cs_interface_get_elt_ids()
331  * when looping over interfaces of a set,
332  *
333  * parameters:
334  * ifs <-- pointer to interface set structure
335  * datatype <-- type of data considered
336  * stride <-- number of values per entity (interlaced)
337  * src_on_parent <-- true if source array is defined on the elements
338  * defined by ifs->elt_ids, false if source array
339  * defined directly on cs_interface_set_n_elts(ifs)
340  * src <-- source array (size: cs_interface_set_n_elts(ifs)*stride
341  * or parent array size * stride)
342  * dest <-- destination array
343  * (size: cs_interface_set_n_elts(ifs)*stride)
344  *----------------------------------------------------------------------------*/
345 
346 void
348  cs_datatype_t datatype,
349  int stride,
350  bool src_on_parent,
351  const void *src,
352  void *dest);
353 
354 /*----------------------------------------------------------------------------
355  * Copy indexed array from distant or matching interface elements to
356  * local elements.
357  *
358  * Source and destination arrays define values for all elements in the
359  * interface set (i.e. all elements listed by cs_interface_get_elt_ids()
360  * when looping over interfaces of a set,
361  *
362  * Note that when copying the same type of data to all matching elements,
363  * the source and destination index may be the same, if src_on_parent is true.
364  * To avoid requiring a separate destination index, the dest_index argument
365  * may be set to NULL, in which case it is assumed that source and destination
366  * are symmetric, and src_index is sufficient to determine sizes (whether
367  * src_on_parent is true or not).
368  *
369  * In some use cases, for example when copying values only in one direction,
370  * the copying is not symmetric, so both a source and destination buffer must
371  * be provided.
372  *
373  * parameters:
374  * ifs <-- pointer to interface set structure
375  * datatype <-- type of data considered
376  * src_on_parent <-- true if source array is defined on the elements
377  * defined by ifs->elt_ids, false if source array
378  * defined directly on cs_interface_set_n_elts(ifs)
379  * src_index <-- index for source array
380  * dest_index <-- index for destination array, or NULL
381  * src <-- source array (size:
382  * src_index[cs_interface_set_n_elts(ifs)]
383  * or parent array size * stride)
384  * dest <-- destination array (size:
385  * src_index[cs_interface_set_n_elts(ifs)] or
386  * dest_index[cs_interface_set_n_elts(ifs)])
387  *----------------------------------------------------------------------------*/
388 
389 void
391  cs_datatype_t datatype,
392  bool src_on_parent,
393  const cs_lnum_t src_index[],
394  const cs_lnum_t dest_index[],
395  const void *src,
396  void *dest);
397 
398 /*----------------------------------------------------------------------------
399  * Update the sum of values for elements associated with an interface set.
400  *
401  * On input, the variable array should contain local contributions. On output,
402  * contributions from matching elements on parallel or periodic boundaries
403  * have been added.
404  *
405  * Only the values of elements belonging to the interfaces are modified.
406  *
407  * parameters:
408  * ifs <-- pointer to a fvm_interface_set_t structure
409  * n_elts <-- number of elements in var buffer
410  * stride <-- number of values (non interlaced) by entity
411  * interlace <-- true if variable is interlaced (for stride > 1)
412  * datatype <-- type of data considered
413  * var <-> variable buffer
414  *----------------------------------------------------------------------------*/
415 
416 void
418  cs_lnum_t n_elts,
420  bool interlace,
421  cs_datatype_t datatype,
422  void *var);
423 
424 /*----------------------------------------------------------------------------
425  * Update to minimum value for elements associated with an interface set.
426  *
427  * On input, the variable array should contain local contributions. On output,
428  * contributions from matching elements on parallel or periodic boundaries
429  * have been added.
430  *
431  * Only the values of elements belonging to the interfaces are modified.
432  *
433  * parameters:
434  * ifs <-- pointer to a fvm_interface_set_t structure
435  * n_elts <-- number of elements in var buffer
436  * stride <-- number of values (non interlaced) by entity
437  * interlace <-- true if variable is interlaced (for stride > 1)
438  * datatype <-- type of data considered
439  * var <-> variable buffer
440  *----------------------------------------------------------------------------*/
441 
442 void
444  cs_lnum_t n_elts,
446  bool interlace,
447  cs_datatype_t datatype,
448  void *var);
449 
450 /*----------------------------------------------------------------------------
451  * Update to maximum value for elements associated with an interface set.
452  *
453  * On input, the variable array should contain local contributions. On output,
454  * contributions from matching elements on parallel or periodic boundaries
455  * have been added.
456  *
457  * Only the values of elements belonging to the interfaces are modified.
458  *
459  * parameters:
460  * ifs <-- pointer to a fvm_interface_set_t structure
461  * n_elts <-- number of elements in var buffer
462  * stride <-- number of values (non interlaced) by entity
463  * interlace <-- true if variable is interlaced (for stride > 1)
464  * datatype <-- type of data considered
465  * var <-> variable buffer
466  *----------------------------------------------------------------------------*/
467 
468 void
470  cs_lnum_t n_elts,
472  bool interlace,
473  cs_datatype_t datatype,
474  void *var);
475 
476 /*----------------------------------------------------------------------------
477  * Dump printout of an interface list.
478  *
479  * parameters:
480  * ifs <-- pointer to structure that should be dumped
481  *----------------------------------------------------------------------------*/
482 
483 void
485 
486 /*----------------------------------------------------------------------------*/
487 
489 
490 #endif /* __CS_INTERFACE_H__ */
cs_interface_get_tr_index_size
cs_lnum_t cs_interface_get_tr_index_size(const cs_interface_t *itf)
Return size of index of sub-sections for different transformations.
Definition: cs_interface.c:3531
cs_interface_get_match_ids
const cs_lnum_t * cs_interface_get_match_ids(const cs_interface_t *itf)
Return pointer to array of matching element ids defining an interface.
Definition: cs_interface.c:3504
cs_interface_set_free_match_ids
void cs_interface_set_free_match_ids(cs_interface_set_t *ifs)
Free matching element id information of an interface set.
Definition: cs_interface.c:5189
cs_interface_rank
int cs_interface_rank(const cs_interface_t *itf)
Return process rank associated with an interface's distant elements.
Definition: cs_interface.c:3428
var
void cs_int_t cs_real_t var[]
Definition: cs_parall.h:63
cs_interface_set_t
struct _cs_interface_set_t cs_interface_set_t
Definition: cs_interface.h:61
cs_interface_t
struct _cs_interface_t cs_interface_t
Definition: cs_interface.h:60
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_interface_set_create
cs_interface_set_t * cs_interface_set_create(cs_lnum_t n_elts, const cs_lnum_t parent_element_id[], const cs_gnum_t global_number[], const fvm_periodicity_t *periodicity, int n_periodic_lists, const int periodicity_num[], const cs_lnum_t n_periodic_couples[], const cs_gnum_t *const periodic_couples[])
Creation of a list of interfaces between elements of a same type.
Definition: cs_interface.c:3607
cs_interface_set_sum
void cs_interface_set_sum(const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
Update the sum of values for elements associated with an interface set.
Definition: cs_interface.c:4302
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_datatype_t
cs_datatype_t
Definition: cs_defs.h:260
stride
void const cs_int_t const cs_int_t const cs_int_t const cs_int_t * stride
Definition: cs_sat_coupling.h:325
cs_interface_set_copy_indexed
void cs_interface_set_copy_indexed(const cs_interface_set_t *ifs, cs_datatype_t datatype, bool src_on_parent, const cs_lnum_t src_index[], const cs_lnum_t dest_index[], const void *src, void *dest)
Copy indexed array from distant or matching interface elements to local elements.
Definition: cs_interface.c:4105
cs_interface_set_add_match_ids
void cs_interface_set_add_match_ids(cs_interface_set_t *ifs)
Add matching element id information to an interface set.
Definition: cs_interface.c:5069
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
fvm_periodicity_t
struct _fvm_periodicity_t fvm_periodicity_t
Definition: fvm_periodicity.h:67
cs_interface_set_size
int cs_interface_set_size(const cs_interface_set_t *ifs)
Return number of interfaces associated with an interface set.
Definition: cs_interface.c:3737
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_interface_set_n_elts
cs_lnum_t cs_interface_set_n_elts(const cs_interface_set_t *ifs)
Return total number of elements in interface set.
Definition: cs_interface.c:3761
cs_interface_set_max
void cs_interface_set_max(const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
Update to maximum value for elements associated with an interface set.
Definition: cs_interface.c:4814
cs_interface_size
cs_lnum_t cs_interface_size(const cs_interface_t *itf)
Return number of local and distant elements defining an interface.
Definition: cs_interface.c:3449
cs_interface_get_tr_index
const cs_lnum_t * cs_interface_get_tr_index(const cs_interface_t *itf)
Return pointer to index of sub-sections for different transformations.
Definition: cs_interface.c:3557
cs_interface_set_periodicity
const fvm_periodicity_t * cs_interface_set_periodicity(const cs_interface_set_t *ifs)
Return pointer to the periocicity structure associated of an interface set.
Definition: cs_interface.c:3810
cs_interface_set_min
void cs_interface_set_min(const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
Update to minimum value for elements associated with an interface set.
Definition: cs_interface.c:4550
cs_interface_set_destroy
void cs_interface_set_destroy(cs_interface_set_t **ifs)
Destruction of an interface set.
Definition: cs_interface.c:3711
fvm_periodicity.h
cs_interface_get_elt_ids
const cs_lnum_t * cs_interface_get_elt_ids(const cs_interface_t *itf)
Return pointer to array of local element ids defining an interface.
Definition: cs_interface.c:3475
cs_interface_set_renumber
void cs_interface_set_renumber(cs_interface_set_t *ifs, const cs_lnum_t old_to_new[])
Apply renumbering of elements referenced by an interface set.
Definition: cs_interface.c:3833
fvm_defs.h
cs_interface_set_dump
void cs_interface_set_dump(const cs_interface_set_t *ifs)
Dump printout of an interface list.
Definition: cs_interface.c:5212
cs_interface_set_copy_array
void cs_interface_set_copy_array(const cs_interface_set_t *ifs, cs_datatype_t datatype, int stride, bool src_on_parent, const void *src, void *dest)
Copy array from distant or matching interface elements to local elements.
Definition: cs_interface.c:3938
cs_interface_set_get
const cs_interface_t * cs_interface_set_get(const cs_interface_set_t *ifs, int interface_id)
Return pointer to a given interface in an interface set.
Definition: cs_interface.c:3785