CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   Mapping Lagrangian particles (https://www.cfd-online.com/Forums/openfoam-bugs/63182-mapping-lagrangian-particles.html)

gschaider March 31, 2009 10:59

Mapping Lagrangian particles
 
1 Attachment(s)
Version: 1.5.x

Description: when mapping a case with lagrangian particles to a smaller mesh some of the particles keep the cell number (in the positions-file) from the old mesh which are a) wrong b) may be outside of the range of the new mesh which causes all kinds of trouble (during decomposePar, trackToFace etc)

Fix: the attached patch. For the particles in question it overwrites the celli_ with the index of the found cell (which was calculated anyway). In order to do this a write-access-method for celli_ had to be introduced

Attachment 113

mattijs April 1, 2009 05:05

Nice one. I put it in.

Ebrahim March 26, 2017 13:55

Quote:

Originally Posted by gschaider (Post 211434)
Version: 1.5.x

Description: when mapping a case with lagrangian particles to a smaller mesh some of the particles keep the cell number (in the positions-file) from the old mesh which are a) wrong b) may be outside of the range of the new mesh which causes all kinds of trouble (during decomposePar, trackToFace etc)

Fix: the attached patch. For the particles in question it overwrites the celli_ with the index of the found cell (which was calculated anyway). In order to do this a write-access-method for celli_ had to be introduced

Attachment 113

Dear Bernhard,

I have faced an issue for lagrangian interpolation in parallel simulation and I will be thankful if you can help me with that.
I use 2 meshes during simulation, a coarse mesh and a fine mesh and I need to transfer my particles between the meshes during the simulation. To do this, I used the same functions that are implemented in mapFields / mapFieldsPar. The major difference between the interpolation function of mapFields and the revised one in my solver is in the lagrangian interpolation part. In mapFields the particle clouds (here passiveParticleCloud) are constructed by reading the cloud directories (objects) in the case time directory, but in my solver the particle clouds (both source and target) are constructed in the solver main loop (as I need the particle data during the solution before they are written in the time directories).
Everything works fine for serial case. Even in the parallel case the Eulerian fields (e.g. velocity, pressure, etc) are interpolated correctly. But just for lagrangian interpolation of particles in parallel, I cannot get the right result. It seems that the host cell of the particle in the target mesh cannot be found in the function:


Code:

autoPtr<passiveParticle> newPtr
                        (
                            new passiveParticle
                            (
                                meshTarget,
                                targetCc[targetCells[i]],
                                targetCells[i]
                            )
                        );

Actually, in the domain decomposition, the two meshes are not decomposed similarly, and processor K for example does not cover the same regions of the meshes. So, when the interpolation function in applied in processor K, it cannot find the target cell of particle i in the same processor because that cell is located in another processor. Would you please let me know how I can solve my issue?

(When I forced the decomposition to be similar in both meshes, the interpolation works fine, but I cannot do such a decomposition in general case of unstructured meshes I think.)

I'm wondering how mapFields can do parallel interpolations for Eulerian field values but not for lagrangian particles.

Thank you in advance
/Ebrahim

gschaider March 28, 2017 05:57

Quote:

Originally Posted by Ebrahim (Post 642343)
Dear Bernhard,

I have faced an issue for lagrangian interpolation in parallel simulation and I will be thankful if you can help me with that.
I use 2 meshes during simulation, a coarse mesh and a fine mesh and I need to transfer my particles between the meshes during the simulation. To do this, I used the same functions that are implemented in mapFields / mapFieldsPar. The major difference between the interpolation function of mapFields and the revised one in my solver is in the lagrangian interpolation part. In mapFields the particle clouds (here passiveParticleCloud) are constructed by reading the cloud directories (objects) in the case time directory, but in my solver the particle clouds (both source and target) are constructed in the solver main loop (as I need the particle data during the solution before they are written in the time directories).
Everything works fine for serial case. Even in the parallel case the Eulerian fields (e.g. velocity, pressure, etc) are interpolated correctly. But just for lagrangian interpolation of particles in parallel, I cannot get the right result. It seems that the host cell of the particle in the target mesh cannot be found in the function:


