-
Notifications
You must be signed in to change notification settings - Fork 1
/
burstingBubbles_elastic_coated.c
156 lines (129 loc) · 4.26 KB
/
burstingBubbles_elastic_coated.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/** Title: Bursting bubble initial condition
# Author: Vatsal Sanjay
# Physics of Fluids
# Last Updated: Jul 21 2024
*/
// 1 is coating, 2 is bulk and 3 is air
#include "axi.h"
#include "navier-stokes/centered.h"
#define FILTERED
#include "three-phase-elastic.h"
#include "log-conform-elastic.h"
#include "tension.h"
#include "distance.h"
#define MINlevel 3 // maximum level
#define tsnap (1e-2)
// Error tolerances
#define fErr (1e-3) // error tolerance in VOF
#define KErr (1e-4) // error tolerance in KAPPA
#define VelErr (1e-2) // error tolerances in velocity
// boundary conditions
double Ohbulk, muR_cb, muR_ab, rho_cb, rho_ab, Ec, tmax, Ldomain;
int MAXlevel;
int main(int argc, char const *argv[]) {
// bulk is water for case III
Ohbulk = 0.003; // this is for case III
muR_cb = 3.3; // this is only the solvent viscosity coated to bulk viscosity ratio
rho_cb = 0.781;
muR_ab = 1e-2;
rho_ab = 1e-3;
Ec = 5e-1;
tmax = 1e0;
Ldomain = 8e0;
MAXlevel = 11;
L0=Ldomain;
X0=-2e0; Y0=0.;
init_grid (1 << (4));
char comm[80];
sprintf (comm, "mkdir -p intermediate");
system(comm);
rho1 = rho_cb; mu1 = muR_cb*Ohbulk; G1 = Ec;
rho2 = 1e0; mu2 = Ohbulk; G2 = 0.;
rho3 = rho_ab; mu3 = muR_ab*Ohbulk; G3 = 0.;
f1.sigma = 27.06/72; // surface tension coating-air!!!
f2.sigma = 32.86/72; // oil and air
fprintf(ferr, "Level %d tmax %g. Oh %3.2e, muR_cb %3.2e, rho_cb %3.2e, Ec %3.2e\n", MAXlevel, tmax, Ohbulk, muR_cb, rho_cb, Ec);
run();
}
event init(t = 0){
if(!restore (file = "dump")){
char filename1[60], filename2[60];
/**
Initialization for f1 and f2
*/
// sprintf(filename1, "initialconditions/CaseIII_VeryThinLayer_PIB_Hexa2wt/f1.dat");
// sprintf(filename2, "initialconditions/CaseIII_VeryThinLayer_PIB_Hexa2wt/f2.dat");
sprintf(filename1, "initialconditions/CaseIV_thickLayer_PIB_Hexa2wt/f1.dat");
sprintf(filename2, "initialconditions/CaseIV_thickLayer_PIB_Hexa2wt/f2.dat");
FILE * fp1 = fopen(filename1,"rb");
if (fp1 == NULL){
fprintf(ferr, "There is no file named %s\n", filename1);
return 1;
}
FILE * fp2 = fopen(filename2,"rb");
if (fp2 == NULL){
fprintf(ferr, "There is no file named %s\n", filename2);
return 1;
}
coord* InitialShape1;
coord* InitialShape2;
InitialShape1 = input_xy(fp1);
fclose (fp1);
InitialShape2 = input_xy(fp2);
fclose (fp2);
scalar d1[], d2[];
distance (d1, InitialShape1);
distance (d2, InitialShape2);
while (adapt_wavelet ((scalar *){f1, f2, d1, d2}, (double[]){1e-8, 1e-8, 1e-8, 1e-8}, MAXlevel).nf);
/**
The distance function is defined at the center of each cell, we have
to calculate the value of this function at each vertex. */
vertex scalar phi1[], phi2[];
foreach_vertex(){
phi1[] = -(d1[] + d1[-1] + d1[0,-1] + d1[-1,-1])/4.;
phi2[] = -(d2[] + d2[-1] + d2[0,-1] + d2[-1,-1])/4.;
}
/**
We can now initialize the volume fractions in the domain. */
fractions (phi1, f1);
fractions (phi2, f2);
}
// dump (file = "dump");
// return 1;
}
scalar KAPPA1[], KAPPA2[];
event adapt(i++) {
curvature(f1, KAPPA1);
curvature(f2, KAPPA2);
adapt_wavelet ((scalar *){f1, f2, u.x, u.y, KAPPA1, KAPPA2},
(double[]){fErr, fErr, VelErr, VelErr, KErr, KErr},
MAXlevel, MINlevel);
}
// Outputs
event writingFiles (t = 0; t += tsnap; t <= tmax + tsnap) {
dump (file = "dump");
char nameOut[80];
sprintf (nameOut, "intermediate/snapshot-%5.4f", t);
dump (file = nameOut);
}
event logWriting (i++) {
double ke = 0.;
foreach (reduction(+:ke)){
ke += sq(Delta)*(sq(u.x[]) + sq(u.y[]))*rho(f1[],f2[]);
}
static FILE * fp;
if (i == 0) {
fprintf (ferr, "i dt t ke\n");
fp = fopen ("log", "w");
fprintf(fp, "Level %d tmax %g. Oh %3.2e, muR_cb %3.2e, rho_cb %3.2e, Ec %3.2e\n", MAXlevel, tmax, Ohbulk, muR_cb, rho_cb, Ec);
fprintf (fp, "i dt t ke\n");
fprintf (fp, "%d %g %g %g\n", i, dt, t, ke);
fclose(fp);
} else {
fp = fopen ("log", "a");
fprintf (fp, "%d %g %g %g\n", i, dt, t, ke);
fclose(fp);
}
fprintf (ferr, "%d %g %g %g\n", i, dt, t, ke);
}