Difference between revisions of "OpenFOAM-version-7/C2/Creating-2D-Channel-Geometry-and-Mesh-in-OpenFOAM/English"
Ashleymelvin (Talk | contribs) (Created page with "'''Title of the script''': Creating 2D Channel Geometry and Mesh in OpenFOAM '''Author''': Ashley Melvin '''Keywords''': OpenFOAM, ParaView, channel flow, blockMesh, meshing...") |
Nancyvarkey (Talk | contribs) |
||
Line 17: | Line 17: | ||
|| Slide: Learning Objective | || Slide: Learning Objective | ||
|| In this tutorial, we will learn to: | || In this tutorial, we will learn to: | ||
− | * Create a '''2D channel | + | * Create a '''2D channel''' geometry using '''blockMeshDict''' |
− | * '''Mesh''' a | + | * '''Mesh''' a geometry |
− | * Label the '''boundary patches''', and | + | * Label the '''boundary patches''', and |
* View the '''mesh''' in '''ParaView''' | * View the '''mesh''' in '''ParaView''' | ||
|- | |- | ||
Line 33: | Line 33: | ||
|| Slide: Code Files | || Slide: Code Files | ||
|| | || | ||
− | * The files used in this tutorial are available in the '''Code | + | * The files used in this tutorial are available in the '''Code Files''' link on this tutorial page |
* Please download and extract them | * Please download and extract them | ||
* Make a copy and then use them while practising | * Make a copy and then use them while practising | ||
Line 41: | Line 41: | ||
|- | |- | ||
|| Slide: Channel Geometry | || Slide: Channel Geometry | ||
− | || This is the | + | || This is the geometry for''' 2D flow in a channel'''. |
|- | |- | ||
|| Slide: Faces | || Slide: Faces | ||
Line 47: | Line 47: | ||
* '''Inlet''' and '''outlet''' | * '''Inlet''' and '''outlet''' | ||
* Bottom and top walls | * Bottom and top walls | ||
− | * Back face, and | + | * Back face, and Front face |
− | + | ||
|- | |- | ||
|| CTRL + ALT + T | || CTRL + ALT + T | ||
− | || Open the '''terminal''' by pressing '''Ctrl | + | || Open the '''terminal''' by pressing '''Ctrl, Alt''' & '''T''' keys. |
|- | |- | ||
|| [Terminal] Type: | || [Terminal] Type: | ||
Line 57: | Line 56: | ||
'''cd $FOAM_RUN''' | '''cd $FOAM_RUN''' | ||
− | || At the '''prompt''', type the following '''command''' to go to the ''' | + | || At the '''prompt''', type the following '''command''' to go to the '''RUN directory'''. |
|- | |- | ||
|| Only Narration | || Only Narration | ||
Line 66: | Line 65: | ||
'''cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/LES/channel395 .''' | '''cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/LES/channel395 .''' | ||
− | || Let us now copy the '''case''' of '''flow in a channel''' from the ''' | + | || Let us now copy the '''case''' of '''flow in a channel''' from the '''TUTORIALS directory''' into the '''RUN directory'''. |
Line 75: | Line 74: | ||
'''rm -r channel395/0''' | '''rm -r channel395/0''' | ||
− | || We will only be creating and '''meshing''' the | + | || We will only be creating and '''meshing''' the geometry. |
Line 108: | Line 107: | ||
− | Hence, | + | Hence, delete the selected section. |
Line 123: | Line 122: | ||
− | The value '''1''' indicates that the values of all the '''coordinates''' are in meters. | + | The value '''1''' indicates that the values of all the '''coordinates''' are in '''meters'''. |
|- | |- | ||
|| [gedit - '''channel'''] | || [gedit - '''channel'''] | ||
Line 143: | Line 142: | ||
|- | |- | ||
|| Slide: Vertices | || Slide: Vertices | ||
− | || The vertices of the '''channel | + | || The vertices of the '''channel''' geometry are numbered as indicated. |
Line 164: | Line 163: | ||
'''(0 0 0)''' | '''(0 0 0)''' | ||
− | || | + | || Vertex '''0''' is located at the '''origin'''. |
Line 173: | Line 172: | ||
'''(4 0 0) ''' | '''(4 0 0) ''' | ||
− | || The''' x, y '''and''' z '''coordinates''' '''of vertex''' 1 '''are '''4 | + | || The''' x, y '''and''' z '''coordinates''' '''of vertex''' 1 '''are '''4, 0''' and '''0''' respectively. |
Line 194: | Line 193: | ||
|- | |- | ||
|| Only Narration | || Only Narration | ||
− | || For '''meshing | + | || For '''meshing, OpenFOAM''' requires '''3-dimensional blocks''' to be defined. |
Line 203: | Line 202: | ||
Blocks List | Blocks List | ||
− | || We use a single '''block''' in our | + | || We use a single '''block''' in our geometry. |
Line 215: | Line 214: | ||
|- | |- | ||
|| Only Narration | || Only Narration | ||
− | || The order in which the vertices are specified define the '''block'''. | + | || 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 first enter the vertices of the lower '''xy-plane''', in this case, the back face. |
Line 244: | Line 243: | ||
We first define the number of '''cells''' in each direction of the '''block'''. | We first define the number of '''cells''' in each direction of the '''block'''. | ||
|- | |- | ||
− | || [gedit - ''' | + | || [gedit - '''blockM''', '''eshDict'''] Highlight: |
Line 251: | Line 250: | ||
− | This indicates that there are 40 cells in '''x direction''' and 25 cells in '''y direction'''. | + | This indicates that there are 40 '''cells''' in '''x direction''' and 25 '''cells''' in '''y direction'''. |
|- | |- | ||
|| [gedit - '''blockMeshDict'''] Highlight: | || [gedit - '''blockMeshDict'''] Highlight: | ||
Line 266: | Line 265: | ||
− | We use '''simpleGrading''' as the cells have '''uniform expansion''' in all | + | We use '''simpleGrading''' as the '''cells''' have '''uniform expansion''' in all directions. |
|- | |- | ||
|| [gedit - '''blockMeshDict'''] Highlight: | || [gedit - '''blockMeshDict'''] Highlight: | ||
Line 272: | Line 271: | ||
'''1 1 1''' | '''1 1 1''' | ||
− | || Let us now define the '''expansion ratios''' in each | + | || Let us now define the '''expansion ratios''' in each direction. |
− | '''Expansion ratio''' along a | + | '''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 | + | Since the '''cell''' width is uniform in all directions, the '''expansion ratio''' is '''1'''. |
|- | |- | ||
|| Only Narration | || Only Narration | ||
Line 290: | Line 289: | ||
Edges List | Edges List | ||
− | || Since all the '''edges''' of '''channel | + | || Since all the '''edges''' of '''channel''' geometry are straight lines, we leave it empty. |
|- | |- | ||
|| Only Narration | || Only Narration | ||
Line 308: | Line 307: | ||
'''bottomWall''' | '''bottomWall''' | ||
− | || The bottom face of the | + | || The bottom face of the geometry is named '''bottomWall'''. |
|- | |- | ||
|| [gedit - '''blockMeshDict'''] Highlight: | || [gedit - '''blockMeshDict'''] Highlight: | ||
Line 315: | Line 314: | ||
'''type''' | '''type''' | ||
|| The '''patch type''' of the '''boundary''' is defined using the '''keyword type'''. | || The '''patch type''' of the '''boundary''' is defined using the '''keyword type'''. | ||
− | |||
− | |||
|- | |- | ||
Line 323: | Line 320: | ||
'''wall''' | '''wall''' | ||
− | || The bottom face resembles the characteristics of a | + | || The bottom face resembles the characteristics of a solid wall. |
Line 335: | Line 332: | ||
− | The vertices and their order for a face is defined using the '''keyword faces'''. | + | The vertices and their order for a face, is defined using the '''keyword faces'''. |
|- | |- | ||
|| Slide: Bottom Wall | || Slide: Bottom Wall | ||
Line 356: | Line 353: | ||
|- | |- | ||
|| Only Narration | || Only Narration | ||
− | || We are creating the | + | || We are creating the geometry for a '''2D simulation''' in '''xy-plane'''. |
− | We do not need to solve in the '''z | + | We do not need to solve in the '''z''' direction. |
Line 374: | Line 371: | ||
− | Since they do not contain any | + | Since they do not contain any geometric or topological information, a '''generic''' label would suffice. |
|- | |- | ||
|| [gedit - '''blockMeshDict'''] Highlight: | || [gedit - '''blockMeshDict'''] Highlight: | ||
Line 380: | Line 377: | ||
'''patch''' | '''patch''' | ||
− | || Such ''' | + | || Such generic '''boundaries''' are labelled using the '''keyword patch'''. |
|- | |- | ||
|| [gedit - '''blockMeshDict'''] Highlight: | || [gedit - '''blockMeshDict'''] Highlight: | ||
Line 404: | Line 401: | ||
'''mergePatchPairs '''List | '''mergePatchPairs '''List | ||
− | || Our | + | || Our geometry has only one '''block''' and there are no '''patches''' to merge. |
Line 428: | Line 425: | ||
'''blockMesh '''>>''' Enter''' | '''blockMesh '''>>''' Enter''' | ||
− | || Let us '''mesh''' the | + | || Let us '''mesh''' the geometry. |
Line 455: | Line 452: | ||
− | You can now see the '''mesh''' structure of the | + | You can now see the '''mesh''' structure of the front face. |
|- | |- | ||
|| [ParaView] Close the window | || [ParaView] Close the window | ||
Line 468: | Line 465: | ||
|| Slide: Summary | || Slide: Summary | ||
|| In this tutorial, we have learnt to: | || In this tutorial, we have learnt to: | ||
− | * Create a '''2D channel | + | * Create a '''2D channel''' geometry using '''blockMeshDict''' |
− | * '''Mesh''' a | + | * '''Mesh''' a geometry |
* Label the '''boundary patches''', and | * Label the '''boundary patches''', and | ||
* View the '''mesh''' in '''ParaView''' | * View the '''mesh''' in '''ParaView''' | ||
Line 475: | Line 472: | ||
|| Slide: Assignment | || Slide: Assignment | ||
|| As an assignment: | || As an assignment: | ||
− | * Create a '''geometry''' having dimensions '''5 | + | * Create a '''geometry''' having dimensions '''5 metres, 4 metres''' and '''3 metres''' along '''x''', '''y''' and '''z axis''' |
− | * Mesh the | + | * Mesh the geometry such that it has 50, 40 and 1 '''cell''' along '''x, y''' and '''z axis''', and |
* View the '''mesh''' in '''ParaView''' | * View the '''mesh''' in '''ParaView''' | ||
|- | |- | ||
Line 486: | Line 483: | ||
|- | |- | ||
|| Slide: Spoken Tutorial Workshops | || Slide: Spoken Tutorial Workshops | ||
− | || We conduct workshops using | + | || We conduct workshops using spoken tutorials and give certificates. |
Line 501: | Line 498: | ||
|| Slide: FOSSEE Case Study Project | || Slide: FOSSEE Case Study Project | ||
|| | || | ||
− | * The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM. | + | * The FOSSEE team coordinates solving feasible '''CFD''' problems of reasonable complexity using '''OpenFOAM'''. |
* We give honorarium and certificates to those who do this. | * We give honorarium and certificates to those who do this. | ||
* For more details, please visit these sites. | * For more details, please visit these sites. |
Revision as of 14:57, 21 July 2020
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:
|
Slide: System Specifications | To record this tutorial, I am using,
You may use any other editor of your choice. |
Slide: Code Files |
|
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:
|
CTRL + ALT + T | Open the terminal by pressing Ctrl, Alt & T keys. |
[Terminal] Type:
|
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:
|
Let us now copy the case of flow in a channel from the TUTORIALS directory into the RUN directory.
|
[Terminal] Type:
|
We will only be creating and meshing the geometry.
|
[Terminal] Type:
|
The blockMeshDict file is located in the system folder.
|
[gedit - blockMeshDict] | We can now see the blockMeshDict file. |
[gedit - blockMeshDict] Highlight
|
Select the contents of the file from vertices to the end of the document, as shown.
|
[gedit - blockMeshDict] Highlight
|
The unit of the coordinates entered in the blockMesh dictionary needs to be specified.
|
[gedit - channel] | Open the channel.txt file, that you had downloaded, in a text editor. |
[gedit - channel] Highlight
|
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.
|
[gedit - blockMeshDict] Highlight
|
The coordinates of the vertices are entered as shown.
|
[gedit - blockMeshDict] Highlight:
|
Vertex 0 is located at the origin.
|
[gedit - blockMeshDict] Highlight:
|
The x, y and z coordinates of vertex 1 are 4, 0 and 0 respectively.
|
[gedit - blockMeshDict] Highlight
|
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
|
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.
|
[gedit - blockMeshDict] Highlight:
|
We use a single block in our geometry.
|
[gedit - blockMeshDict] Highlight:
|
We use hexahedral blocks for meshing. |
Only Narration | The order in which the vertices are specified, define the block.
|
[gedit - blockMeshDict] Highlight:
|
The vertices of the back face are defined as shown. |
[gedit - blockMeshDict] Highlight:
|
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.
|
[gedit - blockM, eshDict] Highlight:
|
The number of cells in each direction is defined as shown.
|
[gedit - blockMeshDict] Highlight:
|
There is only one cell along z direction indicating that the simulation is 2D in xy-plane. |
[gedit - blockMeshDict] Highlight:
|
Next, let us define how the mesh is graded.
|
[gedit - blockMeshDict] Highlight:
|
Let us now define the expansion ratios in each direction.
|
Only Narration | Now, let us define the edges.
|
[gedit - blockMeshDict] Highlight:
|
Since all the edges of channel geometry are straight lines, we leave it empty. |
Only Narration | Let us label the boundary patches.
|
[gedit - blockMeshDict] Highlight:
|
Boundary labels are defined using the boundary list. |
[gedit - blockMeshDict] Highlight:
|
The bottom face of the geometry is named bottomWall. |
[gedit - blockMeshDict] Highlight:
|
The patch type of the boundary is defined using the keyword type. |
[gedit - blockMeshDict] Highlight:
|
The bottom face resembles the characteristics of a solid wall.
|
[gedit - blockMeshDict] Highlight:
|
Vertices define a face.
|
Slide: Bottom Wall | Since the block face is a quadrilateral, it is defined by 4 vertices.
|
[gedit - blockMeshDict] Highlight:
|
Keeping this in mind, the vertices of the bottom wall are ordered as shown. |
[gedit - blockMeshDict] Highlight:
|
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.
|
[gedit - blockMeshDict] Highlight:
|
The back and front faces are defined as shown. |
Only Narration | The inlet and outlet faces need the application of boundary condition.
|
[gedit - blockMeshDict] Highlight:
|
Such generic boundaries are labelled using the keyword patch. |
[gedit - blockMeshDict] Highlight:
|
The inlet and outlet faces are defined as shown. |
Only Narration | We have finished labelling all the boundary patches. |
[gedit - blockMeshDict] Highlight:
|
Next, we merge faces using the mergePatchPairs field.
|
[gedit - blockMeshDict] Highlight:
|
Our geometry has only one block and there are no patches to merge.
|
[gedit - blockMeshDict]
|
We have entered all the necessary fields.
|
[Terminal] Type:
|
In the terminal, type cd(space)channel395. |
[Terminal] Type:
|
Let us mesh the geometry.
|
[Terminal] Highlight: End | The meshing is complete. |
[Terminal] Type:
|
To view the mesh in ParaView, type paraFoam and press Enter. |
[ParaView]
|
Click on the green coloured Apply on the left side of your window in the Properties tab. |
[ParaView]
|
Click on Surface available in the Representation Toolbar and change it to Surface with Edges.
|
[ParaView] Close the window | Close the ParaView window. |
Only Narration | With this we have come to the end of the tutorial.
|
Slide: Summary | In this tutorial, we have learnt to:
|
Slide: Assignment | As an assignment:
|
Slide: About the Spoken Tutorial Project | The video at the following link summarises the Spoken Tutorial project.
|
Slide: Spoken Tutorial Workshops | We conduct workshops using spoken tutorials and give certificates.
|
Slide: Spoken Tutorial Forum | Please post your timed queries in this forum. |
Slide: FOSSEE Forum |
|
Slide: FOSSEE Case Study Project |
|
Slide: Spoken Tutorial | The Spoken Tutorial project is supported by MHRD, Govt. of India.
|