Skip to content

Rewrite level-set coupling; fix rhoPhi, curvature and patch bugs - #2

Merged
cloner0110 merged 3 commits into
mainfrom
lsvof-rewrite
Oct 16, 2026
Merged

cloner0110 merged 3 commits into
mainfrom
lsvof-rewrite

Conversation

@cloner0110

@cloner0110 cloner0110 commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Rewrites the level-set side of the solver as one class and fixes the
coupling bugs found along the way. Closes #1.

Structure

  • New levelSetCoupledMixture class (src/levelSetCoupledMixture). It
    derives from immiscibleIncompressibleTwoPhaseMixture and owns the signed
    distance, Heaviside and curvature fields, the redistance step, and the
    property blending. It replaces mappingPsi.H, solveLsFunction.H,
    calcNewCurvature.H and the const_cast on mixture.nu().
  • constant/levelSetProperties is gone. The settings move to an optional
    levelSet { ... } sub-dictionary of transportProperties, and every entry
    has a default. nu and sigma are no longer duplicated.
  • The cell size is computed from the mesh unless cellSize is given.
  • The psi field is no longer read, so 0/psi is not needed. Written fields
    are now levelSet [m], heaviside and levelSetCurvature.
  • correctPhi.H is renamed to correctMeshPhi.H. On macOS's
    case-insensitive filesystem, a local correctPhi.H shadows OpenFOAM's
    CorrectPhi.H.
  • The level set is rebuilt once per outer corrector. Before, it was also
    rebuilt at the start of every time step, which repeated the same work.

Fixes

  1. Issue rhoPhi update #1, rhoPhi/rho mismatch. rho came from the Heaviside, but
    rhoPhi was still the VOF mass flux. rhoPhi is now built from the same
    Heaviside face density, and UEqn removes the residual
    ddt(rho) + div(rhoPhi).
  2. The level-set curvature was never used. UEqn and pEqn called
    mixture.surfaceTensionForce(), which uses the VOF curvature, and the C
    field was only written out. They now use
    sigma*kappa_LS*snGrad(H) (curvatureFrom levelSet, the default).
  3. The viscosity blend was wrong. It used nu = H nu1 + (1-H) nu2 with
    rho = H rho1 + (1-H) rho2, so rho*nu was not the blended mu. It now
    blends mu and divides by the blended rho.
  4. Boundary values of H and delta were never set. The cell loops left
    them at 0 on every patch, so walls and processor patches saw rho = rho2.
    That made snGrad(rho) and p wrong at walls and broke parallel runs.
    The Heaviside is now evaluated on the whole field.
  5. psi0/mag(psi0) gave NaN in any cell with alpha = 0.5 exactly. It now
    gives a sign of 0 there.
  6. The licence. The README said MIT, but the code derives from interFoam
    (GPL-3.0). This adds LICENSE (GPL-3.0) and keeps the OpenFOAM copyright
    lines.

Tutorial and CI

  • The tutorial uses the new settings, adds Hysing benchmark function objects
    (centre of mass and rise velocity, every step), and drops the stale
    psi, alpha.water.org and levelSetProperties.
  • CI builds on v2312 and v2512 and runs a 20-step smoke test of the tutorial.

Verification

Hysing et al. (2009) test case 2 on a 1/h = 80 mesh, run with v2606. The
reference is TP2D (Table XIII).

Run Vmax1 (t) Vmax2 (t) yc(t=3) water fraction t=0 -> 3
TP2D, 1/h = 80 0.2638 (0.725) 0.2597 (1.969) 1.1370
TP2D, 1/h = 640 0.2524 (0.733) 0.2434 (2.071) 1.1380
main (before) 0.3620 (1.299) grows to 1.63 1.4959 0.8984 -> 0.9603
this PR 0.2450 (0.753) 0.2274 (1.904) 1.1085 0.8984 -> 0.8984
this PR, both options volumeFraction 0.2445 (0.750) 0.2267 (1.910) 1.1046 0.8984 -> 0.8984
  • On main, the bubble does not conserve mass. About 60% of the air
    dissolves (min alpha.water ends at 0.11) and spurious currents reach
    Co = 3.
  • The ~7% first-peak deficit also shows up with pure VOF on the same mesh,
    so it comes from the resolution and schemes, not from the coupling.
  • The tutorial's cAlpha is now 1. With cAlpha 0 the late-time rise is
    low: yc(3) = 1.092.
  • The new mass-imbalance term in UEqn changes yc by less than 0.002.
  • A 4-rank parallel run matches serial: max |delta yc| = 7e-6.
  • The shipped tutorial (1/h = 160, 4 ranks) gives Vmax1 0.2415 (0.756),
    Vmax2 0.2299 (1.985) and yc(3) 1.1099. TP2D at 1/h = 160 gives 0.2570
    (0.743), 0.2522 (2.023) and 1.1377. Mass is conserved. The first peak stays
    about 6% low after refinement, so that is still open.
  • The code builds without warnings on v2306 and v2606. CI covers v2312 and
    v2512.

@cloner0110 cloner0110 mentioned this pull request Oct 16, 2026
@cloner0110
cloner0110 merged commit f32dd2f into main Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rhoPhi update

1 participant