Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
two-phase-clsvof.h
Go to the documentation of this file.
1/** @file two-phase-clsvof.h
2 */
3/**
4# Two-phase interfacial flows with coupled VOF and 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 Volume-Of-Fluid
11method. The signed distance field `d` is advected as a tracer and is
12relaxed toward the VOF-defined interface.
13
14This coupling ensures a mass conservation at least as good as that of
15the [pure VOF solver](two-phase.h).
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 "vof.h"
25#include "tracer.h"
26
27scalar d[], f[], * interfaces = {f}, * tracers = {d};
28
29#include "two-phase-generic.h"
30
31/**
32The initial volume fraction is computed from the initial distance
33field, which must be initialised by the user. */
34
35/** @brief Event: init (i = 0) */
36void event_init (void)
37{
38 scalar phi[];
39 for (int _i = 0; _i < _N; _i++) /* foreach_vertex */
40 phi[] = (d[] + d[-1] + d[0,-1] + d[-1,-1])/4.;
41 fractions (phi, f);
42}
43
44/**
45The distance function is reinitialised at each timestep. */
46
47#include "redistance.h"
48
49/** @brief Event: properties (i++) */
50void event_properties (void)
51{
52
53 /**
54 In interfacial cells, the signed distance is obtained directly from
55 the VOF reconstruction of the interface. This distance is combined
56 with the existing distance using a small weight, thus ensuring
57 exponential time relaxation of the signed distance toward its VOF
58 value. */
59
60 double weight = 0.1;
61 for (int _i = 0; _i < _N; _i++) /* foreach */
62 if (f[] > 1e-6 && f[] < 1. - 1e-6) {
64 normalize (&n);
65 double alpha = plane_alpha (f[], n);
66 d[] = (1. - weight)*d[] + weight*Delta*alpha;
67 }
68
69 /**
70 The redistancing operation itself is quite expensive. We do not use
71 the second-order subcell correction because it tends to introduce
72 noise on the distance field and does not seem to improve results. */
73
74 redistance (d, imax = 3, phixxmin = HUGE);
75}
76
77/**
78## See also
79
80* [Two-phase interfacial flows with VOF](two-phase.h)
81* [Two-phase interfacial flows with levelset](two-phase-levelset.h)
82*/
const vector alpha
Definition all-mach.h:47
int x
Definition common.h:76
void normalize(coord *n)
Definition common.h:98
#define HUGE
Definition common.h:6
Point point
Definition conserving.h:86
static coord interface_normal(Point point, scalar c)
Definition contact.h:29
else return n
Definition curvature.h:101
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
#define plane_alpha
Definition geometry.h:133
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
Definition common.h:78
void event_init(void)
The initial volume fraction is computed from the initial distance field, which must be initialised by...
scalar f[]
scalar * interfaces
The height functions are stored in the vector field associated with each VOF tracer.
scalar d[]
void event_properties(void)
The distance function is reinitialised at each timestep.
scalar * tracers
Here we set the gradient functions for each tracer (as defined in the user-provided tracers list).