9.2
general documentation
cs_ale.h
Go to the documentation of this file.
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-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/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "base/cs_array.h"
39#include "base/cs_base.h"
40#include "cdo/cs_domain.h"
41#include "base/cs_restart.h"
42
43/*============================================================================
44 * Type definitions
45 *============================================================================*/
46
47/*----------------------------------------------------------------------------
48 * ALE type
49 *----------------------------------------------------------------------------*/
50
53typedef enum {
54
57 CS_ALE_CDO = 2
60
63typedef struct {
64
65 int *impale;
66 int *bc_type;
72 /* For neptune ALE implicit coupling */
84
85/*=============================================================================
86 * Global variables
87 *============================================================================*/
88
90
92
93extern int cs_glob_ale_n_ini_f; /* Number of sub-iterations for fluid
94 flow initialization */
95
96extern int cs_glob_ale_need_init; /* Indicate whether an iteration to
97 initialize ALE is required */
98
99/*============================================================================
100 * Public function prototypes
101 *============================================================================*/
102
103/*----------------------------------------------------------------------------*/
104/*
105 * \brief Compute of ALE volumic flux from displacement and deduced volume
106 * at time n+1.
107 *
108 * \param[in, out] domain pointer to a cs_domain_t structure
109 */
110/*----------------------------------------------------------------------------*/
111
112void
114
115/*----------------------------------------------------------------------------*/
116/*
117 * \brief In the ALE framework, update mass flux by adding mesh velocity.
118 *
119 * \param[in] m pointer to associated mesh structure
120 * \param[in] mq pointer to associated mesh quantities structure
121 * \param[in] dt time step at cells
122 * \param[in] crom density at cells
123 * \param[in] brom density at boundary faces
124 * \param[in, out] imasfl interior face mass flux
125 * \param[in, out] bmasfl boundary face mass flux
126 */
127/*----------------------------------------------------------------------------*/
128
129void
131 const cs_mesh_quantities_t *mq,
132 const cs_real_t dt[],
133 const cs_real_t crom[],
134 const cs_real_t brom[],
135 cs_real_t imasfl[],
136 cs_real_t bmasfl[]);
137
138/*----------------------------------------------------------------------------*/
139/*
140 * Compute boundary condition code for ALE
141 *----------------------------------------------------------------------------*/
142
143void
145(
146 const cs_mesh_t *m,
147 const cs_mesh_quantities_t *mq,
148 const bool init,
149 const cs_real_t dt[],
150 const int bc_type[],
152);
153
154/*----------------------------------------------------------------------------*/
155/*
156 * Compute boundary condition code for ALE
157 *----------------------------------------------------------------------------*/
158
159void
161 const cs_mesh_quantities_t *mq,
162 const bool init,
163 const cs_real_t dt[],
164 const int bc_type[],
165 cs_real_t *rcodcl1_vel);
166
167/*----------------------------------------------------------------------------*/
168/*
169 * \brief Allocation of ialtyb and impale for the ALE structure.
170 */
171/*----------------------------------------------------------------------------*/
172
173void cs_ale_allocate(void);
174
175/*----------------------------------------------------------------------------*/
176/*
177 * \brief Compute cell and face centers of gravity, cell volumes
178 * and update bad cells.
179 *
180 * \param[out] min_vol Minimum cell volume
181 * \param[out] max_vol Maximum cell volume
182 * \param[out] tot_vol Total cell volume
183 */
184/*----------------------------------------------------------------------------*/
185
186void
188 cs_real_t *max_vol,
189 cs_real_t *tot_vol);
190
191/*----------------------------------------------------------------------------*/
192/*
193 * \brief Project the displacement on mesh vertices (solved on cell center).
194 *
195 * \param[in] ale_bc_type Type of boundary for ALE
196 * \param[in] meshv Mesh velocity
197 * \param[in] gradm Mesh velocity gradient
198 * (du_i/dx_j : gradv[][i][j])
199 * \param[in] claale Boundary conditions A
200 * \param[in] clbale Boundary conditions B
201 * \param[in] dt Time step
202 * \param[out] disp_proj Displacement projected on vertices
203 */
204/*----------------------------------------------------------------------------*/
205
206void
207cs_ale_project_displacement(const int ale_bc_type[],
208 const cs_real_3_t *meshv,
209 const cs_real_33_t gradm[],
210 const cs_real_3_t *claale,
211 const cs_real_33_t *clbale,
212 const cs_real_t *dt,
213 cs_real_3_t *disp_proj);
214
215/*----------------------------------------------------------------------------*/
216/*
217 * \brief Update mesh in the ALE framework.
218 *
219 * \param[in] itrale number of the current ALE iteration
220 */
221/*----------------------------------------------------------------------------*/
222
223void
224cs_ale_update_mesh(int itrale);
225
226/*----------------------------------------------------------------------------*/
227/*
228 * \brief Update ALE BCs for required for the fluid
229 *
230 * \param[out] ale_bc_type type of ALE bcs
231 * \param[out] b_fluid_vel Fluid velocity at boundary faces
232 */
233/*----------------------------------------------------------------------------*/
234
235void
236cs_ale_update_bcs(int *ale_bc_type,
237 cs_real_3_t *b_fluid_vel);
238
239/*----------------------------------------------------------------------------*/
240/*
241 * \brief Solve a Poisson equation on the mesh velocity in ALE framework.
242 *
243 * It also updates the mesh displacement
244 * so that it can be used to update mass fluxes (due to mesh displacement).
245 *
246 * \param[in] iterns Navier-Stokes iteration number
247 */
248/*----------------------------------------------------------------------------*/
249
250void
251cs_ale_solve_mesh_velocity(const int iterns,
252 const cs_real_t b_rho[],
253 const cs_real_t i_mass_flux[],
254 const cs_real_t b_mass_flux[]);
255
256/*----------------------------------------------------------------------------*/
257/*
258 * \brief Activate the mesh velocity solving with CDO
259 */
260/*----------------------------------------------------------------------------*/
261
262void
263cs_ale_activate(void);
264
265/*----------------------------------------------------------------------------*/
266/*
267 * \brief Test if mesh velocity solving with CDO is activated
268 *
269 * \return true ifmesh velocity solving with CDO is requested, false otherwise
270 */
271/*----------------------------------------------------------------------------*/
272
273bool
275
276/*----------------------------------------------------------------------------*/
277/*
278 * \brief Add "property" fields dedicated to the ALE model.
279 */
280/*----------------------------------------------------------------------------*/
281
282void
284
285/*----------------------------------------------------------------------------*/
286/*
287 * \brief Initialize fields volume dedicated to the ALE model.
288 */
289/*----------------------------------------------------------------------------*/
290
291void
293
294/*----------------------------------------------------------------------------*/
295/*
296 * \brief Setup the equations solving the mesh velocity when CDO is activated
297 *
298 * \param[in, out] domain pointer to a cs_domain_t structure
299 */
300/*----------------------------------------------------------------------------*/
301
302void
304
305/*----------------------------------------------------------------------------
306 *
307 * \brief Print the ALE options to setup.log.
308 *
309 *----------------------------------------------------------------------------*/
310
311void
312cs_ale_log_setup(void);
313
314/*----------------------------------------------------------------------------*/
315/*
316 * \brief Setup the equations solving the mesh velocity
317 *
318 * \param[in] domain pointer to a cs_domain_t structure
319 */
320/*----------------------------------------------------------------------------*/
321
322void
324
325/*----------------------------------------------------------------------------*/
326/*
327 * \brief Finalize the setup stage for the equation of the mesh velocity
328 *
329 * \param[in, out] domain pointer to a cs_domain_t structure
330 */
331/*----------------------------------------------------------------------------*/
332
333void
335
336/*----------------------------------------------------------------------------*/
337/*
338 * \brief Free the main structure related to the ALE mesh velocity solving
339 */
340/*----------------------------------------------------------------------------*/
341
342void
344
345/*----------------------------------------------------------------------------*/
346/*
347 * \brief Read ALE data from restart file.
348 *
349 * \param[in, out] r associated restart file pointer
350 */
351/*----------------------------------------------------------------------------*/
352
353void
355
356/*----------------------------------------------------------------------------*/
357/*
358 * \brief Write ALE data from restart file.
359 *
360 * \param[in, out] r associated restart file pointer
361 */
362/*----------------------------------------------------------------------------*/
363
364void
366
367/*----------------------------------------------------------------------------*/
368
369#endif /* CS_ALE_H */
Define a templated mdspan class (non owner of data)
Definition: cs_mdspan.h:68
void cs_ale_solve_mesh_velocity(const int iterns, const cs_real_t b_rho[], const cs_real_t i_mass_flux[], const cs_real_t b_mass_flux[])
Solve a Poisson equation on the mesh velocity in ALE framework.
Definition: cs_ale.cpp:2287
void cs_mesh_velocity_mass_flux(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, const cs_real_t dt[], const cs_real_t crom[], const cs_real_t brom[], cs_real_t imasfl[], cs_real_t bmasfl[])
Definition: cs_ale.cpp:1446
void cs_ale_log_setup(void)
Definition: cs_ale.cpp:2543
void cs_ale_activate(void)
Activate the mesh velocity solving with CDO.
Definition: cs_ale.cpp:2310
void cs_ale_finalize_setup(cs_domain_t *domain)
Finalize the setup stage for the equation of the mesh velocity.
Definition: cs_ale.cpp:2692
int cs_glob_ale_n_ini_f
Definition: cs_ale.cpp:109
void cs_ale_update_mesh(int itrale)
Update mesh in the ALE framework.
Definition: cs_ale.cpp:2192
void cs_ale_update_bcs(int *ale_bc_type, cs_real_3_t *b_fluid_vel)
Update ALE BCs for required for the fluid.
Definition: cs_ale.cpp:2266
cs_ale_data_t * cs_glob_ale_data
Definition: cs_ale.cpp:106
void cs_boundary_condition_ale_type_nep(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, const bool init, const cs_real_t dt[], const int bc_type[], cs_real_t *rcodcl1_vel)
void cs_ale_add_property_fields(void)
Add "property" fields dedicated to the ALE model.
Definition: cs_ale.cpp:2367
void cs_ale_initialize_volume_fields(void)
Initialize volume fields dedicated to the ALE model.
Definition: cs_ale.cpp:2436
void cs_ale_destroy_all(void)
Free the main structure related to the ALE mesh velocity solving.
Definition: cs_ale.cpp:2715
cs_ale_type_t cs_glob_ale
Definition: cs_ale.cpp:104
void cs_ale_restart_write(cs_restart_t *r)
Write ALE data from restart file.
Definition: cs_ale.cpp:2804
void cs_ale_compute_volume_from_displacement(cs_domain_t *domain)
Compute of ALE volumic flux from displacement and deduced volume at time step n+1.
Definition: cs_ale.cpp:1221
void cs_ale_init_setup(cs_domain_t *domain)
Setup the equations solving the mesh velocity when CDO is activated.
Definition: cs_ale.cpp:2488
void cs_ale_setup_boundaries(const cs_domain_t *domain)
Setup the equations solving the mesh velocity.
Definition: cs_ale.cpp:2581
void cs_ale_allocate(void)
Allocation of ialtyb and impale for the ALE structure.
Definition: cs_ale.cpp:1907
bool cs_ale_is_activated(void)
Test if mesh velocity solving with CDO is activated.
Definition: cs_ale.cpp:2352
cs_ale_type_t
Definition: cs_ale.h:53
@ CS_ALE_LEGACY
Definition: cs_ale.h:56
@ CS_ALE_NONE
Definition: cs_ale.h:55
@ CS_ALE_CDO
Definition: cs_ale.h:57
void cs_ale_restart_read(cs_restart_t *r)
Read ALE data from restart file.
Definition: cs_ale.cpp:2740
void cs_ale_update_mesh_quantities(cs_real_t *min_vol, cs_real_t *max_vol, cs_real_t *tot_vol)
Compute cell and face centers of gravity, cell volumes and update bad cells.
Definition: cs_ale.cpp:1951
void cs_ale_project_displacement(const int ale_bc_type[], const cs_real_3_t *meshv, const cs_real_33_t gradm[], const cs_real_3_t *claale, const cs_real_33_t *clbale, const cs_real_t *dt, cs_real_3_t *disp_proj)
Project the displacement on mesh vertices (solved on cell center).
Definition: cs_ale.cpp:1984
int cs_glob_ale_need_init
Definition: cs_ale.cpp:112
void cs_boundary_condition_ale_type(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, const bool init, const cs_real_t dt[], const int bc_type[], cs::mdspan< cs_real_t, 2, cs::layout::left > val_ext_vel)
Definition: cs_ale.cpp:1593
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:358
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:366
@ dt
Definition: cs_field_pointer.h:61
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:91
Definition: cs_ale.h:63
cs_real_t ** alprof_pre
Definition: cs_ale.h:80
cs_real_t ** i_mass_flux_pre
Definition: cs_ale.h:78
cs_real_33_t ** gradu_pre
Definition: cs_ale.h:73
cs_real_t * i_mass_flux_ale
Definition: cs_ale.h:69
int * impale
Definition: cs_ale.h:65
cs_real_t * b_mass_flux_ale
Definition: cs_ale.h:70
cs_real_t ** b_mass_flux_pre
Definition: cs_ale.h:79
int * bc_type
Definition: cs_ale.h:66
cs_real_t ** alprob_pre
Definition: cs_ale.h:81
cs_real_3_t ** gradvolf_pre
Definition: cs_ale.h:75
cs_real_t ** gamma_pre
Definition: cs_ale.h:82
cs_real_63_t ** gradrij_pre
Definition: cs_ale.h:77
int ale_iteration
Definition: cs_ale.h:67
int implicit_coupling_ite
Definition: cs_ale.h:68
cs_real_3_t ** gradhtot_pre
Definition: cs_ale.h:76
cs_real_3_t * gradp_pre
Definition: cs_ale.h:74
Structure storing the main features of the computational domain and pointers to the main geometrical ...
Definition: cs_domain.h:120
Definition: cs_mesh_quantities.h:88
Definition: cs_mesh.h:85