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