searchableSurfaceWithGaps.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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::searchableSurfaceWithGaps
28
29Description
30 searchableSurface using multiple slightly shifted underlying surfaces
31 to make sure pierces don't go through gaps:
32 - shift test vector with two small vectors (of size gap_) perpendicular
33 to the original.
34 Test with + and - this vector. Only if both register a hit is it seen
35 as one.
36 - extend the test vector slightly (with SMALL) to account for numerical
37 inaccuracies.
38
39 \verbatim
40 sphere.stl
41 {
42 type triSurfaceMesh;
43 }
44
45 sphere
46 {
47 type searchableSurfaceWithGaps;
48 surface sphere.stl; // Underlying surface
49 gap 1e-3; // Perturb distance
50 }
51 \endverbatim
52
53 \heading Dictionary parameters
54 \table
55 Property | Description | Required | Default
56 type | searchableSurfaceWithGaps | selector |
57 surface | Name of the underlying surface | yes |
58 gap | Gap tolerance in meters | yes |
59 \endtable
60
61SourceFiles
62 searchableSurfaceWithGaps.C
63
64\*---------------------------------------------------------------------------*/
65
66#ifndef searchableSurfaceWithGaps_H
67#define searchableSurfaceWithGaps_H
68
69#include "searchableSurface.H"
70#include "UPtrList.H"
71#include "Pair.H"
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
75namespace Foam
76{
77
78/*---------------------------------------------------------------------------*\
79 Class searchableSurfaceWithGaps Declaration
80\*---------------------------------------------------------------------------*/
81
82class searchableSurfaceWithGaps
83:
84 public searchableSurface
85{
86private:
87
88 // Private Member Data
89
90 //- Gap size in metre
91 const scalar gap_;
92
93 //- Underlying geometry (size 1)
94 UPtrList<searchableSurface> subGeom_;
95
96
97 // Private Member Functions
98
99 Pair<vector> offsetVecs(const point&, const point&) const;
100
101 void offsetVecs
102 (
103 const pointField& start,
104 const pointField& end,
105 pointField& offset0,
106 pointField& offset1
107 ) const;
108
109 static label countMisses
110 (
112 labelList& missMap
113 );
114
115 static label countMisses
116 (
117 const List<pointIndexHit>& plusInfo,
118 const List<pointIndexHit>& minInfo,
119 labelList& missMap
120 );
121
122
123 //- No copy construct
125
126 //- No copy assignment
127 void operator=(const searchableSurfaceWithGaps&) = delete;
128
129
130public:
131
132 //- Runtime type information
133 TypeName("searchableSurfaceWithGaps");
134
135
136 // Constructors
137
138 //- Construct from dictionary (used by searchableSurface)
140 (
141 const IOobject& io,
142 const dictionary& dict
143 );
144
145 //- Destructor
146 virtual ~searchableSurfaceWithGaps() = default;
147
148
149 // Member Functions
150
151 //- The underlying searchableSurface
153 {
154 return subGeom_[0];
155 }
156
157 //- Name of regions
158 virtual const wordList& regions() const
159 {
160 return surface().regions();
161 }
162
163 //- Whether supports volume type (below)
164 virtual bool hasVolumeType() const
166 return surface().hasVolumeType();
167 }
168
169 //- What is type of points outside bounds
170 virtual volumeType outsideVolumeType() const
172 return surface().outsideVolumeType();
173 }
174
175 //- Range of local indices that can be returned.
176 virtual label size() const
178 return surface().size();
179 }
180
181 //- Get representative set of element coordinates
182 // Usually the element centres (should be of length size()).
184 {
185 return surface().coordinates();
186 }
187
188 //- Get bounding spheres (centre and radius squared), one per element.
189 // Any point on element is guaranteed to be inside.
190 virtual void boundingSpheres
191 (
192 pointField& centres,
193 scalarField& radiusSqr
194 ) const
196 surface().boundingSpheres(centres, radiusSqr);
197 }
198
199 //- Get the points that define the surface.
200 virtual tmp<pointField> points() const
201 {
202 return surface().points();
203 }
204
205 //- Does any part of the surface overlap the supplied bound box?
206 // Note: use perturbed surface? Since uses boundbox of points and
207 // not actual intersection chosen to use unperturbed surface.
208 virtual bool overlaps(const boundBox& bb) const
210 return surface().overlaps(bb);
211 }
212
213
214 // Multiple point queries.
215
216 //- Find nearest on original surface. Note:does not use perturbation
217 // and hence might be inconsistent with intersections.
218 virtual void findNearest
220 const pointField& sample,
221 const scalarField& nearestDistSqr,
223 ) const
224 {
226 (
228 nearestDistSqr,
229 info
230 );
231 }
232
233 virtual void findLine
234 (
235 const pointField& start,
236 const pointField& end,
238 ) const;
239
240 virtual void findLineAny
241 (
242 const pointField& start,
243 const pointField& end,
245 ) const;
246
247 //- Get all intersections in order from start to end.
248 virtual void findLineAll
249 (
250 const pointField& start,
251 const pointField& end,
253 ) const;
254
255 //- From a set of points and indices get the region
256 virtual void getRegion
257 (
259 labelList& region
260 ) const
261 {
262 surface().getRegion(info, region);
263 }
264
265 //- From a set of points and indices get the normal
266 virtual void getNormal
267 (
269 vectorField& normal
270 ) const
271 {
272 surface().getNormal(info, normal);
273 }
274
275 //- Determine type (inside/outside/mixed) for points.
276 // Unknown if cannot be determined (e.g. non-manifold surface)
277 virtual void getVolumeType
278 (
279 const pointField& samples,
281 ) const
282 {
284 }
286
287 // Other
288
289 //- Set bounds of surface. Bounds currently set as list of
290 // bounding boxes. The bounds are hints to the surface as for
291 // the range of queries it can expect. faceMap/pointMap can be
292 // set if the surface has done any redistribution.
293 //virtual void distribute
294 //(
295 // const List<treeBoundBox>& bbs,
296 // const bool keepNonLocal,
297 // autoPtr<mapDistribute>& faceMap,
298 // autoPtr<mapDistribute>& pointMap
299 //)
300 //{
301 // subGeom_[0].distribute(bbs, keepNonLocal, faceMap, pointMap);
302 //}
303
304 //- WIP. Store element-wise field.
305 virtual void setField(const labelList& values)
306 {
307 subGeom_[0].setField(values);
308 }
309
310 //- WIP. From a set of hits (points and
311 // indices) get the specified field. Misses do not get set. Return
312 // empty field if not supported.
313 virtual void getField
314 (
316 labelList& values
317 ) const
318 {
319 surface().getField(info, values);
320 }
321
322 // regIOobject implementation
323
324 bool writeData(Ostream& os) const
325 {
326 return surface().writeData(os);
327 }
328
329};
330
331
332// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333
334} // End namespace Foam
335
336// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337
338#endif
339
340// ************************************************************************* //
Minimal example by using system/controlDict.functions:
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
InfoProxy< IOobject > info() const
Return info proxy, for printing information to a stream.
Definition: IOobject.H:690
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:69
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool writeData(Ostream &) const =0
Pure virtual writeData function.
searchableSurface using multiple slightly shifted underlying surfaces to make sure pierces don't go t...
virtual label size() const
Range of local indices that can be returned.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
TypeName("searchableSurfaceWithGaps")
Runtime type information.
virtual void getRegion(const List< pointIndexHit > &info, labelList &region) const
From a set of points and indices get the region.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void getNormal(const List< pointIndexHit > &info, vectorField &normal) const
From a set of points and indices get the normal.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
bool writeData(Ostream &os) const
Pure virtual writeData function.
virtual void setField(const labelList &values)
Set bounds of surface. Bounds currently set as list of.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Find nearest on original surface. Note:does not use perturbation.
virtual void getVolumeType(const pointField &samples, List< volumeType > &info) const
Determine type (inside/outside/mixed) for points.
virtual void getField(const List< pointIndexHit > &info, labelList &values) const
WIP. From a set of hits (points and.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared), one per element.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual volumeType outsideVolumeType() const
What is type of points outside bounds.
const searchableSurface & surface() const
The underlying searchableSurface.
virtual ~searchableSurfaceWithGaps()=default
Destructor.
virtual bool hasVolumeType() const
Whether supports volume type (below)
virtual const wordList & regions() const
Name of regions.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const =0
From a set of points and indices get the region.
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual volumeType outsideVolumeType() const =0
If surface supports volume queries, what is type of points outside.
virtual void getField(const List< pointIndexHit > &, labelList &values) const
WIP. From a set of hits (points and.
virtual bool overlaps(const boundBox &bb) const =0
Does any part of the surface overlap the supplied bound box?
virtual const wordList & regions() const =0
Names of regions.
virtual tmp< pointField > points() const =0
Get the points that define the surface.
virtual label size() const =0
Range of local indices that can be returned.
virtual bool hasVolumeType() const
Whether supports volume type (below).
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const =0
Get bounding spheres (centre and radius squared), one per element.
virtual tmp< pointField > coordinates() const =0
Get representative set of element coordinates.
A class for managing temporary objects.
Definition: tmp.H:65
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
vector point
Point is a vector.
Definition: point.H:43
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
scalarField samples(nIntervals, Zero)