CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Lagrangian Particle Tracking (https://www.cfd-online.com/Forums/openfoam-solving/58447-lagrangian-particle-tracking.html)

stephan January 7, 2006 07:15

hi, i am working on a new c
 
hi,

i am working on a new collisionmodel for the euler/lagrangian model.
the class spray works like a container-class for the particles but is there a way to get real pointers instead of iterators to get access to special particles in the class spray?
til now i am skipping through the field like that:
spray::iterator iteratorname = spray.begin() ...
but i need pointers for the particles which are already included in the container.it would be very nice if somebody could help me with that problem.
stephan

stephan January 7, 2006 09:44

hi, maybe my question was n
 
hi,

maybe my question was not clearly formulated:
what i am looking for is a opportunity to access a
particle with an index like spray[number] or direct with a pointer.
thanks in advance
stephan

hjasak January 7, 2006 16:22

Which pointer exactly would yo
 
Which pointer exactly would you like? A Cloud stores the particles in a doubly-linked list, so getting access of the sort:

spray[number]

will still cost you a sweep through the container.

I think you should re-consider your algorithm or implementation.

Enjoy,

Hrv

stephan January 8, 2006 07:34

hi, thanks for your fast an
 
hi,

thanks for your fast answer. actually i wasnt sure what kind of list it is...
i will have to sweep through the container anyway once per timestep to create my own list. i created a kind of "local search area" for the collision-detection and therefore i need pointers to the particles, since the order in the original list has nothing to do with the place where the partice really is. so i want to avoid sweeping through the whole list more than once and searching instead in a smaller "local list" - which needs therefore some kind of index,pointer or reference to the "local particles".
so sweeping once per timestep the whole list from start to end is necessary to findout where the particles are but while checking this, i want to take a pointer to the particle and put into my own "local list".
so i think a pointer to a particle (particle*) would be the right one. but i just dont know how to get this from the iterator.
thanks in advance
stephan

niklas January 9, 2006 02:39

If your iterator is this sp
 
If your iterator is this

spray::iterator pIter = spray.begin();

you access the element by ()
and since they are parcels pIter() will be a parcel.
To get a 'pointer' or a reference to the parcel is done like this
parcel *p = &(pIter())
or
parcel& p = pIter();

And the rest you can probably work out for yourself.

N

stephan January 9, 2006 08:29

hi, thanks for the help! j
 
hi,

thanks for the help!
just in time i found pretty much the same as you mentioned:
parcel* p=&(*pIter);
but still:thanks for helping me!!
stephan

scurtu March 17, 2006 08:10

hi, I need a module for partic
 
hi, I need a module for particle tracking in an isothermal turbulent fluid flow. Is somebody who developed an OpenFOAM module for such a problem?
I would be thankfully if somebody can help me.

DNS

hjasak March 18, 2006 05:52

Yup, I've written a small exam
 
Yup, I've written a small example a while back, doing the tracking of massless particles in an incompressible flow. It was hooked up on icoFoam, but moving it to a turbulent solver would be very easy.

Give me a shout if you want a look and I'll try to revive it.

Hrv

gschaider March 20, 2006 04:21

Hi Nicoleta! I posted such
 
Hi Nicoleta!

I posted such a thing some time ago to the Wiki:

http://openfoamwiki.net/index.php/Contrib_icoLagr angianFoam

It's not a "addWaterAndStirr" kind of thing but it can serve as an example how to add Lagrange particles (using the facilities that are already present in OF) to a solver of your choice (the physics (drag term, particle mass, injection etc) should be adapted to your problem).

PS: But if you can get a solver from Hrv: take it

ville September 24, 2008 12:43

Hi, How can I print out the
 
Hi,

How can I print out the trajectory of a given
parcel?

To be more precise: I know how to print to a file
in parallel but I would need to define a reference
to K parcels and on every time step I would like to sweep those parcels and print their coordinates to the processor directories. I tried defining references to two parcels, p1 and p2 and then to print the parcels that are 'between' those two in the spray cloud. However, there was a problem even doing the following at top-level:

spray::const_iterator parcelNN = dieselSpray.begin();

const parcel *p = &(parcelNN());

Info << p.position().x() << "\n" << endl;

What goes wrong here??!

Thanks!

-Ville

stephan September 24, 2008 13:35

hi ville, try "parcelNN().p
 
hi ville,

try "parcelNN().position().x()" instead - this should work.

regards
stephan

ville September 25, 2008 05:00

Hi, thanks for the answer! Th
 
Hi,
thanks for the answer! The answer above works.
However, if I declare a reference to a parcel
such as

spray::const_iterator parcelNN = dieselSpray.begin();

const parcel* p1;

p1 = &(parcelNN());

the . referencing wont work but
one has to state e.g. p1->position().z()
to refer to the z coordinate.

Q1: There comes a problem in parallel if
a certain parcel is to be tracked since it
seems that e.g. dieselSpray.begin() refers to the
"first" parcel on a certain processor. Thus if
I initially decide I want to follow a parcel
that is the 'first' on processor0
and it goes to processor1 then I loose the parcel.
Is there a way to keep a reference globally to a certain
parcel (keeping in mind that I'd like to print
out the trajectory of a certain droplet)?

Q2: Or is it maybe the simplest to just tag
the parcels according to the order they are injected and then just print the coordinates
for parcels that have a label, say, in between
1000...1020 ?

Thanks!
-Ville

stephan September 25, 2008 06:29

hi, Q1: give the parcel
 
hi,



Q1: give the parcel a label and use an if-statement to checkout the right parcel.

regards
stephan
p.s. there is already a lagrangian class which labels a particle - but it is easy to do ..

ville October 20, 2008 10:36

Hi, I've been doing a lot of
 
Hi,
I've been doing a lot of other stuff lately but now back to finding out how would I print the particle trajectories in a parallel simulation..

In single proc run labeling the parcels works as follows:

1) in parcel.H declare two variables:

