FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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::triSurfaceMesh
26 
27 Description
28  IOoject and searching on triSurface
29 
30  Note: when constructing from dictionary has optional parameters:
31  - scale : scaling factor.
32  - tolerance : relative tolerance for doing intersections
33  (see triangle::intersection)
34 
35 SourceFiles
36  triSurfaceMesh.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef triSurfaceMesh_H
41 #define triSurfaceMesh_H
42 
43 #include <meshTools/treeBoundBox.H>
44 #include "searchableSurface.H"
48 #include <meshTools/treeDataEdge.H>
49 #include <OpenFOAM/EdgeMap.H>
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class triSurfaceMesh Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public searchableSurface,
63  public objectRegistry, // so we can store fields
64  public triSurface
65 {
66 private:
67 
68  // Private member data
69 
70  //- Optional tolerance to use in searches
71  scalar tolerance_;
72 
73  //- Optional max tree depth of octree
74  label maxTreeDepth_;
75 
76  //- Search tree (triangles)
78 
79  //- Search tree for boundary edges.
80  mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
81 
82  //- Names of regions
83  mutable wordList regions_;
84 
85  //- Is surface closed
86  mutable label surfaceClosed_;
87 
88  // Private Member Functions
89 
91  //static word findRawInstance
92  //(
93  // const Time&,
94  // const fileName&,
95  // const word&
96  //);
97 
98  //- Check file existence
99  static const fileName& checkFile
100  (
101  const fileName& fName,
102  const fileName& objectName
103  );
104 
105  //- Helper function for isSurfaceClosed
106  static bool addFaceToEdge
107  (
108  const edge&,
110  );
111 
112  //- Check whether surface is closed without calculating any permanent
113  // addressing.
114  bool isSurfaceClosed() const;
115 
116  //- Steps to next intersection. Adds smallVec and starts tracking
117  // from there.
118  static void getNextIntersections
119  (
121  const point& start,
122  const point& end,
123  const vector& smallVec,
125  );
126 
127  //- Disallow default bitwise copy construct
129 
130  //- Disallow default bitwise assignment
131  void operator=(const triSurfaceMesh&);
132 
133 
134 protected:
135 
136  //- Calculate (number of)used points and their bounding box
137  void calcBounds(boundBox& bb, label& nPoints) const;
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("triSurfaceMesh");
143 
144 
145  // Constructors
146 
147  //- Construct from triSurface
148  triSurfaceMesh(const IOobject&, const triSurface&);
149 
150  //- Construct read.
151  triSurfaceMesh(const IOobject& io);
152 
153  //- Construct from IO and dictionary (used by searchableSurface).
154  // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
156  (
157  const IOobject& io,
158  const dictionary& dict
159  );
160 
161 
162  // Destructor
163 
164  virtual ~triSurfaceMesh();
165 
166  //- Clear storage
167  void clearOut();
168 
169 
170  // Member Functions
171 
172  //- Move points
173  virtual void movePoints(const pointField&);
174 
175  //- Demand driven contruction of octree
177 
178  //- Demand driven contruction of octree for boundary edges
179  const indexedOctree<treeDataEdge>& edgeTree() const;
180 
181 
182  // searchableSurface implementation
183 
184  virtual const wordList& regions() const;
185 
186  //- Whether supports volume type below. I.e. whether is closed.
187  virtual bool hasVolumeType() const;
188 
189  //- Range of local indices that can be returned.
190  virtual label size() const
191  {
192  return triSurface::size();
193  }
194 
195  //- Get representative set of element coordinates
196  // Usually the element centres (should be of length size()).
197  virtual pointField coordinates() const;
198 
199  virtual void findNearest
200  (
201  const pointField& sample,
202  const scalarField& nearestDistSqr,
204  ) const;
205 
206  virtual void findLine
207  (
208  const pointField& start,
209  const pointField& end,
211  ) const;
212 
213  virtual void findLineAny
214  (
215  const pointField& start,
216  const pointField& end,
218  ) const;
219 
220  //- Get all intersections in order from start to end.
221  virtual void findLineAll
222  (
223  const pointField& start,
224  const pointField& end,
226  ) const;
227 
228  //- From a set of points and indices get the region
229  virtual void getRegion
230  (
231  const List<pointIndexHit>&,
232  labelList& region
233  ) const;
234 
235  //- From a set of points and indices get the normal
236  virtual void getNormal
237  (
238  const List<pointIndexHit>&,
240  ) const;
241 
242  //- Determine type (inside/outside/mixed) for point. unknown if
243  // cannot be determined (e.g. non-manifold surface)
244  virtual void getVolumeType
245  (
246  const pointField&,
248  ) const;
249 
250  // Other
251 
252  //- Set bounds of surface. Bounds currently set as list of
253  // bounding boxes. The bounds are hints to the surface as for
254  // the range of queries it can expect. faceMap/pointMap can be
255  // set if the surface has done any redistribution.
256  virtual void distribute
257  (
258  const List<treeBoundBox>&,
259  const bool keepNonLocal,
260  autoPtr<mapDistribute>& faceMap,
261  autoPtr<mapDistribute>& pointMap
262  )
263  {}
264 
265  //- WIP. Store element-wise field.
266  virtual void setField(const labelList& values);
267 
268  //- WIP. From a set of hits (points and
269  // indices) get the specified field. Misses do not get set.
270  virtual void getField(const List<pointIndexHit>&, labelList&) const;
271 
272 
273  // regIOobject implementation
274 
275  bool writeData(Ostream&) const
276  {
277  notImplemented("triSurfaceMesh::writeData(Ostream&) const");
278  return false;
279  }
280 
281  //- Write using given format, version and compression
282  virtual bool writeObject
283  (
287  ) const;
288 
289 };
290 
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 } // End namespace Foam
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #endif
299 
300 // ************************ vim: set sw=4 sts=4 et: ************************ //