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