CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] do particle tracking in paraview?

Register Blogs Community New Posts Updated Threads Search

Like Tree25Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2010, 09:05
Default do particle tracking in paraview?
  #1
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Dear OpenFOAMers,

I completed a transient interFoam case. I am wondering if it is possible to do lagrangian particle tracking in paraview/paraFoam? I do not really care about the forces/sizes of the particles. I just want to show, if massless/sizeless particles released from certain locations, their paths as function of time.

Thanks!

Pei
Luttappy likes this.
phsieh2005 is offline   Reply With Quote

Old   November 15, 2010, 04:33
Default
  #2
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Pei-Ying,

To visualize Lagrangian particles i convert the case to VTK
Code:
foamToVTK
Open the case to visualize what I want to see, e.g. velocity or phase void fraction. Then, with the case open, got to File > Open and open the lagrangian defaultCloud file in the VTK directory. To visualize the particles, select the lagrangian VTK file and make a glyph of that using the glyph button. Then, select as scalar "d" and further down "sphere" and the radius etc you want. in the display tab you can then select "color by" to color the particle by size, cellID, or whatever you like.


sarina likes this.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   November 15, 2010, 06:52
Default
  #3
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi guys,

Or in case if you want to create particle tracking with pathlines that animates over time completely within ParaView from case without lagrangian data, yes you can, but with a bit complex visualization pipeline (see the Pipeline Browser in the screenshot attached below).

The key is to apply Temporal Interpolator that allows you not only to interpolate saved time steps (that are typically too sparse to create a smooth particle tracking animation by themselves) but also to access temporal filters of ParticleTracer and Particle Pathlines. And note that you can create particle seeds from whatever source you like (Plane, Point Source Line, etc) in the Sources menu.

There are lots of options across the filters and sources that affect the formation of the pathlines so you need to do some experiments. Also, in my experience ParticleTracer of ParaView 3.8.0 often crashes ParaView so you might need a git version of ParaView 3.9.

Takuya

7islands is offline   Reply With Quote

Old   November 15, 2010, 07:43
Default
  #4
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Hi, 7islands,

Thanks! This is exactly what I am looking for. I did not include lagrangian particles when running the interFoam case. I am hoping to plot the particles in paraFoam/paraview.

I did experiment particleTracer very briefly (before I saw your post) and could not quite figure out how to do it. Now, I will try to follow your steps to see if I can get it right this time.

Pei
phsieh2005 is offline   Reply With Quote

Old   November 16, 2010, 03:22
Default
  #5
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Pei,

Perhaps the
Code:
particleTracks
utility is interesting for you as well.
Luttappy likes this.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   November 16, 2010, 14:16
Default
  #6
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Dear Gijs,

Thanks! But, where can I find this particleTracks code?

Pei-Ying
phsieh2005 is offline   Reply With Quote

Old   November 17, 2010, 03:43
Default
  #7
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Dear Pei-Ying,

particleTracks is a utility that is part of the OpenFOAM package (see here under "New utilities"). It lives in $FOAM_UTILITIES/postProcessing/lagrangian/particleTracks. In the case directory you need to copy a file called particleTrackProperties into the constant/ directory:
Code:
cp $FOAM_UTILITIES/postProcessing/lagrangian/particleTracks/particleTrackProperties constant/
Then, in the case, type
Code:
particleTracks
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   November 17, 2010, 07:59
Default
  #8
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 334
Rep Power: 18
phsieh2005 is on a distinguished road
Thanks a lot Gijs!

Pei-Ying
phsieh2005 is offline   Reply With Quote

Old   March 28, 2011, 14:28
Default
  #9
New Member
 
Prashant Gupta
Join Date: Mar 2011
Location: Edinburgh
Posts: 29
Rep Power: 15
Prash is on a distinguished road
Dear People

I tried to run FoamToVTK utility inside my case directory
But it didnt run through properly, instead it gave me a message like :

/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 1.7.1-03e7e056c215
Exec : foamToVTK
Date : Mar 28 2011
Time : 17:43:35
Host : vlxhead2
PID : 16896
Case : /home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

At time: 0.001 detected cloud directory : "defaultCloud"
Time: 0
volScalarFields : alpha p k epsilon
volVectorFields : Ua Ub

Internal : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/mono1.5mmPeak-1.7.x-sample_0.vtk"
Original cells:540 points:1184 Additional cells:0 additional points:0

Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/inlet/inlet_0.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/outlet/outlet_0.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/walls/walls_0.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/defaultFaces/defaultFaces_0.vtk"
Lagrangian: "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/lagrangian/defaultCloud/defaultCloud_0.vtk"
Time: 0.001
volScalarFields : alpha p k nutb epsilon
volVectorFields : Ur Ub U Ua Uc

