|
[Sponsors] |
How to efficiently find all cells within an 3D object (e.g. box or sphere)? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 26, 2022, 03:16 |
How to efficiently find all cells within an 3D object (e.g. box or sphere)?
|
#1 |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
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. Last edited by keepfit; February 2, 2022 at 05:10. |
|
February 1, 2022, 18:04 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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).
__________________
Keep foaming, Tobias Holzmann |
|
February 2, 2022, 03:45 |
|
#3 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
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. Last edited by keepfit; February 3, 2022 at 21:26. |
||
December 9, 2024, 13:58 |
Using octree to find cells
|
#5 |
Member
Divyaprakash
Join Date: Jun 2014
Posts: 74
Rep Power: 12 |
I too was looking for someway to select cells programmatically. I am just posting my solution here for those interested.
After reading the documentation I found that you can access the octree from the mesh and then find cells within a bounding box by operating on the returned object. Code:
// Access the octree from the mesh const indexedOctree<treeDataCell>& cellTree = mesh.cellTree(); // Query the cells in the bounding box labelHashSet foundCells; label count = cellTree.findBox(searchBox, foundCells); https://dpcfd.com/posts/2024/12/blog-post-4/ |
|
Tags |
findcell, meshsearch, octree |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] snappyHexMesh stuck when snap is turned on | yukuns | OpenFOAM Meshing & Mesh Conversion | 3 | February 2, 2021 14:05 |
[snappyHexMesh] SnappyHexMesh for internal Flow | vishwa | OpenFOAM Meshing & Mesh Conversion | 24 | June 27, 2016 09:54 |
[foam-extend.org] Error compiling OpenFOAM-1.6-ext | Canesin | OpenFOAM Installation | 137 | January 20, 2016 15:56 |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 06:50 |
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug | unoder | OpenFOAM Installation | 11 | January 30, 2008 21:30 |