Fluid Dynamics - Flow Around A Cylinder (Matlab)
Fluid Dynamics - Flow Around A Cylinder (Matlab)
A well known benchmark, test, and validation problem suite for incompressible fluid flows are the
DFG cylinder benchmark problems [2]. Although it is not possible to derive analytical solutions to
these test cases, accurate numerical solutions to benchmark reference quantities have been
established for a number of configurations [3], [4].
The test configuration used in the following places a solid cylinder centered at (0.2, 0.2) with diameter
in a by rectangular channel. The fluid density is taken as 1 and the
viscosity is 0.001. A fully developed parabolic velocity profile is prescribed at the inlet,
, with the maximum velocity . This results in a
mean velocity and a Reynolds number and thus the flow field will
be laminar.
As the fluid is considered incompressible the problem is governed by the Navier-Stokes equations.
That is,
where in this case the time dependent term can be neglected. The benchmark quantities that should
be computed include the pressure difference between the front and rear of the cylinder
, and the coefficients of drag and lift , defined as
This section describes how to set up and solve the Flow Around a Cylinder example with the
FEATool graphical user interface (GUI).
1. Start Octave or Matlab, and if you have not run the installation script (which automatically adds
the FEATool directory paths at startup) then change your working directory to where your
FEATool installation is, for example
cd C:\featool
2. In the command window type
featool
to start the graphical user interface (GUI).
3. Click on the New Model button in the upper horizontal toolbar to clear all data and start
defining a new model.
4. In the opened New Model dialog box, click on the 2D radio button in the Select Space
Dimensions frame, and select Navier-Stokes Equations from the Select Physics drop-down
list. Leave the space dimension and dependent variable names to their default values. Finish
and close the dialog box by clicking on the OK button.
5. To create the outer rectangle, first click on the Create square/rectangle button in the left
hand side Tools toolbar frame.
6. Then left click in the main plot axes window, hold the mouse button, and move the mouse
pointer to show a rectangle with red outlines.
7. Release the mouse button to finalize and create a solid geometry object. The object properties
must now be edited to set the correct size and position of the rectangle. To do this, click on the
rectangle R1 to select it and highlight it in red. Then click on the Inspect/edit selected
9. To create the inner circle, first left click on the Create circle/ellipse button in the left hand
side Tools toolbar frame.
10. Then click and hold the left mouse button anywhere in the main plot axes window, move the
mouse pointer to show red outlines of a circle or ellipse. Release the button to finalize and
create a solid geometry object.
11. The object properties of the E1 must also be changed to make a circle with radius 0.05
centered at (0.2, 0.2). To do this, click on the E1 to select it which also highlights it in red. Then
12. In the opened Edit Geometry Object dialog box change the center coordinates to 0.2 0.2, and
the x and y radius 0.05 in the corresponding edit fields. Finish editing E1 and close the dialog
box by clicking OK.
13. To subtract the circle from the rectangle first select both geometry objects by clicking on them
so both are highlighted in red. Alternatively, if the circle is obscured by the rectangle they can
be selected by holding the Ctrl key while clicking on the labels R1 and E1 in the Selection list
box (or simply press Ctrl+a to select all objects). When the geometry objects are selected,
press the Subtract geometry objects button to generate the final geometry shape.
14. Switch to Grid mode by click on the corresponding mode toolbar button.
0.047
15. Set a target grid size by entering 0.025 in the Grid Size edit field above the grid toolbar
buttons. Then click on the Generate unstructured grid button to call the automatic grid
generation function.
16. Press the mode button in the Mode toolbar to switch from grid mode to physics
and equation/subdomain specification mode.
17. In the Equation Settings dialog box that automatically opens, set the density to 1 and
viscosity to 0.001 in the corresponding edit fields. The other coefficients can be left to their
zero default values. Press OK to finish and close the dialog box.
18. Switch to boundary condition specification mode by clicking on the mode button
19. In the Boundary Settings dialog box, select all boundaries except the right and left ones (here
boundaries 1, 3, and 5-8) in the left hand side Boundaries list box and choose the Wall/no-slip
boundary conditions from the drop-down list.
20. Now select the left inflow boundary (here number 4) in the left hand side Boundaries list box
and choose the Inlet/velocity boundary condition from the drop-down list. To specify a
parabolic velocity profile enter the expression 4*0.3/0.41^2*y*(0.41-y) in the edit field for the
x-velocity coefficient .
21. Select the right outflow boundary (here number 2) in the left hand side Boundaries list box and
choose the Neutral outflow/stress boundary condition from the drop-down list (alternatively
one can prescribe a pressure with the Outflow/pressure condition). Finish by clicking the
OK button.
22. Now that the problem is specified, press the mode button to switch to solve mode.
Then press the button with an equals sign in the Tools toolbar frame to call the solver with
the default solver settings.
23. After the problem has been solved FEATool will automatically switch to postprocessing mode
and display the computed solution. The default postprocessing visualization shows the
magnitude of the velocity field. Since the solution does not look quite smooth and resolved it
might be worthwhile to refine the grid. Press the mode button in the Mode toolbar
to switch back to grid mode again.
Es posible que no se puedan realizar los siguientes pasos por licencia del software
24. Although we could use the uniform grid refinement option, it is usually better to use the
automatic grid generation routine with a smaller grid size for better grid quality and
approximation of curved boundaries. Set a new target grid size by entering 0.015 in the Grid
Size edit field above the grid toolbar buttons. Then click on the Generate unstructured grid
button .
25. Now go back to Solve mode and solve the problem again with the refined grid.
26. Now that the solution looks better we can calculate the drag and lift coefficients. To do this
select Boundary Integration... from the Post menu.
27. In the Boundary Integration dialog box, select boundaries which make up the circle (5-8) in the
left hand side Boundaries list box. Then enter the expression for the drag coefficient 2*
(nx*p+miu_ns*(-2*nx*ux-ny*(uy+vx)))/(1*0.2^2*0.1) in the Integration Expression edit field.
Press the Apply button to show the result in the lower Integration Result frame and in the
FEATool terminal window.
28. The lift coefficient can similarly be computed by evaluating the expression 2*(T_y)/
(1*0.2^2*0.1) where Ty is the total force, y-component expression (which can be selected in
the drop down box), defined by ny*p+miu_ns*(-nx*(vx+uy)-2*ny*vy). The magnitudes of the
computed drag and lift coefficients are here, 5.4392 and 0.0137, which can be compared with
the benchmark reference solutions, that is 5.5795 and 0.010619. The deviation from the
reference values suggest that it might be desirable to recompute a solution with an even finer
grid, possibly refined around the circle. See for example ex_navierstokes3 where a very
adapted benchmark grid is constructed manually.
The process to set up and solve the flow around cylinder test problem on the command line interface
is illustrated in the ex_navierstokes3 script file which can be found in the examples directory.
In addition to the stationary test case described above. An instationary benchmark test case is also
available (ex_navierstokes6). This test case uses the same geometry but instead applies an inflow
condition that varies with time (u_inflow = 6*sin(pi*t/8)*(y*(0.41-y))/0.41^2) so that 0<Re(t)<100 [5].
Computations with FEATool show that the drag and lift coefficients, and pressure difference between
front and rear of the cylinder agrees very well with the reference values [6].
References
[2] Schäfer M, Turek S. Benchmark computations of laminar flow around cylinder. Flow Simulation
with High–Performance Computers II (Notes on Numerical Fluid Mechanics), 52, 547–566, Vieweg,
1996.
[3] Nabh G. On higher order methods for the stationary incompressible Navier-Stokes equations. PhD
Thesis 1998; Universität Heidelberg. Preprint 42/98, 1998.
[4] John V, Matthies G. Higher-order finite element discretizations in a benchmark problem for
incompressible flows. International Journal for Numerical Methods in Fluids 2001; 37(8):885–903,
DOI: 10.1002/fld.195.
[5] John V. Reference values for drag and lift of a two-dimensional time-dependent flow around a
cylinder. International Journal for Numerical Methods in Fluids 2004; 44:777-788.
[6] John V, Rang J. Adaptive time step control for the incompressible Navier–Stokes equations.
Comput. Methods Appl. Mech. Engrg. 199 (2010) 514–524.
Flow over a Backwards Facing Step with the external FeatFlow CFD Solver
This section describes how to set up and solve the Flow over a Backwards Facing Step example with
the FEATool graphical user interface (GUI) and using the FeatFlow external CFD Solver.
1. Start Octave or Matlab, and if you have not run the installation script (which automatically adds
the FEATool directory paths at startup) then change your working directory to where your
FEATool installation is, for example
cd C:\featool
2. In the command window type