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-2019 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 public:
85 
86  ClassName("searchableSurfaces");
87 
88 
89  // Constructors
90 
91  //- Construct with length specified. Fill later.
92  explicit searchableSurfaces(const label);
93 
94 
96  // searchableSurfaces(const IOobject&, const PtrList<dictionary>&);
97 
98  //- Construct from dictionary and whether to construct names always
99  // as surfaceName "_" regionName (singleRegionName false) or
100  // for single region surfaces as surfaceName only (singleRegionName
101  // true)
103  (
104  const IOobject&,
105  const dictionary&,
106  const bool singleRegionName
107  );
108 
109  //- Disallow default bitwise copy construction
110  searchableSurfaces(const searchableSurfaces&) = delete;
111 
112 
113  // Member Functions
115  const wordList& names() const
116  {
117  return names_;
118  }
120  wordList& names()
121  {
122  return names_;
123  }
125  const List<wordList>& regionNames() const
126  {
127  return regionNames_;
128  }
131  {
132  return regionNames_;
133  }
134 
135 
137  // HashTable<labelPair>& regionNames()
138  //{
139  // return regionNames_;
140  //}
142  // const labelPair& surfaceRegion(const word& globalRegion) const
143  //{
144  // return regionNames_[globalRegion];
145  //}
146 
147  //- Find index of surface. Return -1 if not found.
148  label findSurfaceID(const word& name) const;
149 
151  (
152  const word& surfaceName,
153  const word& regionName
154  ) const;
155 
156  // Multiple point queries.
157 
158  //- Find any intersection. Return hit point information and
159  // surface number. If multiple surfaces hit the first surface
160  // is returned, not necessarily the nearest (to start).
162  (
163  const pointField& start,
164  const pointField& end,
165  labelList& surfaces,
167  ) const;
168 
169  //- Find all intersections in order from start to end. Returns for
170  // every hit the surface and the hit info.
172  (
173  const pointField& start,
174  const pointField& end,
175  labelListList& surfaces,
177  ) const;
178 
179  // Find intersections of edge nearest to both endpoints.
181  (
182  const pointField& start,
183  const pointField& end,
184  labelList& surface1,
185  List<pointIndexHit>& hit1,
186  labelList& surface2,
187  List<pointIndexHit>& hit2
188  ) const;
189 
190  //- Find nearest. Return -1 (and a miss()) or surface and nearest
191  // point.
192  void findNearest
193  (
194  const pointField&,
195  const scalarField& nearestDistSqr,
196  labelList& surfaces,
198  ) const;
199 
200  void findNearest
201  (
202  const pointField& samples,
203  const scalarField& nearestDistSqr,
204  const labelList& regionIndices,
205  labelList& nearestSurfaces,
206  List<pointIndexHit>& nearestInfo
207  ) const;
208 
209  //- Calculate bounding box
210  boundBox bounds() const;
211 
212  // Checking
213 
214  //- Are all surfaces closed and manifold
215  bool checkClosed(const bool report) const;
216 
217  //- Are all (triangulated) surfaces consistent normal orientation
218  bool checkNormalOrientation(const bool report) const;
219 
220  //- Are all bounding boxes of similar size
221  bool checkSizes(const scalar maxRatio, const bool report) const;
222 
223  //- Do surfaces self-intersect or intersect others
224  bool checkIntersection
225  (
226  const scalar tol,
227  const autoPtr<writer<scalar>>&,
228  const bool report
229  ) const;
230 
231  //- Check triangle quality
232  bool checkQuality
233  (
234  const scalar minQuality,
235  const bool report
236  ) const;
237 
238  //- All topological checks. Return number of failed checks
239  label checkTopology(const bool report) const;
240 
241  //- All geometric checks. Return number of failed checks
243  (
244  const scalar maxRatio,
245  const scalar tolerance,
246  const autoPtr<writer<scalar>>& setWriter,
247  const scalar minQuality,
248  const bool report
249  ) const;
250 
251  //- Write some stats
252  void writeStats(const List<wordList>&, Ostream&) const;
253 
254 
255  // Member Operators
256 
257  //- Return const and non-const reference to searchableSurface by index.
259 
260  //- Return const reference to searchableSurface by name.
261  const searchableSurface& operator[](const word&) const;
262 
263  //- Return reference to searchableSurface by name.
265 
266 
267  // Member Operators
268 
269  //- Disallow default bitwise assignment
270  void operator=(const searchableSurfaces&) = delete;
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:158
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.
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.
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.
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.
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.
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: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.