9.2
general documentation
cs_turbomachinery.h
Go to the documentation of this file.
1#ifndef CS_TURBOMACHINERY_H
2#define CS_TURBOMACHINERY_H
3
4/*============================================================================
5 * Turbomachinery modeling features.
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#include "base/cs_defs.h"
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "base/cs_restart.h"
41
42/*=============================================================================
43 * Local Type Definitions
44 *============================================================================*/
45
46/*----------------------------------------------------------------------------
47 * Local Structure Definitions
48 *----------------------------------------------------------------------------*/
49
50/* Turbomachinery model type */
51
52typedef enum {
53
54 CS_TURBOMACHINERY_NONE = 0, /* No turbomachinery modeling */
55 CS_TURBOMACHINERY_FROZEN = 1, /* Frozen rotor model */
56 CS_TURBOMACHINERY_TRANSIENT = 2 /* full transient simulation */
57
59
60/*============================================================================
61 * Static global variables
62 *============================================================================*/
63
64/*============================================================================
65 * Public function prototypes
66 *============================================================================*/
67
68/*----------------------------------------------------------------------------
69 * Define rotor/stator model.
70 *----------------------------------------------------------------------------*/
71
72void
74
75/*----------------------------------------------------------------------------
76 * return rotor/stator model.
77 *----------------------------------------------------------------------------*/
78
81
82/*----------------------------------------------------------------------------*/
90/*----------------------------------------------------------------------------*/
91
92int
94
95/*----------------------------------------------------------------------------
96 * Define a rotor by its axis and cell selection criteria.
97 *
98 * parameters:
99 * cell_criteria <-- cell selection criteria string
100 * rotation_velocity <-- rotation velocity, in radians/second
101 * rotation_axis <-- rotation axis vector
102 * rotation_invariant <-- rotation invariant point
103 *----------------------------------------------------------------------------*/
104
105void
106cs_turbomachinery_add_rotor(const char *cell_criteria,
107 double rotation_velocity,
108 const double rotation_axis[3],
109 const double rotation_invariant[3]);
110
111/*----------------------------------------------------------------------------
112 * Add a cs_join_t structure to the list of rotor/stator joinings.
113 *
114 * parameters:
115 * sel_criteria <-- boundary face selection criteria
116 * fraction <-- value of the fraction parameter
117 * plane <-- value of the plane parameter
118 * verbosity <-- level of verbosity required
119 * visualization <-- level of visualization required
120 *
121 * returns:
122 * number (1 to n) associated with new joining
123 *----------------------------------------------------------------------------*/
124
125int
126cs_turbomachinery_join_add(const char *sel_criteria,
127 float fraction,
128 float plane,
129 int verbosity,
130 int visualization);
131
132/*----------------------------------------------------------------------------
133 * \brief Add a boundary coupling to the list of rotor/stator couplings.
134 *
135 * parameters:
136 * sel_criteria <-- boundary face selection criteria
137 * tolerance <-- value of the search tolerance
138 * verbosity <-- level of verbosity required
139 *
140 * returns:
141 * number (1 to n) associated with new coupling
142 *----------------------------------------------------------------------------*/
143
144int
145cs_turbomachinery_coupling_add(const char *sel_criteria,
146 float tolerance,
147 int verbosity);
148
149/*----------------------------------------------------------------------------
150 * Definitions for turbomachinery computation.
151 *----------------------------------------------------------------------------*/
152
153void
155
156/*----------------------------------------------------------------------------
157 * Initializations for turbomachinery computation
158 *
159 * Note: this function should be called after the mesh is built,
160 * but before cs_post_init_meshes() so that postprocessing meshes are
161 * updated correctly in the transient case.
162 *----------------------------------------------------------------------------*/
163
164void
166
167/*----------------------------------------------------------------------------
168 * Free turbomachinery info
169 *----------------------------------------------------------------------------*/
170
171void
173
174/*----------------------------------------------------------------------------
175 * Update mesh for unsteady rotor/stator computation
176 *
177 * parameters:
178 * t_elapsed --> elapsed computation time
179 *----------------------------------------------------------------------------*/
180
181void
182cs_turbomachinery_update_mesh(double *t_elapsed);
183
184/*----------------------------------------------------------------------------
185 * Update mesh for unsteady rotor/stator computation in case of restart.
186 *
187 * Reads mesh from checkpoint when available.
188 *----------------------------------------------------------------------------*/
189
190void
192
193/*----------------------------------------------------------------------------
194 * Reinitialize interior face-based fields.
195 *----------------------------------------------------------------------------*/
196
197void
199
200/*----------------------------------------------------------------------------
201 * Resize cell-based fields.
202 *
203 * This function only handles fields owning their values.
204 *----------------------------------------------------------------------------*/
205
206void
208
209/*----------------------------------------------------------------------------
210 * Compute rotation matrix
211 *
212 * parameters:
213 * rotor_num <-- rotor number (1 to n numbering)
214 * theta <-- rotation angle, in radians
215 * matrix --> resulting rotation matrix
216 *----------------------------------------------------------------------------*/
217
218void
220 double theta,
221 cs_real_t matrix[3][4]);
222
223/*----------------------------------------------------------------------------
224 * Return number of rotors.
225 *
226 * Note that the number of associated rotations is n_rotors + 1, as the
227 * first rotation id is reserved for the fixed portion of the domain.
228 *
229 * return:
230 * number of rotors
231 *----------------------------------------------------------------------------*/
232
233int
235
236/*----------------------------------------------------------------------------
237 * Return cell rotor number.
238 *
239 * Each cell may be associated with a given rotor, or rotation, with 0
240 * indicating that that cell does not rotate.
241 *
242 * returns:
243 * array defining rotor number associated with each cell
244 * (0 for none, 1 to n otherwise)
245 *----------------------------------------------------------------------------*/
246
247const int *
249
250/*----------------------------------------------------------------------------*/
257/*----------------------------------------------------------------------------*/
258
259void
261 cs_real_t **hfltur);
262
263/*----------------------------------------------------------------------------
264 * Return rotation velocity
265 *
266 * parameters:
267 * rotor_num <-- rotor number (1 to n numbering)
268 *----------------------------------------------------------------------------*/
269
270double
272
273/*----------------------------------------------------------------------------*/
280/*----------------------------------------------------------------------------*/
281
282void
284 double omega);
285
286/*----------------------------------------------------------------------------*/
296/*----------------------------------------------------------------------------*/
297
300
301/*----------------------------------------------------------------------------*/
313/*----------------------------------------------------------------------------*/
314
315void
316cs_turbomachinery_set_rotation_retry(int n_max_join_retries,
317 double dt_retry_multiplier);
318
319/*----------------------------------------------------------------------------
320 * Rotation of vector and tensor fields.
321 *
322 * parameters:
323 * dt <-- cell time step values
324 *----------------------------------------------------------------------------*/
325
326void
328
329/*----------------------------------------------------------------------------
330 * Compute velocity relative to fixed coordinates at a given point
331 *
332 * Deprecated:
333 * Use cs_rotation_velocity for more consistent naming of this reference
334 * frame velocity.
335 *
336 * parameters:
337 * rotor_num <-- associated rotor number (1 to n numbering)
338 * coords <-- point coordinates
339 * velocity --> velocity relative to fixed coordinates
340 *----------------------------------------------------------------------------*/
341
342[[deprecated(
343"Use cs_rotation_velocity for more consistent naming of this "
344"reference frame velocity"
345)]]
346void
348 const cs_real_t coords[3],
349 cs_real_t velocity[3]);
350
351/*----------------------------------------------------------------------------*/
359/*----------------------------------------------------------------------------*/
360
361void
363
364/*----------------------------------------------------------------------------*/
372/*----------------------------------------------------------------------------*/
373
374void
376
377/*----------------------------------------------------------------------------*/
382/*----------------------------------------------------------------------------*/
383
384void
386
387/*----------------------------------------------------------------------------*/
388
389#endif /* CS_TURBOMACHINERY_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_34_t[3][4]
Definition: cs_defs.h:364
@ dt
Definition: cs_field_pointer.h:61
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:91
void cs_turbomachinery_relative_velocity(int rotor_num, const cs_real_t coords[3], cs_real_t velocity[3])
Compute velocity relative to fixed coordinates at a given point.
Definition: cs_turbomachinery.cpp:2075
void cs_turbomachinery_finalize(void)
Free turbomachinery structure.
Definition: cs_turbomachinery.cpp:1667
void cs_turbomachinery_define(void)
Definitions for turbomachinery computation.
Definition: cs_turbomachinery.cpp:1564
void cs_turbomachinery_set_rotation_velocity(int rotor_num, double omega)
Set rotation velocity.
Definition: cs_turbomachinery.cpp:1929
void cs_turbomachinery_rotation_matrix(int rotor_num, double theta, cs_real_t matrix[3][4])
Compute rotation matrix.
Definition: cs_turbomachinery.cpp:1836
int cs_turbomachinery_coupling_add(const char *sel_criteria, float tolerance, int verbosity)
Add a boundary coupling to the list of rotor/stator couplings.
Definition: cs_turbomachinery.cpp:1495
const int * cs_turbomachinery_get_cell_rotor_num(void)
Return cell rotor number.
Definition: cs_turbomachinery.cpp:1881
int cs_turbomachinery_join_add(const char *sel_criteria, float fraction, float plane, int verbosity, int visualization)
Add a cs_join_t structure to the list of rotor/stator joinings.
Definition: cs_turbomachinery.cpp:1446
void cs_turbomachinery_restart_write(cs_restart_t *r)
Write turbomachinery metadata to checkpoint file.
Definition: cs_turbomachinery.cpp:2146
int cs_turbomachinery_n_rotors(void)
Return number of rotors.
Definition: cs_turbomachinery.cpp:1858
void cs_turbomachinery_rotate_fields(const cs_real_t dt[])
Rotation of vector and tensor fields.
Definition: cs_turbomachinery.cpp:2000
void cs_turbomachinery_define_functions(void)
Create or access function objects specific to turbomachinery models (relative_pressure,...
Definition: cs_turbomachinery.cpp:2183
void cs_turbomachinery_resize_cell_fields(void)
Resize cell-based fields.
Definition: cs_turbomachinery.cpp:1729
void cs_turbomachinery_set_rotation_retry(int n_max_join_retries, double dt_retry_multiplier)
Set turbomachinery joining retry parameters.
Definition: cs_turbomachinery.cpp:1952
void cs_turbomachinery_restart_mesh(void)
Update mesh for unsteady rotor/stator computation in case of restart.
Definition: cs_turbomachinery.cpp:1543
int cs_turbomachinery_get_n_couplings(void)
Return number of boundary couplings used for rotor/stator model.
Definition: cs_turbomachinery.cpp:1380
void cs_turbomachinery_restart_read(cs_restart_t *r)
Read turbomachinery metadata from restart file.
Definition: cs_turbomachinery.cpp:2100
cs_turbomachinery_model_t cs_turbomachinery_get_model(void)
Return rotor/stator model.
Definition: cs_turbomachinery.cpp:1361
void cs_turbomachinery_reinit_i_face_fields(void)
Reinitialize interior face-based fields.
Definition: cs_turbomachinery.cpp:1701
cs_real_34_t * cs_turbomachinery_get_rotation_matrices(double dt)
Build rotation matrices for a given time interval.
Definition: cs_turbomachinery.cpp:1974
cs_turbomachinery_model_t
Definition: cs_turbomachinery.h:52
@ CS_TURBOMACHINERY_TRANSIENT
Definition: cs_turbomachinery.h:56
@ CS_TURBOMACHINERY_NONE
Definition: cs_turbomachinery.h:54
@ CS_TURBOMACHINERY_FROZEN
Definition: cs_turbomachinery.h:55
void cs_turbomachinery_update_mesh(double *t_elapsed)
Update mesh for unsteady rotor/stator computation.
Definition: cs_turbomachinery.cpp:1529
void cs_turbomachinery_initialize(void)
Initializations for turbomachinery computation.
Definition: cs_turbomachinery.cpp:1596
void cs_turbomachinery_set_model(cs_turbomachinery_model_t model)
Define rotor/stator model.
Definition: cs_turbomachinery.cpp:1340
double cs_turbomachinery_get_rotation_velocity(int rotor_num)
Return rotation velocity.
Definition: cs_turbomachinery.cpp:1912
void cs_turbomachinery_get_wall_bc_coeffs(cs_real_t **coftur, cs_real_t **hfltur)
Get arrays associated to wall BC update.
Definition: cs_turbomachinery.cpp:1896
void cs_turbomachinery_add_rotor(const char *cell_criteria, double rotation_velocity, const double rotation_axis[3], const double rotation_invariant[3])
Define a rotor by its axis and cell selection criteria.
Definition: cs_turbomachinery.cpp:1402