1 /*============================================================================
2 * Definition of turbomachinery related options.
3 *
4 * Turbomachinery-related user functions (called in this order):
5 * 1) Define rotor cells and associated axis
6 *============================================================================*/
7
8 /* VERS */
9
10 /*
11 This file is part of Code_Saturne, a general-purpose CFD tool.
12
13 Copyright (C) 1998-2021 EDF S.A.
14
15 This program is free software; you can redistribute it and/or modify it under
16 the terms of the GNU General Public License as published by the Free Software
17 Foundation; either version 2 of the License, or (at your option) any later
18 version.
19
20 This program is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 details.
24
25 You should have received a copy of the GNU General Public License along with
26 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27 Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29
30 /*----------------------------------------------------------------------------*/
31
32 #include "cs_defs.h"
33
34 /*----------------------------------------------------------------------------
35 * Standard C library headers
36 *----------------------------------------------------------------------------*/
37
38 #include <assert.h>
39 #include <math.h>
40 #include <stdarg.h>
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include <string.h>
44
45 /*----------------------------------------------------------------------------
46 * Local headers
47 *----------------------------------------------------------------------------*/
48
49 #include "cs_headers.h"
50
51 /*----------------------------------------------------------------------------*/
52
53 BEGIN_C_DECLS
54
55 /*----------------------------------------------------------------------------*/
56 /*!
57 * \file cs_user_turbomachinery.c
58 *
59 * \brief Definition of turbomachinery related options.
60 *
61 * See \ref turbomachinery for examples.
62 */
63 /*----------------------------------------------------------------------------*/
64
65 /*============================================================================
66 * User function definitions
67 *============================================================================*/
68
69 /*----------------------------------------------------------------------------
70 * Define rotor/stator model.
71 *----------------------------------------------------------------------------*/
72
73 void
cs_user_turbomachinery(void)74 cs_user_turbomachinery(void)
75 {
76 /*! [user_tbm_set_model] */
77
78 /* Set turbomachinery model type:
79
80 CS_TURBOMACHINERY_NONE, No turbomachinery modeling
81 CS_TURBOMACHINERY_FROZEN, Frozen rotor model
82 CS_TURBOMACHINERY_TRANSIENT Full transient simulation
83 */
84
85 cs_turbomachinery_set_model(CS_TURBOMACHINERY_TRANSIENT);
86
87 /*! [user_tbm_set_model] */
88 }
89
90 /*----------------------------------------------------------------------------
91 * Define rotor axes, associated cells, and rotor/stator faces.
92 *----------------------------------------------------------------------------*/
93
94 void
cs_user_turbomachinery_rotor(void)95 cs_user_turbomachinery_rotor(void)
96 {
97 /* Define rotor axis and cells, with rotor/stator interface face joining */
98 /* --------------------------------------------------------------------- */
99
100 /*! [user_tbm_set_rotor] */
101 {
102 /* Define cells belonging to rotor and associated axis */
103
104 double rotation_velocity = 2.;
105 double rotation_axis[3] = {0., 0., 1.};
106
107 double rotation_invariant[3] = {0., 0., 0.};
108
109 const char cell_criteria[] = "cylinder[0.0, 0.0, 0.0,"
110 " 0.0, 0.0, 1.0,"
111 " 2.0]";
112
113 cs_turbomachinery_add_rotor(cell_criteria,
114 rotation_velocity,
115 rotation_axis,
116 rotation_invariant);
117
118 }
119 /*! [user_tbm_set_rotor] */
120
121
122 /*! [user_tbm_set_interface] */
123 {
124 /* Define joining associated with rotor/stator interface */
125
126 const char faces_criteria[] = "rotor_interface or stator_interface";
127
128 int verbosity = 0; /* per-task dump if > 1, debug level if >= 3 */
129 int visualization = 0; /* debug level if >= 3 */
130 float fraction = 0.10, plane = 25.;
131
132 int join_num = cs_turbomachinery_join_add(faces_criteria,
133 fraction,
134 plane,
135 verbosity,
136 visualization);
137
138 /* Note that advanced parameters may be defined
139 using cs_join_set_advanced_param(),
140 just as for regular joinings or periodicities. */
141
142 }
143 /*! [user_tbm_set_interface] */
144
145 }
146
147 /*----------------------------------------------------------------------------*/
148 /*!
149 * \brief Define rotation velocity of rotor.
150 */
151 /*----------------------------------------------------------------------------*/
152
153 void
cs_user_turbomachinery_set_rotation_velocity(void)154 cs_user_turbomachinery_set_rotation_velocity(void)
155 {
156 /*! [user_tbm_set_linear_rotation_velocity] */
157 {
158 /* Linearly increase the rotation velocity from 0 to 1470 rd/min in 0.2 s */
159 /* ---------------------------------------------------------------------- */
160
161 int rotor_num = 1;
162 double two_pi = 2. * acos(-1.);
163 double rotation_velocity = -1470. * two_pi / 60.;
164 double rotor_vel = rotation_velocity * CS_MIN(cs_glob_time_step->t_cur / 0.2, 1.);
165
166 cs_turbomachinery_set_rotation_velocity(rotor_num,
167 rotor_vel);
168 }
169 /*! [user_tbm_set_linear_rotation_velocity] */
170 }
171
172 /*----------------------------------------------------------------------------*/
173
174 END_C_DECLS
175