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
114  const wordList& names() const
115  {
116  return names_;
117  }
119  wordList& names()
120  {
121  return names_;
122  }
124  const List<wordList>& regionNames() const
125  {
126  return regionNames_;
127  }
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 // ************************************************************************* //
label checkGeometry(const scalar maxRatio, const scalar tolerance, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
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
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
Foam::word regionName
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:58
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
iterator end()
Return an iterator to end traversing the UPtrList.
Definition: UPtrListI.H:300
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
boundBox bounds() const
Calculate bounding box.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
label findSurfaceRegionID(const word &surfaceName, const word &regionName) const
ClassName("searchableSurfaces")
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
scalarField samples(nIntervals, 0)
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
A class for handling words, derived from string.
Definition: word.H:59
const List< wordList > & regionNames() const
bool checkIntersection(const scalar tol, const bool report) const
Do surfaces self-intersect or intersect others.
Container for searchableSurfaces.
searchableSurfaces(const label)
Construct with length specified. Fill later.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
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.
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
void operator=(const searchableSurfaces &)=delete
Disallow default bitwise assignment.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const wordList & names() const
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
Triangulated surface description with patch information.
Definition: triSurface.H:66
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
Namespace for OpenFOAM.