Internal : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/mono1.5mmPeak-1.7.x-sample_5.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/inlet/inlet_5.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/outlet/outlet_5.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/walls/walls_5.vtk"
Patch : "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/defaultFaces/defaultFaces_5.vtk"
Lagrangian: "/home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/VTK/lagrangian/defaultCloud/defaultCloud_5.vtk"
labels : origId origProcId tag
scalars : d
vectors : U positions
spherical tensors :
symm tensors :
tensors :


--> FOAM FATAL IO ERROR:
wrong token type - expected int found on line 22 the punctuation token '('

file: /home_g07/s1065046/OpenFOAM/s1065046-1.7.1/run/mono1.5mmPeak-1.7.x-sample/mono1.5mmPeak-1.7.x-sample/0.001/lagrangian/defaultCloud/positions at line 22.

From function operator>>(Istream&, int&)
in file primitives/ints/int/intIO.C at line 68.

FOAM exiting



Eventually a Folder named VTK was made in the case directory, but it didn work. Please help. I am not able to understand why it didnt work.

Best Wishes
Prashant
Prash is offline   Reply With Quote

Old   March 28, 2011, 14:51
Default
  #10
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Prashant,

Quote:
spherical tensors :
symm tensors :
tensors :


--> FOAM FATAL IO ERROR:
wrong token type - expected int found on line 22 the punctuation token '('
Looks like there's a typo somewhere; foamToVTK wants to read a tensor starting with an integer, but found a bracket. Probably it reads somewhere "((0 0 0 0 0 0 0 0 0)" instead of "(0 0 0 0 0 0 0 0 0)" ...
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   March 28, 2011, 15:41
Default
  #11
New Member
 
Prashant Gupta
Join Date: Mar 2011
Location: Edinburgh
Posts: 29
Rep Power: 15
Prash is on a distinguished road
Hey,

