diff --git a/18_Rayleigh_Taylor/CASE/DATA/run.cfg b/18_Rayleigh_Taylor/CASE/DATA/run.cfg new file mode 100644 index 0000000..89ecabe --- /dev/null +++ b/18_Rayleigh_Taylor/CASE/DATA/run.cfg @@ -0,0 +1,5 @@ +[job_defaults] + +n_procs: 1 +n_threads: 1 + diff --git a/18_Rayleigh_Taylor/CASE/DATA/setup.xml b/18_Rayleigh_Taylor/CASE/DATA/setup.xml new file mode 100644 index 0000000..8f9e462 --- /dev/null +++ b/18_Rayleigh_Taylor/CASE/DATA/setup.xml @@ -0,0 +1,185 @@ + + + + + + + all[] + + + + + all[] + + + + 1 + + + + + + 10 + + + + + + + + 1 + 10 + 4.4 + + + + + + + 1 + 10 + 0.1 + 0.0005 + 0.1 + + + + Y0 or Y1 or Z0 or Z1 + + + + + + + + + + + + + 1.17862 + 1 + 5 + + + 0.01 + + + + + 1.83e-05 + 0.001 + 0.001 + + + 0 + + + + 101325 + 293.15 + + + 0 + -1 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + 0.1 + 25 + X0 or X1 + + 1 + 0 + 0 + + 1 + 1 + + + + + all[] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + + + + + + + + + + + + + 2 + + + 1 + + + + \ No newline at end of file diff --git a/18_Rayleigh_Taylor/CASE/SRC/cs_user_initialization.cpp b/18_Rayleigh_Taylor/CASE/SRC/cs_user_initialization.cpp new file mode 100644 index 0000000..3e95077 --- /dev/null +++ b/18_Rayleigh_Taylor/CASE/SRC/cs_user_initialization.cpp @@ -0,0 +1,152 @@ +/*============================================================================ + * User initialization for the Rayleigh-Taylor instability (VOF). + * + * A heavy fluid (rho=5) rests on top of a light fluid (rho=1) under + * gravity. A sinusoidal perturbation of the interface triggers the + * instability, producing characteristic mushroom-shaped structures. + *============================================================================*/ + +/* code_saturne version 9.1 */ + +/* + This file is part of code_saturne, a general-purpose CFD tool. + + Copyright (C) 1998-2025 EDF S.A. + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/*----------------------------------------------------------------------------*/ + +#include "cs_defs.h" + +/*---------------------------------------------------------------------------- + * Standard C library headers + *----------------------------------------------------------------------------*/ + +#include +#include + +#if defined(HAVE_MPI) +#include +#endif + +/*---------------------------------------------------------------------------- + * PLE library headers + *----------------------------------------------------------------------------*/ + +#include + +/*---------------------------------------------------------------------------- + * Local headers + *----------------------------------------------------------------------------*/ + +#include "cs_headers.h" + +/*----------------------------------------------------------------------------*/ + +BEGIN_C_DECLS + +/*----------------------------------------------------------------------------*/ +/*! + * \file cs_user_initialization.cpp + * + * \brief Rayleigh-Taylor instability initialization (VOF). + */ +/*----------------------------------------------------------------------------*/ + +/*============================================================================ + * User function definitions + *============================================================================*/ + +/*----------------------------------------------------------------------------*/ +/*! + * \brief Define initial conditions for the Rayleigh-Taylor problem. + * + * Sets zero velocity and a smoothed sinusoidal VOF interface between + * a heavy fluid on top and a light fluid below, under gravity. + * + * \param[in, out] domain pointer to a cs_domain_t structure + */ +/*----------------------------------------------------------------------------*/ + +void +cs_user_initialization(cs_domain_t *domain) +{ + const cs_lnum_t n_cells = domain->mesh->n_cells; + + /* Do not reinitialize on restart */ + if (domain->time_step->nt_prev > 0) + return; + + /* ---- Parameters ---- */ + + const cs_real_t Lx = 1.0; /* domain length in x */ + const cs_real_t y0 = 1.0; /* interface height (middle of Ly=2) */ + const cs_real_t eps = 0.03; /* perturbation amplitude */ + const cs_real_t thickness = 0.005; /* interface smoothing thickness */ + + /* ---- Mesh coordinates (v9.x format) ---- */ + + const cs_real_t (*cell_cen)[3] = + domain->mesh_quantities->cell_cen; + + /* ---- Get VOF field ---- */ + + cs_field_t *vf = cs_field_by_name_try("void_fraction"); + if (vf == nullptr) + vf = cs_field_by_name_try("volume_fraction"); + if (vf == nullptr) + vf = cs_field_by_name_try("alpha"); + + if (vf == nullptr) + bft_error(__FILE__, __LINE__, 0, + "VOF fraction field not found."); + + /* ---- Velocity field ---- */ + + cs_real_t *vel = CS_F_(vel)->val; + + /* ---- Initialization loop ---- */ + + for (cs_lnum_t c_id = 0; c_id < n_cells; c_id++) { + + const cs_real_t x = cell_cen[c_id][0]; + const cs_real_t y = cell_cen[c_id][1]; + + /* 1) Perturbed interface */ + const cs_real_t y_int = + y0 + eps * sin(2.0 * M_PI * x / Lx); + + /* 2) Smoothed VOF (heavy fluid above) */ + const cs_real_t s = (y - y_int) / thickness; + + cs_real_t alpha = + 0.5 * (1.0 + tanh(s)); + + /* Clamp */ + if (alpha < 0.0) alpha = 0.0; + if (alpha > 1.0) alpha = 1.0; + + vf->val[c_id] = alpha; + + /* 3) Initial velocity = 0 everywhere */ + vel[3*c_id + 0] = 0.0; + vel[3*c_id + 1] = 0.0; + vel[3*c_id + 2] = 0.0; + } +} + +END_C_DECLS \ No newline at end of file diff --git a/18_Rayleigh_Taylor/README.md b/18_Rayleigh_Taylor/README.md new file mode 100644 index 0000000..89c79a7 --- /dev/null +++ b/18_Rayleigh_Taylor/README.md @@ -0,0 +1,56 @@ +Rayleigh-Taylor Instability +=========================== + +2D Rayleigh-Taylor instability simulated with the VOF (Volume of Fluid) +method in code_saturne. + +A heavy fluid rests on top of a light fluid under gravity. Any +perturbation of the interface grows exponentially, producing +characteristic mushroom-shaped structures as the heavy fluid sinks +and the light fluid rises. + +Setup +----- + +- Multiphase model: VOF (Volume of Fluid) +- Turbulence: off (laminar) +- Mesh: 64 x 192 x 1 Cartesian (generated at runtime) +- Domain: [0, 1] x [-1, 2] x [0, 1] +- Periodicity: x-direction +- Boundary conditions: + - x0, x1: periodic + - y0, y1, z0, z1: symmetry +- Gravity: g = -1 m/s^2 (y-axis) +- Time stepping: adaptive (CFL = 1), dt_ref = 0.0005 s, t_final = 4.4 s + +Fluid properties: + +| Property | Light fluid | Heavy fluid | +|------------|-------------|-------------| +| Density | 1.0 | 5.0 | +| Viscosity | 0.001 | 0.001 | + +Atwood number: At = (rho_h - rho_l) / (rho_h + rho_l) = 0.667 + +Initial conditions (set in `cs_user_initialization.cpp`): + +| Parameter | Value | +|-------------------------------|-----------------| +| Interface height y0 | 1.0 m | +| Perturbation amplitude eps | 0.03 m | +| Perturbation wavelength | Lx (2 pi mode) | +| Interface smoothing thickness | 0.005 m | + +The VOF fraction is initialized with a smoothed sinusoidal interface. +Velocity is zero everywhere; the instability is driven purely by gravity. + +Reference +--------- + +Lord Rayleigh, "Investigation of the character of the equilibrium of an +incompressible heavy fluid of variable density", Proc. London Math. Soc., +14:170-177, 1883. + +G. I. Taylor, "The instability of liquid surfaces when accelerated in a +direction perpendicular to their planes", Proc. R. Soc. Lond. A, +201(1065):192-196, 1950. diff --git a/18_Rayleigh_Taylor/smgr.xml b/18_Rayleigh_Taylor/smgr.xml new file mode 100644 index 0000000..c5665b7 --- /dev/null +++ b/18_Rayleigh_Taylor/smgr.xml @@ -0,0 +1,7 @@ + + + + + + +