CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to accelerate findCell? (https://www.cfd-online.com/Forums/openfoam-programming-development/158819-how-accelerate-findcell.html)

fst-student September 4, 2015 06:01

How to accelerate findCell?
 
Hello,

I have the coordinates of a large amount of points and have to find the cooresponding points inside the mesh. For this I'm using the findCell command. I expect that this search has the longest duration in my code. Is there a possibilty to accelerate this command?

Thank you very much

Jens

blais.bruno September 6, 2015 09:06

I think it depends on the search method you use.

There is a way to use a tree-based search which is significantly faster than the generic find cell. This is what is used within the CFDEM framework and its relatively fast.

Quote:

Originally Posted by fst-student (Post 562451)
Hello,

I have the coordinates of a large amount of points and have to find the cooresponding points inside the mesh. For this I'm using the findCell command. I expect that this search has the longest duration in my code. Is there a possibilty to accelerate this command?

Thank you very much

Jens


fst-student September 6, 2015 11:23

Thanks for the answer. Do you have some more information about it or a hint, webside or documentation where I can read more about it?

Thank you

blais.bruno September 6, 2015 11:33

Sure,

the class is meshSearch

Then if you intiate your meshSearch engine using something like:

Code:

meshSearch searchEngine_;
searchEngine_(particleCloud_.mesh(),polyMesh::FACE_PLANES);

You can search using the .findCell() routine of meshSearch.



Quote:

Originally Posted by fst-student (Post 562633)
Thanks for the answer. Do you have some more information about it or a hint, webside or documentation where I can read more about it?

Thank you


fst-student September 7, 2015 10:25

Thank you very much. It is not completly clear for me.

I have to define the meshSearch engine right?
I don't know which parameter I have to set for the definition of the search engine.
Obviously I have to change the variable particleCloud_.mesh() but I don't know how it is called in my chase. What is this variable exactly and how can I find it? Can I use the second part (polyMesh::FACE_PLANES) or do I have to change it to?

If I have defined it I can use the mesh.findCell[cellnumber] command to find the cell and openfoam uses the tree search.
I have found the following command:
Code:

findCell (const point &location, const label seedCellI=-1, const bool useTreeSearch=true)
. Do I have to set the variables in brakets to use the tree search?

Sorry I'm new to openfoam.

Thank you very much.

fst-student September 8, 2015 12:17

Ok, I have tried something but I don't get it work.
Here is what I tried:
First of all I copied the meshSearch.H and used the #include command to make it accessable in my code.

Edit:

I integrated this code
Code:

meshSearch ms(mesh);
label cellNumber=ms.findCell(Point,-1,true)

EDIT2: The code is runnig and is about 8 times faster than the conventional findCell.

Thank you very much!

fst-student September 25, 2015 06:57

I have tested the perfomance of the findCell using several parameters.
The fastest way was this command:
Code:

meshSearch ms(mesh); label cellNumber=ms.findCell(Point,0,true)
The zero disables the seeding which slows the search down. Using this configuration the search is very fast.

The speed of search can also be improved by using the findNearestCell command. It is used in the same way:
Code:

meshSearch ms(mesh); label cellNumber=ms.findNearestCell(Point,0,true)

pbachant November 12, 2015 13:17

Have you tested this in parallel? I am profiling some code and it seems findCell and reduce are gobbling up lots of CPU when run in parallel.

pbachant November 12, 2015 17:00

I just tried this out and got a ~20X speedup on a case that should not even be parallel (20k cells). The speed in serial using meshSearch::findNearestCell(point, 0, true) is about the same as polyMesh::findCell.

FlowingTech July 20, 2016 02:30

Could anybody explain the differences between the two available options of the meshSearch class:

polyMesh::FACE_PLANES
and
polyMesh::FACE_DIAGTETS

?

Furthermore, we discovered that implementations of the meshSearch::findCell() algorithm differ between ESI-OpenFOAM and foam-extend-3.2. Could anybody comment on this and explain which algorithm is used in foam-extend-3.2 ?
Cheeers.

blais.bruno July 20, 2016 08:24

The two should be different search options. The first one I guess uses the face positions, the other one might decompose cells into tetahedron to search? I am not sure?

I cannot comment on the foam-extend vs ESI-OpenFOAM. Honestly, it is too hard to track the différences between these codes...



Quote:

Originally Posted by FlowingTech (Post 610372)
Could anybody explain the differences between the two available options of the meshSearch class:

polyMesh::FACE_PLANES
and
polyMesh::FACE_DIAGTETS

?

Furthermore, we discovered that implementations of the meshSearch::findCell() algorithm differ between ESI-OpenFOAM and foam-extend-3.2. Could anybody comment on this and explain which algorithm is used in foam-extend-3.2 ?
Cheeers.



All times are GMT -4. The time now is 16:23.