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-2016 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  // Constructors
96 
97  //- Construct with length specified. Fill later.
98  explicit searchableSurfaces(const label);
99 
100 
102  //searchableSurfaces(const IOobject&, const PtrList<dictionary>&);
103 
104  //- Construct from dictionary and whether to construct names always
105  // as surfaceName "_" regionName (singleRegionName false) or
106  // for single region surfaces as surfaceName only (singleRegionName
107  // true)
109  (
110  const IOobject&,
111  const dictionary&,
112  const bool singleRegionName
113  );
114 
115 
116  // Member Functions
118  const wordList& names() const
119  {
120  return names_;
121  }
122  wordList& names()
123  {
124  return names_;
125  }
127  const List<wordList>& regionNames() const
128  {
129  return regionNames_;
130  }
132  {
133  return regionNames_;
134  }
135 
136 
138  //HashTable<labelPair>& regionNames()
139  //{
140  // return regionNames_;
141  //}
143  //const labelPair& surfaceRegion(const word& globalRegion) const
144  //{
145  // return regionNames_[globalRegion];
146  //}
147 
148  //- Find index of surface. Return -1 if not found.
149  label findSurfaceID(const word& name) const;
150 
152  (
153  const word& surfaceName,
154  const word& regionName
155  ) const;
156 
157  // Multiple point queries.
158 
159  //- Find any intersection. Return hit point information and
160  // surface number. If multiple surfaces hit the first surface
161  // is returned, not necessarily the nearest (to start).
163  (
164  const pointField& start,
165  const pointField& end,
166  labelList& surfaces,
168  ) const;
169 
170  //- Find all intersections in order from start to end. Returns for
171  // every hit the surface and the hit info.
173  (
174  const pointField& start,
175  const pointField& end,
176  labelListList& surfaces,
178  ) const;
179 
180  //Find intersections of edge nearest to both endpoints.
182  (
183  const pointField& start,
184  const pointField& end,
185  labelList& surface1,
186  List<pointIndexHit>& hit1,
187  labelList& surface2,
188  List<pointIndexHit>& hit2
189  ) const;
190 
191  //- Find nearest. Return -1 (and a miss()) or surface and nearest
192  // point.
193  void findNearest
194  (
195  const pointField&,
196  const scalarField& nearestDistSqr,
197  labelList& surfaces,
199  ) const;
200 
201  void findNearest
202  (
203  const pointField& samples,
204  const scalarField& nearestDistSqr,
205  const labelList& regionIndices,
206  labelList& nearestSurfaces,
207  List<pointIndexHit>& nearestInfo
208  ) const;
209 
210  //- Calculate bounding box
211  boundBox bounds() const;
212 
213 
214  // Single point queries
215 
216  //- Calculate point which is on a set of surfaces.
218  (
219  const scalar initialDistSqr,
220  const scalar convergenceDistSqr,
221  const point& start
222  ) const;
223 
224 
225  // Checking
226 
227  //- Are all surfaces closed and manifold
228  bool checkClosed(const bool report) const;
229 
230  //- Are all (triangulated) surfaces consistent normal orientation
231  bool checkNormalOrientation(const bool report) const;
232 
233  //- Are all bounding boxes of similar size
234  bool checkSizes(const scalar maxRatio, const bool report) const;
235 
236  //- Do surfaces self-intersect or intersect others
237  bool checkIntersection
238  (
239  const scalar tol,
240  const autoPtr<writer<scalar>>&,
241  const bool report
242  ) const;
243 
244  //- Check triangle quality
245  bool checkQuality
246  (
247  const scalar minQuality,
248  const bool report
249  ) const;
250 
251  //- All topological checks. Return number of failed checks
252  label checkTopology(const bool report) const;
253 
254  //- All geometric checks. Return number of failed checks
256  (
257  const scalar maxRatio,
258  const scalar tolerance,
259  const autoPtr<writer<scalar>>& setWriter,
260  const scalar minQuality,
261  const bool report
262  ) const;
263 
264  //- Write some stats
265  void writeStats(const List<wordList>&, Ostream&) const;
266 
267 
268  // Member Operators
269 
270  //- Return const and non-const reference to searchableSurface by index.
272 
273  //- Return const reference to searchableSurface by name.
274  const searchableSurface& operator[](const word&) const;
275 
276  //- Return reference to searchableSurface by name.
278 
279 
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #endif
290 
291 // ************************************************************************* //
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar >> &, const bool report) const
Do surfaces self-intersect or intersect others.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const List< wordList > & regionNames() const
Foam::word regionName
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
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.
pointIndexHit facesIntersection(const scalar initialDistSqr, const scalar convergenceDistSqr, const point &start) const
Calculate point which is on a set of surfaces.
ClassName("searchableSurfaces")
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
Container for searchableSurfaces.
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.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
label findSurfaceRegionID(const word &surfaceName, const word &regionName) const
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
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.
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
const wordList & names() const
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Triangulated surface description with patch information.
Definition: triSurface.H:65
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
Namespace for OpenFOAM.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.