FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

triSurfaceMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::triSurfaceMesh
00026 
00027 Description
00028     IOoject and searching on triSurface
00029 
00030     Note: when constructing from dictionary has optional parameters:
00031         - scale     : scaling factor.
00032         - tolerance : relative tolerance for doing intersections
00033                       (see triangle::intersection)
00034 
00035 SourceFiles
00036     triSurfaceMesh.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef triSurfaceMesh_H
00041 #define triSurfaceMesh_H
00042 
00043 #include <meshTools/treeBoundBox.H>
00044 #include "searchableSurface.H"
00045 #include <OpenFOAM/objectRegistry.H>
00046 #include <meshTools/indexedOctree.H>
00047 #include <meshTools/treeDataTriSurface.H>
00048 #include <meshTools/treeDataEdge.H>
00049 #include <OpenFOAM/EdgeMap.H>
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class triSurfaceMesh Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class triSurfaceMesh
00061 :
00062     public searchableSurface,
00063     public objectRegistry,      // so we can store fields
00064     public triSurface
00065 {
00066 private:
00067 
00068     // Private member data
00069 
00070         //- Optional tolerance to use in searches
00071         scalar tolerance_;
00072 
00073         //- Optional max tree depth of octree
00074         label maxTreeDepth_;
00075 
00076         //- Search tree (triangles)
00077         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
00078 
00079         //- Search tree for boundary edges.
00080         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
00081 
00082         //- Names of regions
00083         mutable wordList regions_;
00084 
00085         //- Is surface closed
00086         mutable label surfaceClosed_;
00087 
00088     // Private Member Functions
00089 
00091         //static word findRawInstance
00092         //(
00093         //    const Time&,
00094         //    const fileName&,
00095         //    const word&
00096         //);
00097 
00098         //- Check file existence
00099         static const fileName& checkFile
00100         (
00101             const fileName& fName,
00102             const fileName& objectName
00103         );
00104 
00105         //- Helper function for isSurfaceClosed
00106         static bool addFaceToEdge
00107         (
00108             const edge&,
00109             EdgeMap<label>&
00110         );
00111 
00112         //- Check whether surface is closed without calculating any permanent
00113         //  addressing.
00114         bool isSurfaceClosed() const;
00115 
00116         //- Steps to next intersection. Adds smallVec and starts tracking
00117         //  from there.
00118         static void getNextIntersections
00119         (
00120             const indexedOctree<treeDataTriSurface>& octree,
00121             const point& start,
00122             const point& end,
00123             const vector& smallVec,
00124             DynamicList<pointIndexHit, 1, 1>& hits
00125         );
00126 
00127         //- Disallow default bitwise copy construct
00128         triSurfaceMesh(const triSurfaceMesh&);
00129 
00130         //- Disallow default bitwise assignment
00131         void operator=(const triSurfaceMesh&);
00132 
00133 
00134 protected:
00135 
00136         //- Calculate (number of)used points and their bounding box
00137         void calcBounds(boundBox& bb, label& nPoints) const;
00138 
00139 public:
00140 
00141     //- Runtime type information
00142     TypeName("triSurfaceMesh");
00143 
00144 
00145     // Constructors
00146 
00147         //- Construct from triSurface
00148         triSurfaceMesh(const IOobject&, const triSurface&);
00149 
00150         //- Construct read.
00151         triSurfaceMesh(const IOobject& io);
00152 
00153         //- Construct from IO and dictionary (used by searchableSurface).
00154         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
00155         triSurfaceMesh
00156         (
00157             const IOobject& io,
00158             const dictionary& dict
00159         );
00160 
00161 
00162     // Destructor
00163 
00164         virtual ~triSurfaceMesh();
00165 
00166         //- Clear storage
00167         void clearOut();
00168 
00169 
00170     // Member Functions
00171 
00172         //- Move points
00173         virtual void movePoints(const pointField&);
00174 
00175         //- Demand driven contruction of octree
00176         const indexedOctree<treeDataTriSurface>& tree() const;
00177 
00178         //- Demand driven contruction of octree for boundary edges
00179         const indexedOctree<treeDataEdge>& edgeTree() const;
00180 
00181 
00182         // searchableSurface implementation
00183 
00184             virtual const wordList& regions() const;
00185 
00186             //- Whether supports volume type below. I.e. whether is closed.
00187             virtual bool hasVolumeType() const;
00188 
00189             //- Range of local indices that can be returned.
00190             virtual label size() const
00191             {
00192                 return triSurface::size();
00193             }
00194 
00195             //- Get representative set of element coordinates
00196             //  Usually the element centres (should be of length size()).
00197             virtual pointField coordinates() const;
00198 
00199             virtual void findNearest
00200             (
00201                 const pointField& sample,
00202                 const scalarField& nearestDistSqr,
00203                 List<pointIndexHit>&
00204             ) const;
00205 
00206             virtual void findLine
00207             (
00208                 const pointField& start,
00209                 const pointField& end,
00210                 List<pointIndexHit>&
00211             ) const;
00212 
00213             virtual void findLineAny
00214             (
00215                 const pointField& start,
00216                 const pointField& end,
00217                 List<pointIndexHit>&
00218             ) const;
00219 
00220             //- Get all intersections in order from start to end.
00221             virtual void findLineAll
00222             (
00223                 const pointField& start,
00224                 const pointField& end,
00225                 List<List<pointIndexHit> >&
00226             ) const;
00227 
00228             //- From a set of points and indices get the region
00229             virtual void getRegion
00230             (
00231                 const List<pointIndexHit>&,
00232                 labelList& region
00233             ) const;
00234 
00235             //- From a set of points and indices get the normal
00236             virtual void getNormal
00237             (
00238                 const List<pointIndexHit>&,
00239                 vectorField& normal
00240             ) const;
00241 
00242             //- Determine type (inside/outside/mixed) for point. unknown if
00243             //  cannot be determined (e.g. non-manifold surface)
00244             virtual void getVolumeType
00245             (
00246                 const pointField&,
00247                 List<volumeType>&
00248             ) const;
00249 
00250         // Other
00251 
00252             //- Set bounds of surface. Bounds currently set as list of
00253             //  bounding boxes. The bounds are hints to the surface as for
00254             //  the range of queries it can expect. faceMap/pointMap can be
00255             //  set if the surface has done any redistribution.
00256             virtual void distribute
00257             (
00258                 const List<treeBoundBox>&,
00259                 const bool keepNonLocal,
00260                 autoPtr<mapDistribute>& faceMap,
00261                 autoPtr<mapDistribute>& pointMap
00262             )
00263             {}
00264 
00265             //- WIP. Store element-wise field.
00266             virtual void setField(const labelList& values);
00267 
00268             //- WIP. From a set of hits (points and
00269             //  indices) get the specified field. Misses do not get set.
00270             virtual void getField(const List<pointIndexHit>&, labelList&) const;
00271 
00272 
00273         // regIOobject implementation
00274 
00275             bool writeData(Ostream&) const
00276             {
00277                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
00278                 return false;
00279             }
00280 
00281             //- Write using given format, version and compression
00282             virtual bool writeObject
00283             (
00284                 IOstream::streamFormat fmt,
00285                 IOstream::versionNumber ver,
00286                 IOstream::compressionType cmp
00287             ) const;
00288 
00289 };
00290 
00291 
00292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00293 
00294 } // End namespace Foam
00295 
00296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00297 
00298 #endif
00299 
00300 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines