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