meshSearch.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) 2011-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 Class
25  Foam::meshSearch
26 
27 Description
28  Mesh object that implements searches within the local cells and faces
29 
30 SourceFiles
31  meshSearch.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef meshSearch_H
36 #define meshSearch_H
37 
38 #include "DemandDrivenMeshObject.H"
39 #include "indexedOctree.H"
40 #include "pointInCell.H"
41 #include "treeDataCell.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class meshSearch Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class meshSearch
53 :
55  <
56  polyMesh,
57  DeletableMeshObject,
58  meshSearch
59  >
60 {
61  // Private Data
62 
63  //- Cell tree
64  const indexedOctree<treeDataCell> cellTree_;
65 
66 
67 protected:
68 
69  friend class DemandDrivenMeshObject
70  <
71  polyMesh,
74  >;
75 
76 
77  // Protected Constructors
78 
79  //- Construct from mesh
80  explicit meshSearch(const polyMesh& mesh);
81 
82 
83 public:
84 
85  //- Run-time type information
86  TypeName("meshSearch");
87 
88 
89  // Constructors
90 
91  //- Lookup or construct from mesh and cell decomposition option
92  static const meshSearch& New
93  (
94  const polyMesh& mesh,
96  );
97 
98  //- Disallow default bitwise copy construction
99  meshSearch(const meshSearch&) = delete;
100 
101 
102  //- Destructor
103  virtual ~meshSearch();
104 
105 
106  // Member Functions
107 
108  // Access
109 
110  //- Access the cell tree
111  inline const indexedOctree<treeDataCell>& cellTree() const
112  {
113  return cellTree_;
114  }
115 
116 
117  // Queries
118 
119  //- Find the cell with centre closest to the given point
120  label findNearestCell(const point& p) const;
121 
122  //- Find the cell with centre closest to the given point. Do a
123  // linear search through all the cells instead of using the tree.
125  (
126  const polyMesh& mesh,
127  const point& p
128  );
129 
130  //- Find the face with centre closest to the given point
131  label findNearestFace(const point& p) const;
132 
133  //- Find the cell containing the given point
135  (
136  const point& p,
138  ) const;
139 
140  //- Find the cell containing the given point. Do a
141  // linear search through all the cells instead of using the tree.
142  static label findCellNoTree
143  (
144  const polyMesh& mesh,
145  const point& p,
147  );
148 
149 
150  // Member Operators
151 
152  //- Disallow default bitwise assignment
153  void operator=(const meshSearch&) = delete;
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
MeshObject types:
Definition: MeshObjects.H:70
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:72
Mesh object that implements searches within the local cells and faces.
Definition: meshSearch.H:59
label findNearestCell(const point &p) const
Find the cell with centre closest to the given point.
Definition: meshSearch.C:94
label findCell(const point &p, const pointInCellShapes=pointInCellShapes::tets) const
Find the cell containing the given point.
Definition: meshSearch.C:173
label findNearestFace(const point &p) const
Find the face with centre closest to the given point.
Definition: meshSearch.C:139
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
meshSearch(const polyMesh &mesh)
Construct from mesh.
Definition: meshSearch.C:39
void operator=(const meshSearch &)=delete
Disallow default bitwise assignment.
virtual ~meshSearch()
Destructor.
Definition: meshSearch.C:88
const indexedOctree< treeDataCell > & cellTree() const
Access the cell tree.
Definition: meshSearch.H:110
TypeName("meshSearch")
Run-time type information.
static label findNearestCellNoTree(const polyMesh &mesh, const point &p)
Find the cell with centre closest to the given point. Do a.
Definition: meshSearch.C:113
static label findCellNoTree(const polyMesh &mesh, const point &p, const pointInCellShapes=pointInCellShapes::tets)
Find the cell containing the given point. Do a.
Definition: meshSearch.C:183
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Namespace for OpenFOAM.
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
Function for determining if a point is within a cell of a polyMesh.
volScalarField & p