CFD analysis of pipe flow

CFD analysis of a pipe flow

This tutorial shows how to run a CFD analysis of the flow inside a pipe with multiple inlets using our free CFD software SimWorks. The tutorial will guide you in the setup of the simulation of a pipe with different inlets. The results will show the local pressure distribution inside the pipe and the source of pressure losses. 

cfd analysis of pipe flow
Velocity iso-surfaces coloured with pressure. CFD analysis of a pipe flow using SimWorks

A simple approach to calculate the pressure and velocity distribution in a pipe would be to assume a quasi 1D flow and use the Bernoulli equation (1), which is valid for incompressible inviscid fluids, in conjunction with the conservation of mass (2): 

\begin{gather} p + \frac{1}{2}\rho v^{2} + \rho g h = const \end{gather} (1)
\begin{gather} A v = const \end{gather} (2)

Where A is the sectional area of the pipe. Using these two equations, it is possible to calculate the pressure from the velocity and vice-versa. However, we are assuming that the flow is uniform in each section and we are not taking into account the flow viscosity and the subsequent losses that progressively reduce the flow energy. These assumptions can lead to significant errors in the calculations.  This is particularly evident around bends or geometrical discontinuities, where significant pressure losses can be experienced. 

Carrying out a CFD analysis of pipe flow can provide a reliable results taking into account those pressure losses as well and get the actual velocity distribution at any section of the pipe.

Setting up the CFD analysis of pipe flow

In the following tutorial we will simulate the flow inside a complex pipe in a CFD simulation using out free CFD software Simworks. The overall lenght of the pipe is 3.5m 

This SimWorks tutorial is showing how to simulate the internal flow inside a complex pipe with multiple inlets

The first step is to download SimWorks from the link below, which is completely free and unrestricted. You can follow the installation procedure described in our installation guide and you can also download the geometry file for this tutorial here.

Create a new simulation

The first step after opening SimWorks is to create a new simulation:

  1. File → Create new

Load the geometry

To load the geometry in SimWorks complete the following steps:

  1. Browse geometry icon → select the pipe.igs file
  2. Select m as the Geometry units
  3. Load the geometry → select the pipe.igs file
  4. Rename the simulation to Pipe in the popup that will appear

Check the geometry

Once the geometry is imported, SimWorks will automatically create an outer domain (OD) around it (1), however since this is an internal flow simulation we want to deactivate it by pressing on the Toggle outer domain button (2), not to be confused with the Show / Hide outer domain button in the Geometry Viewer window, which would only hide it.

Once the Outer Domain is deactivated, we can click in the Geometry viewer window on the layering button (1) we can select the Surface normals layering (2) to check the local normals on the different geometrical elements of the geometry. This shows the positive direction of the surface in yellow, so on the yellow patches when we define a positive flow velocity the flow will be entering in the geometry, on the black patches it will be exiting it. 

For instance in the pipe inlet (3) in the image below the positive direction is entering in the pipe, in the case of the inlet (4) the positive direction will be exiting it. Obviously the user can flip those directions in the original CAD and re-export the geometry or alternatively the user can take into account those normals once the boundary conditions are defined, and this is the approach we are going to use.

From the same layering menu it is possible to select the Part names layering to see which patches SimWorks recognised and their names. With this layering active when the user clicks on a part the part name will be displayed:

Define the boundary conditions

Selecting the Boundary condition types layering (1) it appears that the whole pipe is set to be a fixed wall, this is the default boundary condition. To be able to set a specific boundary condition on the Inlet we need to select it, make sure that the Main_Inlet patch is selected in the Parts menu (3) and finally click on the Create new Part Group button to be able to create an independent part group where we can apply a specific boundary condition. It is also possible to change the name of the Part group to one relevant for the user.

We can repeat the exercise with the remaining patches to obtain 5 part groups in total: Main_Inlet, Main_Exit, Second_Inlet, Third_Inlet and the last one containing the body of the pipe, which can remain a fixed wall and rename them to remember which part group corresponds to which surface.

We can now reactivate the Boundary condition types layering and select the Main_Inlet part group. The normal of this face is positive so we can set a positive velocity of 5 m/s:

We can also set / modify those boundary conditions directly in the Simulation editor menu. 

Please find below the boundary conditions used in this case:

  1. Main Inlet: + 5 m/s
  2. Second Inlet: – 10 m/s (remember that the surface normal in this case is negative and plotted in black in the Surface normals layering!)
  3. Third Inlet: + 10 m/s (the normal is positive in this case)
  4. Main Exit: Pressure outlet of 0 Pa (remember that a CFD simulation with all the boundary conditions defined as velocity will be unstable, so in this case we have set the main exit as a constant pressure boundary)

Mesh parameters

