A numerical framework for simulating three-phase stratified interfacial flows using the Basilisk flow solver.
This code simulates three immiscible fluid layers with the following configuration:
- Fluid 1 (bottom): Water (ocean)
- Fluid 2 (middle): Oil layer that forms a precursor film
- Fluid 3 (top): Air
The key feature is that Fluid 2 (oil) always maintains a minimum thickness of one grid cell (when we call it a precursor film, it is the worst case scenario) between Fluids 1 and 3.
stratified.c
: Main simulation file that sets up the three-phase flow configurationthree-phase-stratified.h
: Header file implementing the three-phase flow solver with Volume-Of-Fluid methodreduced-three-phase-stratified.h
: Implements reduced gravity formulation for the three-phase system
getData-threePhase.c
: Extracts field data from simulation snapshotsgetFacet-threePhase.c
: Extracts interface positionsVideo.py
: Python script for visualization and video generation
The main simulation parameters can be found in stratified.c
:
OhBulk
: Ohnesorge number for bulk fluid (water)mu21
,mu31
: Viscosity ratiosrho21
,rho31
: Density ratiossigma12
,sigma23
: Surface tension coefficientsBo
: Bond numberMAXlevel
: Maximum grid refinement level
The three-phase implementation uses two Volume-Of-Fluid fields:
f1
: Distinguishes between fluids 1+2 (value 1) and fluid 3 (value 0)f2
: Distinguishes between fluid 1 (value 1) and fluids 2+3 (value 0)
The property indices for each fluid are:
- Fluid 1 (water):
f1*f2
- Fluid 2 (oil):
f1*(1-f2)
- Fluid 3 (air):
1-f1
- Compile the main simulation:
- Serial
qcc -O2 -Wall stratified.c -o stratified -lm
./stratified
- Using OpenMP
qcc -O2 -Wall stratified.c -o stratified -lm -fopenmp
export OMP_NUM_THREADS=8
./stratified
Here, 8 is the number of threads to use.
- Using OpenMPI
CC99='mpicc -std=c99' qcc -Wall -O2 -D_MPI=1 -disable-dimensions stratified.c -o stratified -lm
mpirun -np 8 stratified
Here, 8 is the number of MPI processes to use.
Post processing:
python Video.py --CPUs 4
Here, 4 is the number of processors to use.