8.3
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-2024 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 "cs_base.h"
33#include "cs_zone.h"
34
35/*----------------------------------------------------------------------------*/
36
38
39typedef enum
40{
45
47
50
51typedef struct {
52
53 // Intersection (surface/volume)
54 int *n_elts; // Number of intersected sys elts for each CFD elt
55 cs_double_int_t **elt_ids_val; // Surface/Volume intersected (absolute!) + id
56
57 cs_real_t *cfd_weight; // Total weight for cfd elements
58 cs_real_t *sys_weight; // Total weight for sys elements
59
61
62typedef struct {
63
64 // Coupling type
66
67 // Coupling zones. If in/out are different both are used, otherwise only
68 // first.
70
72
73 // Inverse flow rate (normal) if necessary
75
76 // Surface coefficient used for symmetrical cases.
78
79 // Fields to send
82
83 // Fields to send
86
87 // Number of elements in system code
88 int n_sys_elts; // 1 For 0D, > 1 for a 1D element
89 cs_cfd2sys_intersection_t *im; // NULL for 0D, !=NULL for a 1D element
90
91 // System element identification
93 int sys_elt_idx[2];
94
96
97typedef struct {
98
99 // ---------------------------
100 // MPI Parameters
101#if defined(HAVE_MPI)
102 MPI_Comm comm;
103#endif
104
108 // ---------------------------
109
110 // ---------------------------
111 // Coupling zones
114 // ---------------------------
115
116 // ---------------------------
117 // send/recv arrays
122 // ---------------------------
123
124 // ---------------------------
125 // Number of coupled phases
127 // ---------------------------
128
129 // ---------------------------
130 // system code instance
131 char *sys_name;
132 // ---------------------------
133
135
136/*============================================================================
137 * Public function definitions
138 *============================================================================*/
139
140/*----------------------------------------------------------------------------*/
148/*----------------------------------------------------------------------------*/
149
151cs_sys_coupling_by_id(const int cpl_id);
152
153/*----------------------------------------------------------------------------*/
161/*----------------------------------------------------------------------------*/
162
164cs_sys_coupling_by_name_try(const char *sys_name);
165
166/*----------------------------------------------------------------------------*/
174/*----------------------------------------------------------------------------*/
175
177cs_sys_coupling_by_name(const char *sys_name);
178
179/*----------------------------------------------------------------------------*/
186/*----------------------------------------------------------------------------*/
187
188void
190 const int field_id);
191
192/*----------------------------------------------------------------------------*/
199/*----------------------------------------------------------------------------*/
200
201void
203 const int field_id);
204
205/*----------------------------------------------------------------------------*/
212/*----------------------------------------------------------------------------*/
213
214void
216 const cs_real_t coeff);
217
218/*----------------------------------------------------------------------------*/
225/*----------------------------------------------------------------------------*/
226
227void
229
230/*----------------------------------------------------------------------------*/
238/*----------------------------------------------------------------------------*/
239
240void
242 const int dir,
243 const int field_id);
244
245/*----------------------------------------------------------------------------*/
258/*----------------------------------------------------------------------------*/
259
260void
263 const cs_zone_t *z_input,
264 const char *sel_criteria_output,
265 const char *element_name,
266 const int c0,
267 const int c1,
268 const int n_sys_elts);
269
270/*----------------------------------------------------------------------------*/
279/*----------------------------------------------------------------------------*/
280
281int
282cs_sys_coupling_add(const char *sys_name,
283 const int n_cpl_phases);
284
285/*----------------------------------------------------------------------------*/
291/*----------------------------------------------------------------------------*/
292
293void
295
296/*----------------------------------------------------------------------------*/
302/*----------------------------------------------------------------------------*/
303
304void
306
307/*----------------------------------------------------------------------------*/
311/*----------------------------------------------------------------------------*/
312
313void
315
316/*----------------------------------------------------------------------------*/
320/*----------------------------------------------------------------------------*/
321
322void
324
325/*----------------------------------------------------------------------------*/
326
328
329#endif /* __CS_SYS_COUPLING_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
cs_syscpl_bc_type_t
Definition: cs_sys_coupling.h:40
@ CS_SYS_CPL_BC_UKNOWN
Definition: cs_sys_coupling.h:48
@ CS_SYS_CPL_BC_VOLUME
Definition: cs_sys_coupling.h:44
@ CS_SYS_CPL_BC_WALL
Definition: cs_sys_coupling.h:43
@ CS_SYS_CPL_BC_INLET
Definition: cs_sys_coupling.h:41
@ CS_N_SYS_CPL_BC_TYPES
Definition: cs_sys_coupling.h:46
@ CS_SYS_CPL_BC_OUTLET
Definition: cs_sys_coupling.h:42
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:655
void cs_sys_coupling_all_init(void)
Initialize cfd<->system coupling once all couplings are defined.
Definition: cs_sys_coupling.cpp:859
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:495
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:709
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:619
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:637
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:596
void cs_sys_coupling_recv_data(cs_sys_cpl_t *cpl)
recieve data from system code
Definition: cs_sys_coupling.cpp:826
int cs_sys_coupling_add(const char *sys_name, const int n_cpl_phases)
Add a cfd<->sys coupling.
Definition: cs_sys_coupling.cpp:768
void cs_sys_coupling_all_finalize(void)
Finalize all cfd<->sys couplings.
Definition: cs_sys_coupling.cpp:904
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:573
void cs_sys_coupling_send_data(cs_sys_cpl_t *cpl)
send data to system code
Definition: cs_sys_coupling.cpp:802
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:551
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:522
real(c_double), dimension(:), pointer, save c1
Definition: cpincl.f90:109
Definition: cs_sys_coupling.h:51
cs_real_t * sys_weight
Definition: cs_sys_coupling.h:58
int * n_elts
Definition: cs_sys_coupling.h:54
cs_real_t * cfd_weight
Definition: cs_sys_coupling.h:57
cs_double_int_t ** elt_ids_val
Definition: cs_sys_coupling.h:55
Definition: cs_sys_coupling.h:62
cs_cfd2sys_intersection_t * im
Definition: cs_sys_coupling.h:89
int * send_field_ids
Definition: cs_sys_coupling.h:81
int input_zone_id
Definition: cs_sys_coupling.h:69
int n_send_fields
Definition: cs_sys_coupling.h:80
int n_recv_fields
Definition: cs_sys_coupling.h:84
cs_real_t surf_coeff
Definition: cs_sys_coupling.h:77
char * selection_criteria_output
Definition: cs_sys_coupling.h:71
char * element_name
Definition: cs_sys_coupling.h:92
int n_sys_elts
Definition: cs_sys_coupling.h:88
cs_syscpl_bc_type_t type
Definition: cs_sys_coupling.h:65
int bnd_dir
Definition: cs_sys_coupling.h:74
int * recv_field_ids
Definition: cs_sys_coupling.h:85
Definition: cs_defs.h:390
Definition: cs_sys_coupling.h:97
int sys_root
Definition: cs_sys_coupling.h:106
int cfd_root
Definition: cs_sys_coupling.h:105
int sys_n_ranks
Definition: cs_sys_coupling.h:107
int n_cpl_phases
Definition: cs_sys_coupling.h:126
int n_cpl_bcs
Definition: cs_sys_coupling.h:112
cs_cfd_sys_cplbc_t ** cplbc
Definition: cs_sys_coupling.h:113
int n_recv_vals
Definition: cs_sys_coupling.h:120
char * sys_name
Definition: cs_sys_coupling.h:131
cs_real_t * send_vals
Definition: cs_sys_coupling.h:119
MPI_Comm comm
Definition: cs_sys_coupling.h:102
cs_real_t * recv_vals
Definition: cs_sys_coupling.h:121
int n_send_vals
Definition: cs_sys_coupling.h:118
Definition: cs_zone.h:55