conformationSurfaces.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) 2012-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::conformationSurfaces
26 
27 Description
28 
29 SourceFiles
30  conformationSurfacesI.H
31  conformationSurfaces.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef conformationSurfaces_H
36 #define conformationSurfaces_H
37 
38 #include "searchableSurfaces.H"
41 #include "boolList.H"
42 #include "volumeType.H"
43 #include "surfaceZonesInfo.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class conformationSurfaces Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 {
57 
58  // Private Data
59 
60  const Time& runTime_;
61 
62  Random& rndGen_;
63 
64  //- Reference to the searchableSurfaces object holding all geometry data
65  const searchableSurfaces& allGeometry_;
66 
67  //- A list of extendedFeatureEdgeMesh
69 
70  //- The location in the mesh that specifies which portion of surfaces is
71  // to be meshed.
72  point locationInMesh_;
73 
74  //- Indices of surfaces in allGeometry that are to be conformed to
75  labelList surfaces_;
76 
77  //- Reverse mapping, which entry in surfaces corresponds to the surface
78  // in allGeometry specified by the list index. -1 for a surface that
79  // isn't used.
80  labelList allGeometryToSurfaces_;
81 
82  //- A boolean value for each surface to be conformed to specifying if it
83  // is to be treated as a baffle
84  List<sideVolumeType> normalVolumeTypes_;
85 
86  //- A flat list of all of the names of the patches from all of the
87  // surfaces to be reproduced in the meshed geometry
88  List<word> patchNames_;
89 
90  //- List of surface zone (face and cell zone) information
91  PtrList<surfaceZonesInfo> surfZones_;
92 
93  //- The offset between the patch indices of the individual surface and
94  // the entry in the overall patch list
95  labelList regionOffset_;
96 
97  //- From global region number to patchType
98  PtrList<dictionary> patchInfo_;
99 
100  //- The overall boundBox of all of the surfaces to be conformed to
101  treeBoundBox globalBounds_;
102 
103  //- The pattern/signature of volumeTypes representing a point in the
104  // domain to be meshed
105  List<volumeType> referenceVolumeTypes_;
106 
107 
108  // Private Member Functions
109 
110  void hasBoundedVolume(List<volumeType>& referenceVolumeTypes) const;
111 
112  //- Read into features_ from a dictionary
113  void readFeatures
114  (
115  const label surfI,
116  const dictionary& featureDict,
117  const word& surfaceName,
118  label& featureIndex
119  );
120 
121  void readFeatures
122  (
123  const dictionary& featureDict,
124  const word& surfaceName,
125  label& featureIndex
126  );
127 
128 
129 public:
130 
131  //- Runtime type information
132  ClassName("conformationSurfaces");
133 
134 
135  // Constructors
136 
137  //- Construct from dictionary and references to conformalVoronoiMesh and
138  // searchableSurfaces
140  (
141  const Time& runTime,
142  Random& rndGen,
143  const searchableSurfaces& allGeometry,
144  const dictionary& surfaceConformationDict
145  );
146 
147  //- Disallow default bitwise copy construction
149 
150 
151  //- Destructor
153 
154 
155  // Member Functions
156 
157  // Access
158 
159  //- Return reference to the searchableSurfaces object containing all
160  // of the geometry
161  inline const searchableSurfaces& geometry() const;
162 
163  //- Return the object holding the feature points and edges
164  inline const PtrList<extendedFeatureEdgeMesh>& features() const;
165 
166  //- Return the location to mesh
167  inline const point& locationInMesh() const;
168 
169  //- Return the surface indices
170  inline const labelList& surfaces() const;
171 
172  //- Return the patch names
173  inline const List<word>& patchNames() const;
174 
175  //- Return the surfaceZonesInfo
176  inline const PtrList<surfaceZonesInfo>& surfZones() const;
177 
178  //- Return the patch info
179  inline const PtrList<dictionary>& patchInfo() const;
180 
181  //- Return the global bounds
182  inline const treeBoundBox& globalBounds() const;
183 
184 
185  // Query
186 
187  //- Check if the supplied bound box overlaps any part of any of
188  // the surfaces
189  bool overlaps(const treeBoundBox& bb) const;
190 
191  //- Check if points are inside surfaces to conform to
192  Field<bool> inside(const pointField& samplePts) const;
193 
194  //- Check if point is inside surfaces to conform to
195  bool inside(const point& samplePt) const;
196 
197  //- Check if points are outside surfaces to conform to
198  Field<bool> outside(const pointField& samplePts) const;
199 
200  //- Check if point is outside surfaces to conform to
201  bool outside(const point& samplePt) const;
202 
203  //- Check if point is closer to the surfaces to conform to than
204  // testDistSqr, in which case return false, otherwise assess in or
205  // outside and return a result depending on the testForInside flag
207  (
208  const pointField& samplePts,
209  const scalarField& testDistSqr,
210  bool testForInside
211  ) const;
212 
213  //- Check if point is inside surfaces to conform to by at least
214  // testDistSqr
216  (
217  const pointField& samplePts,
218  const scalarField& testDistSqr
219  ) const;
220 
221  bool wellInside
222  (
223  const point& samplePt,
224  scalar testDistSqr
225  ) const;
226 
227  //- Check if point is outside surfaces to conform to by at least
228  // testDistSqr
230  (
231  const pointField& samplePts,
232  const scalarField& testDistSqr
233  ) const;
234 
235  bool wellOutside
236  (
237  const point& samplePt,
238  scalar testDistSqr
239  ) const;
240 
241  // Finding if the line joining start and end intersects the surface
243  (
244  const point& start,
245  const point& end
246  ) const;
247 
248  //- Finding if the line joining start and end intersects the surface
249  // and returning the hit and surface information
251  (
252  const point& start,
253  const point& end,
254  pointIndexHit& surfHit,
255  label& hitSurface
256  ) const;
257 
259  (
260  const point& start,
261  const point& end,
262  List<pointIndexHit>& surfHit,
263  labelList& hitSurface
264  ) const;
265 
266  //- Finding the nearestIntersection of the surface to start
268  (
269  const point& start,
270  const point& end,
271  pointIndexHit& surfHit,
272  label& hitSurface
273  ) const;
274 
275  //- Find the nearest point to the sample and return it to the
276  // pointIndexHit
277  void findSurfaceNearest
278  (
279  const point& sample,
280  scalar nearestDistSqr,
281  pointIndexHit& surfHit,
282  label& hitSurface
283  ) const;
284 
285  void findSurfaceNearest
286  (
287  const pointField& samples,
288  const scalarField& nearestDistSqr,
289  List<pointIndexHit>& hitInfo,
290  labelList& hitSurfaces
291  ) const;
292 
293  //- Find the nearest point on any feature edge
295  (
296  const point& sample,
297  scalar nearestDistSqr,
298  pointIndexHit& fpHit,
299  label& featureHit
300  ) const;
301 
302  //- Find the nearest point on any feature edge
303  void findEdgeNearest
304  (
305  const point& sample,
306  scalar nearestDistSqr,
307  pointIndexHit& edgeHit,
308  label& featureHit
309  ) const;
310 
311  void findEdgeNearest
312  (
313  const pointField& samples,
314  const scalarField& nearestDistsSqr,
315  List<pointIndexHit>& edgeHits,
316  labelList& featuresHit
317  ) const;
318 
319  //- Find the nearest point on each type of feature edge
321  (
322  const point& sample,
323  scalar nearestDistSqr,
324  List<pointIndexHit>& edgeHit,
325  List<label>& featuresHit
326  ) const;
327 
328  //- Find the nearest points on each feature edge that is within
329  // a given distance from the sample point. Will need to check for
330  // a hit or a miss because near edges may not have a nearest point
331  // on them which is perpendicular to the sample point.
333  (
334  const point& sample,
335  const scalar searchRadiusSqr,
336  List<List<pointIndexHit>>& edgeHitsByFeature,
337  List<label>& featuresHit
338  ) const;
339 
340  //- Get the region number of a hit surface
342  (
343  const label hitSurface,
344  const pointIndexHit& surfHit
345  ) const;
346 
347  //- Find which patch is intersected by the line from one point to
348  // another
349  label findPatch(const point& ptA, const point& ptB) const;
350 
351  //- Find which patch is closest to the point
352  label findPatch(const point& pt) const;
353 
354  //- Is the surface a baffle.
356  (
357  const label hitSurface,
358  const pointIndexHit& surfHit
359  ) const;
360 
361  void getNormal
362  (
363  const label hitSurface,
364  const List<pointIndexHit>& surfHit,
365  vectorField& normal
366  ) const;
367 
368 
369  // Write
370 
371  //- Write all components of all the extendedFeatureEdgeMeshes as
372  // an obj file
373  void writeFeatureObj(const fileName& prefix) const;
374 
375 
376  // Member Operators
377 
378  //- Disallow default bitwise assignment
379  void operator=(const conformationSurfaces&) = delete;
380 };
381 
382 
383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
384 
385 } // End namespace Foam
386 
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 
389 #include "conformationSurfacesI.H"
390 
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
392 
393 #endif
394 
395 // ************************************************************************* //
Field< bool > inside(const pointField &samplePts) const
Check if points are inside surfaces to conform to.
void operator=(const conformationSurfaces &)=delete
Disallow default bitwise assignment.
void findEdgeNearestByType(const point &sample, scalar nearestDistSqr, List< pointIndexHit > &edgeHit, List< label > &featuresHit) const
Find the nearest point on each type of feature edge.
bool overlaps(const treeBoundBox &bb) const
Check if the supplied bound box overlaps any part of any of.
const searchableSurfaces & geometry() const
Return reference to the searchableSurfaces object containing all.
Field< bool > outside(const pointField &samplePts) const
Check if points are outside surfaces to conform to.
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 class for handling file names.
Definition: fileName.H:79
conformationSurfaces(const Time &runTime, Random &rndGen, const searchableSurfaces &allGeometry, const dictionary &surfaceConformationDict)
Construct from dictionary and references to conformalVoronoiMesh and.
const treeBoundBox & globalBounds() const
Return the global bounds.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
Field< bool > wellInside(const pointField &samplePts, const scalarField &testDistSqr) const
Check if point is inside surfaces to conform to by at least.
const labelList & surfaces() const
Return the surface indices.
const PtrList< surfaceZonesInfo > & surfZones() const
Return the surfaceZonesInfo.
engineTime & runTime
void findFeaturePointNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &fpHit, label &featureHit) const
Find the nearest point on any feature edge.
extendedFeatureEdgeMesh::sideVolumeType meshableSide(const label hitSurface, const pointIndexHit &surfHit) const
Is the surface a baffle.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Random rndGen(label(0))
scalarField samples(nIntervals, 0)
const PtrList< extendedFeatureEdgeMesh > & features() const
Return the object holding the feature points and edges.
bool findSurfaceAnyIntersection(const point &start, const point &end) const
A class for handling words, derived from string.
Definition: word.H:59
void findAllNearestEdges(const point &sample, const scalar searchRadiusSqr, List< List< pointIndexHit >> &edgeHitsByFeature, List< label > &featuresHit) const
Find the nearest points on each feature edge that is within.
void getNormal(const label hitSurface, const List< pointIndexHit > &surfHit, vectorField &normal) const
Container for searchableSurfaces.
sideVolumeType
Normals point to the outside.
void writeFeatureObj(const fileName &prefix) const
Write all components of all the extendedFeatureEdgeMeshes as.
void findSurfaceNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &surfHit, label &hitSurface) const
Find the nearest point to the sample and return it to the.
void findEdgeNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &edgeHit, label &featureHit) const
Find the nearest point on any feature edge.
Field< bool > wellInOutSide(const pointField &samplePts, const scalarField &testDistSqr, bool testForInside) const
Check if point is closer to the surfaces to conform to than.
Random number generator.
Definition: Random.H:57
ClassName("conformationSurfaces")
Runtime type information.
Field< bool > wellOutside(const pointField &samplePts, const scalarField &testDistSqr) const
Check if point is outside surfaces to conform to by at least.
~conformationSurfaces()
Destructor.
const List< word > & patchNames() const
Return the patch names.
void findSurfaceAllIntersections(const point &start, const point &end, List< pointIndexHit > &surfHit, labelList &hitSurface) const
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
void findSurfaceNearestIntersection(const point &start, const point &end, pointIndexHit &surfHit, label &hitSurface) const
Finding the nearestIntersection of the surface to start.
const point & locationInMesh() const
Return the location to mesh.
label getPatchID(const label hitSurface, const pointIndexHit &surfHit) const
Get the region number of a hit surface.
const PtrList< dictionary > & patchInfo() const
Return the patch info.
Namespace for OpenFOAM.
label findPatch(const point &ptA, const point &ptB) const
Find which patch is intersected by the line from one point to.