1 #ifndef __CS_ALE_H__
2 #define __CS_ALE_H__
3 
4 /*============================================================================
5  * Functions associated to ALE formulation
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 #include "cs_domain.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
43 BEGIN_C_DECLS
44 
45 /*============================================================================
46  * Type definitions
47  *============================================================================*/
48 
49 /*----------------------------------------------------------------------------
50  * ALE type
51  *----------------------------------------------------------------------------*/
52 
53 enum {
54 
55   CS_ALE_NONE = 0,
56   CS_ALE_LEGACY = 1,
57   CS_ALE_CDO = 2
58 
59 };
60 
61 /*=============================================================================
62  * Global variables
63  *============================================================================*/
64 
65 extern int cs_glob_ale;
66 
67 /*============================================================================
68  * Fortran wrapper function definitions
69  *============================================================================*/
70 
71 /*----------------------------------------------------------------------------
72  * Get pointer to cs_glob_ale
73  *----------------------------------------------------------------------------*/
74 
75 void
76 cs_f_ale_get_pointers(int **iale);
77 
78 /*============================================================================
79  * Public function prototypes
80  *============================================================================*/
81 
82 /*----------------------------------------------------------------------------*/
83 /*!
84  * \brief  Compute cell and face centers of gravity, cell volumes
85  *         and update bad cells.
86  *
87  * \param[out]       min_vol        Minimum cell volume
88  * \param[out]       max_vol        Maximum cell volume
89  * \param[out]       tot_vol        Total cell volume
90  */
91 /*----------------------------------------------------------------------------*/
92 
93 void
94 cs_ale_update_mesh_quantities(cs_real_t  *min_vol,
95                               cs_real_t  *max_vol,
96                               cs_real_t  *tot_vol);
97 
98 /*----------------------------------------------------------------------------*/
99 /*!
100  * \brief  Project the displacement on mesh vertices (solved on cell center).
101  *
102  * \param[in]       ale_bc_type   Type of boundary for ALE
103  * \param[in]       meshv         Mesh velocity
104  * \param[in]       gradm         Mesh velocity gradient
105  *                                (du_i/dx_j : gradv[][i][j])
106  * \param[in]       claale        Boundary conditions A
107  * \param[in]       clbale        Boundary conditions B
108  * \param[in]       dt            Time step
109  * \param[out]      disp_proj     Displacement projected on vertices
110  */
111 /*----------------------------------------------------------------------------*/
112 
113 void
114 cs_ale_project_displacement(const int           ale_bc_type[],
115                             const cs_real_3_t  *meshv,
116                             const cs_real_33_t  gradm[],
117                             const cs_real_3_t  *claale,
118                             const cs_real_33_t *clbale,
119                             const cs_real_t    *dt,
120                             cs_real_3_t        *disp_proj);
121 
122 /*----------------------------------------------------------------------------*/
123 /*!
124  * \brief  Update mesh in the ALE framework.
125  *
126  * \param[in]       itrale        number of the current ALE iteration
127  */
128 /*----------------------------------------------------------------------------*/
129 
130 void
131 cs_ale_update_mesh(const int           itrale);
132 
133 /*----------------------------------------------------------------------------*/
134 /*!
135  * \brief Update ALE BCs for required for the fluid
136  *
137  * \param[out]      ale_bc_type   type of ALE bcs
138  * \param[out]      b_fluid_vel   Fluid velocity at boundary faces
139  */
140 /*----------------------------------------------------------------------------*/
141 
142 void
143 cs_ale_update_bcs(int         *ale_bc_type,
144                   cs_real_3_t *b_fluid_vel);
145 
146 /*----------------------------------------------------------------------------*/
147 /*!
148  * \brief Solve a Poisson equation on the mesh velocity in ALE framework.
149  *
150  * It also updates the mesh displacement
151  * so that it can be used to update mass fluxes (due to mesh displacement).
152  *
153  * \param[in]       iterns        Navier-Stokes iteration number
154  * \param[in]       impale        Indicator for fixed node displacement
155  * \param[in]       ale_bc_type   Type of boundary for ALE
156  */
157 /*----------------------------------------------------------------------------*/
158 
159 void
160 cs_ale_solve_mesh_velocity(const int   iterns,
161                            const int  *impale,
162                            const int  *ale_bc_type);
163 
164 /*----------------------------------------------------------------------------*/
165 /*!
166  * \brief  Activate the mesh velocity solving with CDO
167  */
168 /*----------------------------------------------------------------------------*/
169 
170 void
171 cs_ale_activate(void);
172 
173 /*----------------------------------------------------------------------------*/
174 /*!
175  * \brief  Test if mesh velocity solving with CDO is activated
176  *
177  * \return true ifmesh velocity solving with CDO is requested, false otherwise
178  */
179 /*----------------------------------------------------------------------------*/
180 
181 bool
182 cs_ale_is_activated(void);
183 
184 /*----------------------------------------------------------------------------*/
185 /*!
186  * \brief Setup the equations related to mesh deformation.
187  *
188  * \param[in, out]   domain     pointer to a cs_domain_t structure
189  */
190 /*----------------------------------------------------------------------------*/
191 
192 void
193 cs_ale_init_setup(cs_domain_t   *domain);
194 
195 /*----------------------------------------------------------------------------*/
196 /*!
197  * \brief Setup the equations solving the mesh velocity
198  *
199  * \param[in]   domain       pointer to a cs_domain_t structure
200  */
201 /*----------------------------------------------------------------------------*/
202 
203 void
204 cs_ale_setup_boundaries(const cs_domain_t   *domain);
205 
206 /*----------------------------------------------------------------------------*/
207 /*!
208  * \brief  Finalize the setup stage for the equation of the mesh velocity
209  *
210  * \param[in, out]  domain       pointer to a cs_domain_t structure
211  */
212 /*----------------------------------------------------------------------------*/
213 
214 void
215 cs_ale_finalize_setup(cs_domain_t   *domain);
216 
217 /*----------------------------------------------------------------------------*/
218 /*!
219  * \brief  Free the main structure related to the ALE mesh velocity solving
220  */
221 /*----------------------------------------------------------------------------*/
222 
223 void
224 cs_ale_destroy_all(void);
225 
226 /*----------------------------------------------------------------------------*/
227 
228 END_C_DECLS
229 
230 #endif /* __CS_ALE_H__ */
231