searchableSurfaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2017 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 #include "writer.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 class triSurface;
49 
50 /*---------------------------------------------------------------------------*\
51  Class searchableSurfaces Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public PtrList<searchableSurface>
57 {
58  // Private data
59 
60  //- Surface names
61  wordList names_;
62 
63  //- Region names per surface
64  List<wordList> regionNames_;
65 
67  //HashTable<labelPair> regionNames_;
68 
69  //- Indices of all surfaces. Precalculated and stored.
70  labelList allSurfaces_;
71 
72 
73  // Private Member Functions
74 
75  //- Is edge on face
76  static bool connected
77  (
78  const triSurface& s,
79  const label edgeI,
80  const pointIndexHit& hit
81  );
82 
83 
84  //- Disallow default bitwise copy construct
86 
87  //- Disallow default bitwise assignment
88  void operator=(const searchableSurfaces&);
89 
90 
91 public:
92 
93  ClassName("searchableSurfaces");
94 
95 
96  // Constructors
97 
98  //- Construct with length specified. Fill later.
99  explicit searchableSurfaces(const label);
100 
101 
103  //searchableSurfaces(const IOobject&, const PtrList<dictionary>&);
104 
105  //- Construct from dictionary and whether to construct names always
106  // as surfaceName "_" regionName (singleRegionName false) or
107  // for single region surfaces as surfaceName only (singleRegionName
108  // true)
110  (
111  const IOobject&,
112  const dictionary&,
113  const bool singleRegionName
114  );
115 
116 
117  // Member Functions
119  const wordList& names() const
120  {
121  return names_;
122  }
124  wordList& names()
125  {
126  return names_;
127  }
129  const List<wordList>& regionNames() const
130  {
131  return regionNames_;
132  }
135  {
136  return regionNames_;
137  }
138 
139 
141  //HashTable<labelPair>& regionNames()
142  //{
143  // return regionNames_;
144  //}
146  //const labelPair& surfaceRegion(const word& globalRegion) const
147  //{
148  // return regionNames_[globalRegion];
149  //}
150 
151  //- Find index of surface. Return -1 if not found.
152  label findSurfaceID(const word& name) const;
153 
155  (
156  const word& surfaceName,
157  const word& regionName
158  ) const;
159 
160  // Multiple point queries.
161 
162  //- Find any intersection. Return hit point information and
163  // surface number. If multiple surfaces hit the first surface
164  // is returned, not necessarily the nearest (to start).
166  (
167  const pointField& start,
168  const pointField& end,
169  labelList& surfaces,
171  ) const;
172 
173  //- Find all intersections in order from start to end. Returns for
174  // every hit the surface and the hit info.
176  (
177  const pointField& start,
178  const pointField& end,
179  labelListList& surfaces,
181  ) const;
182 
183  //Find intersections of edge nearest to both endpoints.
185  (
186  const pointField& start,
187  const pointField& end,
188  labelList& surface1,
189  List<pointIndexHit>& hit1,
190  labelList& surface2,
191  List<pointIndexHit>& hit2
192  ) const;
193 
194  //- Find nearest. Return -1 (and a miss()) or surface and nearest
195  // point.
196  void findNearest
197  (
198  const pointField&,
199  const scalarField& nearestDistSqr,
200  labelList& surfaces,
202  ) const;
203 
204  void findNearest
205  (
206  const pointField& samples,
207  const scalarField& nearestDistSqr,
208  const labelList& regionIndices,
209  labelList& nearestSurfaces,
210  List<pointIndexHit>& nearestInfo
211  ) const;
212 
213  //- Calculate bounding box
214  boundBox bounds() const;
215 
216  // Checking
217 
218  //- Are all surfaces closed and manifold
219  bool checkClosed(const bool report) const;
220 
221  //- Are all (triangulated) surfaces consistent normal orientation
222  bool checkNormalOrientation(const bool report) const;
223 
224  //- Are all bounding boxes of similar size
225  bool checkSizes(const scalar maxRatio, const bool report) const;
226 
227  //- Do surfaces self-intersect or intersect others
228  bool checkIntersection
229  (
230  const scalar tol,
231  const autoPtr<writer<scalar>>&,
232  const bool report
233  ) const;
234 
235  //- Check triangle quality
236  bool checkQuality
237  (
238  const scalar minQuality,
239  const bool report
240  ) const;
241 
242  //- All topological checks. Return number of failed checks
243  label checkTopology(const bool report) const;
244 
245  //- All geometric checks. Return number of failed checks
247  (
248  const scalar maxRatio,
249  const scalar tolerance,
250  const autoPtr<writer<scalar>>& setWriter,
251  const scalar minQuality,
252  const bool report
253  ) const;
254 
255  //- Write some stats
256  void writeStats(const List<wordList>&, Ostream&) const;
257 
258 
259  // Member Operators
260 
261  //- Return const and non-const reference to searchableSurface by index.
263 
264  //- Return const reference to searchableSurface by name.
265  const searchableSurface& operator[](const word&) const;
266 
267  //- Return reference to searchableSurface by name.
269 
270 
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #endif
281 
282 // ************************************************************************* //
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:137
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:296
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.
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar >> &, const bool report) const
Do surfaces self-intersect or intersect others.
A class for handling words, derived from string.
Definition: word.H:59
const List< wordList > & regionNames() const
Container for searchableSurfaces.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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.
label checkGeometry(const scalar maxRatio, const scalar tolerance, const autoPtr< writer< scalar >> &setWriter, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
const wordList & names() const
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
Triangulated surface description with patch information.
Definition: triSurface.H:65
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.