Fluid Tutorial
Introduction
In this tutorial we want to simulate the incompressible flow past a circular cylinder. For further details and references we refer the reader to: [Wall99]

Problem definition and geometrical setup (with friendly permission ;-))
Preprocessing
Creating the Geometry with Cubit
We will use Cubit for creating the geometry and the mesh. Within Cubit, open the Journal-Editor (Tools \(\to\) Journal Editor), paste the text below and press play. After successful geometry and mesh creation, export everything to an EXODUS file of your choice via File \(\to\)Export… and set the dimension explicitly to 2D.
1$***********************
2$ preliminaries
3$***********************
4reset
5set geometry engine acis
6$***********************
7$ create geometry
8$***********************
9
10$ define geometric parameters
11$ in cm
12# {fluid_length = 4.0} $ x-direction
13# {fluid_width = 2.0} $ y-direction
14# {cyl_radius = 0.08}
15# {cyl_offset = 1.0}
16$ create domain
17create vertex {-cyl_offset} {fluid_width/2.0} 0
18create vertex {-cyl_offset} {-fluid_width/2.0} 0
19create vertex {fluid_length-cyl_offset} {fluid_width/2.0} 0
20create vertex {fluid_length-cyl_offset} {-fluid_width/2.0} 0
21create vertex 0 0 0
22create vertex {cyl_offset} {fluid_width/2.0} 0
23create vertex {cyl_offset} {-fluid_width/2.0} 0
24create curve vertex 1 vertex 5
25create curve vertex 5 vertex 6
26create curve vertex 6 vertex 1
27create curve vertex 10 vertex 2
28create curve vertex 2 vertex 8
29create curve vertex 12 vertex 7
30create curve vertex 7 vertex 13
31create curve vertex 15 vertex 9
32create curve vertex 18 vertex 3
33create curve vertex 3 vertex 4
34create curve vertex 4 vertex 17
35create surface curve 3 1 2
36create surface curve 1 4 5
37create surface curve 5 6 7
38create surface curve 7 8 2
39create surface curve 8 9 10 11
40create vertex 0 0 0
41create vertex 0 {cyl_radius} 0
42create vertex {cyl_radius} 0 0
43create curve arc center vertex 24 25 26 {cyl_radius} full
44create surface curve 17
45delete vertex 24 25 26
46subtract volume 6 from volume 1 2 3 4
47imprint volume all
48merge volume all
49
50$***********************
51$ create mesh
52$***********************
53
54# {numele_past_x = 37}
55# {numele_past_y = 34}
56# {numele_cyl_x = 30}
57# {numele_inflow = 22}
58# {numele_radial = 50}
59group "radial" add curve 19 20 23 26
60curve 9 scheme equal interval {numele_past_x}
61curve 10 scheme equal interval {numele_past_y}
62curve in group radial scheme equal interval {numele_radial}
63curve 3 6 scheme equal interval {numele_cyl_x}
64curve 4 scheme equal interval {numele_inflow}
65$ apply bias for better mesh
66curve 19 scheme bias factor 0.9 start vertex 1 interval {numele_radial}
67propagate curve bias volume all
68curve 20 scheme bias factor 0.9 start vertex 6 interval {numele_radial}
69propagate curve bias volume all
70curve 23 scheme bias factor 0.9 start vertex 2 interval {numele_radial}
71propagate curve bias volume all
72curve 26 scheme bias factor 0.9 start vertex 7 interval {numele_radial}
73propagate curve bias volume all
74mesh surface all
75
76$***********************
77$ boundary conditions
78$***********************
79reset block
80block 1 surface all
81nodeset 1 curve 4
82nodeset 1 name "inflow"
83nodeset 2 curve 3 9
84nodeset 2 name "top"
85nodeset 3 curve 6 11
86nodeset 3 name "bottom"
87nodeset 4 curve 18 21 24 27
88nodeset 4 name "cylinder"
89nodeset 5 vertex 1 2
90nodeset 5 name "corners"
91
92$***********************
93$ export mesh
94$***********************
95export mesh "tutorial_fluid.e" dimension 2 block all overwrite
The generated mesh should look like this:

