Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
iforce.h
Go to the documentation of this file.
1/** @file iforce.h
2 */
3/**
4# Interfacial forces
5
6We assume that the interfacial acceleration can be expressed as
7\f[
8\phi\mathbf{n}\delta_s/\rho
9\f]
10with \f$\mathbf{n}\f$ the interface normal, \f$\delta_s\f$ the interface Dirac
11function, \f$\rho\f$ the density and \f$\phi\f$ a generic scalar field. Using
12a CSF/Peskin-like approximation, this can be expressed as
13\f[
14\phi\nabla f/\rho
15\f]
16with \f$f\f$ the volume fraction field describing the interface.
17
18The interfacial force potential \f$\phi\f$ is associated to each VOF
19tracer. This is done easily by adding the following [field
20attributes](/Basilisk C#field-attributes). */
21
23 scalar phi;
24}
25
26/**
27Interfacial forces are a source term in the right-hand-side of the
28evolution equation for the velocity of the [centered Navier--Stokes
29solver](navier-stokes/centered.h) i.e. it is an acceleration. If
30necessary, we allocate a new vector field to store it. */
31
32/** @brief Event: defaults (i = 0) */
33void event_defaults (void) {
34 if (is_constant(a.x)) {
35 a = {0} /* new vector */;
36 for (int _i = 0; _i < _N; _i++) /* foreach_face */ {
37 a.x[] = 0.;
38 /* dim: a.x[] == Delta/sq(DT */);
39 }
40 }
41}
42
43/**
44The calculation of the acceleration is done by this event, overloaded
45from [its definition](navier-stokes/centered.h#acceleration-term) in
46the centered Navier--Stokes solver. */
47
48/** @brief Event: acceleration (i++) */
50{
51
52 /**
53 We check for all VOF interfaces for which \f$\phi\f$ is allocated. The
54 corresponding volume fraction fields will be stored in *list*. */
55
56 scalar * list = NULL;
57 for (int _f = 0; _f < 1; _f++) /* scalar in interfaces */
58 if (f.phi.i) {
59 list = list_add (list, f);
60
61 /**
62 To avoid undeterminations due to round-off errors, we remove
63 values of the volume fraction larger than one or smaller than
64 zero. */
65
66 for (int _i = 0; _i < _N; _i++) /* foreach */
67 f[] = clamp (f[], 0., 1.);
68 }
69
70 /**
71 On trees we need to make sure that the volume fraction gradient
72 is computed exactly like the pressure gradient. This is necessary to
73 ensure well-balancing of the pressure gradient and interfacial force
74 term. To do so, we apply the same prolongation to the volume
75 fraction field as applied to the pressure field. */
76
77#if TREE
78 for (int _f = 0; _f < 1; _f++) /* scalar in list */
79 set_prolongation (f, p.prolongation);
80#endif
81
82 /**
83 Finally, for each interface for which \f$\phi\f$ is allocated, we
84 compute the interfacial force acceleration
85 \f[
86 \phi\mathbf{n}\delta_s/\rho \approx \alpha\phi\nabla f
87 \f]
88 */
89
90 vector ia = a;
91 for (int _i = 0; _i < _N; _i++) /* foreach_face */
92 for (int _f = 0; _f < 1; _f++) /* scalar in list */
93 if (f[] != f[-1] && fm.x[] > 0.) {
94
95 /**
96 We need to compute the potential *phif* on the face, using its
97 values at the center of the cell. If both potentials are
98 defined, we take the average, otherwise we take a single
99 value. If all fails we set the potential to zero: this should
100 happen only because of very pathological cases e.g. weird
101 boundary conditions for the volume fraction. */
102
103 scalar phi = f.phi;
104 double phif =
105 (phi[] < nodata && phi[-1] < nodata) ?
106 (phi[] + phi[-1])/2. :
107 phi[] < nodata ? phi[] :
108 phi[-1] < nodata ? phi[-1] :
109 0.;
110
111 ia.x[] += alpha.x[]/(fm.x[] + SEPS)*phif*(f[] - f[-1])/Delta;
112 }
113
114 /**
115 On trees, we need to restore the prolongation values for the
116 volume fraction field. */
117
118#if TREE
119 for (int _f = 0; _f < 1; _f++) /* scalar in list */
121#endif
122
123 /**
124 Finally we free the potential fields and the list of volume
125 fractions. */
126
127 for (int _f = 0; _f < 1; _f++) /* scalar in list */ {
128 scalar phi = f.phi;
129 delete ({phi});
130 f.phi.i = 0;
131 }
132 free (list);
133}
134
135/**
136## References
137
138See Section 3, pages 8-9 of:
139
140~~~bib
141@hal{popinet2018, hal-01528255}
142~~~
143*/
const vector alpha
Definition all-mach.h:47
const vector a
Definition all-mach.h:59
free(list1)
define VT _attribute[s.i] v y scalar * list
Definition cartesian.h:276
int x
Definition common.h:76
#define nodata
Definition common.h:7
scalar * list_add(scalar *list, scalar s)
Definition common.h:208
static number clamp(number x, number a, number b)
Definition common.h:15
const vector fm[]
Definition common.h:396
#define SEPS
Definition common.h:402
scalar f[]
The primary fields are:
Definition two-phase.h:56
#define p
Definition tree.h:320
scalar phi[]
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
Definition implicit.h:34
void fraction_refine(Point point, scalar c)
Definition fractions.h:42
void event_acceleration(void)
The calculation of the acceleration is done by this event, overloaded from its definition in the cent...
Definition iforce.h:49
attribute
Definition iforce.h:22
void event_defaults(void)
Interfacial forces are a source term in the right-hand-side of the evolution equation for the velocit...
Definition iforce.h:33
void set_prolongation(scalar s, void(*prolongation)(Point, scalar))
def _i
Definition stencils.h:405
int i
Definition common.h:44
scalar x
Definition common.h:47