9.2
general documentation
cs_vof.h
Go to the documentation of this file.
1#ifndef CS_VOF_H
2#define CS_VOF_H
3
4/*============================================================================
5 * Functions associated to VOF model
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_defs.h"
39#include "mesh/cs_mesh.h"
41
42/*=============================================================================
43 * Macro definitions
44 *============================================================================*/
45
55#define CS_VOF_ENABLED (1 << 0)
56
58#define CS_VOF_FREE_SURFACE (1 << 1)
59
61#define CS_VOF_MERKLE_MASS_TRANSFER (1 << 2)
62
68/*============================================================================
69 * Type definitions
70 *============================================================================*/
71
72/* VOF model parameters */
73/*----------------------*/
74
75typedef struct {
76
77 unsigned vof_model; /* VoF model (sum of masks defining Volume of
78 Fluid model and submodels */
79
80 double rho1; /* density */
81
82 double rho2;
83
84 double mu1; /* viscosity */
85
86 double mu2;
87
88 double sigma_s; /* surface tension */
89
90 int idrift; /* drift velocity model */
91
92 double cdrift; /* C_gamma constant (drift flux factor)*/
93
94 double kdrift;
95
97
98/* Cavitation parameters */
99/*-----------------------*/
100
101typedef struct {
102
103 cs_real_t presat; /* reference saturation pressure */
104 cs_real_t uinf; /* reference velocity */
105 cs_real_t linf; /* reference length scale */
106 cs_real_t cdest; /* constant of condensation model (Merkle) */
107 cs_real_t cprod; /* constant of vaporization model (Merkle) */
108 int icvevm; /* eddy-viscosity correction indicator */
109 cs_real_t mcav; /* eddy-viscosity correction cstt (Reboud) */
110 int itscvi; /* eddy-viscosity correction indicator */
111
113
116typedef enum {
122
123/*=============================================================================
124 * Global variables
125 *============================================================================*/
126
127/* pointer to VOF model parameters structure */
128
130
131/* pointer to cavitation model parameters structure */
132
134
135/*============================================================================
136 * Public function prototypes
137 *============================================================================*/
138
139/*----------------------------------------------------------------------------
140 *
141 * \brief Provide write access to VOF structure.
142 */
143/*----------------------------------------------------------------------------*/
144
147
148/*----------------------------------------------------------------------------*/
149/*
150 * \brief Create VoF fields
151 */
152/*----------------------------------------------------------------------------*/
153
154void
156
157/*----------------------------------------------------------------------------*/
158/*
159 * \brief Log setup of VoF model.
160 */
161/*----------------------------------------------------------------------------*/
162
163void
164cs_vof_log_setup(void);
165
166/*----------------------------------------------------------------------------*/
167/*
168 * \brief Compute the mixture density, mixture dynamic viscosity given fluid
169 * volume fractions and the reference density and dynamic viscosity
170 * \f$ \rho_l, \mu_l \f$ (liquid), \f$ \rho_v, \mu_v \f$ (gas).
171 *
172 * Computation is done as follows on cells:
173 * \f[
174 * \rho_\celli = \alpha_\celli \rho_v + (1-\alpha_\celli) \rho_l,
175 * \f]
176 * \f[
177 * \mu_\celli = \alpha_\celli \mu_v + (1-\alpha_\celli) \mu_l,
178 * \f]
179 *
180 * A similar linear formula is followed on boundary using fluid volume fraction
181 * value on the boundary.
182 *
183 * \param[in] m pointer to mesh structure
184 */
185/*----------------------------------------------------------------------------*/
186
187void
189
190/*----------------------------------------------------------------------------*/
191/*
192 * \brief Compute the mixture density, mixture dynamic viscosity and mixture
193 * mass flux given the volumetric flux, the volume fraction and the
194 * reference density and dynamic viscosity \f$ \rho_l, \mu_l \f$
195 * (liquid), \f$ \rho_v, \mu_v \f$ (gas).
196 *
197 * For the computation of mixture density, mixture dynamic viscosity, see
198 * \ref cs_vof_compute_linear_rho_mu.
199 *
200 * Computation of mass flux is as follows:
201 * \f[
202 * \left( \rho\vect{u}\cdot\vect{S} \right)_\ij = \\ \left\lbrace
203 * \begin{array}{ll}
204 * \rho_\celli (\vect{u}\cdot\vect{S})_\ij
205 * &\text{ if } (\vect{u}\cdot\vect{S})_\ij>0, \\
206 * \rho_\cellj (\vect{u}\cdot\vect{S})_\ij
207 * &\text{ otherwise },
208 * \end{array} \right.
209 * \f]
210 * \f[
211 * \left( \rho\vect{u}\cdot\vect{S} \right)_\ib = \\ \left\lbrace
212 * \begin{array}{ll}
213 * \rho_\celli (\vect{u}\cdot\vect{S})_\ib
214 * &\text{ if } (\vect{u}\cdot\vect{S})_\ib>0, \\
215 * \rho_b (\vect{u}\cdot\vect{S})_\ib
216 * &\text{ otherwise }.
217 * \end{array} \right.
218 * \f]
219 *
220 * \param[in] m pointer to mesh structure
221 */
222/*----------------------------------------------------------------------------*/
223
224void
226
227/*----------------------------------------------------------------------------*/
228/*
229 * \brief Compute the surface tension momentum source term following the CSF
230 * model of Brackbill et al. (1992).
231 *
232 * \param[in] m pointer to mesh structure
233 * \param[in] mq pointer to mesh quantities structure
234 * \param[out] stf surface tension momentum source term
235 */
236/*----------------------------------------------------------------------------*/
237
238void
240 const cs_mesh_quantities_t *mq,
241 cs_real_3_t stf[]);
242
243/*----------------------------------------------------------------------------*/
244/*
245 * \brief Write in main log the global mixture mass budget:
246 * \f[
247 * \sum_i\left(
248 * |\Omega_i|\dfrac{\alpha_i^n - \alpha_i^{n-1}}{\Delta t} +
249 * \sum_{j\in\Face{\celli}}\left(\rho\vect{u}\vect{S}\right)_{ij}^n
250 * \right).
251 * \f]
252 *
253 * \param[in] m pointer to mesh structure
254 * \param[in] mq pointer to mesh quantities structure
255 */
256/*----------------------------------------------------------------------------*/
257
258void
260 const cs_mesh_quantities_t *mq);
261
262/*----------------------------------------------------------------------------*/
263/*
264 * \brief Compute the flux of the drift velocity \f$ \vect u _d \f$,
265 * by using the flux of the standard velocity \f$ \vect u \f$
266 * following the approach described by
267 * Suraj S Deshpande et al 2012 Comput. Sci. Disc. 5 014016.
268 * It is activated with the option idrift = 1
269 *
270 * Using the notation:
271 * \f[
272 * \begin{cases}
273 * \left ( \vect u ^{n+1} . \vect S \right ) _{\face} = \Dot{m}_{\face}\\
274 * \left ( \vect u _d^{n+1} . \vect S \right ) _{\face} = \Dot{m^d}_{\face}
275 * \end{cases}
276 * \f]
277 * The drift flux is computed as:
278 * \f[
279 * \Dot{m^d}_{\face} = min \left ( C_{\gamma} \dfrac{\Dot{m}_{\face}}
280 * {\vect S_{\face}}, \underset{\face'}{max} \left [ \dfrac{\Dot{m}_{\face'}}
281 * {\vect S_{\face'}} \right ] \right ) \left ( \vect n . \vect S \right )
282 * _{\face}
283 * \f]
284 * Where \f$ C_{\gamma} \f$ is the drift flux factor defined with the variable
285 * \ref cdrift, \f$ \vect n _{\face} \f$ the normal vector to the interface.
286 * The gradient is computed using a centered scheme:
287 * \f[
288 * {\vect n _{\face}} = \dfrac{\left ( \grad \alpha \right ) _{\face}}
289 * {\norm {\left ( \grad \alpha \right ) _{\face} + \delta}},
290 * \text{ with: }
291 * \left ( \grad \alpha \right ) _{\face _{\celli \cellj}} = \dfrac{\left (
292 * \grad \alpha \right ) _\celli + \left ( \grad \alpha \right ) _\cellj}{2},
293 * \text{ and: }
294 * \delta = 10^{-8} / \overline{\vol \celli} ^{1/3}
295 * \f]
296 *
297 * \param[in] m pointer to mesh structure
298 * \param[in] mq pointer to mesh quantities structure
299 */
300/*----------------------------------------------------------------------------*/
301
302void
304 const cs_mesh_quantities_t *mq);
305
306/*----------------------------------------------------------------------------*/
307/*
308 * \brief Add the explicit part of the convection/diffusion terms of a
309 * standard transport equation of a scalar field \f$ \varia \f$.
310 *
311 * More precisely, the right hand side \f$ Rhs \f$ is updated as follows:
312 * \f[
313 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left(
314 * \alpha_\celli^{n+1} \left( 1 - \alpha_\cellj^{n+1} \right) \left(
315 * \dot{m}_\fij^{d} \right)^{+} + \alpha_\cellj^{n+1} \left( 1 -
316 * \alpha_\celli^{n+1} \right) \left( \dot{m}_\fij^{d} \right)^{-}
317 * \right)
318 * \f]
319 *
320 * \param[in] imrgra indicator
321 * - 0 iterative gradient
322 * - 1 least squares gradient
323 * \param[in] nswrgp number of reconstruction sweeps for the
324 * gradients
325 * \param[in] imligp clipping gradient method
326 * - < 0 no clipping
327 * - = 0 by neighboring gradients
328 * - = 1 by the mean gradient
329 * \param[in] iwarnp verbosity
330 * \param[in] epsrgp relative precision for the gradient
331 * reconstruction
332 * \param[in] climgp clipping coefficient for the computation of
333 * the gradient
334 * \param[in] pvar solved variable (current time step)
335 * \param[in] pvara solved variable (previous time step)
336 * \param[in,out] rhs right hand side \f$ \vect{Rhs} \f$
337 */
338/*----------------------------------------------------------------------------*/
339
340void
342 int nswrgp,
343 int imligp,
344 int iwarnp,
345 cs_real_t epsrgp,
346 cs_real_t climgp,
347 cs_real_t *pvar,
348 const cs_real_t *pvara,
349 cs_real_t *rhs);
350
351/*----------------------------------------------------------------------------*/
352/*
353 * \param[in] iterns Navier-Stokes iteration number
354 */
355/*----------------------------------------------------------------------------*/
356
357void
359
360/*----------------------------------------------------------------------------*/
361/*
362 * \brief Smoothe a variable after several double-projections
363 * cells->faces->cells.
364 *
365 * \param[in] m pointer to mesh structure
366 * \param[in] mq pointer to mesh quantities structure
367 * \param[in] bc_coeffs boundary condition structure for the variable
368 * \param[in, out] pvar diffused variable
369 */
370/*----------------------------------------------------------------------------*/
371
372void
374 const cs_mesh_quantities_t *mq,
375 cs_field_bc_coeffs_t *bc_coeffs,
376 cs_real_t *pvar);
377
378/*----------------------------------------------------------------------------
379 *
380 * \brief Provide write access to cavitation parameters structure.
381 */
382/*----------------------------------------------------------------------------*/
383
386
387/*----------------------------------------------------------------------------*/
388/*
389 * \brief Compute the vaporization source term
390 * \f$ \Gamma_V \left(\alpha, p\right) = m^+ + m^- \f$ using the
391 * Merkle model:
392 *
393 * \f[
394 * m^+ = -\dfrac{C_{prod} \rho_l \min \left( p-p_V,0 \right)\alpha(1-\alpha)}
395 * {0.5\rho_lu_\infty^2t_\infty},
396 * \f]
397 * \f[
398 * m^- = -\dfrac{C_{dest} \rho_v \max \left( p-p_V,0 \right)\alpha(1-\alpha)}
399 * {0.5\rho_lu_\infty^2t_\infty},
400 * \f]
401 * with \f$ C_{prod}, C_{dest} \f$ empirical constants,
402 * \f$ t_\infty=l_\infty/u_\infty \f$ a reference time scale and \f$p_V\f$
403 * the reference saturation pressure.
404 * \f$ l_\infty \f$, \f$ u_\infty \f$ and \f$p_V\f$ may be provided by
405 * the user (user function).
406 *
407 * Note that the r.h.s. of the void fraction transport equation is
408 * \f$ \Gamma_V/\rho_v \f$.
409 *
410 * \param[in] pressure Pressure array
411 * \param[in] voidf Void fraction array
412 */
413/*----------------------------------------------------------------------------*/
414
415void
417 const cs_real_t voidf[]);
418
419/*----------------------------------------------------------------------------*/
420/* Set the contact angle mode */
421/*----------------------------------------------------------------------------*/
422
423void
425(
426 const cs_vof_contact_angle_t choice
427);
428
429/*----------------------------------------------------------------------------*/
430
431#endif /* CS_VOF_H */
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
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
void cs_vof_deshpande_drift_flux(const cs_mesh_t *m, const cs_mesh_quantities_t *mq)
Compute a relative velocity directly at internal faces (drift flux), following the approach describe...
Definition: cs_vof.cpp:1164
void cs_vof_smoothe(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t *pvar)
void cs_vof_surface_tension(const cs_mesh_t *m, const cs_mesh_quantities_t *mq, cs_real_3_t stf[])
Compute the surface tension momentum source term following the CSF model of Brackbill et al....
Definition: cs_vof.cpp:915
cs_cavitation_parameters_t * cs_get_glob_cavitation_parameters(void)
Definition: cs_vof.cpp:2124
cs_vof_contact_angle_t
Definition: cs_vof.h:116
@ CS_VOF_N_CONTACT_ANGLE_TYPES
Definition: cs_vof.h:120
@ CS_VOF_CONTACT_ANGLE_STATIC
Definition: cs_vof.h:118
@ CS_VOF_CONTACT_ANGLE_DYN
Definition: cs_vof.h:119
@ CS_VOF_CONTACT_ANGLE_OFF
Definition: cs_vof.h:117
void cs_vof_drift_term(int imrgra, int nswrgp, int imligp, int iwarnp, cs_real_t epsrgp, cs_real_t climgp, cs_real_t *pvar, const cs_real_t *pvara, cs_real_t *rhs)
void cs_vof_compute_linear_rho_mu(const cs_mesh_t *m)
Compute the mixture density, mixture dynamic viscosity given fluid volume fractions and the reference...
Definition: cs_vof.cpp:599
void cs_vof_field_create(void)
Create VoF fields.
Definition: cs_vof.cpp:392
void cs_cavitation_compute_source_term(const cs_real_t pressure[], const cs_real_t voidf[])
Compute the vaporization source term using the Merkle model:
Definition: cs_vof.cpp:2158
void cs_vof_log_setup(void)
Log setup of VoF model.
Definition: cs_vof.cpp:506
const cs_vof_parameters_t * cs_glob_vof_parameters
void cs_vof_log_mass_budget(const cs_mesh_t *m, const cs_mesh_quantities_t *mq)
Write in main log the global mixture mass budget:
Definition: cs_vof.cpp:742
void cs_vof_contact_angle_set(const cs_vof_contact_angle_t choice)
Set the contact angle mode.
Definition: cs_vof.cpp:2210
const cs_cavitation_parameters_t * cs_glob_cavitation_parameters
void cs_vof_update_phys_prop(const cs_mesh_t *m)
Compute the mixture density, mixture dynamic viscosity and mixture mass flux given the volumetric flu...
Definition: cs_vof.cpp:680
void cs_vof_solve_void_fraction(int iterns)
Solve the void fraction for the Volume of Fluid method (and hence for cavitating flows).
Definition: cs_vof.cpp:1477
cs_vof_parameters_t * cs_get_glob_vof_parameters(void)
Definition: cs_vof.cpp:380
int itscvi
Definition: cs_vof.h:110
cs_real_t cprod
Definition: cs_vof.h:107
cs_real_t presat
Definition: cs_vof.h:103
cs_real_t uinf
Definition: cs_vof.h:104
cs_real_t cdest
Definition: cs_vof.h:106
cs_real_t linf
Definition: cs_vof.h:105
cs_real_t mcav
Definition: cs_vof.h:109
int icvevm
Definition: cs_vof.h:108
double cdrift
Definition: cs_vof.h:92
double rho2
Definition: cs_vof.h:82
unsigned vof_model
Definition: cs_vof.h:77
double mu2
Definition: cs_vof.h:86
double mu1
Definition: cs_vof.h:84
int idrift
Definition: cs_vof.h:90
double sigma_s
Definition: cs_vof.h:88
double kdrift
Definition: cs_vof.h:94
double rho1
Definition: cs_vof.h:80
Cavitation model parameters.
Definition: cs_vof.h:101
Definition: cs_mesh_quantities.h:88
Definition: cs_mesh.h:85
VOF model parameters. Void fraction variable tracks fluid 2.
Definition: cs_vof.h:75