Introductory OpenFOAM From 17th to 21st February, 2014 ... · Matteo Bargiacchi...
Transcript of Introductory OpenFOAM From 17th to 21st February, 2014 ... · Matteo Bargiacchi...
Matteo [email protected]
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Introductory OpenFOAM® Course
From 17th to 21st February, 2014
Today’s lecture
1. Post-processing tools: paraFoam and Paraview, differences and basic commands;
2. How to export animations from Paraview;3. More on post-processing complex flow patterns;4. Python scripting in Paraview 4.1.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Acknowledgements
These slides and the tutorials presented are based upon personal experience, OpenFOAM® source code, OpenFOAM® user guide, OpenFOAM® programmer’s guide, and presentations from previous OpenFOAM® training sessions and OpenFOAM® workshops.
We gratefully acknowledge the following OpenFOAM® users for their consent to use their material:• Hrvoje Jasak. Wikki Ltd.• Hakan Nilsson. Department of Applied Mechanics, Chalmers University of
Technology.• Eric Paterson. Applied Research Laboratory Professor of Mechanical
Engineering, Pennsylvania State University.• Tommaso Lucchini. Department of Energy, Politecnico di Milano.• Rupert Fisch. Technische Universitaet Muenchen.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Today’s lecture
1. Post-processing tools: paraFoam and Paraview, differences and basic commands;
2. How to export animations from Paraview;3. More on post-processing complex flow patterns;4. Python scripting in Paraview 4.1.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Paraview and paraFoam
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
● Paraview is a post-processing environment able to read and process a vast variety of formats.
● ParaFoam is a specific version of Paraview (3.14) able to directly read the output produced by OpenFOAM® without intermediate conversion
● The differences are few:- paraFoam is able to manage results from different processors without reconstruction- paraview needs the domain to be reconstructed (otherwise each single processor should be singly opened) and converted to a readable file format
reconstructParfoamToVTK
- paraview from version 4.1 onwards has a very instructive Start Trace-Stop Trace tool
A simple cavity 3D case
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
● Open the cavity simulation folder and runparaFoam
or
● Open the blended wing body simulation folder and runFoamToVTK
● Run paraview and import the *.vtk files
Hands-on session
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
● Open the Blended Wing Body simulation folder and runparaFoam
or
● Open the blended wing body simulation folder and runFoamToVTK
● Run paraview and import the *.vtk files
Group slices and plot a velocity profile
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Show Mach threshold and streamlines
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Hands-on session
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
In the course’s directory ($ptofc) you will find many tutorials (which are different from those that come with the OpenFOAM® installation), let us try to go through each one to understand and get functional using OpenFOAM®.
If you have a case of your own, let me know and I will try to do my best to help you to setup your case. But remember, the physics is yours.
Today’s lecture
1. Post-processing tools: paraFoam and Paraview, differences and basic commands;
2. How to export animations from Paraview;3. More on post-processing complex flow patterns;4. Python scripting in Paraview 4.1.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
Hands-on session
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
● Open the cylinder2D simulation folder and runparaFoam
or
● Open the blended wing body simulation folder and runFoamToVTK
● Run paraview and import the *.vtk files
Today’s lecture
1. Geometry and Mesh generation using Salome: a mixing elbow created inside the GUI;
2. Hands on to create a simple geometry inside the GUI;3. Learn how to program in python to create script for
Salome and automatize the pre-processing phase;4. Import 2D images and create 2D meshes for OpenFOAM®;
5. Import geometries and create a meshed domain of computation;
6. Post-processing tools: paraFoam and Paraview, differences and basic commands;
7. How to export animations from Paraview;8. More on post-processing complex flow patterns;9. Python scripting in Paraview 4.1.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
The Q-criterion was named after the second invariant of the velocity gradient tensor u by Hunt [1988] (see also Dubrief [2000])∇
Visualize flow patterns: The Q criterion
where
positive Q isosurfaces isolate areas where the strength of rotation overcomes the strain, thus making those surfaces eligible as vortex envelopes
Q-criterion and streamlines
Northrop YF17: iso-surfaces of Q=10^5 colored according to pressure and streamlines colored according to velocity magnitude
Q-criterion and streamlines
Open /Day2/paraview/yf17Run foamToVTK or directly run paraFoam
Launch paraview and open vtk files
Create a streamTracer filter with the parameters:
● Point source: (-3.55, 0.55, 0.55)● Number of Points: 20● Radius: 0.1
Create a Gradient Of Unstructured Data Set filter computing Vorticity and Q-criterion from the velocity field
Create a Contour filter with positive Q iso-surfaces (choose a value around 10'000)
The Calculator Filter
Let us calculate the Density field from Pressure and Temperature distributions.
Set a Calculator filter and define the following expression with the Result Array Name “density”:
p/(287.3*T)
Set another Calculator filter to check the post-processed field “density” against the calculated field “rho” with the following expression:
(density-rho)/rho
Today’s lecture
1. Post-processing tools: paraFoam and Paraview, differences and basic commands;
2. How to export animations from Paraview;3. More on post-processing complex flow patterns;4. Python scripting in Paraview 4.1.
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
The Python Shell
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”
The Python shell in paraview is a powerful plugin to automatize post-processing phases.
From version 4.0 onwards a Start Trace / Stop Trace utility is available
Unfortunately paraFoam (running on version 3.14) is not compatible with different versions. In order to use version 4.1 the environment variable should be cleaned in the following way:
● comment # source $HOME/OpenFOAM/OpenFOAM-2.2.x/etc/bashrc● Log Out and Log In again
Otherwise take advantage of the paraview module inside Salome 7.3.0
Trace an action and run a *.py script
From Tools menu click on Start Trace
DO ONE SIMPLE THING...
...and Stop Trace.
Understand the output visualized in a pop-up window and copy only the relevant snippets in your *.py script beginning with:
from paraview.simple import *
From Tools menu, click on Python Shell;Then Run Script ;
Thank you for your attention
Disclaimer
“This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.”