static label m_nNextID
label m_nID;

2) in the constructor in parcel.C
set m_nID = m_nNextID; and then

increment
m_nNextID by 1 this labels parcels
from 0 ... X in the order they are introduced
(if mnNextID is initialized to zero)

3) defining a function GetID in parcel.C
to return m_nID; completes the labeling
and now we can be happy and print the
parcel coordinates and labels to see the
paths of the particles



4) but how sad! in parallel this doesn not
work anymore! Or it works as long as the
particles stay on proc0 but when they go to
proc1 the parcel label is lost and it
turns to something irrelevant !! Could anyone
give me any hint
why this is so and what should be done differently
or what changes should be done in order to
make the parcel label to be copied
to the new processor ?

Regards,
-Ville

ville October 21, 2008 10:17

Hi, good news since yesterday
 
Hi,
good news since yesterday. The parallel problems
probably arised (regarding labeling of the parcels)
because the parcelIO-files were not modified.
That's why the parcel label did not get copied
from proc0 to proc1 etc.

I suppose a fast way to go around this problem
is to simply create a copy of the dieselSpray class
for personal use and then to start modifying the class. Then, as I am interested in non evaporating
sprays without parcel deformation it's possible
to borrow e.g. the variable ddev from the parcel class and to update ddev to get the label of the parcel in the constructor with the running number using the variable m_nID (as described above).

HOWEVER, it's important to note that this does
not work if one uses e.g. the ETAB breakup
model. So the above way-around applies only if
ddev is not needed elsewhere.


If anyone has a better, more elegant way of doing
this please yell http://www.cfd-online.com/OpenFOAM_D...part/happy.gif !

Regards,
Ville

parcel class.

az1362f September 4, 2009 10:31

droplet position
 
Hi

I tried to write position and relative velocity of each parcel after evolving spray by adding these line to the main solver(dieselfoam.C)

Info << "Evolving Spray" << endl;

dieselSpray.evolve();
//forAllIter(spray, dieselSpray, iter)

for

(

spray::iterator iter = (dieselSpray).begin();

iter != (dieselSpray).end();

++iter

)

{

parcel& p=iter();


vector vec=dieselSpray.UInterpolator().interpolate(p.posi tion(), p.cell())

+ p.Uturb();

scalar x= p.position().x();

scalar y= p.position().y();

scalar z= p.position().z();

scalar vrelx= p.Urel(vec).x();

scalar vrely= p.Urel(vec).y();

scalar vrelz= p.Urel(vec).z();

rel<<x<<" "<<y<<" "<<z<<" "<<vrelx<<" "<<vrely<<" "<<vrelz<< nl;

rel.close();
}
/////////////////////////////////////////////////////////////////////////////////////////
Info << "Solving chemistry" << endl;


and I compiled solver without any errors but when I tried to run dieselfoam application I face an error like this :

Evolving Spray


object is not allocated#0 Foam::error::printStack(Foam::Ostream&) in "/home/john/OpenFOAM/OpenFOAM-1.6/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/john/OpenFOAM/OpenFOAM-1.6/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 main in "/home/john /OpenFOAM/OpenFOAM-1.6/applications/bin/linuxGccDPOpt/dieselFoam"
#3 __libc_start_main in "/lib/libc.so.6"
#4 Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType) const in "/home/john/OpenFOAM/OpenFOAM-1.6/applications/bin/linuxGccDPOpt/dieselFoam"


From function const T& autoPtr<T>::operator()() const
in file /home/john/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/autoPtrI.H at line 133.

FOAM aborting

Aborted
john@spray:~/OpenFOAM/john-1.6/run/tutorials/combustion/dieselFoam/New>

I don't know where is my mistake.
I will be glad If someone help me.

su_junwei September 9, 2009 18:28

It seems that you use a autoPtr object that was not allocated or it has been released.

For instance, you pass a autoPtr object to other object or use it as a parameter will cause such a problem.

Junwei

prapanj October 6, 2009 05:00

Hi Hrv,

Could you send me the example for particle track post processing based on icoFoam that you have mentioned in this thread? It will be of great help to me.
Thank you

Prapanj

Izunna March 6, 2010 09:41

Multiphse flow
 
Can anyone tell me how to use langragian particle tracking algorithm in Matlab. I am working on particle deposition but can not continue because i do not know how to do particle tracking in multiphase flow


All times are GMT -4. The time now is 17:31.