CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to efficiently find all cells within an 3D object (e.g. box or sphere)? (https://www.cfd-online.com/Forums/openfoam/240830-how-efficiently-find-all-cells-within-3d-object-e-g-box-sphere.html)

keepfit January 26, 2022 02:16

How to efficiently find all cells within an 3D object (e.g. box or sphere)?
 
Hi Foamers,

suppose there is a moving object in fluid. I want to know all cells (IDs) that intersects the object at EVERY timestep. Is there any way to avoid loop all cells in the fluid domain?

My idea is: first find the cell near the center of the object, then loop over the neighboring cells of the first cell. We repeat this process on preciously found cells until new cells are all outside the object. This way we don't need to loop over cells that are far away from the object.

Nevertheless, I am not familiar with existing OpenFOAM algorithms to do this job more efficiently. Any wonderful advice will be highly appreciated.

Tobi February 1, 2022 17:04

Hey, probably you could use some waveFront algorithm in OpenFOAM. We use it for blockLevel feature in snappyHexMesh and search cells close around some surface. However, if you have a surface (of the object) you should simply be able to find the intersecting cells. Nontheless, searching and selecting cells within an object should be very fast and straight forward (e.g., setSets, topoSet).

keepfit February 2, 2022 02:45

Quote:

Originally Posted by Tobi (Post 821375)
Hey, probably you could use some waveFront algorithm in OpenFOAM. We use it for blockLevel feature in snappyHexMesh and search cells close around some surface. However, if you have a surface (of the object) you should simply be able to find the intersecting cells. Nontheless, searching and selecting cells within an object should be very fast and straight forward (e.g., setSets, topoSet).

hey Tobi, thanks very much for your reply. At the moment I am implementing a BFS (breath first search) algorithm: treat the cell at the central of the object as root node, then use the connectivity (neighboring cells) between cells to propagate from the center to the outside of the object. I think it is quite similar to iead of waveFront algorithm you mentioned:D.

By the way, the object surface in my case is implicit: the surface is described as signed distance field, so it is quite easy to determine if one cell (center) is inside or outside of the object surface. But for the case of STL mesh, is there any native algorithms in OpenFOAM to do this job? I once used some algorithms from the geometry library - CGAL for lazy implementation. I guess we can directly call these methods from CGAL since it is ready integrated in OpenFOAM? TopoSet with stl file is not useful when we need to update the cells intersects with obj at every few steps.

Tobi February 3, 2022 17:35

Only can tell you that CGAL is implemented - yes :)


All times are GMT -4. The time now is 02:50.