pointInCell.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 InNamespace
25  Foam
26 
27 Description
28  Function for determining if a point is within a cell of a polyMesh
29 
30 SourceFiles
31  pointInCell.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef pointInCell_H
36 #define pointInCell_H
37 
38 #include "point.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward declaration of classes
46 class polyMesh;
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 //- Enumeration for the sub-shapes used to perform the inside calculation
52 {
53  facePlanes,
56  tets
57 };
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 //- Test if a point is in a given cell. For each of the cell's faces, define a
62 // plane based on the face centre and the outward pointing face normal. The
63 // point is considered to be inside the cell if it is below all such planes.
64 // This is not guaranteed to be correct if the cell is not convex. Even if the
65 // cell is convex, this approach is still somewhat approximate if the faces
66 // are not flat.
68 (
69  const point& p,
70  const polyMesh& mesh,
71  const label celli
72 );
73 
74 //- Test if a point is in a given cell. For each of the cell's faces,
75 // triangulate by connecting each edge to the face centre. Then proceed as for
76 // pointInCellFacePlanes, but using these triangles instead of the faces.
77 // Triangles are flat by definition, so this approach resolves the ambiguities
78 // associated with representing faces as planes. It doesn't fix the convexity
79 // requirement, however. If anything it makes it worse, as now the cell has
80 // to be convex with respect to the triangles, of which there are more than
81 // there are faces.
83 (
84  const point& p,
85  const polyMesh& mesh,
86  const label celli
87 );
88 
89 //- Test if a point is in a given cell. For each of the cell's faces,
90 // triangulate by connecting each edge not containing the tetBasePt to the
91 // tetBasePt. Then proceed as for pointInCellFacePlanes, but using these
92 // triangles instead of the faces. This constructs fewer faces than
93 // pointInCellFaceCentreTris, so it should be computationally advantageous
94 // over that method. It shares the same limitations otherwise.
96 (
97  const point& p,
98  const polyMesh& mesh,
99  const label celli
100 );
101 
102 //- Test if a point is in a given cell by decomposing the cell into tetrahedra
103 // and asking the tetrahedral decomposition engine to determine whether the
104 // point is inside one of the tetrahedra. This method has the greatest cost,
105 // but is the most general and should be robust to concave non-flat faces and
106 // concave cells.
107 bool pointInCellTets
108 (
109  const point& p,
110  const polyMesh& mesh,
111  const label celli
112 );
113 
114 //- Test if a point is in a given cell
115 bool pointInCell
116 (
117  const point& p,
118  const polyMesh& mesh,
119  const label celli,
121 );
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #endif
130 
131 // ************************************************************************* //
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
bool pointInCellFaceDiagTris(const point &p, const polyMesh &mesh, const label celli)
Test if a point is in a given cell. For each of the cell's faces,.
Definition: pointInCell.C:112
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
pointInCellShapes
Enumeration for the sub-shapes used to perform the inside calculation.
Definition: pointInCell.H:52
vector point
Point is a vector.
Definition: point.H:41
bool pointInCellFaceCentreTris(const point &p, const polyMesh &mesh, const label celli)
Test if a point is in a given cell. For each of the cell's faces,.
Definition: pointInCell.C:61
bool pointInCellTets(const point &p, const polyMesh &mesh, const label celli)
Test if a point is in a given cell by decomposing the cell into tetrahedra.
Definition: pointInCell.C:144
bool pointInCellFacePlanes(const point &p, const polyMesh &mesh, const label celli)
Test if a point is in a given cell. For each of the cell's faces, define a.
Definition: pointInCell.C:32
bool pointInCell(const point &p, const polyMesh &mesh, const label celli, const pointInCellShapes=pointInCellShapes::tets)
Test if a point is in a given cell.
Definition: pointInCell.C:155
volScalarField & p