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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::searchableSurfaces
28 
29 Description
30  Container for searchableSurfaces.
31  The collection is specified as a dictionary. For example,
32 
33  \verbatim
34  geometry
35  {
36  surface1
37  {
38  type ...;
39  }
40  surface2
41  {
42  type ...;
43  }
44  }
45  \endverbatim
46 
47  \heading The Sub-dictionary parameters
48  \table
49  Property | Description | Required | Default
50  name | alternative name for surface | no | dict name
51  regions | Region names sub-dictionary | no |
52  \endtable
53 
54 SourceFiles
55  searchableSurfaces.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef searchableSurfaces_H
60 #define searchableSurfaces_H
61 
62 #include "searchableSurface.H"
63 #include "labelPair.H"
64 #include "writer.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 // Forward declarations
72 class triSurface;
73 
74 /*---------------------------------------------------------------------------*\
75  Class searchableSurfaces Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class searchableSurfaces
79 :
80  public PtrList<searchableSurface>
81 {
82  // Private data
83 
84  //- Surface names
85  wordList names_;
86 
87  //- Region names per surface
88  List<wordList> regionNames_;
89 
90  //- Indices of all surfaces. Precalculated and stored.
91  labelList allSurfaces_;
92 
93 
94  // Private Member Functions
95 
96  //- Is edge on face
97  static bool connected
98  (
99  const triSurface& s,
100  const label edgeI,
101  const pointIndexHit& hit
102  );
103 
104 
105  //- No copy construct
106  searchableSurfaces(const searchableSurfaces&) = delete;
107 
108  //- No copy assignment
109  void operator=(const searchableSurfaces&) = delete;
110 
111 
112 public:
113 
114  ClassName("searchableSurfaces");
115 
116 
117  // Constructors
118 
119  //- Construct with length specified. Fill later.
120  explicit searchableSurfaces(const label);
121 
122 
124  //searchableSurfaces(const IOobject&, const PtrList<dictionary>&);
125 
126  //- Construct from dictionary.
127  // \param singleRegionName controls if names are constructed as
128  // surfaceName "_" regionName (singleRegionName false) or for
129  // single region surfaces as surfaceName only (singleRegionName
130  // true)
132  (
133  const IOobject&,
134  const dictionary&,
135  const bool singleRegionName
136  );
137 
138 
139  // Member Functions
140 
141  //- Surface names, not region names
142  const wordList& names() const
143  {
144  return names_;
145  }
146 
147  //- Surface names, not region names
148  wordList& names()
149  {
150  return names_;
151  }
152 
153  //- Region names per surface
154  const List<wordList>& regionNames() const
155  {
156  return regionNames_;
157  }
158 
159  //- Region names per surface
161  {
162  return regionNames_;
163  }
164 
165 
167  //HashTable<labelPair>& regionNames()
168  //{
169  // return regionNames_;
170  //}
172  //const labelPair& surfaceRegion(const word& globalRegion) const
173  //{
174  // return regionNames_[globalRegion];
175  //}
176 
177  //- Find index of surface. Return -1 if not found.
178  label findSurfaceID(const word& name) const;
179 
180  label findSurfaceRegionID
181  (
182  const word& surfaceName,
183  const word& regionName
184  ) const;
185 
186  // Multiple point queries.
187 
188  //- Find any intersection. Return hit point information and
189  // surface number. If multiple surfaces hit the first surface
190  // is returned, not necessarily the nearest (to start).
192  (
193  const pointField& start,
194  const pointField& end,
195  labelList& surfaces,
197  ) const;
198 
199  //- Find all intersections in order from start to end. Returns for
200  // every hit the surface and the hit info.
202  (
203  const pointField& start,
204  const pointField& end,
205  labelListList& surfaces,
207  ) const;
208 
209  //Find intersections of edge nearest to both endpoints.
211  (
212  const pointField& start,
213  const pointField& end,
214  labelList& surface1,
215  List<pointIndexHit>& hit1,
216  labelList& surface2,
217  List<pointIndexHit>& hit2
218  ) const;
219 
220  //- Find nearest. Return -1 (and a miss()) or surface and nearest
221  // point.
222  void findNearest
223  (
224  const pointField&,
225  const scalarField& nearestDistSqr,
226  labelList& surfaces,
228  ) const;
229 
230  void findNearest
231  (
232  const labelListList& regionIndices,
233  const pointField& samples,
234  const scalarField& nearestDistSqr,
235  labelList& nearestSurfaces,
236  List<pointIndexHit>& nearestInfo
237  ) const;
238 
239  //- Calculate bounding box
240  boundBox bounds() const;
241 
242  // Checking
243 
244  //- Are all surfaces closed and manifold
245  bool checkClosed(const bool report) const;
246 
247  //- Are all (triangulated) surfaces consistent normal orientation
248  bool checkNormalOrientation(const bool report) const;
249 
250  //- Are all bounding boxes of similar size
251  bool checkSizes(const scalar maxRatio, const bool report) const;
252 
253  //- Do surfaces self-intersect or intersect others
254  bool checkIntersection
255  (
256  const scalar tol,
257  const autoPtr<writer<scalar>>&,
258  const bool report
259  ) const;
260 
261  //- Check triangle quality
262  bool checkQuality
263  (
264  const scalar minQuality,
265  const bool report
266  ) const;
267 
268  //- All topological checks. Return number of failed checks
269  label checkTopology(const bool report) const;
270 
271  //- All geometric checks. Return number of failed checks
272  label checkGeometry
273  (
274  const scalar maxRatio,
275  const scalar tolerance,
276  const autoPtr<writer<scalar>>& setWriter,
277  const scalar minQuality,
278  const bool report
279  ) const;
280 
281  //- Write some stats
282  void writeStats(const List<wordList>&, Ostream&) const;
283 
284 
285  // Member Operators
286 
287  //- Return const and non-const reference to searchableSurface by index.
289 
290  //- Return const reference to searchableSurface by name.
291  const searchableSurface& operator[](const word&) const;
292 
293  //- Return reference to searchableSurface by name.
295 
296 
297 };
298 
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 } // End namespace Foam
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Definition: gmvOutputSpray.H:25
searchableSurface.H
Foam::searchableSurfaces::checkIntersection
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar >> &, const bool report) const
Do surfaces self-intersect or intersect others.
Definition: searchableSurfaces.C:611
Foam::searchableSurfaces::checkQuality
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
Definition: searchableSurfaces.C:755
Foam::searchableSurfaces::findNearestIntersection
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
Definition: searchableSurfaces.C:372
Foam::searchableSurfaces::checkTopology
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
Definition: searchableSurfaces.C:820
Foam::searchableSurfaces::writeStats
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
Definition: searchableSurfaces.C:870
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::searchableSurfaces::findAnyIntersection
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
Definition: searchableSurfaces.C:331
Foam::searchableSurfaces::bounds
boundBox bounds() const
Calculate bounding box.
Definition: searchableSurfaces.C:439
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:55
Foam::Field< vector >
Foam::searchableSurfaces::checkClosed
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
Definition: searchableSurfaces.C:449
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:76
Foam::searchableSurfaces::findNearest
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
Definition: searchableSurfaces.C:396
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
samples
scalarField samples(nIntervals, Zero)
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::searchableSurfaces::findSurfaceRegionID
label findSurfaceRegionID(const word &surfaceName, const word &regionName) const
Definition: searchableSurfaces.C:318
Foam::searchableSurfaces::findSurfaceID
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
Definition: searchableSurfaces.C:309
Foam::searchableSurfaces::names
wordList & names()
Surface names, not region names.
Definition: searchableSurfaces.H:162
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::searchableSurfaces::regionNames
List< wordList > & regionNames()
Region names per surface.
Definition: searchableSurfaces.H:174
Foam::searchableSurfaces::operator[]
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
Definition: searchableSurfaces.C:915
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam::writer< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::searchableSurfaces::checkSizes
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
Definition: searchableSurfaces.C:563
Foam::searchableSurfaces::regionNames
const List< wordList > & regionNames() const
Region names per surface.
Definition: searchableSurfaces.H:168
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::searchableSurfaces::checkGeometry
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.
Definition: searchableSurfaces.C:840
Foam::List< word >
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::searchableSurfaces::checkNormalOrientation
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
Definition: searchableSurfaces.C:516
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::searchableSurfaces::names
const wordList & names() const
Surface names, not region names.
Definition: searchableSurfaces.H:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
writer.H
Foam::searchableSurfaces::ClassName
ClassName("searchableSurfaces")
Foam::searchableSurfaces::findAllIntersections
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.
Definition: searchableSurfaces.C:351
labelPair.H