Difference between revisions of "OpenFOAM/C3/Using-PyFoam-Utilities/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 21: Line 21:
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show Slide : Learning Objectives
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show Slide : Learning Objectives
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| In this tutorial we will learn :
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| In this tutorial we will learn :
 +
  
 
* About '''PyFoam Utilities'''
 
* About '''PyFoam Utilities'''
* How to use '''PyFoam Utilites'''
+
* How to use '''PyFoam Utilites'''
* How to run and plot data for the '''shockTube''' case using '''PyFoam Utilites'''
+
* How to run and plot''' '''data for the '''shockTube''' case using '''PyFoam Utilites'''
 +
 
 +
 
  
 
|-
 
|-
Line 31: Line 34:
 
System Requirement
 
System Requirement
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| To record this tutorial I am using:
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| To record this tutorial I am using:
 +
  
 
* '''Ubuntu Linux '''14.04
 
* '''Ubuntu Linux '''14.04
 
* '''OpenFOAM v2.3.0'''
 
* '''OpenFOAM v2.3.0'''
 
* '''PyFoam 0.6.5'''
 
* '''PyFoam 0.6.5'''
 +
 +
  
 
|-
 
|-
Line 40: Line 46:
  
 
Pre-requisite
 
Pre-requisite
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| As a prerequisite user should have:
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| As a prerequisite user should have :
* Basic knowledge of running commands on the '''Linux terminal'''
+
 
 +
* basic knowledge of running commands on the '''Linux terminal'''
 
* And some experience of running and analyzing '''OpenFOAM''' cases
 
* And some experience of running and analyzing '''OpenFOAM''' cases
 +
 +
  
 
|-
 
|-
Line 48: Line 57:
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Let me introduce you to '''PyFoam utilities.'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Let me introduce you to '''PyFoam utilities.'''
  
* '''Utilities '''are''' Python programs '''which come inbuilt with '''PyFoam.'''  
+
 
* Each '''utility''' has a specific function.
+
* '''Utilities '''are''' Python programs '''which come inbuilt with '''PyFoam.'''<br/>
 +
 
 +
* Each '''utility''' has a specific function.<br/>
 +
 
 
* '''Utilities''' are executed from the '''command line.'''
 
* '''Utilities''' are executed from the '''command line.'''
 +
 +
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : List of Utilities
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : List of Utilities
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| List of '''utilites''' that can be viewed using '''tab completion'''
 
  
|-
+
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Open terminal  
+
<nowiki>--------------------------</nowiki>
 +
 
 +
Open terminal  
  
  
 
Type '''pyFoam''' and press '''Tab''' twice
 
Type '''pyFoam''' and press '''Tab''' twice
 +
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| List of '''utilites''' that can be viewed using '''tab completion'''
  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Open the '''terminal'''.
+
 
 +
<nowiki>-------------------------------------------------------------------------------------------</nowiki>
 +
 
 +
Open the terminal  
  
  
 
The list of '''utilities''' can be viewed by  
 
The list of '''utilities''' can be viewed by  
 +
 
* typing '''pyFoam '''
 
* typing '''pyFoam '''
 
* and then pressing '''Tab '''key twice
 
* and then pressing '''Tab '''key twice
 +
 +
  
 
|-
 
|-
Line 73: Line 95:
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Let me switch back to the slides.
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Let me switch back to the slides.
  
Each '''utility''' can be executed with the '''–help''' option.
+
Each '''utility''' can be executed with the '''–help''' option  
  
  
This helps us to find out what it does and what its options are.
+
This helps us to find out what it does and what its options are
  
 
|-
 
|-
Line 83: Line 105:
  
  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| We are going to use the below '''PyFoam Utilities''' to run the '''Shock Tube''' case.  
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| We are going to use the following '''PyFoam Utilities''' to solve the '''Shock Tube''' case.  
  
  
Line 91: Line 113:
 
* '''PyFoamSamplePlot.py'''
 
* '''PyFoamSamplePlot.py'''
  
And then plot the necessary data using '''PyFoam'''.
+
And then plot the necessary data using '''PyFoam'''
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : PyFoamRunner.py
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : PyFoamRunner.py
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''PyFoamRunner.py''' can be used to run '''cases'''.
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| '''PyFoamRunner.py''' can be used to run '''cases'''
  
  
It also generates '''log files '''for later use.
+
It also generates '''log files '''for later use
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : PyFoamSamplePlot.py
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : PyFoamSamplePlot.py
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| This '''utility''' is used to plot the various data obtained from the previously set up '''sampleDict.'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| This '''utility''' is used to plot the various data obtained from the previously set up '''sampleDict.'''
 +
 +
 +
  
 
|-
 
|-
Line 121: Line 146:
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''run/tutorials/compressible/rhoCentralFoam'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''run/tutorials/compressible/rhoCentralFoam'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Open the '''Terminal'''.
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Open the '''Terminal''' and type the path for '''rhoCentralFoam''' inside '''compressible solver.'''
 
+
Type the path for '''rhoCentralFoam''' inside '''compressible solver.'''
+
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''ls'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''ls'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Type '''ls'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Type '''ls'''
 +
 +
|-
 +
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type the command shown in Narration column
 +
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Type:
 +
 +
'''cd $FOAM_TUTORIALS/compressible/rhoCentralFoam/'''
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''ls'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''ls'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| You can see the '''shockTube''' case
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Now type '''ls'''. You can see the '''shockTube''' case
  
 
|-
 
|-
Line 148: Line 177:
  
  
So type '''cp -r 0.org 0''' and press '''Enter'''.
+
So type '''cp -r 0.org 0'''
  
 
|-
 
|-
Line 160: Line 189:
  
 
'''gedit sampleDict'''
 
'''gedit sampleDict'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Open the '''sampleDict''' file using '''gedit.'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Open the '''sampleDict''' file using '''the editor of your choice.'''
  
 
|-
 
|-
Line 167: Line 196:
  
  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go to the bottom of the file and remove '''U.Component(0).'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go to the bottom of the file and '''Remove U.Component(0).'''
  
  
Line 181: Line 210:
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''cd ..'''
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Type '''cd ..'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go one level back by typing '''cd ..'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go one level back by typing cd ..
  
 
|-
 