Mesh for a flow past a circular cylinder.
Working with 4C
General Procedure of Creating a Valid 4C Input File
The execution of 4C is controlled by an input file. Let us create a file
tutorial_fluid.4C.yaml
and enter the essential parameters:
PROBLEM TYPE:
PROBLEMTYPE: Fluid
FLUID DYNAMIC:
LINEAR_SOLVER: 1
PREDICTOR: explicit_second_order_midpoint
NUMSTEP: 10
RESTARTEVERY: 1
SOLVER 1:
SOLVER: UMFPACK
MATERIALS:
- MAT: 1
MAT_fluid:
DYNVISCOSITY: 0.004
DENSITY: 1
FUNCT1:
- SYMBOLIC_FUNCTION_OF_SPACE_TIME: 0.5*(sin((t*pi/0.1)-(pi/2)))+0.5
The mesh is read from the EXODUS file created in the previous step. We can read the mesh as follows:
FLUID GEOMETRY:
FILE: tutorial_fluid.e
ELEMENT_BLOCKS:
- ID: 1
ELEMENT_NAME: FLUID
ELEMENT_DATA: MAT 1 NA Euler
This tells 4C to read the mesh as the fluid geometry and assign corresponding elements.
Setting the boundary conditions
The boundary conditions are set as follows:
DESIGN LINE DIRICH CONDITIONS:
- E: 1
ENTITY_TYPE: node_set_id
NUMDOF: 3
ONOFF:
- 1
- 1
- 0
VAL:
- 1.0
- 0.0
- 0.0
FUNCT:
- 1
- null
- null
- E: 2
ENTITY_TYPE: node_set_id
NUMDOF: 3
ONOFF:
- 0
- 1
- 0
VAL:
- 0.0
- 0.0
- 0.0
FUNCT:
- null
- null
- null
- E: 3
ENTITY_TYPE: node_set_id
NUMDOF: 3
ONOFF:
- 0
- 1
- 0
VAL:
- 0.0
- 0.0
- 0.0
FUNCT:
- null
- null
- null
- E: 4
ENTITY_TYPE: node_set_id
NUMDOF: 3
ONOFF:
- 1
- 1
- 0
VAL:
- 0.0
- 0.0
- 0.0
FUNCT:
- null
- null
- null
DESIGN POINT DIRICH CONDITIONS:
- E: 5
ENTITY_TYPE: node_set_id
NUMDOF: 3
ONOFF:
- 1
- 1
- 0
VAL:
- 1.0
- 0.0
- 0.0
FUNCT:
- null
- null
- null
Running a Simulation with 4C
Execute 4C as usual:
./4C <input_directory>/<input_file_name> <output_directory>/output_prefix
The prefix that you choose will be applied to all output files that 4C generates.
Postprocessing
You can postprocess your results with any visualization software you like. In this tutorial, we choose Paraview.
Filtering result data
Before you can admire your results, you have to generate a filter which converts the generic binary 4C output to the desired format. Starting from the
build-release
directory, executemake post_drt_ensight
.The filter should now be available in the
build-release
folder. Filter your results with the following call inside thebuild-release
folder:./post_drt_ensight - -file=<outputdirectory>/outputprefix
Further options of the filter program are made visible by the command
./post_drt_ensight –help
Visualize your results in Paraview
After the filtering process is finished open paraview by typing
paraview &
File :math:`to` Open and select the filtered
*\*.case*
file: outputprefix_fluid.casePress Apply to activate the display.
Set the time step in the top menu bar to \(19\) (\(=0.2\)).
In the Color section you can now choose between pressure and velocity. Select velocity and pick the \(X\)-component from the adjacent drop-down menu. Then press the Rescale button and the Show button. You receive a visualization of the \(X\)-velocity field, which should look similar to this figure:

\(X\)-velocity for a flow past a circular cylinder