All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
searchableSurfaces.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-2021 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::searchableSurfaces
26 
27 Description
28  Container for searchableSurfaces.
29 
30 SourceFiles
31  searchableSurfaces.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef searchableSurfaces_H
36 #define searchableSurfaces_H
37 
38 #include "searchableSurface.H"
39 #include "labelPair.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 class triSurface;
48 
49 /*---------------------------------------------------------------------------*\
50  Class searchableSurfaces Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public PtrList<searchableSurface>
56 {
57  // Private Data
58 
59  //- Surface names
60  wordList names_;
61 
62  //- Region names per surface
63  List<wordList> regionNames_;
64 
66  // HashTable<labelPair> regionNames_;
67 
68  //- Indices of all surfaces. Precalculated and stored.
69  labelList allSurfaces_;
70 
71 
72  // Private Member Functions
73 
74  //- Is edge on face
75  static bool connected
76  (
77  const triSurface& s,
78  const label edgeI,
79  const pointIndexHit& hit
80  );
81 
82 
83 public:
84 
85  ClassName("searchableSurfaces");
86 
87 
88  // Constructors
89 
90  //- Construct with length specified. Fill later.
91  explicit searchableSurfaces(const label);
92 
93 
95  // searchableSurfaces(const IOobject&, const PtrList<dictionary>&);
96 
97  //- Construct from dictionary and whether to construct names always
98  // as surfaceName "_" regionName (singleRegionName false) or
99  // for single region surfaces as surfaceName only (singleRegionName
100  // true)
102  (
103  const IOobject&,
104  const dictionary&,
105  const bool singleRegionName
106  );
107 
108  //- Disallow default bitwise copy construction
109  searchableSurfaces(const searchableSurfaces&) = delete;
110 
111 
112  // Member Functions
113 
114  const wordList& names() const
115  {
116  return names_;
117  }
118 
119  wordList& names()
120  {
121  return names_;
122  }
123 
124  const List<wordList>& regionNames() const
125  {
126  return regionNames_;
127  }
128 
130  {
131  return regionNames_;
132  }
133 
134 
136  // HashTable<labelPair>& regionNames()
137  //{
138  // return regionNames_;
139  //}
141  // const labelPair& surfaceRegion(const word& globalRegion) const
142  //{
143  // return regionNames_[globalRegion];
144  //}
145 
146  //- Find index of surface. Return -1 if not found.
147  label findSurfaceID(const word& name) const;
148 
150  (
151  const word& surfaceName,
152  const word& regionName
153  ) const;
154 
155  // Multiple point queries.
156 
157  //- Find any intersection. Return hit point information and
158  // surface number. If multiple surfaces hit the first surface
159  // is returned, not necessarily the nearest (to start).
161  (
162  const pointField& start,
163  const pointField& end,
164  labelList& surfaces,
166  ) const;
167 
168  //- Find all intersections in order from start to end. Returns for
169  // every hit the surface and the hit info.
171  (
172  const pointField& start,
173  const pointField& end,
174  labelListList& surfaces,
176  ) const;
177 
178  // Find intersections of edge nearest to both endpoints.
180  (
181  const pointField& start,
182  const pointField& end,
183  labelList& surface1,
184  List<pointIndexHit>& hit1,
185  labelList& surface2,
186  List<pointIndexHit>& hit2
187  ) const;
188 
189  //- Find nearest. Return -1 (and a miss()) or surface and nearest
190  // point.
191  void findNearest
192  (
193  const pointField&,
194  const scalarField& nearestDistSqr,
195  labelList& surfaces,
197  ) const;
198 
199  void findNearest
200  (
201  const pointField& samples,
202  const scalarField& nearestDistSqr,
203  const labelList& regionIndices,
204  labelList& nearestSurfaces,
205  List<pointIndexHit>& nearestInfo
206  ) const;
207 
208  //- Calculate bounding box
209  boundBox bounds() const;
210 
211  // Checking
212 
213  //- Are all surfaces closed and manifold
214  bool checkClosed(const bool report) const;
215 
216  //- Are all (triangulated) surfaces consistent normal orientation
217  bool checkNormalOrientation(const bool report) const;
218 
219  //- Are all bounding boxes of similar size
220  bool checkSizes(const scalar maxRatio, const bool report) const;
221 
222  //- Do surfaces self-intersect or intersect others
223  bool checkIntersection
224  (
225  const scalar tol,
226  const bool report
227  ) const;
228 
229  //- Check triangle quality
230  bool checkQuality
231  (
232  const scalar minQuality,
233  const bool report
234  ) const;
235 
236  //- All topological checks. Return number of failed checks
237  label checkTopology(const bool report) const;
238 
239  //- All geometric checks. Return number of failed checks
241  (
242  const scalar maxRatio,
243  const scalar tolerance,
244  const scalar minQuality,
245  const bool report
246  ) const;
247 
248  //- Write some stats
249  void writeStats(const List<wordList>&, Ostream&) const;
250 
251 
252  // Member Operators
253 
254  //- Return const and non-const reference to searchableSurface by index.
256 
257  //- Return const reference to searchableSurface by name.
258  const searchableSurface& operator[](const word&) const;
259 
260  //- Return reference to searchableSurface by name.
262 
263 
264  // Member Operators
265 
266  //- Disallow default bitwise assignment
267  void operator=(const searchableSurfaces&) = delete;
268 };
269 
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #endif
278 
279 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:54
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
iterator end()
Return an iterator to end traversing the UPtrList.
Definition: UPtrListI.H:316
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Container for searchableSurfaces.
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
label checkGeometry(const scalar maxRatio, const scalar tolerance, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
const wordList & names() const
boundBox bounds() const
Calculate bounding box.
label findSurfaceRegionID(const word &surfaceName, const word &regionName) const
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
const List< wordList > & regionNames() const
void findAllIntersections(const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit >> &) const
Find all intersections in order from start to end. Returns for.
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
ClassName("searchableSurfaces")
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
bool checkIntersection(const scalar tol, const bool report) const
Do surfaces self-intersect or intersect others.
void operator=(const searchableSurfaces &)=delete
Disallow default bitwise assignment.
searchableSurfaces(const label)
Construct with length specified. Fill later.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
Triangulated surface description with patch information.
Definition: triSurface.H:69
A class for handling words, derived from string.
Definition: word.H:62
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const word & regionName(const solver &region)
Definition: solver.H:209
scalarField samples(nIntervals, 0)