8.1
general documentation
cs_sat_coupling.h
Go to the documentation of this file.
1 #ifndef __CS_SAT_COUPLING_H__
2 #define __CS_SAT_COUPLING_H__
3 
4 /*============================================================================
5  * Functions associated with code coupling.
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2023 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 /*----------------------------------------------------------------------------
31  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 /*----------------------------------------------------------------------------
35  * Local headers
36  *----------------------------------------------------------------------------*/
37 
38 #include "fvm_defs.h"
39 #include "fvm_nodal.h"
40 
41 #include "cs_base.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
46 
47 /*============================================================================
48  * Global variables
49  *============================================================================*/
50 
52 
53 /*=============================================================================
54  * Type Definitions
55  *============================================================================*/
56 
57 typedef struct _cs_sat_coupling_t cs_sat_coupling_t;
58 
59 /*----------------------------------------------------------------------------
60  * Function pointer to mesh tagging function.
61  *
62  * Each function of this sort may be used to tag a mesh and associated
63  * points for mocatin exclusion.
64  *
65  * Note: if the context pointer is non-NULL, it must point to valid data
66  * when the selection function is called, so that value or structure
67  * should not be temporary (i.e. local);
68  *
69  * parameters:
70  * context <-> pointer to optional (untyped) value or structure.
71  * mesh <-> nodal mesh which should be tagged
72  * n_points <-- number of points to tag
73  * point_list_base <-- base numbering for point_list
74  * point_list <-- optional indirection for points
75  * point_tag --> point tag values (size: n_tags)
76  *----------------------------------------------------------------------------*/
77 
78 typedef void
79 (cs_sat_coupling_tag_t) (void *context,
80  fvm_nodal_t *mesh,
81  cs_lnum_t n_points,
82  cs_lnum_t point_list_base,
83  const cs_lnum_t point_list[],
84  int *point_tag);
85 
86 /*============================================================================
87  * Public function prototypes for Fortran API
88  *============================================================================*/
89 
90 /*----------------------------------------------------------------------------
91  * Get number of code couplings
92  *
93  * Fortran interface:
94  *
95  * SUBROUTINE NBCCPL
96  * *****************
97  *
98  * INTEGER NBRCPL : <-- : number of code couplings
99  *----------------------------------------------------------------------------*/
100 
101 void CS_PROCF (nbccpl, NBCCPL)
102 (
103  int *nbrcpl
104 );
105 
106 /*----------------------------------------------------------------------------
107  * Set the list of cells and boundary faces associated to a coupling
108  * and a cloud of point.
109  *
110  * The local "support" cells and boundary faces are used to localize
111  * the values in the distant "coupled" cells and faces.
112  * Depending on the role of sender and/or receiver of the current process
113  * in the coupling, some of these sets can be empty or not.
114  *
115  * The cell values are always localized and interpolated on the distant
116  * "cells" support. The face values are localized and interpolated on
117  * the distant "face" support if present, or on the distant "cell" support
118  * if not.
119  *
120  * If the input arrays LCESUP and LFBSUP are not ordered, they will be
121  * orderd in output.
122  *
123  * Fortran interface:
124  *
125  * SUBROUTINE DEFLOC
126  * *****************
127  *
128  * INTEGER NUMCPL : --> : coupling number
129  *----------------------------------------------------------------------------*/
130 
131 void CS_PROCF (defloc, DEFLOC)
132 (
133  const int *numcpl
134 );
135 
136 /*----------------------------------------------------------------------------
137  * Get the number of cells and boundary faces, "support", coupled and not
138  * localized associated to a given coupling
139  *
140  * Fortran interface:
141  *
142  * SUBROUTINE NBECPL
143  * *****************
144  *
145  * INTEGER NUMCPL : --> : coupling number
146  * INTEGER reverse : <-- : reverse mode if 1
147  * INTEGER NCESUP : <-- : number of "support" cells
148  * INTEGER NFBSUP : <-- : number of "support" boundary faces
149  * INTEGER NCECPL : <-- : number of coupled cells
150  * INTEGER NFBCPL : <-- : number of coupled boundary faces
151  * INTEGER NCENCP : <-- : number of not coupled cells
152  * : : (since not localized)
153  * INTEGER NFBNCP : <-- : number of not coupled boundary faces
154  * : : (since not localized)
155  *----------------------------------------------------------------------------*/
156 
157 void CS_PROCF (nbecpl, NBECPL)
158 (
159  const int *numcpl,
160  int *reverse,
161  cs_lnum_t *ncesup,
162  cs_lnum_t *nfbsup,
163  cs_lnum_t *ncecpl,
164  cs_lnum_t *nfbcpl,
165  cs_lnum_t *ncencp,
166  cs_lnum_t *nfbncp
167 );
168 
169 /*----------------------------------------------------------------------------
170  * Get the lists of coupled cells and boundary faces (i.e. receiving)
171  * associated to a given coupling
172  *
173  * The number of cells and boundary faces, got with NBECPL(), are used
174  * for arguments coherency checks.
175  *
176  * Fortran interface:
177  *
178  * SUBROUTINE LELCPL
179  * *****************
180  *
181  * INTEGER NUMCPL : --> : coupling number
182  * INTEGER NCECPL : --> : number of coupled cells
183  * INTEGER NFBCPL : --> : number of coupled boundary faces
184  * INTEGER LCECPL(*) : <-- : list of coupled cells
185  * INTEGER LFBCPL(*) : <-- : list of coupled boundary faces
186  *----------------------------------------------------------------------------*/
187 
188 void CS_PROCF (lelcpl, LELCPL)
189 (
190  const int *numcpl,
191  const cs_lnum_t *ncecpl,
192  const cs_lnum_t *nfbcpl,
193  cs_lnum_t *lcecpl,
194  cs_lnum_t *lfbcpl
195 );
196 
197 /*----------------------------------------------------------------------------
198  * Get the lists of not coupled cells and boundary faces (i.e. receiving but
199  * not localized) associated to a given coupling
200  *
201  * The number of cells and boundary faces, got with NBECPL(), are used
202  * for arguments coherency checks.
203  *
204  * Fortran interface:
205  *
206  * SUBROUTINE LENCPL
207  * *****************
208  *
209  * INTEGER NUMCPL : --> : coupling number
210  * INTEGER NCENCP : --> : number of not coupled cells
211  * INTEGER NFBNCP : --> : number of not coupled boundary faces
212  * INTEGER LCENCP(*) : <-- : list of not coupled cells
213  * INTEGER LFBNCP(*) : <-- : list of not coupled boundary faces
214  *----------------------------------------------------------------------------*/
215 
216 void CS_PROCF (lencpl, LENCPL)
217 (
218  const int *numcpl,
219  const cs_lnum_t *ncencp,
220  const cs_lnum_t *nfbncp,
221  cs_lnum_t *lcencp,
222  cs_lnum_t *lfbncp
223 );
224 
225 /*----------------------------------------------------------------------------
226  * Get the number of distant point associated to a given coupling
227  * and localized on the local domain
228  *
229  * Fortran interface:
230  *
231  * SUBROUTINE NPDCPL
232  * *****************
233  *
234  * INTEGER NUMCPL : --> : coupling number
235  * INTEGER NCEDIS : <-- : number of distant cells
236  * INTEGER NFBDIS : <-- : numbre de distant boundary faces
237  *----------------------------------------------------------------------------*/
238 
239 void CS_PROCF (npdcpl, NPDCPL)
240 (
241  const int *numcpl,
242  cs_lnum_t *ncedis,
243  cs_lnum_t *nfbdis
244 );
245 
246 /*----------------------------------------------------------------------------
247  * Get the distant points coordinates associated to a given coupling
248  * and a list of points, and the elements number and type (cell or face)
249  * "containing" this points.
250  *
251  * The number of distant points NBRPTS must be equal to one the arguments
252  * NCEDIS or NFBDIS given by NPDCPL(), and is given here for coherency checks
253  * between the arguments NUMCPL and ITYSUP.
254  *
255  * Fortran interface:
256  *
257  * SUBROUTINE COOCPL
258  * *****************
259  *
260  * INTEGER NUMCPL : --> : coupling number
261  * INTEGER NBRPTS : --> : number of distant points
262  * INTEGER ITYDIS : --> : 1 : access to the points associated
263  * : : to the distant cells
264  * : : 2 : access to the points associated
265  * : : to the distant boundary faces
266  * INTEGER ITYLOC : <-- : 1 : localization on the local cells
267  * : : 2 : localization on the local faces
268  * INTEGER LOCPTS(*) : <-- : "containing" number associated to
269  * : : each point
270  * DOUBLE PRECISION COOPTS(3,*) : <-- : distant point coordinates
271  * DOUBLE PRECISION DJPPTS(3,*) : <-- : distant vectors to the coupled face
272  * DOUBLE PRECISION PNDPTS(*) : <-- : distant weighting coefficients
273  *----------------------------------------------------------------------------*/
274 
275 void CS_PROCF (coocpl, COOCPL)
276 (
277  const int *numcpl,
278  const cs_lnum_t *nbrpts,
279  const int *itydis,
280  int *ityloc,
281  cs_lnum_t *locpts,
282  cs_real_t *coopts,
283  cs_real_t *djppts,
284  cs_real_t *dofpts,
285  cs_real_t *pndpts
286 );
287 
288 /*----------------------------------------------------------------------------
289  * Get the weighting coefficient needed for a centered-like interpolation
290  * in the case of a coupling on boundary faces.
291  *
292  * Fortran interface:
293  *
294  * SUBROUTINE PONDCP
295  * *****************
296  *
297  * INTEGER NUMCPL : --> : coupling number
298  * INTEGER NBRPTS : --> : number of distant points
299  * INTEGER ITYLOC : <-- : 1 : localization on the local cells
300  * : : 2 : localization on the local faces
301  * DOUBLE PRECISION PNDCPL(*) : <-- : weighting coefficients
302  *----------------------------------------------------------------------------*/
303 
304 void CS_PROCF (pondcp, PONDCP)
305 (
306  const int *numcpl,
307  const cs_lnum_t *nbrpts,
308  int *ityloc,
309  cs_real_t *pndcpl,
310  cs_real_t *distof
311 );
312 
313 /*----------------------------------------------------------------------------
314  * Exchange a variable associated to a set of point and a coupling.
315  *
316  * Fortran interface:
317  *
318  * SUBROUTINE VARCPL
319  * *****************
320  *
321  * INTEGER NUMCPL : --> : coupling number
322  * INTEGER NBRDIS : --> : number of values to send
323  * INTEGER NBRLOC : --> : number of values to receive
324  * INTEGER ITYVAR : --> : 1 : variables defined at cells
325  * : : 2 : variables defined at faces
326  * INTEGER STRIDE : --> : 1 : for scalars
327  * : : 3 : for vectors
328  * DOUBLE PRECISION VARDIS(*) : --> : distant variable(to send)
329  * DOUBLE PRECISION VARLOC(*) : <-- : local variable (to receive)
330  *----------------------------------------------------------------------------*/
331 
332 void CS_PROCF (varcpl, VARCPL)
333 (
334  const int *numcpl,
335  const cs_lnum_t *nbrdis,
336  const cs_lnum_t *nbrloc,
337  const int *ityvar,
338  const cs_lnum_t *stride,
339  const int *reverse,
340 
341  cs_real_t *vardis,
342  cs_real_t *varloc
343 );
344 
345 /*----------------------------------------------------------------------------
346  * Array of integers exchange, associated to a given coupling.
347  *
348  * It is assumed that the arrays have the same size and the same values on
349  * each group of processus (local and distant).
350  *
351  * Fortran interface:
352  *
353  * SUBROUTINE TBICPL
354  * *****************
355  *
356  * INTEGER NUMCPL : --> : coupling number
357  * INTEGER NBRDIS : --> : number of values to send
358  * INTEGER NBRLOC : --> : number of values to receive
359  * INTEGER TABDIS(*) : --> : distant values (to send)
360  * INTEGER TABLOC(*) : <-- : local values (to receive)
361  *----------------------------------------------------------------------------*/
362 
363 void CS_PROCF (tbicpl, TBICPL)
364 (
365  const int *numcpl,
366  const cs_lnum_t *nbrdis,
367  const cs_lnum_t *nbrloc,
368  cs_lnum_t *vardis,
369  cs_lnum_t *varloc
370 );
371 
372 /*----------------------------------------------------------------------------
373  * Compute the maximum value of an integer variable associated to a coupling.
374  *
375  * It is assumed that the integer value is the same for each group of
376  * processus (local and distant).
377  *
378  * Fortran interface:
379  *
380  * SUBROUTINE MXICPL
381  * *****************
382  *
383  * INTEGER NUMCPL : --> : coupling number
384  * INTEGER VALDIS : --> : distant value (to send)
385  * INTEGER VALMAX : <-- : local maximum (to receive)
386  *----------------------------------------------------------------------------*/
387 
388 void CS_PROCF (mxicpl, MXICPL)
389 (
390  const int *const numcpl,
391  cs_lnum_t *const vardis,
392  cs_lnum_t *const varmax
393 );
394 
395 /*============================================================================
396  * Public function prototypes
397  *============================================================================*/
398 
399 /*----------------------------------------------------------------------------*/
421 /*----------------------------------------------------------------------------*/
422 
423 void
424 cs_sat_coupling_define(const char *saturne_name,
425  const char *boundary_cpl_criteria,
426  const char *volume_cpl_criteria,
427  const char *boundary_loc_criteria,
428  const char *volume_loc_criteria,
429  int reverse,
430  int verbosity);
431 
432 /*----------------------------------------------------------------------------
433  * Get number of code_saturne couplings.
434  *
435  * returns:
436  * number of code_saturne couplings
437  *----------------------------------------------------------------------------*/
438 
439 int
441 
442 /*----------------------------------------------------------------------------
443  * Get pointer to code_saturne coupling.
444  *
445  * parameters:
446  * coupling_id <-- Id (0 to n-1) of code_saturne coupling
447  *
448  * returns:
449  * pointer to code_saturne coupling structure
450  *----------------------------------------------------------------------------*/
451 
453 cs_sat_coupling_by_id(int coupling_id);
454 
455 /*----------------------------------------------------------------------------
456  * Create a sat_coupling_t structure.
457  *
458  * parameters:
459  * ref_axis <-- reference axis
460  * face_sel_criterion <-- criterion for selection of boundary faces
461  * cell_sel_criterion <-- criterion for selection of cells
462  * sat_name <-- code_saturne application name
463  * reverse <-- reverse mode if 1
464  * verbosity <-- verbosity level
465  *----------------------------------------------------------------------------*/
466 
467 void
468 cs_sat_coupling_add(const char *face_cpl_sel_c,
469  const char *cell_cpl_sel_c,
470  const char *face_loc_sel_c,
471  const char *cell_loc_sel_c,
472  const char *sat_name,
473  int reverse,
474  int verbosity);
475 
476 /*----------------------------------------------------------------------------
477  * Create a new internal code_saturne coupling.
478  *
479  * arguments:
480  * tag_func <-- pointer to tagging function
481  * tag_context <-- pointer to tagging function context
482  * boundary_criteria <-- boundary face selection criteria, or NULL
483  * volume_criteria <-- volume cell selection criteria, or NULL
484  * loc_tolerance <-- location tolerance factor (0.1 recommended)
485  * reverse <-- reverse mode if 1
486  * verbosity <-- verbosity level
487  *----------------------------------------------------------------------------*/
488 
489 void
491  void *tag_context,
492  const char *boundary_cpl_criteria,
493  const char *volume_cpl_criteria,
494  const char *boundary_loc_criteria,
495  const char *volume_loc_criteria,
496  float loc_tolerance,
497  int reverse,
498  int verbosity);
499 
500 /*----------------------------------------------------------------------------
501  * Initialize code_saturne couplings.
502  *
503  * This function may be called once all couplings have been defined,
504  * and it will match defined couplings with available applications.
505  *----------------------------------------------------------------------------*/
506 
507 void
509 
510 /*----------------------------------------------------------------------------
511  * Array of reals exchange, associated to a given coupling.
512  *
513  * It is assumed that the arrays have the same size and the same values on
514  * each group of processes (local and distant).
515  *
516  * int numcpl : --> : coupling number (1-based)
517  * int nbrdis : --> : number of values to send
518  * int nbrloc : --> : number of values to receive
519  * cs_real_t vardis : --> : distant values (to send)
520  * cs_real_t varloc : <-- : local values (to receive)
521  *----------------------------------------------------------------------------*/
522 
523 void
525  cs_lnum_t nbrdis,
526  cs_lnum_t nbrloc,
527  cs_real_t *vardis,
528  cs_real_t *varloc);
529 
530 /*----------------------------------------------------------------------------
531  * Destroy all couplings
532  *----------------------------------------------------------------------------*/
533 
534 void
536 
537 /*----------------------------------------------------------------------------*/
538 
540 
541 #endif /* __CS_COUPLAGE_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define CS_PROCF(x, y)
Definition: cs_defs.h:528
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
int cs_glob_sat_coupling_face_interpolation_type
void nbccpl(int *nbrcpl)
Definition: cs_sat_coupling.c:873
cs_sat_coupling_t * cs_sat_coupling_by_id(int coupling_id)
Definition: cs_sat_coupling.c:1939
void pondcp(const int *numcpl, const cs_lnum_t *nbrpts, int *ityloc, cs_real_t *pndcpl, cs_real_t *distof)
Definition: cs_sat_coupling.c:1552
void cs_sat_coupling_define(const char *saturne_name, const char *boundary_cpl_criteria, const char *volume_cpl_criteria, const char *boundary_loc_criteria, const char *volume_loc_criteria, int reverse, int verbosity)
Define new code_saturne coupling.
Definition: cs_sat_coupling.c:1859
void nbecpl(const int *numcpl, int *reverse, cs_lnum_t *ncesup, cs_lnum_t *nfbsup, cs_lnum_t *ncecpl, cs_lnum_t *nfbcpl, cs_lnum_t *ncencp, cs_lnum_t *nfbncp)
Definition: cs_sat_coupling.c:1180
void lelcpl(const int *numcpl, const cs_lnum_t *ncecpl, const cs_lnum_t *nfbcpl, cs_lnum_t *lcecpl, cs_lnum_t *lfbcpl)
Definition: cs_sat_coupling.c:1245
void npdcpl(const int *numcpl, cs_lnum_t *ncedis, cs_lnum_t *nfbdis)
Definition: cs_sat_coupling.c:1389
void cs_sat_coupling_all_finalize(void)
Definition: cs_sat_coupling.c:2206
void cs_sat_coupling_add(const char *face_cpl_sel_c, const char *cell_cpl_sel_c, const char *face_loc_sel_c, const char *cell_loc_sel_c, const char *sat_name, int reverse, int verbosity)
Definition: cs_sat_coupling.c:1997
int cs_sat_coupling_n_couplings(void)
Definition: cs_sat_coupling.c:1923
struct _cs_sat_coupling_t cs_sat_coupling_t
Definition: cs_sat_coupling.h:57
void() cs_sat_coupling_tag_t(void *context, fvm_nodal_t *mesh, cs_lnum_t n_points, cs_lnum_t point_list_base, const cs_lnum_t point_list[], int *point_tag)
Definition: cs_sat_coupling.h:79
void tbicpl(const int *numcpl, const cs_lnum_t *nbrdis, const cs_lnum_t *nbrloc, cs_lnum_t *vardis, cs_lnum_t *varloc)
Definition: cs_sat_coupling.c:1719
void cs_sat_coupling_array_exchange(int numcpl, cs_lnum_t nbrdis, cs_lnum_t nbrloc, cs_real_t *vardis, cs_real_t *varloc)
Definition: cs_sat_coupling.c:2147
void varcpl(const int *numcpl, const cs_lnum_t *nbrdis, const cs_lnum_t *nbrloc, const int *ityvar, const cs_lnum_t *stride, const int *reverse, cs_real_t *vardis, cs_real_t *varloc)
Definition: cs_sat_coupling.c:1628
void cs_sat_coupling_add_internal(cs_sat_coupling_tag_t *tag_func, void *tag_context, const char *boundary_cpl_criteria, const char *volume_cpl_criteria, const char *boundary_loc_criteria, const char *volume_loc_criteria, float loc_tolerance, int reverse, int verbosity)
Definition: cs_sat_coupling.c:2098
void defloc(const int *numcpl)
Definition: cs_sat_coupling.c:912
void coocpl(const int *numcpl, const cs_lnum_t *nbrpts, const int *itydis, int *ityloc, cs_lnum_t *locpts, cs_real_t *coopts, cs_real_t *djppts, cs_real_t *dofpts, cs_real_t *pndpts)
Definition: cs_sat_coupling.c:1450
void cs_sat_coupling_all_init(void)
Definition: cs_sat_coupling.c:1958
void lencpl(const int *numcpl, const cs_lnum_t *ncencp, const cs_lnum_t *nfbncp, cs_lnum_t *lcencp, cs_lnum_t *lfbncp)
Definition: cs_sat_coupling.c:1320
void mxicpl(const int *const numcpl, cs_lnum_t *const vardis, cs_lnum_t *const varmax)
Definition: cs_sat_coupling.c:1792
Definition: mesh.f90:26