src/examples/karman.c
Bénard–von Kármán Vortex Street for flow around a cylinder at Re=160
An example of 2D viscous flow around a simple solid boundary. Fluid is injected to the left of a channel bounded by solid walls with a slip boundary condition. A passive tracer is injected in the bottom half of the inlet.
Animation of the vorticity field.
Animation of the tracer field.
We use the centered Navier-Stokes solver, with embedded boundaries and advect the passive tracer f.
#include "embed.h"
#include "navier-stokes/centered.h"
// #include "navier-stokes/perfs.h"
#include "tracer.h"
scalar f[];
scalar * tracers = {f};
double Reynolds = 160.;
int maxlevel = 9;
face vector muv[];
The domain is eight units long, centered vertically.
int main()
{
= 8. [1];
L0 (-0.5, -L0/2.);
origin = 512;
N = muv; mu
When using bview we can interactively control the Reynolds number and maximum level of refinement.
(Reynolds, 10, 1000);
display_control (maxlevel, 6, 12);
display_control
run();
}
We set a constant viscosity based on the Reynolds number, the cylinder diameter D and the inflow velocity U0.
double D = 0.125, U0 = 1.;
event properties (i++)
{
foreach_face()
.x[] = fm.x[]*D*U0/Reynolds;
muv}
The fluid is injected on the left boundary with velocity U0. The tracer is injected in the lower-half of the left boundary. An outflow condition is used on the right boundary.
.n[left] = dirichlet(U0);
u[left] = neumann(0.);
p[left] = neumann(0.);
pf[left] = dirichlet(y < 0);
f
.n[right] = neumann(0.);
u[right] = dirichlet(0.);
p[right] = dirichlet(0.); pf
The top and bottom walls are free-slip and the cylinder is no-slip.
.n[embed] = fabs(y) > 0.25 ? neumann(0.) : dirichlet(0.);
u.t[embed] = fabs(y) > 0.25 ? neumann(0.) : dirichlet(0.);
u
event init (t = 0)
{
The domain is the intersection of a channel of width unity and a circle of diameter 0.125.
solid (cs, fs, intersection (intersection (0.5 - y, 0.5 + y),
(sq(x) + sq(y)) - D/2.)); sqrt
We set the initial velocity field.
foreach()
.x[] = cs[] ? U0 : 0.;
u}
We check the number of iterations of the Poisson and viscous problems.
We produce animations of the vorticity and tracer fields…
event movies (i += 4; t <= 15.)
{
scalar omega[], m[];
vorticity (u, omega);
foreach()
[] = cs[] - 0.5;
moutput_ppm (omega, file = "vort.mp4", box = {{-0.5,-0.5},{7.5,0.5}},
= -10, max = 10, linear = true, mask = m);
min output_ppm (f, file = "f.mp4", box = {{-0.5,-0.5},{7.5,0.5}},
= false, min = 0, max = 1, mask = m);
linear }
We adapt according to the error on the embedded geometry, velocity and tracer fields.
event adapt (i++) {
({cs,u,f}, (double[]){1e-2,3e-2,3e-2,3e-2}, maxlevel, 4);
adapt_wavelet }