My Project
programmer's 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-2019 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 "cs_defs.h"
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_restart.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*=============================================================================
47  * Local Type Definitions
48  *============================================================================*/
49 
50 /*----------------------------------------------------------------------------
51  * Local Structure Definitions
52  *----------------------------------------------------------------------------*/
53 
54 /* Turbomachinery model type */
55 
56 typedef enum {
57 
58  CS_TURBOMACHINERY_NONE, /* No turbomachinery modeling */
59  CS_TURBOMACHINERY_FROZEN, /* Frozen rotor model */
60  CS_TURBOMACHINERY_TRANSIENT /* full transient simulation */
61 
63 
64 /*============================================================================
65  * Static global variables
66  *============================================================================*/
67 
68 /*============================================================================
69  * Public function prototypes
70  *============================================================================*/
71 
72 /*----------------------------------------------------------------------------
73  * Define rotor/stator model.
74  *----------------------------------------------------------------------------*/
75 
76 void
78 
79 /*----------------------------------------------------------------------------
80  * return rotor/stator model.
81  *----------------------------------------------------------------------------*/
82 
85 
86 /*----------------------------------------------------------------------------
87  * Define a rotor by its axis and cell selection criteria.
88  *
89  * parameters:
90  * cell_criteria <-- cell selection criteria string
91  * rotation_velocity <-- rotation velocity, in radians/second
92  * rotation_axis <-- rotation axis vector
93  * rotation_invariant <-- rotation invariant point
94  *----------------------------------------------------------------------------*/
95 
96 void
97 cs_turbomachinery_add_rotor(const char *cell_criteria,
98  double rotation_velocity,
99  const double rotation_axis[3],
100  const double rotation_invariant[3]);
101 
102 /*----------------------------------------------------------------------------
103  * Add a cs_join_t structure to the list of rotor/stator joinings.
104  *
105  * parameters:
106  * sel_criteria <-- boundary face selection criteria
107  * fraction <-- value of the fraction parameter
108  * plane <-- value of the plane parameter
109  * verbosity <-- level of verbosity required
110  * visualization <-- level of visualization required
111  *
112  * returns:
113  * number (1 to n) associated with new joining
114  *----------------------------------------------------------------------------*/
115 
116 int
117 cs_turbomachinery_join_add(const char *sel_criteria,
118  float fraction,
119  float plane,
120  int verbosity,
121  int visualization);
122 
123 /*----------------------------------------------------------------------------
124  * Add a cs_join_t structure to the list of rotor/stator couplings.
125  *
126  * parameters:
127  * sel_criteria <-- boundary face selection criteria
128  * tolerance <-- value of the search tolerance
129  * verbosity <-- level of verbosity required
130  *
131  * returns:
132  * number (1 to n) associated with new coupling
133  *----------------------------------------------------------------------------*/
134 
135 int
136 cs_turbomachinery_coupling_add(const char *sel_criteria,
137  float tolerance,
138  int verbosity);
139 
140 /*----------------------------------------------------------------------------
141  * Definitions for turbomachinery computation.
142  *----------------------------------------------------------------------------*/
143 
144 void
146 
147 /*----------------------------------------------------------------------------
148  * Initializations for turbomachinery computation
149  *
150  * Note: this function should be called after the mesh is built,
151  * but before cs_post_init_meshes() so that postprocessing meshes are
152  * updated correctly in the transient case.
153  *----------------------------------------------------------------------------*/
154 
155 void
157 
158 /*----------------------------------------------------------------------------
159  * Free turbomachinery info
160  *----------------------------------------------------------------------------*/
161 
162 void
164 
165 /*----------------------------------------------------------------------------
166  * Update mesh for unsteady rotor/stator computation
167  *
168  * parameters:
169  * t_cur_mob <-- current rotor time
170  * t_elapsed --> elapsed computation time
171  *----------------------------------------------------------------------------*/
172 
173 void
174 cs_turbomachinery_update_mesh(double t_cur_mob,
175  double *t_elapsed);
176 
177 /*----------------------------------------------------------------------------
178  * Update mesh for unsteady rotor/stator computation in case of restart.
179  *
180  * Reads mesh from checkpoint when available.
181  *----------------------------------------------------------------------------*/
182 
183 void
185 
186 /*----------------------------------------------------------------------------
187  * Reinitialize interior face-based fields.
188  *----------------------------------------------------------------------------*/
189 
190 void
192 
193 /*----------------------------------------------------------------------------
194  * Resize cell-based fields.
195  *
196  * This function only handles fields owning their values.
197  *----------------------------------------------------------------------------*/
198 
199 void
201 
202 /*----------------------------------------------------------------------------
203  * Compute rotation matrix
204  *
205  * parameters:
206  * rotor_num <-- rotor number (1 to n numbering)
207  * theta <-- rotation angle, in radians
208  * matrix --> resulting rotation matrix
209  *----------------------------------------------------------------------------*/
210 
211 void
213  double theta,
214  cs_real_t matrix[3][4]);
215 
216 /*----------------------------------------------------------------------------
217  * Return number of rotors.
218  *
219  * Note that the number of associated rotations is n_rotors + 1, as the
220  * first rotation id is reserved for the fixed portion of the domain.
221  *
222  * return:
223  * number of rotors
224  *----------------------------------------------------------------------------*/
225 
226 int
228 
229 /*----------------------------------------------------------------------------
230  * Return cell rotor number.
231  *
232  * Each cell may be associated with a given rotor, or rotation, with 0
233  * indicating that that cell does not rotate.
234  *
235  * returns:
236  * array defining rotor number associated with each cell
237  * (0 for none, 1 to n otherwise)
238  *----------------------------------------------------------------------------*/
239 
240 const int *
242 
243 /*----------------------------------------------------------------------------
244  * Return rotation velocity
245  *
246  * parameters:
247  * rotor_num <-- rotor number (1 to n numbering)
248  *----------------------------------------------------------------------------*/
249 
250 double
252 
253 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void
264  double omega);
265 
266 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
277 
278 cs_real_34_t *
280 
281 /*----------------------------------------------------------------------------*/
293 /*----------------------------------------------------------------------------*/
294 
295 void
296 cs_turbomachinery_set_rotation_retry(int n_max_join_retries,
297  double dt_retry_multiplier);
298 
299 /*----------------------------------------------------------------------------
300  * Rotation of vector and tensor fields.
301  *
302  * parameters:
303  * dt <-- cell time step values
304  *----------------------------------------------------------------------------*/
305 
306 void
308 
309 /*----------------------------------------------------------------------------
310  * Compute velocity relative to fixed coordinates at a given point
311  *
312  * Deprecated:
313  * Use cs_rotation_velocity for more consistent naming of this reference
314  * frame velocity.
315  *
316  * parameters:
317  * rotor_num <-- associated rotor number (1 to n numbering)
318  * coords <-- point coordinates
319  * velocity --> velocity relative to fixed coordinates
320  *----------------------------------------------------------------------------*/
321 
322 void
324  const cs_real_t coords[3],
325  cs_real_t velocity[3]);
326 
327 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
337 void
339 
340 /*----------------------------------------------------------------------------*/
348 /*----------------------------------------------------------------------------*/
349 
350 void
352 
353 /*----------------------------------------------------------------------------*/
354 
356 
357 #endif /* __CS_TURBOMACHINERY_H__ */
358 
cs_turbomachinery_model_t
cs_turbomachinery_model_t
Definition: cs_turbomachinery.h:56
cs_defs.h
cs_turbomachinery_set_model
void cs_turbomachinery_set_model(cs_turbomachinery_model_t model)
Define rotor/stator model.
Definition: cs_turbomachinery.c:1186
CS_TURBOMACHINERY_NONE
Definition: cs_turbomachinery.h:58
cs_turbomachinery_relative_velocity
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.c:1821
cs_turbomachinery_get_cell_rotor_num
const int * cs_turbomachinery_get_cell_rotor_num(void)
Return cell rotor number.
Definition: cs_turbomachinery.c:1624
cs_turbomachinery_rotation_matrix
void cs_turbomachinery_rotation_matrix(int rotor_num, double theta, cs_real_t matrix[3][4])
Compute rotation matrix.
Definition: cs_turbomachinery.c:1579
cs_turbomachinery_update_mesh
void cs_turbomachinery_update_mesh(double t_cur_mob, double *t_elapsed)
Update mesh for unsteady rotor/stator computation.
Definition: cs_turbomachinery.c:1339
cs_turbomachinery_restart_mesh
void cs_turbomachinery_restart_mesh(void)
Update mesh for unsteady rotor/stator computation in case of restart.
Definition: cs_turbomachinery.c:1354
cs_turbomachinery_rotate_fields
void cs_turbomachinery_rotate_fields(const cs_real_t dt[])
Rotation of vector and tensor fields.
Definition: cs_turbomachinery.c:1726
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_turbomachinery_n_rotors
int cs_turbomachinery_n_rotors(void)
Return number of rotors.
Definition: cs_turbomachinery.c:1601
cs_turbomachinery_initialize
void cs_turbomachinery_initialize(void)
Initializations for turbomachinery computation.
Definition: cs_turbomachinery.c:1407
cs_turbomachinery_join_add
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.c:1271
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cpincl::omega
double precision, dimension(ncharm), save omega
Definition: cpincl.f90:99
cs_turbomachinery_set_rotation_velocity
void cs_turbomachinery_set_rotation_velocity(int rotor_num, double omega)
Set rotation velocity.
Definition: cs_turbomachinery.c:1655
atimbr::theta
double precision, dimension(:,:,:), allocatable theta
Definition: atimbr.f90:123
cs_turbomachinery_set_rotation_retry
void cs_turbomachinery_set_rotation_retry(int n_max_join_retries, double dt_retry_multiplier)
Set turbomachinery joining retry parameters.
Definition: cs_turbomachinery.c:1678
cs_turbomachinery_resize_cell_fields
void cs_turbomachinery_resize_cell_fields(void)
Resize cell-based fields.
Definition: cs_turbomachinery.c:1523
cs_turbomachinery_add_rotor
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.c:1227
cs_turbomachinery_finalize
void cs_turbomachinery_finalize(void)
Free turbomachinery structure.
Definition: cs_turbomachinery.c:1469
cs_turbomachinery_define
void cs_turbomachinery_define(void)
Definitions for turbomachinery computation.
Definition: cs_turbomachinery.c:1375
cs_turbomachinery_get_model
cs_turbomachinery_model_t cs_turbomachinery_get_model(void)
Return rotor/stator model.
Definition: cs_turbomachinery.c:1207
cs_turbomachinery_restart_read
void cs_turbomachinery_restart_read(cs_restart_t *r)
Read turbomachinery metadata from restart file.
Definition: cs_turbomachinery.c:1846
cs_restart_t
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:87
cs_real_34_t
cs_real_t cs_real_34_t[3][4]
Definition: cs_defs.h:325
cs_turbomachinery_coupling_add
int cs_turbomachinery_coupling_add(const char *sel_criteria, float tolerance, int verbosity)
Add a cs_join_t structure to the list of rotor/stator couplings.
Definition: cs_turbomachinery.c:1311
cs_turbomachinery_reinit_i_face_fields
void cs_turbomachinery_reinit_i_face_fields(void)
Reinitialize interior face-based fields.
Definition: cs_turbomachinery.c:1500
cs_turbomachinery_restart_write
void cs_turbomachinery_restart_write(cs_restart_t *r)
Write turbomachinery metadata to checkpoint file.
Definition: cs_turbomachinery.c:1891
CS_TURBOMACHINERY_FROZEN
Definition: cs_turbomachinery.h:59
dt
Definition: cs_field_pointer.h:65
cs_turbomachinery_get_rotation_matrices
cs_real_34_t * cs_turbomachinery_get_rotation_matrices(double dt)
Build rotation matrices for a given time interval.
Definition: cs_turbomachinery.c:1700
coords
void const cs_int_t const cs_real_t const cs_real_t * coords
Definition: cs_measures_util.h:360
cs_restart.h
cs_turbomachinery_get_rotation_velocity
double cs_turbomachinery_get_rotation_velocity(int rotor_num)
Return rotation velocity.
Definition: cs_turbomachinery.c:1638
CS_TURBOMACHINERY_TRANSIENT
Definition: cs_turbomachinery.h:60