Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
two-phase-generic.h
Go to the documentation of this file.
1/** @file two-phase-generic.h
2 */
3double rho1 = 1., mu1 = 0., rho2 = 1., mu2 = 0.;
4
5/**
6Auxilliary fields are necessary to define the (variable) specific
7volume \f$\alpha=1/\rho\f$ as well as the cell-centered density. */
8
11
12/** @brief Event: defaults (i = 0) */
13void event_defaults (void)
14{
15 alpha = alphav;
16 rho = rhov;
17
18 /**
19 If the viscosity is non-zero, we need to allocate the face-centered
20 viscosity field. */
21
22 if (mu1 || mu2) {
23 mu = {0} /* new vector */;
24 reset ((scalar *){mu}, 0);
25 }
26
27 /**
28 We add the interface to the default display. */
29
30 display ("draw_vof (c = 'f');");
31}
32
33/**
34The density and viscosity are defined using arithmetic averages by
35default. The user can overload these definitions to use other types of
36averages (i.e. harmonic). */
37
38#ifndef rho
39# define rho(f) (clamp(f,0.,1.)*(rho1 - rho2) + rho2)
40#endif
41#ifndef mu
42# define mu(f) (clamp(f,0.,1.)*(mu1 - mu2) + mu2)
43#endif
44
45/**
46We have the option of using some "smearing" of the density/viscosity
47jump. */
48
49#if FILTERED
50scalar sf[];
51#else
52# define sf f
53#endif
54
55/** @brief Event: tracer_advection (i++) */
57{
58
59 /**
60 When using smearing of the density jump, we initialise *sf* with the
61 vertex-average of *f*. */
62
63#ifndef sf
64#if dimension <= 2
65 for (int _i = 0; _i < _N; _i++) /* foreach */
66 sf[] = (4.*f[] +
67 2.*(f[0,1] + f[0,-1] + f[1,0] + f[-1,0]) +
68 f[-1,-1] + f[1,-1] + f[1,1] + f[-1,1])/16.;
69#else // dimension == 3
70 for (int _i = 0; _i < _N; _i++) /* foreach */
71 sf[] = (8.*f[] +
72 4.*(f[-1] + f[1] + f[0,1] + f[0,-1] + f[0,0,1] + f[0,0,-1]) +
73 2.*(f[-1,1] + f[-1,0,1] + f[-1,0,-1] + f[-1,-1] +
74 f[0,1,1] + f[0,1,-1] + f[0,-1,1] + f[0,-1,-1] +
75 f[1,1] + f[1,0,1] + f[1,-1] + f[1,0,-1]) +
76 f[1,-1,1] + f[-1,1,1] + f[-1,1,-1] + f[1,1,1] +
77 f[1,1,-1] + f[-1,-1,-1] + f[1,-1,-1] + f[-1,-1,1])/64.;
78#endif
79#endif // !sf
80
81#if TREE
83#endif
84}
85
86#include "fractions.h"
87
88/** @brief Event: properties (i++) */
89void event_properties (void)
90{
91 for (int _i = 0; _i < _N; _i++) /* foreach_face */ {
92 double ff = (sf[] + sf[-1])/2.;
93 alphav.x[] = fm.x[]/rho(ff);
94 if (mu1 || mu2) {
95 vector muv = mu;
96 muv.x[] = fm.x[]*mu(ff);
97 }
98 }
99
100 for (int _i = 0; _i < _N; _i++) /* foreach */
101 rhov[] = cm[]*rho(sf[]);
102
103#if TREE
105#endif
106}
const vector alpha
Definition all-mach.h:47
int x
Definition common.h:76
const scalar cm[]
Definition common.h:397
void display(const char *commands, bool overwrite=false)
Definition common.h:527
const vector fm[]
Definition common.h:396
scalar f[]
The primary fields are:
Definition two-phase.h:56
void fraction_refine(Point point, scalar c)
Definition fractions.h:42
#define reset(...)
Definition grid.h:1388
vector muv[]
Definition momentum.h:22
static void refine_bilinear(Point point, scalar s)
void set_prolongation(scalar s, void(*prolongation)(Point, scalar))
def _i
Definition stencils.h:405
scalar x
Definition common.h:47
double rho2
#define rho(f)
The density and viscosity are defined using arithmetic averages by default.
#define mu(f)
#define sf
We have the option of using some "smearing" of the density/viscosity jump.
double mu1
void event_defaults(void)
Event: defaults (i = 0)
double rho1
double mu2
void event_properties(void)
Event: properties (i++)
void event_tracer_advection(void)
Event: tracer_advection (i++)
scalar rhov[]
vector alphav[]
Auxilliary fields are necessary to define the (variable) specific volume as well as the cell-centere...