OpenFOAM-version-7/C2/Creating-2D-Channel-Geometry-and-Mesh-in-OpenFOAM/English

From Script | Spoken-Tutorial
Revision as of 14:57, 21 July 2020 by Nancyvarkey (Talk | contribs)

Jump to: navigation, search

Title of the script: Creating 2D Channel Geometry and Mesh in OpenFOAM

Author: Ashley Melvin

Keywords: OpenFOAM, ParaView, channel flow, blockMesh, meshing, structured mesh, graded mesh, pre-processing, video tutorial


Visual Cue Narration
Slide: Opening Slide Hello and welcome to this tutorial on Creating 2D Channel Geometry and Mesh in OpenFOAM.
Slide: Learning Objective In this tutorial, we will learn to:
  • Create a 2D channel geometry using blockMeshDict
  • Mesh a geometry
  • Label the boundary patches, and
  • View the mesh in ParaView
Slide: System Specifications To record this tutorial, I am using,
  • Ubuntu Linux OS version 18.04
  • OpenFOAM version 7
  • ParaView version 5.6.0, and
  • gedit Text Editor

You may use any other editor of your choice.

Slide: Code Files
  • The files used in this tutorial are available in the Code Files link on this tutorial page
  • Please download and extract them
  • Make a copy and then use them while practising
Slide: 2D Channel Flow The problem description of 2D flow in a channel is as shown in the diagram.
Slide: Channel Geometry This is the geometry for 2D flow in a channel.
Slide: Faces The faces of the geometry are:
  • Inlet and outlet
  • Bottom and top walls
  • Back face, and Front face
CTRL + ALT + T Open the terminal by pressing Ctrl, Alt & T keys.
[Terminal] Type:


cd $FOAM_RUN

At the prompt, type the following command to go to the RUN directory.
Only Narration Here onwards, please remember to press the Enter key after typing each command in the terminal.
[Terminal] Type:


cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/LES/channel395 .

Let us now copy the case of flow in a channel from the TUTORIALS directory into the RUN directory.


Type the following command to do so.

[Terminal] Type:


rm -r channel395/0

We will only be creating and meshing the geometry.


Hence, we do not need the boundary conditions folder.


Type the following command to delete the boundary conditions folder.

[Terminal] Type:


gedit channel395/system/blockMeshDict

The blockMeshDict file is located in the system folder.


Let us open it in any text editor.


I am doing it in gedit Text Editor.

[gedit - blockMeshDict] We can now see the blockMeshDict file.
[gedit - blockMeshDict] Highlight


Selection in the Text Editor >> Delete

Select the contents of the file from vertices to the end of the document, as shown.


We don’t need the selected content as we will be entering the input parameters.


Hence, delete the selected section.


The remaining content is common for all blockMeshDict files.

[gedit - blockMeshDict] Highlight


convertToMeters 1

The unit of the coordinates entered in the blockMesh dictionary needs to be specified.


It is defined using the keyword convertToMeters.


The value 1 indicates that the values of all the coordinates are in meters.

[gedit - channel] Open the channel.txt file, that you had downloaded, in a text editor.
[gedit - channel] Highlight


Selection in the Text Editor >> Copy

Copy the entire content of the text file.
[gedit - blockMeshDict] Let me switch back to the blockMeshDict file.
[gedit - blockMeshDict]

Paste

Paste the copied contents into the blockMeshDict file as shown.
Slide: Vertices The vertices of the channel geometry are numbered as indicated.


The vertex numbering starts from 0.

[gedit - blockMeshDict] Highlight


Vertices List


The coordinates of the vertices are entered as shown.


Note that the vertices are entered in the ascending order of their vertex numbers.

[gedit - blockMeshDict] Highlight:


(0 0 0)

Vertex 0 is located at the origin.


Its coordinates are entered as shown.

[gedit - blockMeshDict] Highlight:


(4 0 0)

The x, y and z coordinates of vertex 1 are 4, 0 and 0 respectively.


Its coordinates are entered as shown.

[gedit - blockMeshDict] Highlight


(0 2 0) and (4 2 0)

Similarly, the coordinates of vertex 2 and 3 are entered as shown.
Only Narration The z coordinate of all the points on the front face is 2.
[gedit - blockMeshDict] Highlight


(0 0 2) to (4 2 2)

The coordinates of front face vertices 4, 5, 6 and 7 are entered as shown.
Only Narration For meshing, OpenFOAM requires 3-dimensional blocks to be defined.


The blocks are specified using the vertices that define them.

[gedit - blockMeshDict] Highlight:


Blocks List

We use a single block in our geometry.


The block is defined as shown.

[gedit - blockMeshDict] Highlight:


hex

We use hexahedral blocks for meshing.
Only Narration The order in which the vertices are specified, define the block.


We first enter the vertices of the lower xy-plane, in this case, the back face.


We start from the origin and enter the vertices of the face.


When viewed along the negative z-direction, the vertices should be ordered counterclockwise.

[gedit - blockMeshDict] Highlight:


0 1 3 2

The vertices of the back face are defined as shown.
[gedit - blockMeshDict] Highlight:


4 5 7 6

The vertices of the front face are entered in the same order as that of the back face.
Only Narration Let us start defining the meshing parameters of the block.


We first define the number of cells in each direction of the block.

[gedit - blockM, eshDict] Highlight:


40 25 1

The number of cells in each direction is defined as shown.


This indicates that there are 40 cells in x direction and 25 cells in y direction.

[gedit - blockMeshDict] Highlight:


1

There is only one cell along z direction indicating that the simulation is 2D in xy-plane.
[gedit - blockMeshDict] Highlight:


simpleGrading

Next, let us define how the mesh is graded.


We use simpleGrading as the cells have uniform expansion in all directions.

[gedit - blockMeshDict] Highlight:


1 1 1

Let us now define the expansion ratios in each direction.


Expansion ratio along a direction is the ratio of width of the end cell to that of the start cell in that direction.


Since the cell width is uniform in all directions, the expansion ratio is 1.

Only Narration Now, let us define the edges.


Edges are used to define arc or spline edges.

[gedit - blockMeshDict] Highlight:


Edges List

Since all the edges of channel geometry are straight lines, we leave it empty.
Only Narration Let us label the boundary patches.


The labels are used to impose boundary conditions on the respective faces.

[gedit - blockMeshDict] Highlight:


boundary

Boundary labels are defined using the boundary list.
[gedit - blockMeshDict] Highlight:


bottomWall

The bottom face of the geometry is named bottomWall.
[gedit - blockMeshDict] Highlight:


type

The patch type of the boundary is defined using the keyword type.
[gedit - blockMeshDict] Highlight:


wall

The bottom face resembles the characteristics of a solid wall.


Hence, the face is of the type wall.

[gedit - blockMeshDict] Highlight:


faces

Vertices define a face.


The vertices and their order for a face, is defined using the keyword faces.

Slide: Bottom Wall Since the block face is a quadrilateral, it is defined by 4 vertices.


When viewed from inside the block, the vertices of the face should be ordered clockwise.

[gedit - blockMeshDict] Highlight:


0 1 5 4

Keeping this in mind, the vertices of the bottom wall are ordered as shown.
[gedit - blockMeshDict] Highlight:


topWall definition

Following the same convention, the top face is named topWall and is defined as shown.
Only Narration We are creating the geometry for a 2D simulation in xy-plane.


We do not need to solve in the z direction.


Hence, we keep the front and back faces empty.

[gedit - blockMeshDict] Highlight:


Back and front planes definitions

The back and front faces are defined as shown.
Only Narration The inlet and outlet faces need the application of boundary condition.


Since they do not contain any geometric or topological information, a generic label would suffice.

[gedit - blockMeshDict] Highlight:


patch

Such generic boundaries are labelled using the keyword patch.
[gedit - blockMeshDict] Highlight:


Inlet and outlet planes definitions

The inlet and outlet faces are defined as shown.
Only Narration We have finished labelling all the boundary patches.
[gedit - blockMeshDict] Highlight:


mergePatchPairs

Next, we merge faces using the mergePatchPairs field.


We merge faces when a patch face from one block is connected to a patch face of another block.

[gedit - blockMeshDict] Highlight:


mergePatchPairs List

Our geometry has only one block and there are no patches to merge.


Therefore, we leave the mergePatchPairs field empty.

[gedit - blockMeshDict]


Save >> Close the window

We have entered all the necessary fields.


Save and close the file.

[Terminal] Type:


cd channel395

In the terminal, type cd(space)channel395.
[Terminal] Type:


blockMesh >> Enter

Let us mesh the geometry.


Type blockMesh and press Enter to do so.

[Terminal] Highlight: End The meshing is complete.
[Terminal] Type:


paraFoam >> Enter

To view the mesh in ParaView, type paraFoam and press Enter.
[ParaView]


Click on Apply

Click on the green coloured Apply on the left side of your window in the Properties tab.
[ParaView]


Click on Surface >> Click on Surface with Edges

Click on Surface available in the Representation Toolbar and change it to Surface with Edges.


You can now see the mesh structure of the front face.

[ParaView] Close the window Close the ParaView window.
Only Narration With this we have come to the end of the tutorial.


Let us summarize.

Slide: Summary In this tutorial, we have learnt to:
  • Create a 2D channel geometry using blockMeshDict
  • Mesh a geometry
  • Label the boundary patches, and
  • View the mesh in ParaView
Slide: Assignment As an assignment:
  • Create a geometry having dimensions 5 metres, 4 metres and 3 metres along x, y and z axis
  • Mesh the geometry such that it has 50, 40 and 1 cell along x, y and z axis, and
  • View the mesh in ParaView
Slide: About the Spoken Tutorial Project The video at the following link summarises the Spoken Tutorial project.


Please download and watch it.

Slide: Spoken Tutorial Workshops We conduct workshops using spoken tutorials and give certificates.


Please contact us.

Slide: Spoken Tutorial Forum Please post your timed queries in this forum.
Slide: FOSSEE Forum
  • Do you have any general/technical questions?
  • Please visit the forum given in this link.
Slide: FOSSEE Case Study Project
  • The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM.
  • We give honorarium and certificates to those who do this.
  • For more details, please visit these sites.
Slide: Spoken Tutorial The Spoken Tutorial project is supported by MHRD, Govt. of India.


The script for this tutorial is contributed by Ashley Melvin.


And this is Swetha Sridhar from IIT Bombay signing off.


Thank you for joining.

Contributors and Content Editors

Ashleymelvin, Nancyvarkey