CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   do particle tracking in paraview? (http://www.cfd-online.com/Forums/openfoam-paraview/82036-do-particle-tracking-paraview.html)

phsieh2005 November 14, 2010 09:05

do particle tracking in paraview?
 
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

gwierink November 15, 2010 04:33

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.


http://users.tkk.fi/%7Egwierink/exte...lyph-small.png

7islands November 15, 2010 06:52

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

http://dl.dropbox.com/u/7352393/Part...Screenshot.png

phsieh2005 November 15, 2010 07:43

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

gwierink November 16, 2010 03:22

Hi Pei,

Perhaps the
Code:

particleTracks
utility is interesting for you as well.

phsieh2005 November 16, 2010 14:16

Dear Gijs,

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

Pei-Ying

gwierink November 17, 2010 03:43

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

phsieh2005 November 17, 2010 07:59

Thanks a lot Gijs!

Pei-Ying

Prash March 28, 2011 14:28

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

gwierink March 28, 2011 14:51

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)" ...

Prash March 28, 2011 15:41

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 (Post 301247)
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)" ...


gwierink March 29, 2011 02:37

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 March 29, 2011 08:28

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 (Post 301305)
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 ..)


gwierink March 29, 2011 09:25

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 March 29, 2011 10:07

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 (Post 301368)
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).


gwierink March 29, 2011 10:54

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 March 29, 2011 11:30

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 (Post 301383)
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



gwierink March 29, 2011 12:18

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


motahar May 20, 2011 04:44

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

maysmech May 22, 2011 21:43

Quote:

Originally Posted by gwierink (Post 283721)
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.


All times are GMT -4. The time now is 15:32.