OpenFOAM-version-7/C2/Multi-block-Meshing-of-a-2D-Geometry-in-OpenFOAM/English

From Script | Spoken-Tutorial
Jump to: navigation, search

Title of the script: Multi-block Meshing of 2D Geometry in OpenFOAM

Author: Ashley Melvin

Keywords: OpenFOAM, ParaView, blockMesh, meshing, multiple blocks, graded mesh, mesh refinement, inflation layer, pre-processing, video tutorial


Visual Cue Narration
Slide: Opening Slide Hello and welcome to this tutorial on Multi-block Meshing of 2D Geometry in OpenFOAM.
Slide: Learning Objectives In this tutorial, we will learn to:
  • Create a geometry with multiple blocks using blockMeshDict
  • Vary meshing parameters for each block
  • 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 text editor of your choice.

Slide: Prerequisites As a prerequisite:
  • You should be familiar with the creation of a basic geometry using the blockMesh utility.
  • If not, please go through the prerequisite OpenFOAM tutorial on this website.
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, and
  • Make a copy and then use them while practising
Slide: Geometry This is the geometry we will be creating and meshing later on.
Slide: Faces
  • The left and right faces are the inlet and outlet respectively.
  • The top and bottom faces are the two walls.
  • The front and back faces are empty faces.


The faces are empty as we are creating a geometry for a 2D simulation.

CTRL + ALT + T Now, 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 .

Now, let us copy the case 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.


So, we do not need the boundary conditions folder.


Type the following command to delete the boundary conditions folder.

[Terminal] Type:


gedit channel395/system/blockMeshDict

Now open the blockMeshDict file in a text editor.


I am opening it in the gedit text editor.

