OpenFOAM-version-7/C2/Grid-Resolution-and-Convergence-in-OpenFOAM/English

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

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of the script: Grid Resolution and Convergence in OpenFOAM

Author: Ashley Melvin

Keywords: OpenFOAM, ParaView, blockMesh, meshing, mesh refinement, coarse mesh, medium mesh, fine mesh, grid independence study, Courant number, lid-driven cavity, video tutorial


Visual Cue Narration
Slide: Opening Slide Welcome to this tutorial on Grid Resolution and Convergence in OpenFOAM.
Slide: Learning Objectives In this tutorial, we will learn to:
  • Refine a mesh using blockMeshDict
  • Change the time step to achieve numerical stability, and
  • Perform a grid independence study
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

However, you may use any other text editor of your choice.

Slide: Prerequisites As a prerequisite:
  • You should be familiar with setting up a case and creating a mesh in OpenFOAM.
  • You should also be familiar with basic post-processing using ParaView.
  • If not, please go through the prerequisite OpenFOAM tutorials on this website.
Slide: Lid Driven Cavity We will use the lid driven cavity case in this tutorial.


This is the diagram of Lid Driven Cavity Flow.

CTRL + ALT + T Open the terminal by pressing Ctrl, Alt & T keys.
Only Narration Here onwards please remember to press the Enter key after typing each command.
[Terminal]


Type: cd $FOAM_RUN

Type the following command to move into the RUN directory.
[Terminal] Type:


cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .

Let us copy the Lid driven cavity case from the TUTORIALS directory into the RUN directory.


Type the following command to do so.

[Terminal]


Type: cd cavity

Now let us go into the Lid Driven Cavity case folder using the cd command.
[Terminal]


Type: gedit system/blockMeshDict

Let’s open the blockMeshDict file in a text editor.
[gedit - blockMeshDict]


Highlight (20 20 1)

This is a 2 dimensional mesh having 20 cells along both x and y directions.
[gedit - blockMeshDict]


Close Text Editor

Close the blockMeshDict file.
[Terminal]


Type: gedit system/controlDict

Now, let’s open the controlDict file in a text editor.
[gedit - controlDict] Highlight:


deltaT

The time step for the simulation is specified using the keyword delta T.


When running the simulation, temporal accuracy and numerical stability needs to be achieved.


The Courant number is required to be less than 1 to achieve this.


Please refer to the Additional Reading Material on this tutorial page for details.


It mentions the steps used to calculate the time-step.

[gedit - controlDict]


Highlight: 0.005

We have calculated the time step for this simulation to be 0.005 seconds.


So, this will be the value of delta T.

[gedit - controlDict] Close Text Editor Close the controlDict file.
[Terminal] Type:


blockMesh

Let us mesh the geometry now using the blockMesh command on the terminal.
[Terminal] Type:

icoFoam

We will be using the icoFoam solver to simulate the case.


Type the following command on the terminal to start the simulation.

[Terminal] Highlight:


End

The iterations are now complete.
[Terminal] Type:


paraFoam

Let us view the simulated results in ParaView using the paraFoam command.
[ParaView] Properties Tab


Click on Apply

Click on the Apply button in the Properties tab to view the geometry.
[ParaView] Active Variable Controls


Click on vtkBlockColors >> Click on p

Next, let’s view the pressure contours for the simulation.


Click on the vtkBlockColors dropdown in the Active Variable Controls and select p.

[ParaView] VCR Controls


Click on Last Frame

Now, let us view the contours at the end of the simulation.


Click on the Last Frame button in the VCR Controls.

[ParaView] Data Analysis


Click on Probe Location

Next, let’s see the values of pressure and velocity at the centre of the domain.


To do so, click on the Probe Location button in the Data Analysis section.

Slide: Probe Location
  • Probe Location filter shows the details of the points within an arbitrary sphere.
  • By default, this sphere is centered at the center of the domain and has zero radius.
  • Changing these parameters will change the probe location or the range of the probe.
[ParaView] Properties Tab


Click on Apply

We need the values at the centre of the domain.


Therefore, we stick with the default Sphere Parameters in the Properties Tab.


Click on the Apply button.

[ParaView] SpreadSheetView We can now see the velocity and pressure values in the SpreadSheetView.


Note down the value of pressure as we will be using this later.

[ParaView] Close the Window Then close the ParaView window.
Only Narration Now, let us increase the number of cells in the x and y direction to 40 cells.
Slide: Mesh Refinement
  • This process of dividing the existing cells is called mesh refinement.
  • Mesh refinement changes a coarse mesh into a finer mesh.
[Terminal] Type:


gedit system/blockMeshDict

Let us open the blockMeshDict file in a text editor.
[gedit - blockMeshDict] Highlight:


40 40

Change the number of cells in x and y direction as shown.
[gedit - blockMeshDict]


Save >> Close the window

Save and close the file.
Only Narration Since we have changed the number of cells, we need to update the time step.


This is to ensure that the Courant number is less than 1.

[Terminal] Type:


gedit system/controlDict

Let’s open the controlDict file in a text editor.
[gedit - controlDict]


Highlight: 0.0025

For the refined mesh, the calculated time-step is 0.0025 seconds.


Update delta T as shown.

[gedit - controlDict]


Save >> Close the window

Save and close the file.
[Terminal]


Type: blockMesh

Since we have changed the meshing parameters, we need to mesh the geometry again.


On the terminal, type the command as shown.

[Terminal] Type:

ls

Let us view the contents of the cavity folder.


Type ls in the terminal.

[Terminal] Highlight:


0.1 0.2 0.3 0.4 0.5

We can see that the files from the previous run exist in the cavity folder.
[Terminal] Type:


foamListTimes -rm

Let’s remove these files by typing this command.
[Terminal] Type:


icoFoam

Let’s run the icoFoam solver.
[Terminal] Type:


paraFoam

And view the results in ParaView by typing paraFoam.
[ParaView]


Click Apply >> Click on vtkBlockColors >> Click on p >> Click on Last Frame >> Click on Probe Location >> Click Apply

Let us find the value of the pressure field at the centre of the domain at the final time step.


As explained earlier, we use the Last Frame option to move to the final time step.


And, we use the Probe Location filter to find the data at the centre of the domain.

[ParaView] SpreadSheetView We can see the value of the pressure field at the centre of the domain.
[ParaView] Close the Window Close the ParaView window.
Only Narration Similarly, we can find the pressure at the centre for more number of cells.


Note that the time step is changed for each run depending on the cell size.

Slide: Pressure at the Centre The following table shows the pressure values for various numbers of cells.
Slide: Pressure at the Centre This is the Pressure versus number of cells plot based on the data.


Let’s consider that values within the order of 10-3 (10 to the power minus 3) are acceptable.


We can see that the pressure values at 6400 and 25600 cells differ only by an order of 10-4 (10 to the power minus 4).


Any more refinement than 6400 cells, will only give us results that differ by less than 10-3 (10 to the power minus 3).


Therefore, the results from a mesh having 6400 cells or more, surely gives acceptable results.


In other words, the results become independent of the mesh, if it has more than 6400 cells.


What we have just performed is called a grid independence study.

Only Narration The Additional Reading Material has more details on grid independence study.


Please refer to it.

Only Narration With this we have come to the end of the tutorial.


Let’s summarize.

Slide: Summary In this tutorial, we have learnt to:
  • Refine a mesh using blockMeshDict
  • Change the time step to achieve numerical stability, and
  • Perform a grid independence study
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 the 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