Difference between revisions of "OpenFOAM/C3/Using-Template-files-in-PyFoam/English"
Viraj20feb (Talk | contribs) |
Viraj20feb (Talk | contribs) |
||
| Line 160: | Line 160: | ||
| style="border:0.25pt solid #000000;padding:0cm;"| '''Add the following lines above convertToMeters''' | | style="border:0.25pt solid #000000;padding:0cm;"| '''Add the following lines above convertToMeters''' | ||
| − | + | ||
'''$$import math''' | '''$$import math''' | ||
| Line 171: | Line 171: | ||
|- | |- | ||
| − | | style="border:0.25pt solid #000000;padding:0cm;"| | + | | style="border:0.25pt solid #000000;padding:0cm;"| Any line preceded with '''$$ '''is a '''Python '''line, and will be interpreted and |
| style="border:0.25pt solid #000000;padding:0cm;"| executed by '''Python''' | | style="border:0.25pt solid #000000;padding:0cm;"| executed by '''Python''' | ||
Revision as of 17:58, 23 February 2017
Tutorial 21: C2
Title : Using Template files in PyFoam Script : Anmol Sahoo, Rahul Joshi Narration : Rahul Joshi
Keywords : OpenFOAM, PyFoam, Python, Template, supersonic flow, wedge
| Visual Cue | |
| Show slide : Title | Hello and welcome to the spoken tutorial on Using Template files in PyFoam. |
| Show Slide : Learning Objective | In this tutorial we will:
We can run this for different wedge angles using template files. |
| Show Slide : System requirement | To record this tutorial I am using
|
| Show slide : Prerequisite | To practice this tutorial the user should have :
If not, please refer to the spoken tutorial series on Linux and OpenFOAM. |
| Show slide : Template Files | What are template files?
Template files are used to generate OpenFOAM files like blockMeshDict or controlDict
|
| Show slide : Syntax of Template files | A template file should be an OpenFOAM file, with the following -
| -varname - | |
| Show slide : Using a template file | The following steps should be followed to use a template file :
|
| Show slide : Creating a template file | Template file will be created for blockMeshDict.
We will use the supersonic flow over a wedge as an example case. The case file is available in the rhoCentralFoam solver. |
| Type run/tutorials/compres sible/rhoCentralFoam | Open the terminal.
|
| Type
cp -r Wedge15Ma5 /home/fossee/OpenFOAM/ |
Now copy the Wedge15Ma5 case directory into OpenFOAM directory
by typing cp -r Wedge15Ma5 Type the path of your OpenFOAM directory and press Enter. |
| Cd OpenFOAM/Wedge5 M15 | On the terminal, type the path for Wedge5M15 folder inside
OpenFOAM directory. |
| Type cd constant/polyMesh/bl ockMeshDict | Type the path for blockMeshDict file inside polyMesh directory inside
constant. |
| Type gedit blockMeshDict | Open the blockMeshDict file in any editor of your choice. |
| Point to the vertices section | We can see the vertices section. |
| Show slide : vertices to
be changed |
We need to calculate the co-ordinates of the end points of the slope.
Based on the angle, change the following lines ( 0.3048 0.081670913853 -0.005) ( 0.3048 0.081670913853 0.005) |
| On the terminal type
cp -r blockMeshDict blockMeshDict.templ ate |
Switch back to the terminal
Copy your blockMeshDict file into a file called blockMeshDict.template, type the following- cp -r blockMeshDict blockMeshDict.template |
| gedit blockMeshDict.templat e | Open the blockMeshDict.template file using gedit |
| Show slide : Template file syntax | Add the following lines above convertToMeters
$$import math $$thetaDegrees = 10.0 $$thetaRadians = math . radians ( thetaDegrees ) $$y_coord = 0.3048* math . tan ( thetaRadians ) |
| Any line preceded with $$ is a Python line, and will be interpreted and | executed by Python |
| Show slide : Template file syntax | Modify the vertices entry as
|
| Python variables assigned in the template file, should be substituted at any location in the file.
| |
| Highlight or point to the changes | We can see the changes made into this file. |
| Now, let's create a blank file | |
| Type gedit templateFileConst | On the terminal, type gedit templateFileConst and press Enter. |
| templateFileConst | Create a dummy entry inside it by typing
|
| Press Ctrl+S and close | Save and close the both the files |
| cd ../../ | Now go 2 levels back to your case file. |
| Switch back to slides | Let me switch back to slides |
| Show slide : Running PyFoam command | We have to run the template command now.
--output=./blockMeshDict --values-dictionary=templateFileConst --allow-exec-instead-of-assignment |
| Type this command in terminal >> press Enter | Type this command in terminal and press Enter |
| Type cd constant/polyMesh | Now again go inisde the polyMesh folder inside constant |
| Point to blockMeshDict and a python file | We can see that
|
| Point to the Python
file. |
Do not edit the Python file. |
| On the terminal type
gedit blockMeshDict |
In the terminal, open the blockMeshDict file by typing - |
| gedit blockMeshDict and press Enter. | |
| Point to wedge angle | We had changed the wedge angle from 15 deg to 10 deg. |
| Point to end points | The end points of the slope have also changed. |
| Show slide :Running the case file | We can now run the case file by executing the OpenFOAM commands
|
| Show slide : Assignment | As an assignment, use the following wedge angles and run the template
commands.
|
| Show slide : Summary | Let us summarize.
|
| Show Slide
|
Please post your timed queries in this forum. |
| Show Slide
|
Please post your general queries on OpenFOAM in this forum. |
| Show Slide Textbook Companion | The FOSSEE team coordinates the TBC project. |
| Show Slide Acknowledgement | The Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India
|
| Thank You | This is Rahul Joshi from IIT Bombay signing off. Thanks for watching |