Code:

autoPtr<passiveParticle> newPtr
                        (
                            new passiveParticle
                            (
                                meshTarget,
                                targetCc[targetCells[i]],
                                targetCells[i]
                            )
                        );

Actually, in the domain decomposition, the two meshes are not decomposed similarly, and processor K for example does not cover the same regions of the meshes. So, when the interpolation function in applied in processor K, it cannot find the target cell of particle i in the same processor because that cell is located in another processor. Would you please let me know how I can solve my issue?

(When I forced the decomposition to be similar in both meshes, the interpolation works fine, but I cannot do such a decomposition in general case of unstructured meshes I think.)

I'm wondering how mapFields can do parallel interpolations for Eulerian field values but not for lagrangian particles.

Thank you in advance
/Ebrahim

You don't say which OF-version you're using. Which is essential information.

Anyway: I haven't worked on this for a long time (you'll notice that my posts in this threads are more than a couple of weeks ago) so I can't comment on this. Anyway: when looking at the sources for mapFieldsPar in v1612+ and 4.1 there are source files called "mapLagrangian" so something IS there (but I don't have time to go through the source to see WHAT. You'll have to do this yourself)

Ebrahim March 28, 2017 11:08

Quote:

Originally Posted by gschaider (Post 642632)
You don't say which OF-version you're using. Which is essential information.

Anyway: I haven't worked on this for a long time (you'll notice that my posts in this threads are more than a couple of weeks ago) so I can't comment on this. Anyway: when looking at the sources for mapFieldsPar in v1612+ and 4.1 there are source files called "mapLagrangian" so something IS there (but I don't have time to go through the source to see WHAT. You'll have to do this yourself)

Thank you for you response. I'm using OpenFOAM 3.0.
Yes, A mapping function called "mapLagrangian" is defined there which can find the host cell of the particle in the target mesh, but the function that I mentioned in the previous post cannot be executed in the parallel case without using the time directories (cloudDirs[cloudI]).

Thanks,
Ebrahim

gschaider March 28, 2017 16:58

Quote:

Originally Posted by Ebrahim (Post 642697)
Thank you for you response. I'm using OpenFOAM 3.0.
Yes, A mapping function called "mapLagrangian" is defined there which can find the host cell of the particle in the target mesh, but the function that I mentioned in the previous post cannot be executed in the parallel case without using the time directories (cloudDirs[cloudI]).

Thanks,
Ebrahim

I THINK (I don't have time to check this) that if you construct a particle it is assumed that you know that it "belongs" on the current processor. So you'll have to take the particle from the original mesh, take the position and find out which processor on the other mesh has that position. Then you construct the new particle there. Easiest would probably be to broadcast all original particles (or only their positions if that is sufficient) to all processors. Each processor goes through that list and constructs "his" particles

Ebrahim March 31, 2017 10:56

Quote:

Originally Posted by gschaider (Post 642749)
I THINK (I don't have time to check this) that if you construct a particle it is assumed that you know that it "belongs" on the current processor. So you'll have to take the particle from the original mesh, take the position and find out which processor on the other mesh has that position. Then you construct the new particle there. Easiest would probably be to broadcast all original particles (or only their positions if that is sufficient) to all processors. Each processor goes through that list and constructs "his" particles

Yes, I agree with you. I think it is not possible to inject a particle on a processor from another processor.
Finally I decided to use the approach that you mentioned and this works for a simple test case. I hope It wouldn't be an expensive approach for complex cases with a lot of particles and fine grids.
The only point that I want to say here is that I guess its more efficient to make separate list for different particle properties (i.e. a list for diameters, another one for positions, etc) and distribute them among all processors rather than distributing a list of particles themselves.

Thank you again,
Ebrahim


All times are GMT -4. The time now is 19:46.