9.2
general documentation
cs_syr_coupling.h
Go to the documentation of this file.
1#ifndef CS_SYR_COUPLING_H
2#define CS_SYR_COUPLING_H
3
4/*============================================================================
5 * SYRTHES coupling
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
30/*----------------------------------------------------------------------------
31 * Standard C library headers
32 *----------------------------------------------------------------------------*/
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "fvm/fvm_defs.h"
39
40#include "base/cs_base.h"
41#include "base/cs_zone.h"
42
43/*=============================================================================
44 * Local Macro Definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Structure definition
49 *============================================================================*/
50
51/*============================================================================
52 * Global variables definition
53 *============================================================================*/
54
55/*============================================================================
56 * Public function prototypes
57 *============================================================================*/
58
59/*----------------------------------------------------------------------------
60 * Define new SYRTHES coupling.
61 *
62 * In the case of a single code_saturne and single SYRTHES instance, the
63 * syrthes_name argument is ignored.
64 *
65 * In case of multiple couplings, a coupling will be matched with available
66 * SYRTHES instances based on the syrthes_name argument.
67 *
68 * arguments:
69 * syrthes_name <-- name of SYRTHES instance
70 * boundary_criteria <-- boundary face selection criteria, or NULL
71 * volume_criteria <-- volume cell selection criteria, or NULL
72 * projection_axis <-- 'x', 'y', or 'y' for 2D projection axis (case
73 * independent), or ' ' for standard 3D coupling
74 * allow_nonmatching <-- allow nearest-neighbor mapping where matching
75 * within tolerance is not available
76 * tolerance <-- addition to local extents of each element
77 * extent = base_extent * (1 + tolerance)
78 * verbosity <-- verbosity level
79 * visualization <-- visualization output level (0 or 1)
80 *----------------------------------------------------------------------------*/
81
82void
83cs_syr_coupling_define(const char *syrthes_name,
84 const char *boundary_criteria,
85 const char *volume_criteria,
86 char projection_axis,
87 bool allow_nonmatching,
88 float tolerance,
89 int verbosity,
90 int visualization);
91
92/*----------------------------------------------------------------------------*/
100/*----------------------------------------------------------------------------*/
101
102void
103cs_syr_coupling_add_zone(const char *syrthes_name,
104 const cs_zone_t *z);
105
106/*----------------------------------------------------------------------------
107 * Initialize SYRTHES couplings.
108 *
109 * This function may be called once all couplings have been defined,
110 * and it will match defined couplings with available applications.
111 *----------------------------------------------------------------------------*/
112
113void
115
116/*----------------------------------------------------------------------------
117 * Finalize all SYRTHES couplings.
118 *----------------------------------------------------------------------------*/
119
120void
122
123/*----------------------------------------------------------------------------
124 * Return number of SYRTHES couplings.
125 *
126 * return:
127 * number of SYRTHES couplings defined
128 *----------------------------------------------------------------------------*/
129
130int
132
133/*----------------------------------------------------------------------------
134 * Set conservativity forcing flag to True (1) or False (0) for all defined
135 * SYRTHES couplings
136 *
137 * parameter:
138 * flag <-- Conservativity forcing flag to set
139 *----------------------------------------------------------------------------*/
140
141void
143
144/*----------------------------------------------------------------------------
145 * Set explicit treatment for the source terms in SYRTHES volume couplings
146 *----------------------------------------------------------------------------*/
147
148void
150
151/*----------------------------------------------------------------------------*/
152/*
153 * \brief Set time synchronization mode for a given SYRTHES coupling.
154 *
155 * This will suggest options on the SYRTHES side.
156 *
157 * \param[in] cpl_id matching SYRTHES coupling id
158 * \param[in] flag suggested synchronization flags for the SYRTHES side
159 * This should be a combination of
160 * - PLE_COUPLING_TS_MIN (use smallest time step)
161 * - PLE_COUPLING_TS_LEADER (prescribe time step for all)
162 * - PLE_COUPLING_TS_FOLLOWER (time step of this domain
163 * is ignored by coupled applications)
164 * - PLE_COUPLING_TS_INDEPENDENT (do not modify time
165 * step based on other applications)
166 *
167 * By default, no flags are set for constant and local (pseudo-steady) time
168 * stepping schemes. With a adaptive time step, the default is
169 * PLE_COUPLING_TS_MIN | PLE_COUPLING_TS_FOLLOWER
170 * so that the smallest time step of code_saturne domains will be used, but
171 * the time step of the SYRTHES domains is ignored (as it does not recompute
172 * an adaptive time step, not making it a follower would let it provide the
173 * smallest time step encountered, preventing time steps from icnreasing
174 * again in the case of multiple fluid domains).
175 */
176/*----------------------------------------------------------------------------*/
177
178void
180 int flag);
181
182/*----------------------------------------------------------------------------*/
183/*
184 * \brief Log SYRTHES coupling setup information.
185 */
186/*----------------------------------------------------------------------------*/
187
188void
190
191/*----------------------------------------------------------------------------*/
192/*
193 * \brief Create coupled meshes and setup PLE locator for Syrthes couplings.
194 */
195/*----------------------------------------------------------------------------*/
196
197void
199
200/*----------------------------------------------------------------------------*/
201/*
202 * \brief Check if the given SYRTHES coupling number is a surface couplings.
203 *
204 * \param[in] cpl_id matching SYRTHES coupling id
205 *
206 * \return 1 if the coupling includes the surface, 0 otherwise.
207 */
208/*----------------------------------------------------------------------------*/
209
210int
211cs_syr_coupling_is_surf(int cpl_id);
212
213/*----------------------------------------------------------------------------*/
214/*
215 * \brief Read boundary field/variable values relative to a SYRTHES coupling.
216 *
217 * \param[in] nvar number of variables
218 * \param[in] bc_type boundary condition type
219 * \param[out] icodcl boundary condition codes
220 * \param[out] rcodcl boundary condition values
221 */
222/*----------------------------------------------------------------------------*/
223
224void
225cs_syr_coupling_recv_boundary(const int nvar,
226 int bc_type[]);
227
228/*----------------------------------------------------------------------------*/
229/*
230 * \brief Send field/variable values relative to a SYRTHES coupling.
231 *
232 * \param[in] h_wall wall thermal exchange coefficient
233 * \param[in] v_fluid near-wall fluid thermal variable
234 */
235/*----------------------------------------------------------------------------*/
236
237void
239 cs_real_t v_fluid[]);
240
241/*----------------------------------------------------------------------------*/
242/*
243 * \brief Exchange volume values relative to a SYRTHES coupling.
244 */
245/*----------------------------------------------------------------------------*/
246
247void
249
250/*----------------------------------------------------------------------------*/
251/*
252 * \brief Compute the source term (implicit and/or explicit part) for a
253 * volume coupling with SYRTHES.
254 *
255 * \param[in] field_id field id
256 * \param[in, out] st_exp explicit source term
257 * \param[in, out] st_imp implicit source term
258 */
259/*----------------------------------------------------------------------------*/
260
261void
263 cs_real_t st_exp[],
264 cs_real_t st_imp[]);
265
266/*----------------------------------------------------------------------------*/
267/*
268 * \brief Get number of coupled elements with SYRTHES.
269 *
270 * \param[in] cpl_id coupling id
271 * \param[in] mode 0 for boundary, 1 for volume
272 *
273 * \return number of coupled elements for this coupling
274 */
275/*----------------------------------------------------------------------------*/
276
278cs_syr_coupling_n_elts(int cpl_id,
279 int mode);
280
281/*----------------------------------------------------------------------------*/
282/*
283 * \brief Get local ids of elements coupled with SYRTHES
284 *
285 * \param[in] cpl_id coupling id
286 * \param[in] mode 0 for boundary, 1 for volume
287 * \param[out] elt_ids ids of coupled elements (preallocated)
288 */
289/*----------------------------------------------------------------------------*/
290
291void
292cs_syr_coupling_elt_ids(int cpl_id,
293 int mode,
294 cs_lnum_t elt_ids[]);
295
296/*----------------------------------------------------------------------------*/
297/*
298 * \brief Receive coupling variables from SYRTHES.
299 *
300 * \param[in] cpl_id coupling id
301 * \param[in] mode 0 for boundary, 1 for volume
302 * \param[out] t_solid solid temperature
303 */
304/*----------------------------------------------------------------------------*/
305
306void
308 int mode,
309 cs_real_t t_solid[]);
310
311/*----------------------------------------------------------------------------*/
312/*
313 * \brief Send coupling variables to SYRTHES.
314 *
315 * \param[in] cpl_id coupling id
316 * \param[in] mode 0 for boundary, 1 for volume
317 * \param[in] elt_ids ids of coupled elements
318 * \param[in] t_fluid fluid temperature
319 * \param[in] h_fluid fluid exchange coefficient
320 */
321/*----------------------------------------------------------------------------*/
322
323void
325 int mode,
326 const cs_lnum_t elt_ids[],
327 cs_real_t t_fluid[],
328 cs_real_t h_fluid[]);
329
330/*----------------------------------------------------------------------------*/
331/*
332 * \brief Receive coupling variables (Tf,hf) from code_saturne
333 * (called by CDO thermal solver).
334 */
335/*----------------------------------------------------------------------------*/
336
337void
339(
340 int cpl_id,
341 int mode,
342 const cs_lnum_t elt_ids[],
343 cs_real_t t_fluid[],
344 cs_real_t h_fluid[]
345);
346
347/*----------------------------------------------------------------------------*/
348/*
349 * \brief Send coupling variables (Ts) to code_saturne
350 * (called by CDO thermal solver).
351 */
352/*----------------------------------------------------------------------------*/
353
354void
356(
357 int cpl_id,
358 int mode,
359 const cs_real_t t_solid[]
360);
361
362/*----------------------------------------------------------------------------*/
363/*
364 * \brief Check if a boundary zone is coupled.
365 *
366 * \return 1 if coupled 0 if not.
367 */
368/*----------------------------------------------------------------------------*/
369
370int
372(
373 const cs_zone_t *z
374);
375
376/*----------------------------------------------------------------------------*/
377
378#endif /* CS_SYR_COUPLING_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
int cs_syr_coupling_is_bnd_zone_coupled(const cs_zone_t *z)
Check if a boundary zone is coupled.
Definition: cs_syr_coupling.cpp:3359
void cs_syr_coupling_set_explicit_treatment(void)
Definition: cs_syr_coupling.cpp:2380
void cs_syr_coupling_log_setup(void)
Log SYRTHES coupling setup information.
Definition: cs_syr_coupling.cpp:2444
void cs_syr_coupling_all_init(void)
Definition: cs_syr_coupling.cpp:2303
void cs_syr_coupling_define(const char *syrthes_name, const char *boundary_criteria, const char *volume_criteria, char projection_axis, bool allow_nonmatching, float tolerance, int verbosity, int visualization)
Define new SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2150
void cs_syr_coupling_exchange_volume(void)
Exchange volume values relative to a SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2895
cs_lnum_t cs_syr_coupling_n_elts(int cpl_id, int mode)
Get number of coupled elements with SYRTHES.
Definition: cs_syr_coupling.cpp:3089
void cs_syr_coupling_recv_tf_hf(int cpl_id, int mode, const cs_lnum_t elt_ids[], cs_real_t t_fluid[], cs_real_t h_fluid[])
Receive coupling variables (Tf,hf) from code_saturne (called by CDO thermal solver).
Definition: cs_syr_coupling.cpp:3231
void cs_syr_coupling_elt_ids(int cpl_id, int mode, cs_lnum_t elt_ids[])
Get local ids of elements coupled with SYRTHES.
Definition: cs_syr_coupling.cpp:3132
int cs_syr_coupling_n_couplings(void)
Definition: cs_syr_coupling.cpp:2355
void cs_syr_coupling_add_zone(const char *syrthes_name, const cs_zone_t *z)
Associated a zone to a defined SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2258
void cs_syr_coupling_set_conservativity(int flag)
Definition: cs_syr_coupling.cpp:2369
int cs_syr_coupling_is_surf(int cpl_id)
Check if the given SYRTHES coupling number is a surface couplings.
Definition: cs_syr_coupling.cpp:2535
void cs_syr_coupling_send_tsolid(int cpl_id, int mode, const cs_real_t t_solid[])
Send coupling variables (Ts) to code_saturne (called by CDO thermal solver).
Definition: cs_syr_coupling.cpp:3301
void cs_syr_coupling_set_time_sync_flag(int cpl_id, int flag)
Set time synchronization mode for a given SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2413
void cs_syr_coupling_send_tf_hf(int cpl_id, int mode, const cs_lnum_t elt_ids[], cs_real_t t_fluid[], cs_real_t h_fluid[])
Send coupling variables to SYRTHES.
Definition: cs_syr_coupling.cpp:3203
void cs_syr_coupling_recv_boundary(const int nvar, int bc_type[])
Read boundary field/variable values relative to a SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2564
void cs_syr_coupling_all_finalize(void)
Definition: cs_syr_coupling.cpp:2342
void cs_syr_coupling_init_meshes(void)
Create coupled meshes and setup PLE locator for Syrthes couplings.
Definition: cs_syr_coupling.cpp:2514
void cs_syr_coupling_volume_source_terms(int field_id, cs_real_t st_exp[], cs_real_t st_imp[])
Compute the source term (implicit and/or explicit part) for a volume coupling with SYRTHES.
Definition: cs_syr_coupling.cpp:2998
void cs_syr_coupling_send_boundary(const cs_real_t h_wall[], cs_real_t v_fluid[])
Send field/variable values relative to a SYRTHES coupling.
Definition: cs_syr_coupling.cpp:2698
void cs_syr_coupling_recv_tsolid(int cpl_id, int mode, cs_real_t t_solid[])
Receive coupling variables from SYRTHES.
Definition: cs_syr_coupling.cpp:3174
Definition: cs_zone.h:51