Loading...
Searching...
No Matches
triSurfaceMesh.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 Copyright (C) 2015-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::triSurfaceMesh
29
30Description
31 IOoject and searching on triSurface
32
33 Note: when constructing from dictionary has the following parameters:
34 - scale : scaling factor.
35 - tolerance : relative tolerance for doing intersections
36 (see triangle::intersection)
37 - minQuality: discard triangles with low quality when getting normal
38
39 \heading Dictionary parameters
40 \table
41 Property | Description | Required | Default
42 type | triSurfaceMesh | selector |
43 file | File name to locate the surface | no |
44 fileType | The surface format (Eg, nastran) | no |
45 scale | Scaling factor | no | 0
46 minQuality | Quality criterion | no | -1
47 \endtable
48
49SourceFiles
50 triSurfaceMesh.C
51
52\*---------------------------------------------------------------------------*/
53
54#ifndef triSurfaceMesh_H
55#define triSurfaceMesh_H
56
57#include "searchableSurface.H"
58#include "treeBoundBox.H"
59#include "objectRegistry.H"
60#include "indexedOctree.H"
61#include "treeDataTriSurface.H"
63#include "treeDataEdge.H"
64#include "edgeHashes.H"
65#include "triSurface.H"
67
68// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69
70namespace Foam
71{
72
73/*---------------------------------------------------------------------------*\
74 Class triSurfaceMesh Declaration
75\*---------------------------------------------------------------------------*/
76
78:
79 public searchableSurface,
80 public objectRegistry, // so we can store fields
81 public triSurface,
83{
84protected:
85
86 // Private member data
87
88 //- Supplied fileName override
89 fileName fName_;
90
91 //- Optional min triangle quality. Triangles below this get
92 // ignored for normal calculation
93 scalar minQuality_;
94
95 //- Search tree for boundary edges.
96 mutable autoPtr<indexedOctree<treeDataEdge>> edgeTree_;
97
98 //- Names of regions
99 mutable wordList regions_;
100
101 //- Is surface closed
102 mutable label surfaceClosed_;
103
104 //- If surface is closed, what is type of outside points
106
107
108 // Private Member Functions
109
110 //- Helper function for isSurfaceClosed
111 static bool addFaceToEdge
112 (
113 const edge&,
115 );
117 //- Check whether surface is closed without calculating any permanent
118 // addressing.
119 bool isSurfaceClosed() const;
120
121 //- Steps to next intersection. Adds smallVec and starts tracking
122 // from there.
124 (
126 const point& start,
127 const point& end,
128 const vector& smallVec,
130 );
131
132 //- No copy construct
134
135 //- No copy assignment
136 void operator=(const triSurfaceMesh&) = delete;
137
139public:
140
141 //- Runtime type information
142 TypeName("triSurfaceMesh");
144 //- Return the mesh sub-directory name (usually "triSurface")
145 static word meshSubDir;
146
147
148 // Constructors
149
150 //- Construct from triSurface
151 triSurfaceMesh(const IOobject&, const triSurface&);
152
153 //- Construct read
154 triSurfaceMesh(const IOobject& io);
155
156 //- Construct from IO and dictionary (used by searchableSurface).
157 // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
159 (
160 const IOobject& io,
161 const dictionary& dict
162 );
163
164
165 // Special constructors for use by distributedTriSurface. File search
166 // method supplied:
167
168 enum readAction
170 localOnly, // load from (processor-)local file only
171 localOrGlobal, // load from (processor-)local or global file
172 masterOnly // as localOrGlobal but only load on master
173 };
174
175 triSurfaceMesh(const IOobject& io, const readAction r);
176
178 (
179 const IOobject& io,
180 const dictionary& dict,
182 );
183
184
185 //- Destructor
187
188
189 //- Clear storage
190 void clearOut();
191
192
193 // Member Functions
195 //- Move points
196 virtual void movePoints(const pointField&);
197
198 //- Demand driven construction of octree for boundary edges
200
201
202 // searchableSurface implementation
203
204 //- Names of regions
205 virtual const wordList& regions() const;
206
207 //- Whether supports volume type (below) - i.e. whether is closed.
208 virtual bool hasVolumeType() const;
209
210 //- If surface is closed, what is type of points outside bounds
211 virtual volumeType outsideVolumeType() const;
212
213 //- Range of local indices that can be returned.
214 virtual label size() const
215 {
216 return triSurface::size();
217 }
218
219 //- Flip triangles, outsideVolumeType and all cached inside/outside.
220 virtual void flip();
221
222 //- Get representative set of element coordinates
223 // Usually the element centres (should be of length size()).
224 virtual tmp<pointField> coordinates() const;
225
226 //- Get bounding spheres (centre and radius squared). Any point
227 // on surface is guaranteed to be inside.
228 virtual void boundingSpheres
230 pointField& centres,
231 scalarField& radiusSqr
232 ) const;
234 //- Get the points that define the surface.
235 virtual tmp<pointField> points() const;
236
237 // Does any part of the surface overlap the supplied bound box?
238 virtual bool overlaps(const boundBox& bb) const;
239
240 virtual void findNearest
241 (
242 const pointField& sample,
243 const scalarField& nearestDistSqr,
245 ) const;
246
247 virtual void findNearest
248 (
249 const pointField& sample,
250 const scalarField& nearestDistSqr,
251 const labelList& regionIndices,
253 ) const;
254
255 virtual void findLine
256 (
257 const pointField& start,
258 const pointField& end,
260 ) const;
261
262 virtual void findLineAny
263 (
264 const pointField& start,
265 const pointField& end,
267 ) const;
268
269 //- Get all intersections in order from start to end.
270 virtual void findLineAll
271 (
272 const pointField& start,
273 const pointField& end,
275 ) const;
276
277 //- From a set of points and indices get the region
278 virtual void getRegion
279 (
280 const List<pointIndexHit>&,
281 labelList& region
282 ) const;
283
284 //- From a set of points and indices get the normal
285 virtual void getNormal
286 (
287 const List<pointIndexHit>&,
288 vectorField& normal
289 ) const;
290
291 //- Determine type (inside/outside/mixed) for point.
292 // Unknown if cannot be determined (e.g. non-manifold surface)
293 virtual void getVolumeType
294 (
295 const pointField& points,
296 List<volumeType>& volType
297 ) const;
298
299
300 // Other
301
302 //- WIP. Store element-wise field.
303 virtual void setField(const labelList& values);
304
305 //- WIP. From a set of hits (points and
306 // indices) get the specified field. Misses do not get set.
307 virtual void getField(const List<pointIndexHit>&, labelList&) const;
308
309
310 // regIOobject implementation
311
312 bool writeData(Ostream&) const
313 {
315 return false;
316 }
317
318 //- Write using stream options
319 virtual bool writeObject
320 (
321 IOstreamOption streamOpt,
322 const bool writeOnProc
323 ) const;
324
325 //- Is object global
326 virtual bool global() const
327 {
328 return true;
329 }
330
331 //- Return complete path + object name if the file exists
332 // either in the case/processor or case otherwise null
333 virtual fileName filePath() const
334 {
336 }
337};
338
339
340// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341
342//- Global file type for triSurfaceMesh
343template<>
344struct is_globalIOobject<triSurfaceMesh> : std::true_type {};
345
346
347// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348
349} // End namespace Foam
350
351// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352
353#endif
354
355// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
Definition edgeHashes.H:59
Minimal example by using system/controlDict.functions:
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition IOobject.C:604
A simple container for options an IOstream can normally have.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
label size() const noexcept
The number of elements in the container.
Definition UList.H:706
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bounding box defined in terms of min/max extrema points.
Definition boundBox.H:71
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
A class for handling file names.
Definition fileName.H:75
Non-pointer based hierarchical recursive searching.
Registry of regIOobjects.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for managing temporary objects.
Definition tmp.H:75
IOoject and searching on triSurface.
label surfaceClosed_
Is surface closed.
virtual label size() const
Range of local indices that can be returned.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
static void getNextIntersections(const indexedOctree< treeDataTriSurface > &octree, const point &start, const point &end, const vector &smallVec, DynamicList< pointIndexHit > &hits)
Steps to next intersection. Adds smallVec and starts tracking.
virtual void flip()
Flip triangles, outsideVolumeType and all cached inside/outside.
void operator=(const triSurfaceMesh &)=delete
No copy assignment.
wordList regions_
Names of regions.
volumeType outsideVolType_
If surface is closed, what is type of outside points.
virtual ~triSurfaceMesh()
Destructor.
bool writeData(Ostream &) const
Pure virtual writeData function.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
virtual bool global() const
Is object global.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
scalar minQuality_
Optional min triangle quality. Triangles below this get.
autoPtr< indexedOctree< treeDataEdge > > edgeTree_
Search tree for boundary edges.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
triSurfaceMesh(const triSurfaceMesh &)=delete
No copy construct.
virtual fileName filePath() const
Return complete path + object name if the file exists.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
TypeName("triSurfaceMesh")
Runtime type information.
fileName fName_
Supplied fileName override.
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual void movePoints(const pointField &)
Move points.
virtual const wordList & regions() const
Names of regions.
virtual bool hasVolumeType() const
Whether supports volume type (below) - i.e. whether is closed.
bool isSurfaceClosed() const
Check whether surface is closed without calculating any permanent.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface").
virtual volumeType outsideVolumeType() const
If surface is closed, what is type of points outside bounds.
static bool addFaceToEdge(const edge &, EdgeMap< label > &)
Helper function for isSurfaceClosed.
void clearOut()
Clear storage.
virtual tmp< pointField > points() const
Get the points that define the surface.
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
Triangulated surface description with patch information.
Definition triSurface.H:74
triSurface()
Default construct.
Definition triSurface.C:426
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition volumeType.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
const auto & io
const pointField & points
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
dictionary dict
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68