fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / meshTools / searchableSurface / triSurfaceMesh.H
blobeaec0514bc4e07352e5a57c9d250699e124f2357
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::triSurfaceMesh
28 Description
29     IOoject and searching on triSurface
31     Note: when constructing from dictionary has optional parameters:
32         - scale     : scaling factor.
33         - tolerance : relative tolerance for doing intersections
34                       (see triangle::intersection)
36 SourceFiles
37     triSurfaceMesh.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef triSurfaceMesh_H
42 #define triSurfaceMesh_H
44 #include "treeBoundBox.H"
45 #include "searchableSurface.H"
46 #include "objectRegistry.H"
47 #include "indexedOctree.H"
48 #include "treeDataTriSurface.H"
49 #include "octreeDataTriSurfaceTreeLeaf.H"
50 #include "treeDataEdge.H"
51 #include "EdgeMap.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 namespace Foam
58 /*---------------------------------------------------------------------------*\
59                            Class triSurfaceMesh Declaration
60 \*---------------------------------------------------------------------------*/
62 class triSurfaceMesh
64     public searchableSurface,
65     public objectRegistry,      // so we can store fields
66     public triSurface
68 private:
70     // Private member data
72         //- Optional tolerance to use in searches
73         scalar tolerance_;
75         //- Optional max tree depth of octree
76         label maxTreeDepth_;
78         //- Search tree (triangles)
79         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
81         //- Search tree for boundary edges.
82         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
84         //- Names of regions
85         mutable wordList regions_;
87         //- Is surface closed
88         mutable label surfaceClosed_;
90     // Private Member Functions
92         ////- Helper: find instance of files without header
93         //static word findRawInstance
94         //(
95         //    const Time&,
96         //    const fileName&,
97         //    const word&
98         //);
100         //- Check file existence
101         static const fileName& checkFile
102         (
103             const fileName& fName,
104             const fileName& objectName
105         );
107         //- Helper function for isSurfaceClosed
108         static bool addFaceToEdge
109         (
110             const edge&,
111             EdgeMap<label>&
112         );
114         //- Check whether surface is closed without calculating any permanent
115         //  addressing.
116         bool isSurfaceClosed() const;
118         //- Steps to next intersection. Adds smallVec and starts tracking
119         //  from there.
120         static void getNextIntersections
121         (
122             const indexedOctree<treeDataTriSurface>& octree,
123             const point& start,
124             const point& end,
125             const vector& smallVec,
126             DynamicList<pointIndexHit, 1, 1>& hits
127         );
129         //- Disallow default bitwise copy construct
130         triSurfaceMesh(const triSurfaceMesh&);
132         //- Disallow default bitwise assignment
133         void operator=(const triSurfaceMesh&);
136 protected:
138         //- Calculate (number of)used points and their bounding box
139         void calcBounds(boundBox& bb, label& nPoints) const;
141 public:
143     //- Runtime type information
144     TypeName("triSurfaceMesh");
147     // Constructors
149         //- Construct from triSurface
150         triSurfaceMesh(const IOobject&, const triSurface&);
152         //- Construct read.
153         triSurfaceMesh(const IOobject& io);
155         //- Construct from IO and dictionary (used by searchableSurface).
156         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
157         triSurfaceMesh
158         (
159             const IOobject& io,
160             const dictionary& dict
161         );
164     // Destructor
166         virtual ~triSurfaceMesh();
168         //- Clear storage
169         void clearOut();
172     // Member Functions
174         //- Move points
175         virtual void movePoints(const pointField&);
177         //- Demand driven contruction of octree
178         const indexedOctree<treeDataTriSurface>& tree() const;
180         //- Demand driven contruction of octree for boundary edges
181         const indexedOctree<treeDataEdge>& edgeTree() const;
184         // searchableSurface implementation
186             virtual const wordList& regions() const;
188             //- Whether supports volume type below. I.e. whether is closed.
189             virtual bool hasVolumeType() const;
191             //- Range of local indices that can be returned.
192             virtual label size() const
193             {
194                 return triSurface::size();
195             }
197             //- Get representative set of element coordinates
198             //  Usually the element centres (should be of length size()).
199             virtual pointField coordinates() const;
201             virtual void findNearest
202             (
203                 const pointField& sample,
204                 const scalarField& nearestDistSqr,
205                 List<pointIndexHit>&
206             ) const;
208             virtual void findLine
209             (
210                 const pointField& start,
211                 const pointField& end,
212                 List<pointIndexHit>&
213             ) const;
215             virtual void findLineAny
216             (
217                 const pointField& start,
218                 const pointField& end,
219                 List<pointIndexHit>&
220             ) const;
222             //- Get all intersections in order from start to end.
223             virtual void findLineAll
224             (
225                 const pointField& start,
226                 const pointField& end,
227                 List<List<pointIndexHit> >&
228             ) const;
230             //- From a set of points and indices get the region
231             virtual void getRegion
232             (
233                 const List<pointIndexHit>&,
234                 labelList& region
235             ) const;
237             //- From a set of points and indices get the normal
238             virtual void getNormal
239             (
240                 const List<pointIndexHit>&,
241                 vectorField& normal
242             ) const;
244             //- Determine type (inside/outside/mixed) for point. unknown if
245             //  cannot be determined (e.g. non-manifold surface)
246             virtual void getVolumeType
247             (
248                 const pointField&,
249                 List<volumeType>&
250             ) const;
252         // Other
254             //- Set bounds of surface. Bounds currently set as list of
255             //  bounding boxes. The bounds are hints to the surface as for
256             //  the range of queries it can expect. faceMap/pointMap can be
257             //  set if the surface has done any redistribution.
258             virtual void distribute
259             (
260                 const List<treeBoundBox>&,
261                 const bool keepNonLocal,
262                 autoPtr<mapDistribute>& faceMap,
263                 autoPtr<mapDistribute>& pointMap
264             )
265             {}
267             //- WIP. Store element-wise field.
268             virtual void setField(const labelList& values);
270             //- WIP. From a set of hits (points and
271             //  indices) get the specified field. Misses do not get set.
272             virtual void getField(const List<pointIndexHit>&, labelList&) const;
275         // regIOobject implementation
277             bool writeData(Ostream&) const
278             {
279                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
280                 return false;
281             }
283             //- Write using given format, version and compression
284             virtual bool writeObject
285             (
286                 IOstream::streamFormat fmt,
287                 IOstream::versionNumber ver,
288                 IOstream::compressionType cmp
289             ) const;
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 } // End namespace Foam
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 #endif
302 // ************************************************************************* //