[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.


Then delete the selected section as we will be entering the input parameters.

[gedit - multiBlock] Next open the multiBlock.txt file that you have downloaded in the text editor.
[gedit - multiBlock] Highlight:


Selection in the Text Editor >> Copy

Copy the entire content of the text file.
[gedit - blockMeshDict]


Paste

Paste the copied content into the blockMeshDict file as shown.
Ctrl + S And save the file.
Slide: Blocks The geometry is divided into 2 blocks as shown in the figure.
Slide: Vertices There are 12 vertices and they are numbered as shown.


Note that the vertex numbering starts from 0.

Only Narration Let me switch back to the blockMeshDict file.
Only Narration Let us enter the coordinates of vertices in ascending order of their vertex numbers.


The vertices are defined using the list vertices.

[gedit - blockMeshDict] Highlight:


vertices list

The coordinates of the 12 vertices are entered as shown.
[gedit - blockMeshDict] Highlight:


blocks

Now, let us see how the blocks for this geometry are defined.
Slide: Blocks The geometry is divided into 2 blocks.


This division enables us to mesh the top and bottom sections of the geometry differently.


The blocks are numbered as shown.

[gedit - blockMeshDict] Highlight:


Block 1 definition

Block 1 is defined as shown.
[gedit - blockMeshDict] Highlight:


hex

We use hexahedral blocks for meshing.
Only Narration We will enter the vertices that define block 1.


We first enter the vertices of the lower xy-plane.

Slide: Block 1 To define block 1,
  • We first enter the vertices of the back face and then that of the front face
  • When viewed along the negative z-direction, the vertices should be ordered counterclockwise
  • Following this convention, the vertices of the back face are 0, 1, 3 and 2
  • The corresponding order of the front face is 6, 7, 9 and 8
[gedit - blockMeshDict] Highlight:


0 1 3 2 6 7 9 8

The vertices of block 1 are therefore entered in the order as shown.
[gedit - blockMeshDict] Highlight:


40 25 1

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


There is only 1 cell in the z direction as this is a mesh for 2D simulation in xy-plane.

[gedit - blockMeshDict] Highlight:


simpleGrading

We use simpleGrading as the cells have uniform expansion in all directions.
[gedit - blockMeshDict] Highlight:


1 10 1

The ratio of width of the end cell to that of the start cell in a direction is its expansion ratio.


The expansion ratio in each direction is defined as shown.

[gedit - blockMeshDict] Highlight:


1 in x direction

This means that all cells have uniform width along x direction.
[gedit - blockMeshDict] Highlight:


1 in z direction

The same is the case for z direction.
[gedit - blockMeshDict] Highlight:


10 in y direction

However, along the y direction, the end cell is 10 times as wide as the start cell.
[gedit - blockMeshDict] Highlight:


Block 2 definition

Block 2 is defined as shown.
[gedit - blockMeshDict] Highlight:


0.1 in y direction

The expansion ratio in y direction is the only parameter different in block 2 from that of 1.


Along y direction, the end cell is now only 0.1 times as wide as the start cell.

[gedit - blockMeshDict] Highlight:


edges list

Since all the edges of the channel geometry are straight lines, we leave the edges field empty.
[gedit - blockMeshDict] Highlight:


boundary

Let us label the boundary patches now.
Slide: Boundary The bottom and top face is as shown in the figure.


We shall name them wallBottom and wallTop respectively.

Only Narration Each face resembles the characteristics of a solid wall.


Hence, the face is of the type wall.

[gedit - blockMeshDict] Highlight:


wallBottom and wallTop definitions

The two faces are defined as shown.
Only Narration We need to impose cyclic boundary conditions on the inlet and outlet faces of block 1.
Slide: Cyclic Patch
  • The face type for a cyclic patch is defined using the keyword cyclic.
  • The pair of faces are linked to each other through the keyword neighbourPatch.
Slide: Boundary The inlet and outlet faces of block 1 are named in1 and out1 respectively.


The same for block 2 are named in2 and out2 respectively.

[gedit - blockMeshDict] Highlight:


in1 definition

The inlet face of block 1 is defined as shown.
[gedit - blockMeshDict] Highlight:


cyclic

The boundary face type is cyclic.
[gedit - blockMeshDict] Highlight:


neighbourPatch out1

The outlet face is linked to the inlet face using the keyword neighbourPatch.
[gedit - blockMeshDict] Highlight:


((0 6 8 2))

The vertices of the inlet face are ordered in clockwise direction when viewed from inside of block 1.
[gedit - blockMeshDict] Highlight:


out1 definition

The outlet face of block 1 is defined as shown here.
[gedit - blockMeshDict] Highlight:


in2 and out2 definitions

The inlet and outlet faces of block 2 are defined as shown here.
Slide: Boundary
  • The back and front faces of block 1 are named sides1_half0 and sides1_half1 respectively.
  • The back and front faces of block 2 are named sides2_half0 and sides2_half1 respectively.
Only Narration We are creating a geometry for a 2D simulation in the xy-plane.


Therefore, the faces normal to z-direction are kept empty.

[gedit - blockMeshDict] Highlight:


sides1_half0 definition

The back face of block 1 is defined as shown.
[gedit - blockMeshDict] Highlight:


empty

Note that we have kept the face empty.
[gedit - blockMeshDict] Highlight:


sides1_half1, sides2_half0 and sides2_half1 definition

Similarly, we define the other 3 faces.
Only Narration We have now finished labelling all the boundary patches.
[gedit - blockMeshDict] Highlight:


mergePatchPairs list

Since we do not have any patches to merge, we leave the mergePatchPairs field empty.
[gedit - blockMeshDict]


Click on Save >> Close Text Editor

We have now entered all the necessary fields.


Save and close the file.

[Terminal] Type:


cd channel395

Come to the terminal, and type cd (space) channel395.
[Terminal] Type:


blockMesh >> Enter

To mesh the geometry, type blockMesh and press Enter.
[Terminal] Highlight:


End

The meshing is now complete.
[Terminal] Type:


paraFoam

To view the mesh in ParaView, type paraFoam.
[ParaView] Properties Tab


Click on Apply

Click on Apply in the Properties tab.
[ParaView] Active Variable Controls


Click on Surface >> Click on Surface with Edges

Click on Surface available in the Active Variable Controls and change it to Surface with Edges.


We can now see the mesh structure in the xy-plane.


Notice the mesh refinement near the top and bottom faces of the geometry.

[ParaView] Close the Window And now, close the ParaView window.
Only Narration With this we have come to the end of the tutorial.


To summarize.

Slide: Summary In this tutorial, we have learnt to:
  • Create a geometry with multiple blocks using blockMeshDict
  • Vary meshing parameters for each block
  • Label the boundary patches, and
  • View the mesh in ParaView
Slide: Assignment As an assignment:
  • Create a geometry having dimensions 5 m, 4 m and 3 m along x, y and z axis
  • Divide the geometry into 2 equal blocks along the x axis
  • Mesh the geometry such that it has 25, 20 and 1 cell along x, y and z axis for each block
  • Set expansion ratio as 10, 1 and 1 along the x, y and z axis for both the blocks, 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