CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   A question in understanding icoLagrangeFoam by Gschaider (

xiao April 2, 2008 18:32

Hi all, I am newcomer to Open
Hi all,
I am newcomer to OpenFoam and I am trying to do Lagrangian particle tracking. Gschaider's icoLagrangeFoam is a good starting point. There are a few issues not clear to me. It would be greatly appreciated if anyone could answer my questions or give me a pointer.

1. When in the main program is the Lagrangian field (as well as the Eulerian field) written to the files? Is it the following statement:


runTime is a "Time" object. Does it have the reference to all the fileds in the program and output them according to write control parameters?
In addition, the position/mass/density/velocity of the "IncompressibleCloud" do not seem to be a "field".

2. The construction of particles. It seems that the particles can only be generated by "injection". If we want to read in a particle list (position/velocity/index/ etc.), how would that be done?

3. When the IncompressibleCloud object is created with: (in createParticles.H)

InCompressibleCloud cloud(vpi, U)

there is no particle in the object, right?

5. (OF in general) In createParticles.H, there is a statement:

pointMesh pMesh(mesh)

What points are stored in the pointMesh object pMesh?

Thanks very much.


hjasak April 2, 2008 19:31

Welcome! 1) correct: runTi

1) correct: runTime is a database of all objects that need writing and it will make them all write themselves into files.

2) Make a new injector which reads the file and introduces particles into the simulation based on file data. Sounds a bit agricultural - maybe you can find a better way of generating particles, eg. doing a calculation. It all depends, of course, on where the file comes from...

3) a cloud is a collection of particles

4) there's no 4!

5) pointMesh is just wrapping around polyMesh/fvMesh to make it easier to support point-based fields. It stores no data and refers to the same points (vertices) of the original mesh.



xiao April 3, 2008 00:50

Thanks very much for the reply
Thanks very much for the reply from Hrv.
It has been very helpful. Here are a few follow-ups:

1) There are many objects in a program, and only a few of them would write into files (p, U, T). How do they make the "requests" or "sign-up" so that runTime knows who will be written to files? That is necessary to know when I want to control what to output. and I am curious in general about how this is done.

2). That is a smart idea. I think the essential difficulty for me was that I am not familiar with the idea of IO in OpenFoam in general, as I asked in my earlier post. The IO features seems be hidden very deep (either in IOoject, or regObject ?), which are then inherited by many classes, and I had difficulty of following all these.

3) & 5): I understand that Cloud needs to have a mesh and a collection of particles, but I am not clear why the construction of a Cloud object need three following steps:
1. Construct pointMesh from a fvMesh:
pointMesh pMesh(mesh)
2. construct an interpolatino object:
volPointInterpolation vpi(mesh, pMesh)
3. the cloude itself:
IncompressibleCloud cloud(vpi, U)

Intuitively, I would think a Lagrangian field (say, diameter or velocity of the particles) and a fvMesh would be enough. Why construct pointMesh and volPointInterpolation when fvMesh all the information (including the vertex and volume centers and much more)

Finally a general comment. I am trying to start coding ASAP, but when trying to understand the code I feel overwhelmed by the details above. I think OpenFoam is very well written, powerful, and with very clear and dedicated hierarchy, taking advantage of almost all features of C++. My question is: Am I having the wrong learning approach and too concerned with the details or is the learning curve is supposed to be this steep? I mean, did others have the same initial difficulty as well?

Anyway, I have been using OpenFoam and digging up the source code for about 2 weeks, and I think OF is a miracle! The code is both scientific work and art work! It has been very enjoyable to read it and try to understand it. The only pity is that there is no document explaining the designing idea behind it. The user guide explained the usage and programming guide explained the objective-oriented design of "field" and "mesh", but the IO, interpolation, and many other features are still not explained. To understand, I had to navigate through the Doxygen document and the source code.

Any comments and hint are appreciated.


gschaider April 3, 2008 06:52

Hi Xiao! @3&5: the interpol
Hi Xiao!

@3&5: the interpolation stuff is needed for the particles to "see" the velocity of the fluid at their present location (for drag force calculation and stuff)

@1: That is controlled by the IOobject::AUTO_WRITE-stuff that you see during the construction of the fields

@2: I wouldn't look too close into these classes in the beginning. As a start it is sufficient to know "If I set AUTO_WRITE this stuff will get written at appropriate times"


xiao April 3, 2008 12:20

Hi Bernhard, Thanks for the
Hi Bernhard,

Thanks for the reply. I found the "Auto_WRITE" stuff in the "createField.H" function, which solved the question. But I did not find where you ask the output of lagrangian field of particle positions.

I found in your "IncompressibleCloudIO.C":

IOField<vector> U(fieldIOobject("U"), np);

And the same for p and m.

However, in the "lagrangian" folder, the position was also written. Where did you output the position field?

2. Another question is about your particle generation. It seems to me that the current scheme of generating particle is rather restrictive for me in that:
1) There is no particle initially. The cloud is empty.
2) Particles are only generated by "injection"; Only one particle is generated per time step (between "tStart" and "tEnd" specified in the file "cloudProperties". Thus, the number of particles generated depends on the duration between tStart and tEnd, as well as the time step.
Is that correct?
For my current purpose, all the particles are there initially. I want to change the particle generating scheme to either generate by reading from a file, or equivalently, inject all particles before the actual simulation starts. Could you give me some hints on how to do that?


gschaider April 3, 2008 15:18

Hi Xiao! Sorry. I can only
Hi Xiao!

Sorry. I can only do a lot of handwaving here as I currently don't have access to the source and I havn't worked on it for quite some time (as they say: "Uncommented code older than 3 months could have been written by anybody else")

@1: I didn't write the position field. The super-class (the particle-class you'll find in $FOAM_SRC/lagrangian/basic) does. And rightfully so, because the position belongs to it. Look out for a call to the equivalent method of the super-class

@2.1: Yeah. But they will be read in if some information is found in the 0/lagrangian
@2.2: The solver was only intended as a demonstration how to add lagrangian particles. I never bothered to write an injection method that would fit everone's needs. So you'll have to modify the injector to fit your needs. For a more complex example have a look at the injector-Submodels in the $FOAM_SRC/lagrangian/dieselSpray. For your purpose you could write an injector that inserts all the particles at the start (or create them during the construction of the cloud)


xiao April 4, 2008 11:32

Thanks to Bernhard. The explan
Thanks to Bernhard. The explanation is very helpful. I appreciate it. I will try the two approaches you mentioned: 1) write a function to inject all the particles initially; and 2) prepare files in 0/lagrangian (d, m, U) to initialize the langrangian field.

ivan_cozza October 27, 2008 03:17

Hi to everybody! I'm managing
Hi to everybody!
I'm managing to do some calculation in which a tracking of massles particles is involved. What should be a easy way to enter in the "cloud" world? So, what shold be an easy tutorial to understand how the lagrangian tracking in OF works?
I'm not interested in forces, interactions, etc, only in the tracking of massles particles that keep with them a reference to a certain list.
Thank you!

All times are GMT -4. The time now is 03:25.