9.2
general documentation
cs_sys_coupling.h
Go to the documentation of this file.
1#ifndef CS_SYS_COUPLING_H
2#define CS_SYS_COUPLING_H
3
4/*============================================================================
5 * SYSTEM Scale code coupling (0D/1D equations)
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 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 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "base/cs_base.h"
33#include "base/cs_zone.h"
34
35/*----------------------------------------------------------------------------*/
36
37typedef enum
38{
43
45
48
49typedef struct {
50
51 // Intersection (surface/volume)
52 int *n_elts; // Number of intersected sys elts for each CFD elt
53 cs_double_int_t **elt_ids_val; // Surface/Volume intersected (absolute!) + id
54
55 cs_real_t *cfd_weight; // Total weight for cfd elements
56 cs_real_t *sys_weight; // Total weight for sys elements
57
59
60typedef struct {
61
62 // Coupling type
64
65 // Coupling zones. If in/out are different both are used, otherwise only
66 // first.
68
70
71 // Inverse flow rate (normal) if necessary
73
74 // Surface coefficient used for symmetrical cases.
76
77 // Fields to send
80
81 // Fields to send
84
85 // Number of elements in system code
86 int n_sys_elts; // 1 For 0D, > 1 for a 1D element
87 cs_cfd2sys_intersection_t *im; // NULL for 0D, !=NULL for a 1D element
88
89 // System element identification
91 int sys_elt_idx[2];
92
94
95typedef struct {
96
97 // ---------------------------
98 // MPI Parameters
99#if defined(HAVE_MPI)
100 MPI_Comm comm;
101#endif
102
106 // ---------------------------
107
108 // ---------------------------
109 // Coupling zones
112 // ---------------------------
113
114 // ---------------------------
115 // send/recv arrays
120 // ---------------------------
121
122 // ---------------------------
123 // Number of coupled phases
125 // ---------------------------
126
127 // ---------------------------
128 // system code instance
129 char *sys_name;
130 // ---------------------------
131
133
134/*============================================================================
135 * Public function definitions
136 *============================================================================*/
137
138/*----------------------------------------------------------------------------*/
146/*----------------------------------------------------------------------------*/
147
149cs_sys_coupling_by_id(const int cpl_id);
150
151/*----------------------------------------------------------------------------*/
159/*----------------------------------------------------------------------------*/
160
162cs_sys_coupling_by_name_try(const char *sys_name);
163
164/*----------------------------------------------------------------------------*/
172/*----------------------------------------------------------------------------*/
173
175cs_sys_coupling_by_name(const char *sys_name);
176
177/*----------------------------------------------------------------------------*/
184/*----------------------------------------------------------------------------*/
185
186void
188 const int field_id);
189
190/*----------------------------------------------------------------------------*/
197/*----------------------------------------------------------------------------*/
198
199void
201 const int field_id);
202
203/*----------------------------------------------------------------------------*/
210/*----------------------------------------------------------------------------*/
211
212void
214 const cs_real_t coeff);
215
216/*----------------------------------------------------------------------------*/
223/*----------------------------------------------------------------------------*/
224
225void
227
228/*----------------------------------------------------------------------------*/
236/*----------------------------------------------------------------------------*/
237
238void
240 const int dir,
241 const int field_id);
242
243/*----------------------------------------------------------------------------*/
256/*----------------------------------------------------------------------------*/
257
258void
261 const cs_zone_t *z_input,
262 const char *sel_criteria_output,
263 const char *element_name,
264 const int c0,
265 const int c1,
266 const int n_sys_elts);
267
268/*----------------------------------------------------------------------------*/
277/*----------------------------------------------------------------------------*/
278
279int
280cs_sys_coupling_add(const char *sys_name,
281 const int n_cpl_phases);
282
283/*----------------------------------------------------------------------------*/
289/*----------------------------------------------------------------------------*/
290
291void
293
294/*----------------------------------------------------------------------------*/
300/*----------------------------------------------------------------------------*/
301
302void
304
305/*----------------------------------------------------------------------------*/
309/*----------------------------------------------------------------------------*/
310
311void
313
314/*----------------------------------------------------------------------------*/
318/*----------------------------------------------------------------------------*/
319
320void
322
323/*----------------------------------------------------------------------------*/
324
325#endif /* CS_SYS_COUPLING_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_syscpl_bc_type_t
Definition: cs_sys_coupling.h:38
@ CS_SYS_CPL_BC_UKNOWN
Definition: cs_sys_coupling.h:46
@ CS_SYS_CPL_BC_VOLUME
Definition: cs_sys_coupling.h:42
@ CS_SYS_CPL_BC_WALL
Definition: cs_sys_coupling.h:41
@ CS_SYS_CPL_BC_INLET
Definition: cs_sys_coupling.h:39
@ CS_N_SYS_CPL_BC_TYPES
Definition: cs_sys_coupling.h:44
@ CS_SYS_CPL_BC_OUTLET
Definition: cs_sys_coupling.h:40
void cs_sys_cplbc_add_exchanged_field(cs_cfd_sys_cplbc_t *cplbc, const int dir, const int field_id)
Add a field to send/recv during coupling to a given coupled BC.
Definition: cs_sys_coupling.cpp:642
void cs_sys_coupling_all_init(void)
Initialize cfd<->system coupling once all couplings are defined.
Definition: cs_sys_coupling.cpp:838
cs_sys_cpl_t * cs_sys_coupling_by_id(const int cpl_id)
Get a cfd<-->sys coupling structure by its id.
Definition: cs_sys_coupling.cpp:490
void cs_sys_coupling_add_cplbc(cs_sys_cpl_t *sys_coupling, cs_syscpl_bc_type_t type, const cs_zone_t *z_input, const char *sel_criteria_output, const char *element_name, const int c0, const int c1, const int n_sys_elts)
Add a coupled condition to a cfd<-->sys coupling.
Definition: cs_sys_coupling.cpp:695
void cs_sys_cplbc_define_surf_coeff(cs_cfd_sys_cplbc_t *cplbc, const cs_real_t coeff)
Define a surface coefficient to a given coupled BC.
Definition: cs_sys_coupling.cpp:606
void cs_sys_cplbc_inverse_bnd_dir(cs_cfd_sys_cplbc_t *cplbc)
Define a flowrate inversion between CFD and System codes if signs are inversed for a given coupled BC...
Definition: cs_sys_coupling.cpp:624
void cs_sys_cplbc_add_field_to_recv(cs_cfd_sys_cplbc_t *cplbc, const int field_id)
Add a field to recieve during coupling to a given coupled BC.
Definition: cs_sys_coupling.cpp:585
void cs_sys_coupling_recv_data(cs_sys_cpl_t *cpl)
recieve data from system code
Definition: cs_sys_coupling.cpp:807
int cs_sys_coupling_add(const char *sys_name, const int n_cpl_phases)
Add a cfd<->sys coupling.
Definition: cs_sys_coupling.cpp:753
void cs_sys_coupling_all_finalize(void)
Finalize all cfd<->sys couplings.
Definition: cs_sys_coupling.cpp:881
void cs_sys_cplbc_add_field_to_send(cs_cfd_sys_cplbc_t *cplbc, const int field_id)
Add a field to send during coupling to a given coupled BC.
Definition: cs_sys_coupling.cpp:564
void cs_sys_coupling_send_data(cs_sys_cpl_t *cpl)
send data to system code
Definition: cs_sys_coupling.cpp:785
cs_sys_cpl_t * cs_sys_coupling_by_name(const char *sys_name)
Get a cfd<-->sys coupling structure by its name.
Definition: cs_sys_coupling.cpp:542
cs_sys_cpl_t * cs_sys_coupling_by_name_try(const char *sys_name)
Try getting a cfd<-->sys coupling structure by its name.
Definition: cs_sys_coupling.cpp:515
Definition: cs_sys_coupling.h:49
cs_real_t * sys_weight
Definition: cs_sys_coupling.h:56
int * n_elts
Definition: cs_sys_coupling.h:52
cs_real_t * cfd_weight
Definition: cs_sys_coupling.h:55
cs_double_int_t ** elt_ids_val
Definition: cs_sys_coupling.h:53
Definition: cs_sys_coupling.h:60
cs_cfd2sys_intersection_t * im
Definition: cs_sys_coupling.h:87
int * send_field_ids
Definition: cs_sys_coupling.h:79
int input_zone_id
Definition: cs_sys_coupling.h:67
int n_send_fields
Definition: cs_sys_coupling.h:78
int n_recv_fields
Definition: cs_sys_coupling.h:82
cs_real_t surf_coeff
Definition: cs_sys_coupling.h:75
char * selection_criteria_output
Definition: cs_sys_coupling.h:69
char * element_name
Definition: cs_sys_coupling.h:90
int n_sys_elts
Definition: cs_sys_coupling.h:86
cs_syscpl_bc_type_t type
Definition: cs_sys_coupling.h:63
int bnd_dir
Definition: cs_sys_coupling.h:72
int * recv_field_ids
Definition: cs_sys_coupling.h:83
Definition: cs_defs.h:380
Definition: cs_sys_coupling.h:95
int sys_root
Definition: cs_sys_coupling.h:104
int cfd_root
Definition: cs_sys_coupling.h:103
int sys_n_ranks
Definition: cs_sys_coupling.h:105
int n_cpl_phases
Definition: cs_sys_coupling.h:124
int n_cpl_bcs
Definition: cs_sys_coupling.h:110
cs_cfd_sys_cplbc_t ** cplbc
Definition: cs_sys_coupling.h:111
int n_recv_vals
Definition: cs_sys_coupling.h:118
char * sys_name
Definition: cs_sys_coupling.h:129
cs_real_t * send_vals
Definition: cs_sys_coupling.h:117
MPI_Comm comm
Definition: cs_sys_coupling.h:100
cs_real_t * recv_vals
Definition: cs_sys_coupling.h:119
int n_send_vals
Definition: cs_sys_coupling.h:116
Definition: cs_zone.h:51