I checked in file, but there was not an instance of (( occuring . Anyways its a OpenFoam result file that it has indicated to a have a error in, I am not sure how to proceed, is there any other way to post process lagragian particles than using FoamToVTK.

Best Wishes
Prashant








Quote:
Originally Posted by gwierink View Post
Hi Prashant,



Looks like there's a typo somewhere; foamToVTK wants to read a tensor starting with an integer, but found a bracket. Probably it reads somewhere "((0 0 0 0 0 0 0 0 0)" instead of "(0 0 0 0 0 0 0 0 0)" ...
manuc likes this.
Prash is offline   Reply With Quote

Old   March 29, 2011, 02:37
Default
  #12
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Prashant,

Perhaps it's possible to use foamToTecplot, but i don't know. I don't have Tecplot and always use ParaView with VTK files.

Still, there must be something wrong with line 22 in some file in 0.001, whoever wrote that file . What does
Code:
awk 'FNR==22 {print FILENAME": "$0}' 0.001/*
say? (assuming that it is time 0.001 that we're deaing with ..)
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   March 29, 2011, 08:28
Default
  #13
New Member
 
Prashant Gupta
Join Date: Mar 2011
Location: Edinburgh
Posts: 29
Rep Power: 15
Prash is on a distinguished road
Hey ,

I found the file it mentions, it reads like

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class vectorField;
location "0.001";
object positions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


2160
(
(0.00101927 0.000749988 0.00222566)
(0.00948121 0.000749997 0.000872757)
(0.0132042 0.000749993 0.0036906)
(0.0151473 0.00180264 0.00075)
(0.0207055 0.000749997 0.000750031)
(0.0215812 0.000749995 0.00196801)
(0.0271111 0.000749991 0.00075002)
(0.0310265 0.000749997 0.00252693)
........

)

Though it reads a punctuation mark at line 22 which is the fourth line after 2160

(0.00948121 0.000749997 0.000872757)

This file is a result file generated by OpenFoam , even if I want I cant change its format. Can you copy paste a result file you get after you execute FoamToVTK. Please suggest how to go about this.

Also I tried to run another code and tried using FoamToVTK , it still didnt work, but gave some other error. I am not sure what its upto

Can you help ?


Best Wishes
Prashant









Quote:
Originally Posted by gwierink View Post
Hi Prashant,

Perhaps it's possible to use foamToTecplot, but i don't know. I don't have Tecplot and always use ParaView with VTK files.

Still, there must be something wrong with line 22 in some file in 0.001, whoever wrote that file . What does
Code:
awk 'FNR==22 {print FILENAME": "$0}' 0.001/*
say? (assuming that it is time 0.001 that we're deaing with ..)
Prash is offline   Reply With Quote

Old   March 29, 2011, 09:25
Default
  #14
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi Prashant,

Hmm, at first glance the file looks alright. Can you e-mail me the case with time steps 0 and 0.001? Then I can have a go ... My e-mail is gijsbert dot wierink at gmail dot com.

PS Please send a tar file. In case you don't know how, do "tar -pczf case.tar.gz case" in the directory where you case directory lives (here, "case" is the name of your case).
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   March 29, 2011, 10:07
Default
  #15
New Member
 
Prashant Gupta
Join Date: Mar 2011
Location: Edinburgh
Posts: 29
Rep Power: 15
Prash is on a distinguished road
Hey Thanks very much,

I have sent you email with the whole folder I run FoamToVTK command. In it there are cases 0 and 0.001

please help


Best Wishes
Prashant







Quote:
Originally Posted by gwierink View Post
Hi Prashant,

Hmm, at first glance the file looks alright. Can you e-mail me the case with time steps 0 and 0.001? Then I can have a go ... My e-mail is gijsbert dot wierink at gmail dot com.

PS Please send a tar file. In case you don't know how, do "tar -pczf case.tar.gz case" in the directory where you case directory lives (here, "case" is the name of your case).
Prash is offline   Reply With Quote

Old   March 29, 2011, 10:54
Default
  #16
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi!

I received your e-mail and fixed the case (or at least it converts to VTK without error). The trick was to change "vectorField" to "volVectorField" in <timeStep>/lagrangian/defaultCloud/positions. Also, you need to add a space and a zero at the end of every vector line in the same file.

Since you have more than 2000 particles, you'll probably go nuts if you do this by hand. This should do the job in the case dir:
Code:
sed -i '12s/vector/volVector/' 0.001/lagrangian/defaultCloud/positions
sed -i '21,2180s/$/ 0/g' 0.001/lagrangian/defaultCloud/positions
samir likes this.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   March 29, 2011, 11:30
Default
  #17
New Member
 
Prashant Gupta
Join Date: Mar 2011
Location: Edinburgh
Posts: 29
Rep Power: 15
Prash is on a distinguished road
Hey ,

It worked, thanks very much for your help
Also if you could suggest how can I do these changes for more time steps like 0.001, 0.002.... 0.1 ( 100 directories ) all at once.

Best Wishes
Prashant




Quote:
Originally Posted by gwierink View Post
Hi!

I received your e-mail and fixed the case (or at least it converts to VTK without error). The trick was to change "vectorField" to "volVectorField" in <timeStep>/lagrangian/defaultCloud/positions. Also, you need to add a space and a zero at the end of every vector line in the same file.

Since you have more than 2000 particles, you'll probably go nuts if you do this by hand. This should do the job in the case dir:
Code:
sed -i '12s/vector/volVector/' 0.001/lagrangian/defaultCloud/positions
sed -i '21,2180s/$/ 0/g' 0.001/lagrangian/defaultCloud/positions
Prash is offline   Reply With Quote

Old   March 29, 2011, 12:18
Default
  #18
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi,

Haha, our mails crossed again .

Just make a bash script something like this:

Code:
#!/bin/bash

for i in `ls -d */ | sed -e 's/\///'`;do
    sed -i '12s/vector/volVector/' $i/lagrangian/defaultCloud/positions
    sed -i '21,2180s/$/ 0/g' $i/lagrangian/defaultCloud/positions
done
Save the script in ~/bin (make that dir if it's not there), and make it executable. Suppose you name the script foo, then
Code:
chmod +x ~/bin/foo
. ~/.bashrc
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   May 20, 2011, 04:44
Default
  #19
New Member
 
M. A.
Join Date: Jul 2010
Posts: 27
Rep Power: 16
motahar is on a distinguished road
Hi friends,
I'm simulating a tube with water flow.
The tube encounters boiling near the wall.
I intend to calculate 'void fraction versus enthalpy' along the channel.
Can you help me how to calculate void fraction?

I'm in an emergency condition.
Waiting for your comments!!!

Thanks Everybody
motahar is offline   Reply With Quote

Old   May 22, 2011, 21:43
Default
  #20
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Quote:
Originally Posted by gwierink View Post
Dear Pei-Ying,

particleTracks is a utility that is part of the OpenFOAM package (see here under "New utilities"). It lives in $FOAM_UTILITIES/postProcessing/lagrangian/particleTracks. In the case directory you need to copy a file called particleTrackProperties into the constant/ directory:
Code:
cp $FOAM_UTILITIES/postProcessing/lagrangian/particleTracks/particleTrackProperties constant/
Then, in the case, type
Code:
particleTracks
Dear gwierink,

If i understand truly this works when the simulation has been done with lagrangian solvers.

I have simulated a hydrocyclone with pisoFoam solver for one phase.

Now i want inject particles as second phase and do particle trajectory for them. I didn't find any suitable solver in lagrangian solvers.

What is your suggestion for me?

Regards.
maysmech is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] ParaView ErrOr soheil nazmdeh ParaView 1 August 17, 2013 08:40
injection problem Mark New FLUENT 0 August 4, 2013 02:30
Particle Tracking for ion Jun CFX 2 August 31, 2010 09:19
particle tracking in unsteady flow peterchen FLUENT 1 July 22, 2010 23:18
restarting lagrange (particle tracking) simulation dbdias CFX 0 September 22, 2007 20:26


All times are GMT -4. The time now is 23:59.