sandbox/MCVacher/slosh_reg_stable.c
Stable jet under a free-surface
soon
#include "grid/multigrid.h"
#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "navier-stokes/conserving.h"
#include "tracer.h"
#include "tag.h"
double h;
double U0;
double R_d;A passive tracer is injected with the jet to follow lagrangian paths.
scalar s[];
scalar * tracers = {s};
FILE * fpmax; //
int main() {
R_d=0.005;
L0=0.4;
rho2 = 1.3;
rho1=1000;
mu1 = 0.1;
mu2 = 0.01*mu1;
U0=0.4;
h=0.1;
TOLERANCE = 1e-3 [*];
u.n[bottom] = dirichlet (f[]*U0*(x > -R_d && x <R_d));
u.t[bottom] = dirichlet(0.);
u.n[top] = u.n[] > 0. ? neumann(0.) : dirichlet(0.);
p[top] = dirichlet(0.);
s[bottom] = dirichlet (f[]*U0*(x > -R_d && x <R_d));
u.n[left] = y < R_d ? dirichlet(-U0) : dirichlet(0.);
u.n[right] = y < R_d ? dirichlet(U0) : dirichlet(0.);
u.t[left] = y < R_d ? neumann(0.) : dirichlet(0.);
u.t[right] = y < R_d ? neumann(0.) : dirichlet(0.);
N=128;
origin (-L0/2, 0);
init_grid(N);
fpmax = fopen("log.dat", "w");
run();
}We initiate gravity, which is opposing to the inertia of the jet.
At each iteration, we calculate residuals to see if the solution has converged. They are saved in “log.dat”.
double sum_u = 0.;
double sum_u_t = 0.;
double res_u = 0.;
double sum_p = 0.;
double sum_p_t = 0.;
double res_p = 0.;
event logfile (i++) {
sum_u_t=0.;
sum_p_t=0.;
foreach_face(){
sum_u_t += sqrt(sq(u.x[]) + sq(u.y[]));
}
foreach(){
sum_p_t += p[];
}
res_u = fabs(sum_u_t - sum_u);
res_p = fabs(sum_p_t - sum_p);
sum_u=sum_u_t;
sum_p=sum_p_t;
fprintf (stderr, "%d %g %g %g\n", i, t, res_u,res_p);
fprintf (fpmax, "%d %g %g %g\n", i, t, res_u,res_p);
}We kill eventual numerical bubbles (not real bubbles because there is no surface tension here.
event remove_droplets (i++) {
remove_droplets (f, threshold=0.05, bubbles=true);
}
event profile (t = end) {
printf ("-----END-----\n");
}
int isave1 = 1;
event res_save (t += 1; t <= 100) {
char name[80];
sprintf (name, "interface-%d.txt", isave1);
FILE * fpfacet = fopen(name, "w");
output_facets (f, fpfacet);
fclose(fpfacet);
isave1++;
}To visualize both the surface and the jet, we can follow lagrangian trajectories using a passive tracer. We generate videos:
event ppm_output (t = 0; t += 0.5; t <= 100) {
char name[80];
sprintf (name, "f.mp4");
output_ppm (f, file = name, n = 512, min = 0, max = 1, linear = true);
char name1[80];
sprintf (name1, "uY.mp4");
output_ppm (u.y, file = name1, n = 512, min = -U0, max = +U0, linear = true);
// optionally tracer
char name2[80];
sprintf (name2, "s.mp4");
output_ppm (s, file = name2, n = 512, min = 0., max = U0, linear = true);
}Free-surface
Passive tracer
Vertical velocity
