|
[Sponsors] |
October 28, 2019, 20:57 |
How to use nearestPoint()?
|
#1 |
New Member
samuel
Join Date: Oct 2019
Posts: 15
Rep Power: 6 |
Dear all:
I am wondering how openfoam calculates y (not yPlus) which is (maybe) the shorstest distance from the cell center to the wall. And I find a function nearestPoint() which maybe is to calculate y as following: Foam::scalar Foam::cellDistFuncs::smallestDist ( ... ) const { ... for (label wallFacei = 0; wallFacei < nWallFaces; wallFacei++) { label patchFacei = wallFaces[wallFacei]; pointHit curHit = patch[patchFacei].nearestPoint(p, points); if (curHit.distance() < minDist) { minDist = curHit.distance(); minFacei = patch.start() + patchFacei; } } return minDist; } But the source code of nearestPoint() is difficult for me to find out how nearestPoint() calculates. Could anyone please explain how nearstPoint() works or share the materials related to it? Each reply will be appreciated. Thanks Samuel |
|
October 29, 2019, 05:39 |
|
#2 | |
Member
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 93
Rep Power: 14 |
Quote:
I just looked at the code and it seems to be messy to track stuff. However, I may give you at least what I understood at first glance . The version of function nearestPoint with 2 arguments of point and pointField can be found here (https://github.com/OpenFOAM/OpenFOAM...Intersection.C). You should follow the code from line 198. From what I understood, the aim here is to do the calculations with an arbitrary point and a triangulated face. So, if your face is already a triangle it will do the calculations immediately, and if not it will try to triangulate the face first and then do the calculations. Note that here face means each of single faces which constructs the whole wallFace. And the piece of code I think you are interested to see is this one (https://github.com/OpenFOAM/OpenFOAM...le/triangleI.H). You may follow the code from line 516 to see how this calculation is done with an arbitrary point and a triangulated face. This ref. is also given there (Real-time collision detection, Christer Ericson, 2005, p136-142) Hope this helps... |
||
October 29, 2019, 06:36 |
|
#3 | |
New Member
samuel
Join Date: Oct 2019
Posts: 15
Rep Power: 6 |
Quote:
Thank you again! |
||
Tags |
nearestpoint |
|
|