Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
two-phase-levelset.h
Go to the documentation of this file.
1/** @file two-phase-levelset.h
2 */
3/**
4# Two-phase interfacial flows with levelset
5
6This file helps setup simulations for flows of two fluids separated by
7an interface (i.e. immiscible fluids). It is typically used in
8combination with a [Navier--Stokes solver](navier-stokes/centered.h).
9
10The interface between the fluids is tracked with a levelset
11method. The signed distance to the interface is tracked by `d`. The
12volume fraction field `f` is computed from the signed distance.
13
14Note that the [coupled VOF and levelset solver](two-phase-clsvof.h)
15should be prefered as it ensures much better mass conservation.
16
17This solver can be combined with the [integral formulation of surface
18tension](integral.h).
19
20The volume fraction in fluid 1 is \f$f=1\f$ and \f$f=0\f$ in fluid
212. The densities and dynamic viscosities for fluid 1 and 2 are *rho1*,
22*mu1*, *rho2*, *mu2*, respectively. */
23
24#include "tracer.h"
25
26scalar d[], f[], * tracers = {d};
27
28#include "two-phase-generic.h"
29
31{
32 scalar phi[];
33 for (int _i = 0; _i < _N; _i++) /* foreach_vertex */
34 phi[] = (d[] + d[-1] + d[0,-1] + d[-1,-1])/4.;
35 fractions (phi, f);
36}
37
38/**
39The initial volume fraction is computed from the initial distance
40field, which must be initialised by the user. */
41
42/** @brief Event: init (i = 0) */
43void event_init (void)
44{
46}
47
48/**
49The distance function is reinitialised at each timestep. */
50
51#include "redistance.h"
52
53/** @brief Event: properties (i++) */
54void event_properties (void)
55{
56 redistance (d, imax = 3);
58}
59
60/**
61## See also
62
63* [Two-phase interfacial flows with VOF](two-phase.h)
64* [Two-phase interfacial flows with coupled levelset and VOF](two-phase-clsvof.h)
65*/
int x
Definition common.h:76
scalar phi[]
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
Definition implicit.h:34
trace void fractions(scalar Phi, scalar c, vector s={0}, double val=0.)
Definition fractions.h:123
trace int redistance(scalar phi, int imax=1, double cfl=0.5, int order=3, double eps=1e-6, double band=HUGE, scalar resf={-1}, const double phixxmin=1./HUGE)
Definition redistance.h:224
def _i
Definition stencils.h:405
void event_init(void)
The initial volume fraction is computed from the initial distance field, which must be initialised by...
scalar f[]
scalar d[]
void event_properties(void)
The distance function is reinitialised at each timestep.
void levelset_to_vof(scalar d, scalar f)
scalar * tracers
Here we set the gradient functions for each tracer (as defined in the user-provided tracers list).