|-
Line 195: Line 224:
  
 
'''pyFoamRunner.py rhoCentralFoam'''
 
'''pyFoamRunner.py rhoCentralFoam'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Now we will use the '''pyFoam utility''' of '''pyFoamRunner.py'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Now we will use the '''pyFoam utility of pyFoamRunner.py'''
  
  
Line 208: Line 237:
  
  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go back to the '''terminal''' and type '''ls.'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Go back to the terminal and type '''ls.'''
  
  
We can see the '''log''' files which are generated.
+
We can see the log files which are generated.
  
 
|-
 
|-
Line 249: Line 278:
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : Summary
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;"| Show slide : Summary
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| In this tutorial, we learnt about '''PyFoam Utilities.'''
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Let us summarize.
 +
 
 +
 
 +
In this tutorial, we learnt about '''PyFoam Utilities.'''
  
  
Line 257: Line 289:
 
# '''pyFoamRunner.py''' to run the '''solver'''  
 
# '''pyFoamRunner.py''' to run the '''solver'''  
 
# '''pyFoamSamplePlot''' utility to generate a '''png''' file  
 
# '''pyFoamSamplePlot''' utility to generate a '''png''' file  
 +
 +
  
 
|-
 
|-
Line 264: Line 298:
 
Forum to answer questions
 
Forum to answer questions
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Please post your timed queries in this forum.
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;"| Please post your timed queries in this forum.
 +
 +
 +
  
 
|-
 
|-

Revision as of 17:33, 8 February 2017

Tutorial : 22

Name : Using PyFoam Utilities

Script : Anmol Sahoo and Rahul Joshi

Narration : Rahul Joshi

Keywords : OpenFOAM, PyFoam, CFD, Linux, PyFoam utilities,shockTube


Visual Cue
Narration
Show Slide : Title Welcome to the spoken tutorial on Using PyFoam Utilities
Show Slide : Learning Objectives In this tutorial we will learn :


  • About PyFoam Utilities
  • How to use PyFoam Utilites
  • How to run and plot data for the shockTube case using PyFoam Utilites


Show Slide :

System Requirement

To record this tutorial I am using:


  • Ubuntu Linux 14.04
  • OpenFOAM v2.3.0
  • PyFoam 0.6.5


Show Slide :

Pre-requisite

As a prerequisite user should have :
  • basic knowledge of running commands on the Linux terminal
  • And some experience of running and analyzing OpenFOAM cases


Show slide : Introduction to PyFoam Utilities Let me introduce you to PyFoam utilities.


  • Utilities are Python programs which come inbuilt with PyFoam.
  • Each utility has a specific function.
  • Utilities are executed from the command line.


Show slide : List of Utilities


--------------------------

Open terminal


Type pyFoam and press Tab twice

List of utilites that can be viewed using tab completion


-------------------------------------------------------------------------------------------

Open the terminal


The list of utilities can be viewed by

  • typing pyFoam
  • and then pressing Tab key twice


Show slide : List of utilities Let me switch back to the slides.

Each utility can be executed with the –help option


This helps us to find out what it does and what its options are

Show Slide : using utilties


We are going to use the following PyFoam Utilities to solve the Shock Tube case.


We will use -

  • PyFoamRunner.py
  • PyFoamSamplePlot.py

And then plot the necessary data using PyFoam

Show slide : PyFoamRunner.py PyFoamRunner.py can be used to run cases


It also generates log files for later use

Show slide : PyFoamSamplePlot.py This utility is used to plot the various data obtained from the previously set up sampleDict.



Show slide : Problem definition


Diagram

Shock Tube is an instrument -
  • used to replicate and direct blast waves at a sensor
  • to model actual explosion and their effects

In this case, the rectangular tube has low pressure on the right side and high pressure on the left side.


Both the pressures zones are seperated by a thin diaphgram.

Type run/tutorials/compressible/rhoCentralFoam Open the Terminal and type the path for rhoCentralFoam inside compressible solver.
Type ls Type ls
Type the command shown in Narration column Type:

cd $FOAM_TUTORIALS/compressible/rhoCentralFoam/

Type ls Now type ls. You can see the shockTube case
Type cd shockTube Type cd shockTube
Point to the 3 files You can see three folders 0.org , constant and system.
On Terminal type

cp -r 0.org 0

We need to copy the 0 file from 0.org


So type cp -r 0.org 0

Type cd system Now, go to the system folder by typing

cd system

Type

gedit sampleDict

Open the sampleDict file using the editor of your choice.
In sampleDict file, do as narrated


Go to the bottom of the file and Remove U.Component(0).


Replace it with Ux Uy and Uz.


Remove rho as well.

Save the file and exit Save and exit the file.
Type cd .. Go one level back by typing cd ..
Type blockMesh Run the command blockMesh to mesh the geometry.
Type setFields After this type setFields to set the pressure boundary condition.
Type

pyFoamRunner.py rhoCentralFoam

Now we will use the pyFoam utility of pyFoamRunner.py


Type pyFoamRunner.py <followed by name of the solver > i.e. RhoCentralFoam


This runs the case and creates a postProcessing log.

Switch to the terminal and type ls


Go back to the terminal and type ls.


We can see the log files which are generated.

Type sample Now type sample to run the sample utility.
Type

pyFoamSamplePlot.py ./ --dir=postProcessing/sets –info

After this we can plot for various time steps using-


pyFoamSamplePlot.py ./ --dir=postProcessing/sets –info


This will show which fields we have with us.

Type pyFoamSamplePlot.py ./ --dir=postProcessing/sets --field=T --mode=timesInOne | gnuplot Then type pyFoamSamplePlot.py ./ --dir=postProcessing/sets --field=T --mode=timesInOne | gnuplot
The output generated will be a png file.
Type ls


Highlight/point to the png file

Type ls.


We can see the png file which is generated.

Show slide : Summary Let us summarize.


In this tutorial, we learnt about PyFoam Utilities.


We also learnt to-

  1. Check for various pyFoam utilities
  2. pyFoamRunner.py to run the solver
  3. pyFoamSamplePlot utility to generate a png file


Show Slide


Forum to answer questions

Please post your timed queries in this forum.



Show Slide


Forum to answer questions

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


For more details , visit this website.

Thank You This is Rahul Joshi from IIT Bombay signing off. Thanks for watching

Contributors and Content Editors

Nancyvarkey, Viraj20feb