In the Mesh tab in the Simulation editor window we can now define all the mesh parameters for the simulation. The point in mesh defines which portion of space has to be meshed, so in our case the point has to be inside the pipe and its size is purely defined for visual purposes.

  1. Define the Base size of the mesh of 0.01 m
  2. The point in mesh defines which portion of the space is to be meshed, so define the Point in mesh (position) as 0 -0.3 0 and its Radius as 0.05 m
  3. To check that the Point in mesh is inside the geometry just press on the Toggle transparency button in the Geometry viewer, this will make the whole geometry transparent and show that the Point in mesh is in effect inside the pipe

Select the Mesh tab in the Simulation editor window, we have a single Surface mesh group containing all the geometrical patches. It is possible at this stage to create different Surface mesh groups as done in the Part group case. This can be done both in the Geometry viewer window with the relevant Mesh groups layering active as seen above with the Part groups or directly in the Simulation editor window 

  1. Select the Mesh tab
  2. Select the Main_Body patch from the Parts dropdown menu
  3. Click on the Create Part Group button 

4. Rename the Surface mesh group as main_body_surface

5. Define a first cell height of 0.01 m, 3 layers and 1.2 expansion ratio

Output parameters

In the Output tab in the Simulation editor window it is possible to specify what we want to output for the pipe simulation. We will need more planes in the X direction to assess the development of the flow inside the pipe

  1. Select the Output tab in the Simulation editor window
  2. Define 40 planes in X from X -2 m to X 2 m
  3. Define for both Y and Z 20 planes from -1 m to 1 m

Setup and Mesh phases

We will complete the Setup phase to write all the simulation parameters and run the Mesh phase to visualise the results of the mesh parameters defined in the previous point paragraph. Optionally define the Numbers of processes as 4 in the Simulation editor window to run the example in parallel using 4 processes.

  1. Run the Setup phase
  2. Run the Mesh phase
  3. The Live Data window will automatically appear showing the live feed from of the mesher
  4. Finally the mesh progress bar will be 100% complete. To visualise the mesh, right click on it → select Fields → Load

Mesh quality assessment

From the Fields window it is possible to scroll through the planes in any direction and assess the mesh quality and dimensions. You can visualise the external mesh by making sure that the Show parts checkbox is thicked, or you can unthick it and select one of the sections in the Show sections dropdown menu. It is then possible to scroll along the direction set in the Direction dropdown menu by pressing the arrows next to it or the up and down arrows on the keyboard.

From the plane view it is possible to see that the near wall mesh has 3 layers as requested.

Please bear in mind that the cells are triangulated for visualisation purposes but in reality the cells are prisms/hexahedrals.

Run the simulation

Now it is time to run the simulation and analyse the results. We have set the simulation to run for 500 iterations on 4 processes (both parameters available in the Setup tab in the Simulation editor window)

  1. Click on the Run simulation icon in the Simulation manager window
  2. The Live data window will be populated with the solver feedback and the simulation residuals and forces. The progress bar will be updated with the simulation progress, when it reaches 100% the simulation is complete
  3. Once completed as already done to check the mesh right click on the progress bar and select Fields → Load, this way the mesh visualisation will be overwritten with the actual CFD simulation results

Analyse the results of the CFD analysis of a pipe flow

From the Field viewer window it is possible to analyse flow inside the pipe

  1. Trigger the Show/Hide edges to hide all the cell edges and have a smooth view. It is important to note that the planes in this case are fully triangulated to improve the results calculation, so comparing this with the mesh visualisation the edges represent the actual cell size but with additional splitting
  2. Uncheck the Show parts checkbox 
  3. Select the Show sections and turn on the normals to all the directions x, y and z
  4. Select the x, y and z directions and slide the planes using the keyboard arrows 

5. Select in the Variable tab and define the range from -100 Pa to 100 Pa

6. Click on update legend button to visualise the new field

7. Select the Point probing button

8. Click on one point of the planes to get the local vale of pressure, which in the case below is -19.2 Pa


You can see from the pressure plot above how the static pressure changes within the pipe. The velocity field shows how the flow progressively accelerates as additional flow is injected by the secondary inlets. Also in the velocity plot, it is possible to check the actual velocity distribution in the exit face of the pipe that shows a much higher velocity on the far side with respect to the last inlet.

velocity distribution at the exit of a pipe

This velocity distribution as well as the actual pressure loss in the system would not be captured correctly by simply using the Bernoulli equation. You can now change any parameter of the simulation and rerun it to see how the results change, in particular you can change the velocity in the inlet close to the main exit to see how this affects the actual velocity distribution at the exit of the pipe. 

This tutorial has shown how to carry out a CFD analysis of a pipe flow using the free CFD software SimWorks, see also the following fluid flow notes for reference.

Try our free CFD software SimWorks, no registration required or contact us to find out more

Share on whatsapp
Share on email
Share on linkedin
Share on facebook
Share on twitter