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