simulationCases/dropImpact_legacy.c
dropImpact_legacy.c
Legacy axisymmetric drop-impact simulation in a single Basilisk file.
Usage (legacy CLI)
./dropImpact_legacy <MAXlevel> <tmax> <We> <Ohd> <Ohs> <Ldomain>Notes
- Uses fixed error tolerances and a hard-coded initial drop location.
- Writes snapshots to
intermediate/and logs tolog.
Author
Vatsal Sanjay ([email protected]) CoMPhy Lab, Durham University Original date: 2022-02-08
// 1 is drop
#include "axi.h"
#include "navier-stokes/centered.h"
#define FILTERED
#include "two-phase.h"
#include "navier-stokes/conserving.h"
#include "tension.h"
// Error tolerances
#define fErr (1e-3) // error tolerance in VOF
#define KErr (1e-6) // error tolerance in KAPPA
#define VelErr (1e-2) // error tolerances in velocity
// air-water
#define Rho21 (1e-3)
// Calculations!
#define Xdist (1.02)
#define R2Drop(x,y) (sq(x - Xdist) + sq(y))
// boundary conditions
u.t[left] = dirichlet(0.0);
f[left] = dirichlet(0.0);
u.n[right] = neumann(0.);
p[right] = dirichlet(0.0);
u.n[top] = neumann(0.);
p[top] = dirichlet(0.0);
int MAXlevel;
double tmax, We, Ohd, Ohs, Bo, Ldomain;
#define MINlevel// maximum level
#define tsnap (0.01)
int main(int argc, char const *argv[]) {
if (argc < 7){
fprintf(ferr, "Lack of command line arguments. Check! Need %d more arguments\n",8-argc);
return 1;
}
MAXlevel = atoi(argv[1]);
tmax = atof(argv[2]);
We = atof(argv[3]); // We is 1 for 0.22 m/s <1250*0.22^2*0.001/0.06>
Ohd = atof(argv[4]); // <\mu/sqrt(1250*0.060*0.001)>
Ohs = atof(argv[5]); //\mu_r * Ohd
Ldomain = atof(argv[6]); // size of domain. must keep Ldomain \gg
fprintf(ferr, "Level %d tmax %g. We %g, Ohd %3.2e, Ohs %3.2e, Bo %g, Lo %g\n", MAXlevel, tmax, We, Ohd, Ohs, Bo, Ldomain);
L0=Ldomain;
X0=0.; Y0=0.;
init_grid (1 << (6));
char comm[4096];
snprintf(comm, sizeof(comm), "mkdir -p intermediate");
system(comm);
rho1 = 1.0; mu1 = Ohd/sqrt(We);
rho2 = Rho21; mu2 = Ohs/sqrt(We);
f.sigma = 1.0/We;
run();
}
event init(t = 0){
if(!restore (file = "restart")){
refine((R2Drop(x,y) < 1.05) && (level < MAXlevel));
fraction (f, 1. - R2Drop(x,y));
foreach () {
u.x[] = -1.0*f[];
u.y[] = 0.0;
}
}
}
event adapt(i++){
scalar KAPPA[];
curvature(f, KAPPA);
adapt_wavelet ((scalar *){f, KAPPA, u.x, u.y},
(double[]){fErr, KErr, VelErr, VelErr},
MAXlevel, MINlevel);
unrefine(x>0.95*Ldomain || y>4e0); // ensure there is no backflow from the outflow walls!
}
// Outputs
// static
event writingFiles (t = 0, t += tsnap; t <= tmax) {
dump (file = "restart");
char nameOut[4096];
snprintf(nameOut, sizeof(nameOut), "intermediate/snapshot-%5.4f", t);
dump (file = nameOut);
}
event logWriting (i++) {
double ke = 0.;
foreach (reduction(+:ke)){
ke += 2*pi*y*(0.5*rho(f[])*(sq(u.x[]) + sq(u.y[])))*sq(Delta);
}
static FILE * fp;
if (i == 0) {
fprintf (ferr, "i dt t ke p\n");
fp = fopen ("log", "w");
fprintf(fp, "Level %d tmax %g. We %g, Ohd %3.2e, Ohs %3.2e\n", MAXlevel, tmax, We, Ohd, Ohs);
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);
}