CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Accessing the position and diameter of lagrangian particles (http://www.cfd-online.com/Forums/openfoam-programming-development/131908-accessing-position-diameter-lagrangian-particles.html)

ahcai007 March 22, 2014 10:35

Accessing the position and diameter of lagrangian particles
 
Hi all,

I am working on a code to track lagrangian particles by refering to Jelena Andric's work:
http://www.tfd.chalmers.se/~hani/kur...dric_Final.pdf

I successfully replicated the work in OF20x.

My problem now is that I am unable to access the position and diameter of the particles. I know that there is a function in particle.H to access position but I don't know how to tap into it and get access it.

I tried
Code:

    const particle& par = particle.Foam::particle::position();
but it didn't work.

Anyone have any idea how to output the diameter and positions of all the particles inside the domain??

Thanks.

Regards,
Ahcai

gschaider March 25, 2014 18:42

Quote:

Originally Posted by ahcai007 (Post 481474)
Hi all,

I am working on a code to track lagrangian particles by refering to Jelena Andric's work:
http://www.tfd.chalmers.se/~hani/kur...dric_Final.pdf

I successfully replicated the work in OF20x.

My problem now is that I am unable to access the position and diameter of the particles. I know that there is a function in particle.H to access position but I don't know how to tap into it and get access it.

I tried
Code:

    const particle& par = particle.Foam::particle::position();
but it didn't work.

Anyone have any idea how to output the diameter and positions of all the particles inside the domain??

Thanks.

Regards,
Ahcai

No offence Ahcai, but it seems that you're currently in the CargoCultProgramming-phase. I won't comment on the details of your code. I'd strongly suggest that you get an introductory C++-text and figure out why this doesn't work on so many level. Also familiarize yourself with Doxygen to find yourself with OF-classes

Concerning output of diameters and positions: these are usually written at every regular output in a folder lagrangian inside the timestep. So no need to reinvent the wheel there.

ahcai007 March 26, 2014 09:35

Quote:

Originally Posted by gschaider (Post 482102)
No offence Ahcai, but it seems that you're currently in the CargoCultProgramming-phase. I won't comment on the details of your code. I'd strongly suggest that you get an introductory C++-text and figure out why this doesn't work on so many level. Also familiarize yourself with Doxygen to find yourself with OF-classes

Concerning output of diameters and positions: these are usually written at every regular output in a folder lagrangian inside the timestep. So no need to reinvent the wheel there.

Hi Bernhard,

Thanks for your advice. Frankly speaking, indeed I am in this phase and struggling to get out of it. I only started using OpenFOAM for a year and have been self-studying it up till now. Same goes for C++. I have an overall picture of the working of C++ (although still not an expert), I have understood the working of class, how to access them and so on... However, I am still unable to link the knowledge of C++ to OpenFOAM. To me, they are similar yet different at the same time. Any advice on how to link them to a novice in OpenFOAM?

As for the diameter and position, I am aware that the they are output (including the velocity of particles) in the lagrangian folder at each timestep. However, I still can't find a way to access them. The reason for accessing them is so that I can do some additional calculation on them before they are output.

Any advice on how to get them out?

Thanks~

gschaider March 31, 2014 19:22

Quote:

Originally Posted by ahcai007 (Post 482198)
Hi Bernhard,

Thanks for your advice. Frankly speaking, indeed I am in this phase and struggling to get out of it. I only started using OpenFOAM for a year and have been self-studying it up till now. Same goes for C++. I have an overall picture of the working of C++ (although still not an expert), I have understood the working of class, how to access them and so on... However, I am still unable to link the knowledge of C++ to OpenFOAM. To me, they are similar yet different at the same time. Any advice on how to link them to a novice in OpenFOAM?

Not really. Most of the time I think "which utility does something similar". Then I check the sources of that utility. Check the Doxygen. And then a picture starts to emerge.

Quote:

Originally Posted by ahcai007 (Post 482198)
As for the diameter and position, I am aware that the they are output (including the velocity of particles) in the lagrangian folder at each timestep. However, I still can't find a way to access them. The reason for accessing them is so that I can do some additional calculation on them before they are output.

Any advice on how to get them out?

If the info that is written to disk is sufficient for your calculation then it might be easier to write a script that reads those text files from disk and does the calculation.

Another possibility might be the new particle-parser in swak4Foam (shown in this presentation http://openfoamwiki.net/staticPages/...tml#/sec-2-1-4 ) but its hard to tell if that might work without knowing what you want to calculate

Other than that the codes in $FOAM_SRC/lagrangian/intermediate/submodels/CloudFunctionObjects/ might give you an idea how to get particle info out of a cloud


All times are GMT -4. The time now is 00:56.