1 #ifndef __CS_FAN_H__
2 #define __CS_FAN_H__
3 
4 /*============================================================================
5  * Fan modeling through velocity source terms.
6  *============================================================================*/
7 
8 /*
9   This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11   Copyright (C) 1998-2021 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 "cs_base.h"
39 
40 #include "cs_mesh.h"
41 #include "cs_mesh_quantities.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
45 BEGIN_C_DECLS
46 
47 /*============================================================================
48  * Structure definition
49  *============================================================================*/
50 
51 typedef struct _cs_fan_t cs_fan_t;
52 
53 /*============================================================================
54  *  Public function prototypes for Fortran API
55  *============================================================================*/
56 
57 /*----------------------------------------------------------------------------
58  * Compute the flows through the fans
59  *
60  * Fortran interface:
61  *
62  * subroutine debvtl
63  * *****************
64  *
65  * double precision flumas(*)      : <-- : interior faces mass flux
66  * double precision flumab(*)      : <-- : boundary faces mass flux
67  * double precision rhofac(*)      : <-- : density at cells
68  * double precision rhofab(*)      : <-- : density at boundary faces
69  *----------------------------------------------------------------------------*/
70 
71 void CS_PROCF (debvtl, DEBVTL)
72 (
73  cs_real_t  flumas[],
74  cs_real_t  flumab[],
75  cs_real_t  rhofac[],
76  cs_real_t  rhofab[]
77 );
78 
79 /*----------------------------------------------------------------------------
80  * Compute the force induced by the fans (needs a previous calculation
81  * of the flows through each fan).
82  *
83  * The induced force is added to the array crvxep (which can have other
84  * contributions).
85  *
86  * Fortran interface:
87  *
88  * subroutine tsvvtl
89  * *****************
90  *
91  * parameters:
92  *  crvexp         <-> Explicit source term (velocity)
93  *----------------------------------------------------------------------------*/
94 
95 void CS_PROCF (tsvvtl, TSVVTL)
96 (
97  cs_real_3_t  crvexp[]
98 );
99 
100 /*============================================================================
101  * Public function prototypes
102  *============================================================================*/
103 
104 /*----------------------------------------------------------------------------
105  * Fan definition (added to the ones previously defined)
106  *
107  * Fans are handled as explicit momentum source terms at the given location,
108  * based on the fan's axis and diameter.
109  * The fan's pressure characteristic curve is defined by 3 coefficients,
110  * such that:
111  *   delta P = C_0 + C_1.flow + C_2.flow^2
112  * An axial torque may also be defined for the 3D model.
113  *
114  * parameters:
115  *   fan_dim             <-- fan dimension:
116  *                             2: pseudo-2D (extruded mesh)
117  *                             3: 3D (standard)
118  *   mode                <-- mode:
119  *                             0: fan
120  *                             1: wind turbine
121  *   inlet_axis_coords   <-- intersection coords. of axis and inlet face
122  *   outlet_axis_coords  <-- intersection coords. od axis and outlet face
123  *   fan_radius          <-- fan radius
124  *   blades_radius       <-- blades radius
125  *   hub_radius          <-- hub radius
126  *   curve_coeffs        <-- coefficients of degre 0, 1 and 2 of
127  *                           the pressure drop/flow rate
128  *                           characteristic curve
129  *   axial_torque        <-- fan axial torque
130  *----------------------------------------------------------------------------*/
131 
132 void
133 cs_fan_define(int              fan_dim,
134               int              mode,
135               const cs_real_t  inlet_axis_coords[3],
136               const cs_real_t  outlet_axis_coords[3],
137               cs_real_t        fan_radius,
138               cs_real_t        blades_radius,
139               cs_real_t        hub_radius,
140               const cs_real_t  curve_coeffs[3],
141               cs_real_t        axial_torque);
142 
143 /*----------------------------------------------------------------------------
144  * Destroy the structures associated with fans.
145  *----------------------------------------------------------------------------*/
146 
147 void
148 cs_fan_destroy_all(void);
149 
150 /*----------------------------------------------------------------------------
151  * Return number of fans.
152  *
153  * returns:
154  *   number of defined fans
155  *----------------------------------------------------------------------------*/
156 
157 int
158 cs_fan_n_fans(void);
159 
160 /*----------------------------------------------------------------------------
161  * Log fans definition setup information.
162  *----------------------------------------------------------------------------*/
163 
164 void
165 cs_fan_log_setup(void);
166 
167 /*----------------------------------------------------------------------------
168  * Log fan information for a given iteration.
169  *----------------------------------------------------------------------------*/
170 
171 void
172 cs_fan_log_iteration(void);
173 
174 /*----------------------------------------------------------------------------
175  * Define the cells belonging to the different fans.
176  *
177  * parameters:
178  *   mesh            <-- associated mesh structure
179  *   mesh_quantities <-- mesh quantities
180  *----------------------------------------------------------------------------*/
181 
182 void
183 cs_fan_build_all(const cs_mesh_t             *mesh,
184                  const cs_mesh_quantities_t  *mesh_quantities);
185 
186 /*----------------------------------------------------------------------------
187  * Compute the flows through the fans.
188  *
189  * parameters:
190  *   mesh            <-- mesh structure
191  *   mesh_quantities <-- mesh quantities
192  *   i_mass_flux     <-- interior faces mass flux
193  *   b_mass_flux     <-- boundary faces mass flux
194  *   c_rho           <-- density at cells
195  *   b_rho           <-- density at boundary faces
196  *----------------------------------------------------------------------------*/
197 
198 void
199 cs_fan_compute_flows(const cs_mesh_t             *mesh,
200                      const cs_mesh_quantities_t  *mesh_quantities,
201                      const cs_real_t              i_mass_flux[],
202                      const cs_real_t              b_mass_flux[],
203                      const cs_real_t              c_rho[],
204                      const cs_real_t              b_rho[]);
205 
206 /*----------------------------------------------------------------------------
207  * Compute the force induced by the fans (needs a previous calculation
208  * of the flows through each fan).
209  *
210  * The induced force is added to the array CRVXEP (which can have other
211  * other contributions).
212  *
213  * parameters:
214  *   mesh_quantities <-- mesh quantities
215  *   source_t        <-> explicit source term for the velocity
216  *----------------------------------------------------------------------------*/
217 
218 void
219 cs_fan_compute_force(const cs_mesh_quantities_t  *mesh_quantities,
220                      cs_real_3_t                  source_t[]);
221 
222 /*----------------------------------------------------------------------------
223  * Flag the cells belonging to the different fans
224  * (by the fan id, -1 otherwise)
225  *
226  * parameters:
227  *   mesh        <-- associated mesh structure
228  *   cell_fan_id --> indicator by cell
229  *----------------------------------------------------------------------------*/
230 
231 void
232 cs_fan_flag_cells(const cs_mesh_t  *mesh,
233                   int               cell_fan_id[]);
234 
235 /*----------------------------------------------------------------------------
236  * Selection function for cells belonging to fans.
237  *
238  * This function may be used for the definition of postprocessing meshes.
239  *
240  * param
241  * \param[in, out]  input    pointer to input (unused here)
242  * \param[out]      n_cells  number of selected cells
243  * \param[out]      cell_ids array of selected cell ids (0 to n-1 numbering)
244  */
245 /*----------------------------------------------------------------------------*/
246 
247 void
248 cs_fan_cells_select(void         *input,
249                     cs_lnum_t    *n_cells,
250                     cs_lnum_t   **cell_ids);
251 
252 /*----------------------------------------------------------------------------*/
253 
254 END_C_DECLS
255 
256 #endif /* __CS_FAN_H__ */
257