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