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
77class triSurfaceMesh
78:
79 public searchableSurface,
80 public objectRegistry, // so we can store fields
81 public triSurface,
82 public triSurfaceRegionSearch
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
105 mutable volumeType outsideVolType_;
107
108 // Private Member Functions
109
110 //- Helper function for isSurfaceClosed
111 static bool addFaceToEdge
112 (
113 const edge&,
115 );
116
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.
123 static void getNextIntersections
124 (
126 const point& start,
127 const point& end,
128 const vector& smallVec,
130 );
132 //- No copy construct
133 triSurfaceMesh(const triSurfaceMesh&) = delete;
135 //- No copy assignment
136 void operator=(const triSurfaceMesh&) = delete;
137
138
139public:
140
141 //- Runtime type information
142 TypeName("triSurfaceMesh");
143
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&);
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
169 {
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 };
175 triSurfaceMesh(const IOobject& io, const readAction r);
176
178 (
179 const IOobject& io,
180 const dictionary& dict,
181 const readAction r
182 );
183
184
185 //- Destructor
186 virtual ~triSurfaceMesh();
187
188
189 //- Clear storage
190 void clearOut();
191
192
193 // Member Functions
194
195 //- Move points
196 virtual void movePoints(const pointField&);
198 //- Demand driven construction of octree for boundary edges
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 //- Get representative set of element coordinates
220 // Usually the element centres (should be of length size()).
221 virtual tmp<pointField> coordinates() const;
222
223 //- Get bounding spheres (centre and radius squared). Any point
224 // on surface is guaranteed to be inside.
225 virtual void boundingSpheres
226 (
227 pointField& centres,
228 scalarField& radiusSqr
229 ) const;
230
231 //- Get the points that define the surface.
232 virtual tmp<pointField> points() const;
233
234 // Does any part of the surface overlap the supplied bound box?
235 virtual bool overlaps(const boundBox& bb) const;
236
237 virtual void findNearest
238 (
239 const pointField& sample,
240 const scalarField& nearestDistSqr,
242 ) const;
244 virtual void findNearest
245 (
246 const pointField& sample,
247 const scalarField& nearestDistSqr,
248 const labelList& regionIndices,
250 ) const;
251
252 virtual void findLine
253 (
254 const pointField& start,
255 const pointField& end,
257 ) const;
258
259 virtual void findLineAny
260 (
261 const pointField& start,
262 const pointField& end,
264 ) const;
265
266 //- Get all intersections in order from start to end.
267 virtual void findLineAll
268 (
269 const pointField& start,
270 const pointField& end,
272 ) const;
273
274 //- From a set of points and indices get the region
275 virtual void getRegion
276 (
277 const List<pointIndexHit>&,
278 labelList& region
279 ) const;
280
281 //- From a set of points and indices get the normal
282 virtual void getNormal
283 (
284 const List<pointIndexHit>&,
285 vectorField& normal
286 ) const;
287
288 //- Determine type (inside/outside/mixed) for point.
289 // Unknown if cannot be determined (e.g. non-manifold surface)
290 virtual void getVolumeType
291 (
292 const pointField& points,
293 List<volumeType>& volType
294 ) const;
295
296
297 // Other
298
299 //- WIP. Store element-wise field.
300 virtual void setField(const labelList& values);
301
302 //- WIP. From a set of hits (points and
303 // indices) get the specified field. Misses do not get set.
304 virtual void getField(const List<pointIndexHit>&, labelList&) const;
305
306
307 // regIOobject implementation
308
309 bool writeData(Ostream&) const
310 {
312 return false;
313 }
314
315 //- Write using stream options
316 virtual bool writeObject
317 (
318 IOstreamOption streamOpt,
319 const bool valid
320 ) const;
321
322 //- Is object global
323 virtual bool global() const
324 {
325 return true;
326 }
327
328 //- Return complete path + object name if the file exists
329 // either in the case/processor or case otherwise null
330 virtual fileName filePath() const
331 {
333 }
334};
335
336
337//- Template function for obtaining global status
338template<>
339inline bool typeGlobal<triSurfaceMesh>()
340{
341 return true;
342}
343
344
345// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346
347} // End namespace Foam
348
349// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350
351#endif
353// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:54
Minimal example by using system/controlDict.functions:
iterator end() noexcept
iterator to signal the end (for any HashTable)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:593
The IOstreamOption is a simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
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
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
A class for handling file names.
Definition: fileName.H:76
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
Registry of regIOobjects.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for managing temporary objects.
Definition: tmp.H:65
IOoject and searching on triSurface.
label surfaceClosed_
Is surface closed.
virtual label size() const
Range of local indices that can be returned.
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.
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
writeData function required by regIOobject but not used.
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 bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
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:79
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
bool typeGlobal< triSurfaceMesh >()
Template function for obtaining global status.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73