Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
# Build and test the solver using Docker containers
# Build the solver and run a short smoke test of the tutorial
name: Build and test

on:
workflow_dispatch:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
build-and-test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
container-image:
- name: "OpenFOAM-v2312"
image: "opencfd/openfoam-dev:2312"
source: "/usr/lib/openfoam/openfoam2312/etc/bashrc"
buildflags: "-j"
version: ["2312", "2512"]

container:
image: ${{ matrix.container-image.image }}
image: opencfd/openfoam-dev:${{ matrix.version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: make
shell: bash -l {0}
# OpenFOAM's bashrc is not safe under "bash -e": source it first
- name: Build
shell: bash {0}
run: |
source ${{ matrix.container-image.source }}
(cd src && wmake)
source /usr/lib/openfoam/openfoam${{ matrix.version }}/etc/bashrc
set -eo pipefail
cd src && wmake 2>&1 | tee log.wmake
test -x "$FOAM_USER_APPBIN/interTrackFoam"

- name: Smoke test (bubbleColumn, coarse mesh, 20 steps)
shell: bash {0}
run: |
source /usr/lib/openfoam/openfoam${{ matrix.version }}/etc/bashrc
set -eo pipefail
cp -r Tutorial/bubbleColumn "$RUNNER_TEMP/case" && cd "$RUNNER_TEMP/case"
sed -i 's/(160 320 1)/(40 80 1)/' system/blockMeshDict
foamDictionary -entry levelSet/cellSize -remove constant/transportProperties
foamDictionary -entry endTime -set 0.0078125 system/controlDict
foamDictionary -entry writeInterval -set 0.0078125 system/controlDict
./Allrun
grep -q '^End' log.interTrackFoam
test -s postProcessing/bubble/0/volFieldValue.dat
tail -n 2 postProcessing/bubble/0/volFieldValue.dat
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,12 @@ PlyParser_FoamFileParser_parsetab.py
/.tags

# end-of-file

# tutorial run output (0.orig holds the initial fields)
Tutorial/*/0/
Tutorial/*/0.[0-9]*/
Tutorial/*/[1-9]*/
Tutorial/*/constant/polyMesh/
Tutorial/*/postProcessing/
Tutorial/*/processor*/
Tutorial/*/log.*
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

173 changes: 116 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,122 @@
# Level-Set and VOF Hybrid Method in OpenFOAM

![OpenFOAM Version](https://img.shields.io/badge/OpenFOAM-V2312-blue)

## Overview
This repository contains the implementation of a **hybrid Level-Set and Volume of Fluid (VOF) method** for interface tracking in OpenFOAM. The hybrid approach combines the high interface precision of the Level-Set method with the mass conservation benefits of the VOF method, enabling robust and accurate multiphase flow simulations.

The solver is designed for applications such as:
- Free-surface flows
- Droplet dynamics
- Multiphase interactions
- Interface capturing in complex geometries

![grab-landing-page](Tutorial/bubbleColumn/result/gifLSVOF.gif)

## Features
- **Hybrid Level-Set and VOF Approach**: Improved interface tracking by leveraging both methods.
- **Mass Conservation**: Retains the advantages of VOF for global mass conservation.
- **Sharp Interface Representation**: Enhanced by the Level-Set method's ability to track fine interface details.
- **Robust Solver**: Built on the OpenFOAM framework for extensibility and flexibility.
- **Customization Options**: Adjustable parameters for interface smoothing, reinitialization, and flux correction.

## Installation
**Clone the Repository**:
```bash
git clone https://github.com/cloner0110/LevelSet-VOF.git
cd LevelSet-VOF/src && wmake
```


## Prerequisites
- **OpenFOAM** (v2312)

## Methodology
This implementation integrates:
1. **Level-Set Method**: Solves for a signed distance function to track interfaces.
2. **VOF Method**: Utilizes a volume fraction field for mass conservation.
3. **Hybrid Correction**:
- Reinitialization of the Level-Set field.
- Flux corrections to ensure interface consistency.


## Contact
For questions, feedback, or collaboration inquiries, please reach out:
- **Email**: [amirhossein.taran@ucdconnect.ie](mailto:amirhossein.taran@ucdconnect.ie)
- **GitHub Issues**: [Report an Issue](https://github.com/cloner0110/LevelSet-VOF/issues)


# Coupled Level-Set / VOF Solver for OpenFOAM

![OpenFOAM](https://img.shields.io/badge/OpenFOAM-v2312--v2606-blue)
![License](https://img.shields.io/badge/license-GPL--3.0-green)

`interTrackFoam` simulates two incompressible, immiscible fluids. The volume
fraction is transported with VOF/MULES, which conserves mass. At every outer
corrector, a signed-distance level set is rebuilt from that volume fraction.
The level set then supplies the interface curvature and the smooth density
and viscosity that the momentum equation uses.

![rising bubble](Tutorial/bubbleColumn/result/gifLSVOF.gif)

## How it works

All of the level-set work lives in one class, `levelSetCoupledMixture`
(`src/levelSetCoupledMixture`). It extends OpenFOAM's
`immiscibleIncompressibleTwoPhaseMixture`, so the rest of the solver
(MULES, turbulence, `fvOptions`, dynamic meshes) is unchanged. With `h` the
reference cell size, every rebuild does the following:

| Step | Operation |
|---|---|
| Seed | `d0 = (2 alpha1 - 1) * seedCoeff * h` |
| Redistance | `d <- d + dTau * sgn(d0) * (1 - \|grad d\|)`, `dTau = pseudoTimeCoeff * h`, `nRedistanceIter` times |
| Heaviside | `H = (1 + x + sin(pi x)/pi) / 2`, `x = clamp(d/eps, -1, 1)`, `eps = widthCoeff * h` |
| Curvature | `kappa = -div(n_f)`, `n_f = (grad d)_f / \|(grad d)_f\|` |
| Surface tension | `f_f = sigma * kappa_f * snGrad(H)` |
| Properties | `rho = H rho1 + (1-H) rho2`, `mu = H mu1 + (1-H) mu2` |

The density and the mass flux `rhoPhi` both come from `H`. The momentum
equation also removes the remaining mass imbalance,
`ddt(rho) + div(rhoPhi)`. Together, these keep `ddt(rho U)` and
`div(rhoPhi U)` consistent with each other. The coupling follows the
simple coupled level-set/VOF approach of Albadawi et al. (2013).

## Settings

Every entry is optional. They all go in a `levelSet` sub-dictionary of
`constant/transportProperties`. The surface tension coefficient is the usual
`sigma` entry.

```
levelSet
{
cellSize 0.00625; // h [m]; default: smallest cell spacing
widthCoeff 1.5; // interface half-width eps / h
seedCoeff 0.75; // |seed distance| / h
pseudoTimeCoeff 0.1; // redistance pseudo-time step / h
nRedistanceIter 15; // default: ceil(widthCoeff/pseudoTimeCoeff)
curvatureFrom levelSet; // levelSet | volumeFraction
propertiesFrom levelSet; // levelSet | volumeFraction
}
```

On graded meshes, set `cellSize` explicitly to the cell size near the
interface. The solver writes three extra fields: `levelSet` (signed distance),
`heaviside` and `levelSetCurvature`.

## Build

```bash
git clone https://github.com/cloner0110/LevelSet-VOF.git
cd LevelSet-VOF/src && wmake
```

Tested with OpenFOAM.com v2306, v2312 (CI), v2512 (CI) and v2606.

## Tutorial: 2-D rising bubble

`Tutorial/bubbleColumn` is test case 2 of Hysing et al. (2009):
ρ1/ρ2 = 1000, μ1/μ2 = 100, σ = 1.96, g = 0.98. The case writes the bubble's
centre of mass and its mean rise velocity at every time step, to
`postProcessing/bubble/0/volFieldValue.dat`.

```bash
cd Tutorial/bubbleColumn && ./Allrun
```

Benchmark results below were run with OpenFOAM v2606 and `cAlpha 1`. The
1/h = 160 run is the tutorial as shipped, on 4 MPI ranks. The 1/h = 80 runs use
`(80 160 1)` cells and `deltaT 7.8125e-4`. The reference is TP2D from Hysing
et al. (2009), Table XIII.

| Run | V<sub>max,1</sub> (t) | V<sub>max,2</sub> (t) | y<sub>c</sub>(t = 3) |
|---|---|---|---|
| TP2D, 1/h = 80 | 0.2638 (0.725) | 0.2597 (1.969) | 1.1370 |
| TP2D, 1/h = 160 | 0.2570 (0.743) | 0.2522 (2.023) | 1.1377 |
| TP2D, 1/h = 640 | 0.2524 (0.733) | 0.2434 (2.071) | 1.1380 |
| this solver, 1/h = 80, level-set coupling (default) | 0.2450 (0.753) | 0.2274 (1.904) | 1.1085 |
| this solver, 1/h = 80, `curvatureFrom`/`propertiesFrom volumeFraction` | 0.2445 (0.750) | 0.2267 (1.910) | 1.1046 |
| this solver, 1/h = 160, level-set coupling (default) | 0.2415 (0.756) | 0.2299 (1.985) | 1.1099 |

The phase volume is conserved to all printed digits. The first rise-velocity
peak is about 6% below TP2D, and refining from 1/h = 80 to 160 does not close
that gap.

## References

- Albadawi, A., Donoghue, D.B., Robinson, A.J., Murray, D.B., Delauré, Y.M.C.
(2013). Influence of surface tension implementation in Volume of Fluid and
coupled Volume of Fluid with Level Set methods for bubble growth and
detachment. *Int. J. Multiphase Flow* 53:11–28.
- Hysing, S., Turek, S., Kuzmin, D., Parolini, N., Burman, E., Ganesan, S.,
Tobiska, L. (2009). Quantitative benchmark computations of two-dimensional
bubble dynamics. *Int. J. Numer. Meth. Fluids* 60:1259–1288.

## License
This project is licensed under the [MIT License](LICENSE). You are free to use, modify, and distribute the code with proper attribution.









This solver is derived from OpenFOAM's `interFoam` and links against
OpenFOAM libraries. It is therefore distributed under the
[GNU General Public License v3](LICENSE), like OpenFOAM itself. Files that
derive from OpenFOAM keep the original OpenFOAM Foundation and OpenCFD
copyright lines.

OpenFOAM® is a registered trade mark of OpenCFD Ltd. This project is not
approved or endorsed by OpenCFD Ltd.

## Contact

- **Email**: [amirhossein.taran@ucdconnect.ie](mailto:amirhossein.taran@ucdconnect.ie)
- **Issues**: [GitHub Issues](https://github.com/cloner0110/LevelSet-VOF/issues)
4 changes: 2 additions & 2 deletions Tutorial/bubbleColumn/0.orig/U
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
Expand Down
4 changes: 2 additions & 2 deletions Tutorial/bubbleColumn/0.orig/alpha.water
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
Expand Down
44 changes: 0 additions & 44 deletions Tutorial/bubbleColumn/0.orig/alpha.water.org

This file was deleted.

4 changes: 2 additions & 2 deletions Tutorial/bubbleColumn/0.orig/p_rgh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
Expand Down
44 changes: 0 additions & 44 deletions Tutorial/bubbleColumn/0.orig/psi

This file was deleted.

Loading
Loading