OpenFOAM/C3/Using-Template-files-in-PyFoam/English-timed
From Script | Spoken-Tutorial
Revision as of 15:52, 5 September 2017 by Pratik kamble (Talk | contribs)
| Time | Narration |
| 00:01 | Hello and welcome to the spoken tutorial on Using Template files in PyFoam. |
| 00:07 | In this tutorial we will: Understand the function of PyFoam Utilities |
| 00:13 | Create and use template files |
| 00:17 | Use PyFoamFromTemplate dot py for solving the supersonic flow over wedge |
| 00:24 | We can run this for different wedge angles using template files. |
| 00:29 | To record this tutorial I am using Ubuntu Linux Operating System 14.04 |
| 00:36 | OpenFOAM 2.3.0
PyFoam-0.6.5 |
| 00:42 | To practice this tutorial the user should have : Basic Knowledge of using Linux terminal |
| 00:49 | Experience of running and analyzing OpenFOAM cases |
| 00:54 | If not, please refer to the spoken tutorial series on Linux and OpenFOAM. |
| 01:00 | What are template files? |
| 01:03 | Template files are used to generate OpenFOAM files like blockMeshDict or controlDict |
| 01:10 | Template files can be programmed, hence we can procedurally generate data. |
| 01:16 | A template file should be an OpenFOAM file, with the following - |
| 01:22 | Any line beginning with $$ is a Python program line. |
| 01:28 | It will be executed by Python |
| 01:31 | Any variable can be substituted in the file by using the syntax vertical pipe dash variable name dash vertical pipe |
| 01:42 | The following steps should be followed to use a template file : |
| 01:47 | First copy an existing file |
| 01:50 | After this create a template file |
| 01:54 | Then run PyFoamFromTemplate dot py |
| 01:58 | Template file will be created for blockMeshDict. |
| 02:02 | We will use the supersonic flow over a wedge as an example case. The case file is available in the rhoCentralFoam solver. |
| 02:12 | Open the terminal. Type the path for the rhoCentralFoam inside compressible solvers. |
| 02:22 | Now copy the Wedge15Ma5 case directory into OpenFOAM directory by typing cp space minus r space Wedge15Ma5 space type the path of your OpenFOAM directory and press Enter. |
| 02:46 | On the terminal, type the path for Wedge15Ma5 folder inside OpenFOAM directory. |
| 02:53 | Type the path for blockMeshDict file inside polyMesh directory inside constant. |
| 03:00 | Open the blockMeshDict file in any editor of your choice. |
| 03:06 | We can see the vertices section. |
| 03:09 | We need to calculate the co-ordinates of the end points of the slope. |
| 03:14 | Based on the angle, change the following lines |
| 03:19 | Switch back to the terminal. |
| 03:22 | Copy your blockMeshDict file into a file called blockMeshDict dot template |
| 03:29 | Type the following- cp space minus r space blockMeshDict space blockMeshDict dot template |
| 03:40 | Open the blockMeshDict dot template file using gedit. |
| 03:46 | Add the following lines above convertToMeters. |
| 03:51 | Any line preceded with $$ (dollar dollar) is a Python line, and will be interpreted and executed by Python |
| 04:02 | Modify the vertices entry as |
| 04:06 | Python variables assigned in the template file, should be substituted at any location in the file. |
| 04:14 | To do so, use vertical pipe dash variable name dash vertical pipe in the file. |
| 04:22 | We can see the changes made into this file. |
| 04:26 | Now, let's create a blank file. |
| 04:30 | On the terminal, type gedit templateFileConst and press Enter. |
| 04:40 | Create a dummy entry inside it by typing dummy space 1.0 semicolon |
| 04:48 | A dummy entry is mandatory. |
| 04:51 | An external dict has to be provided with any constant that is to be used in the template file. |
| 04:59 | Save and close the file. |
| 05:04 | We have to run the template command now. |
| 05:08 | Type this command in terminal and press Enter |
| 05:15 | We can see that 2 new files are generated the blockMeshDict and a Python file is also generated. |
| 05:24 | Do not edit the Python file. |
| 05:27 | Open the blockMeshDict file by typing gedit space blockMeshDict and press Enter. |
| 05:36 | We had changed the wedge angle from 15 deg to 10 deg. |
| 05:41 | The end points of the slope have also changed. |
| 05:45 | We can now run the case file by executing the OpenFOAM commands
blockMesh, rhoCentralFoam, visualize the results using Paraview. |
| 05:57 | As an assignment, use the following wedge angles and run the template commands. |
| 06:03 | Let us summarize. |
| 06:05 | In this tutorial, we learnt about PyFoam Template Files |
| 06:10 | We also learnt to- Create and use template files and using the PyFoamFromTemplate dot py command |
| 06:19 | Please post your timed queries in this forum. |
| 06:23 | Please post your general queries on OpenFOAM in this forum. |
| 06:28 | The FOSSEE team coordinates the TBC project. |
| 06:32 | The Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India. For more details , visit this website. |
| 06:41 | This is Rahul Joshi from IIT Bombay signing off. Thanks for watching |