conformationSurfaces.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) 2012-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::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  //- Disallow default bitwise copy construct
130 
131  //- Disallow default bitwise assignment
132  void operator=(const conformationSurfaces&);
133 
134 
135 public:
136 
137  //- Runtime type information
138  ClassName("conformationSurfaces");
139 
140 
141  // Constructors
142 
143  //- Construct from dictionary and references to conformalVoronoiMesh and
144  // searchableSurfaces
146  (
147  const Time& runTime,
148  Random& rndGen,
149  const searchableSurfaces& allGeometry,
150  const dictionary& surfaceConformationDict
151  );
152 
153  //- Destructor
155 
156 
157  // Member Functions
158 
159  // Access
160 
161  //- Return reference to the searchableSurfaces object containing all
162  // of the geometry
163  inline const searchableSurfaces& geometry() const;
164 
165  //- Return the object holding the feature points and edges
166  inline const PtrList<extendedFeatureEdgeMesh>& features() const;
167 
168  //- Return the location to mesh
169  inline const point& locationInMesh() const;
170 
171  //- Return the surface indices
172  inline const labelList& surfaces() const;
173 
174  //- Return the patch names
175  inline const List<word>& patchNames() const;
176 
177  //- Return the surfaceZonesInfo
178  inline const PtrList<surfaceZonesInfo>& surfZones() const;
179 
180  //- Return the patch info
181  inline const PtrList<dictionary>& patchInfo() const;
182 
183  //- Return the global bounds
184  inline const treeBoundBox& globalBounds() const;
185 
186 
187  // Query
188 
189  //- Check if the supplied bound box overlaps any part of any of
190  // the surfaces
191  bool overlaps(const treeBoundBox& bb) const;
192 
193  //- Check if points are inside surfaces to conform to
194  Field<bool> inside(const pointField& samplePts) const;
195 
196  //- Check if point is inside surfaces to conform to
197  bool inside(const point& samplePt) const;
198 
199  //- Check if points are outside surfaces to conform to
200  Field<bool> outside(const pointField& samplePts) const;
201 
202  //- Check if point is outside surfaces to conform to
203  bool outside(const point& samplePt) const;
204 
205  //- Check if point is closer to the surfaces to conform to than
206  // testDistSqr, in which case return false, otherwise assess in or
207  // outside and return a result depending on the testForInside flag
209  (
210  const pointField& samplePts,
211  const scalarField& testDistSqr,
212  bool testForInside
213  ) const;
214 
215  //- Check if point is inside surfaces to conform to by at least
216  // testDistSqr
218  (
219  const pointField& samplePts,
220  const scalarField& testDistSqr
221  ) const;
222 
223  bool wellInside
224  (
225  const point& samplePt,
226  scalar testDistSqr
227  ) const;
228 
229  //- Check if point is outside surfaces to conform to by at least
230  // testDistSqr
232  (
233  const pointField& samplePts,
234  const scalarField& testDistSqr
235  ) const;
236 
237  bool wellOutside
238  (
239  const point& samplePt,
240  scalar testDistSqr
241  ) const;
242 
243  // Finding if the line joining start and end intersects the surface
245  (
246  const point& start,
247  const point& end
248  ) const;
249 
250  //- Finding if the line joining start and end intersects the surface
251  // and returning the hit and surface information
253  (
254  const point& start,
255  const point& end,
256  pointIndexHit& surfHit,
257  label& hitSurface
258  ) const;
259 
261  (
262  const point& start,
263  const point& end,
264  List<pointIndexHit>& surfHit,
265  labelList& hitSurface
266  ) const;
267 
268  //- Finding the nearestIntersection of the surface to start
270  (
271  const point& start,
272  const point& end,
273  pointIndexHit& surfHit,
274  label& hitSurface
275  ) const;
276 
277  //- Find the nearest point to the sample and return it to the
278  // pointIndexHit
279  void findSurfaceNearest
280  (
281  const point& sample,
282  scalar nearestDistSqr,
283  pointIndexHit& surfHit,
284  label& hitSurface
285  ) const;
286 
287  void findSurfaceNearest
288  (
289  const pointField& samples,
290  const scalarField& nearestDistSqr,
291  List<pointIndexHit>& hitInfo,
292  labelList& hitSurfaces
293  ) const;
294 
295  //- Find the nearest point on any feature edge
297  (
298  const point& sample,
299  scalar nearestDistSqr,
300  pointIndexHit& fpHit,
301  label& featureHit
302  ) const;
303 
304  //- Find the nearest point on any feature edge
305  void findEdgeNearest
306  (
307  const point& sample,
308  scalar nearestDistSqr,
309  pointIndexHit& edgeHit,
310  label& featureHit
311  ) const;
312 
313  void findEdgeNearest
314  (
315  const pointField& samples,
316  const scalarField& nearestDistsSqr,
317  List<pointIndexHit>& edgeHits,
318  labelList& featuresHit
319  ) const;
320 
321  //- Find the nearest point on each type of feature edge
323  (
324  const point& sample,
325  scalar nearestDistSqr,
326  List<pointIndexHit>& edgeHit,
327  List<label>& featuresHit
328  ) const;
329 
330  //- Find the nearest points on each feature edge that is within
331  // a given distance from the sample point. Will need to check for
332  // a hit or a miss because near edges may not have a nearest point
333  // on them which is perpendicular to the sample point.
335  (
336  const point& sample,
337  const scalar searchRadiusSqr,
338  List<List<pointIndexHit>>& edgeHitsByFeature,
339  List<label>& featuresHit
340  ) const;
341 
342  //- Get the region number of a hit surface
344  (
345  const label hitSurface,
346  const pointIndexHit& surfHit
347  ) const;
348 
349  //- Find which patch is intersected by the line from one point to
350  // another
351  label findPatch(const point& ptA, const point& ptB) const;
352 
353  //- Find which patch is closest to the point
354  label findPatch(const point& pt) const;
355 
356  //- Is the surface a baffle.
358  (
359  const label hitSurface,
360  const pointIndexHit& surfHit
361  ) const;
362 
363  void getNormal
364  (
365  const label hitSurface,
366  const List<pointIndexHit>& surfHit,
368  ) const;
369 
370 
371  // Write
372 
373  //- Write all components of all the extendedFeatureEdgeMeshes as
374  // an obj file
375  void writeFeatureObj(const fileName& prefix) const;
376 
377 };
378 
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 } // End namespace Foam
383 
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 
386 #include "conformationSurfacesI.H"
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 #endif
391 
392 // ************************************************************************* //
cachedRandom rndGen(label(0),-1)
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:69
Field< bool > wellOutside(const pointField &samplePts, const scalarField &testDistSqr) const
Check if point is outside surfaces to conform to by at least.
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Field< bool > wellInOutSide(const pointField &samplePts, const scalarField &testDistSqr, bool testForInside) const
Check if point is closer to the surfaces to conform to than.
bool overlaps(const treeBoundBox &bb) const
Check if the supplied bound box overlaps any part of any of.
void writeFeatureObj(const fileName &prefix) const
Write all components of all the extendedFeatureEdgeMeshes as.
Field< bool > inside(const pointField &samplePts) const
Check if points are inside surfaces to conform to.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
void getNormal(const label hitSurface, const List< pointIndexHit > &surfHit, vectorField &normal) const
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
label getPatchID(const label hitSurface, const pointIndexHit &surfHit) const
Get the region number of a hit surface.
bool findSurfaceAnyIntersection(const point &start, const point &end) const
const labelList & surfaces() const
Return the surface indices.
scalarField samples(nIntervals, 0)
const PtrList< extendedFeatureEdgeMesh > & features() const
Return the object holding the feature points and edges.
Pre-declare SubField and related Field type.
Definition: Field.H:57
A class for handling words, derived from string.
Definition: word.H:59
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.
Container for searchableSurfaces.
sideVolumeType
Normals point to the outside.
void findSurfaceAllIntersections(const point &start, const point &end, List< pointIndexHit > &surfHit, labelList &hitSurface) const
const searchableSurfaces & geometry() const
Return reference to the searchableSurfaces object containing all.
Simple random number generator.
Definition: Random.H:49
ClassName("conformationSurfaces")
Runtime type information.
~conformationSurfaces()
Destructor.
A normal distribution model.
label findPatch(const point &ptA, const point &ptB) const
Find which patch is intersected by the line from one point to.
const point & locationInMesh() const
Return the location to mesh.
const PtrList< surfaceZonesInfo > & surfZones() const
Return the surfaceZonesInfo.
void findSurfaceNearestIntersection(const point &start, const point &end, pointIndexHit &surfHit, label &hitSurface) const
Finding the nearestIntersection of the surface to start.
void findFeaturePointNearest(const point &sample, scalar nearestDistSqr, pointIndexHit &fpHit, label &featureHit) const
Find the nearest point on any feature edge.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
Field< bool > wellInside(const pointField &samplePts, const scalarField &testDistSqr) const
Check if point is inside surfaces to conform to by at least.
void findEdgeNearestByType(const point &sample, scalar nearestDistSqr, List< pointIndexHit > &edgeHit, List< label > &featuresHit) const
Find the nearest point on each type of feature edge.
const PtrList< dictionary > & patchInfo() const
Return the patch info.
extendedFeatureEdgeMesh::sideVolumeType meshableSide(const label hitSurface, const pointIndexHit &surfHit) const
Is the surface a baffle.
const List< word > & patchNames() const
Return the patch names.
const treeBoundBox & globalBounds() const
Return the global bounds.
Namespace for OpenFOAM.