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