OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::triSurfaceMesh
00027 
00028 Description
00029     IOoject and searching on triSurface
00030 
00031     Note: when constructing from dictionary has optional parameters:
00032         - scale     : scaling factor.
00033         - tolerance : relative tolerance for doing intersections
00034                       (see triangle::intersection)
00035 
00036 SourceFiles
00037     triSurfaceMesh.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef triSurfaceMesh_H
00042 #define triSurfaceMesh_H
00043 
00044 #include "treeBoundBox.H"
00045 #include "searchableSurface.H"
00046 #include "objectRegistry.H"
00047 #include "indexedOctree.H"
00048 #include "treeDataTriSurface.H"
00049 #include "treeDataEdge.H"
00050 #include "EdgeMap.H"
00051 
00052 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00053 
00054 namespace Foam
00055 {
00056 
00057 /*---------------------------------------------------------------------------*\
00058                            Class triSurfaceMesh Declaration
00059 \*---------------------------------------------------------------------------*/
00060 
00061 class triSurfaceMesh
00062 :
00063     public searchableSurface,
00064     public objectRegistry,      // so we can store fields
00065     public triSurface
00066 {
00067 private:
00068 
00069     // Private member data
00070 
00071         //- Optional tolerance to use in searches
00072         scalar tolerance_;
00073 
00074         //- Search tree (triangles)
00075         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
00076 
00077         //- Search tree for boundary edges.
00078         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
00079 
00080         //- Names of regions
00081         mutable wordList regions_;
00082 
00083         //- Is surface closed
00084         mutable label surfaceClosed_;
00085 
00086     // Private Member Functions
00087 
00089         //static word findRawInstance
00090         //(
00091         //    const Time&,
00092         //    const fileName&,
00093         //    const word&
00094         //);
00095 
00096         //- Check file existence
00097         static const fileName& checkFile
00098         (
00099             const fileName& fName,
00100             const fileName& objectName
00101         );
00102 
00103         //- Helper function for isSurfaceClosed
00104         static bool addFaceToEdge
00105         (
00106             const edge&,
00107             EdgeMap<label>&
00108         );
00109 
00110         //- Check whether surface is closed without calculating any permanent
00111         //  addressing.
00112         bool isSurfaceClosed() const;
00113 
00114         //- Disallow default bitwise copy construct
00115         triSurfaceMesh(const triSurfaceMesh&);
00116 
00117         //- Disallow default bitwise assignment
00118         void operator=(const triSurfaceMesh&);
00119 
00120 
00121 public:
00122 
00123     //- Runtime type information
00124     TypeName("triSurfaceMesh");
00125 
00126 
00127     // Constructors
00128 
00129         //- Construct from triSurface
00130         triSurfaceMesh(const IOobject&, const triSurface&);
00131 
00132         //- Construct read.
00133         triSurfaceMesh(const IOobject& io);
00134 
00135         //- Construct from IO and dictionary (used by searchableSurface).
00136         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
00137         triSurfaceMesh
00138         (
00139             const IOobject& io,
00140             const dictionary& dict
00141         );
00142 
00143 
00144     // Destructor
00145 
00146         virtual ~triSurfaceMesh();
00147 
00148         //- Clear storage
00149         void clearOut();
00150 
00151 
00152     // Member Functions
00153 
00154         //- Move points
00155         virtual void movePoints(const pointField&);
00156 
00157         //- Demand driven contruction of octree
00158         const indexedOctree<treeDataTriSurface>& tree() const;
00159 
00160         //- Demand driven contruction of octree for boundary edges
00161         const indexedOctree<treeDataEdge>& edgeTree() const;
00162 
00163 
00164         // searchableSurface implementation
00165 
00166             virtual const wordList& regions() const;
00167 
00168             //- Whether supports volume type below. I.e. whether is closed.
00169             virtual bool hasVolumeType() const;
00170 
00171             //- Range of local indices that can be returned.
00172             virtual label size() const
00173             {
00174                 return triSurface::size();
00175             }
00176 
00177             virtual void findNearest
00178             (
00179                 const pointField& sample,
00180                 const scalarField& nearestDistSqr,
00181                 List<pointIndexHit>&
00182             ) const;
00183 
00184             virtual void findLine
00185             (
00186                 const pointField& start,
00187                 const pointField& end,
00188                 List<pointIndexHit>&
00189             ) const;
00190 
00191             virtual void findLineAny
00192             (
00193                 const pointField& start,
00194                 const pointField& end,
00195                 List<pointIndexHit>&
00196             ) const;
00197 
00198             //- Get all intersections in order from start to end.
00199             virtual void findLineAll
00200             (
00201                 const pointField& start,
00202                 const pointField& end,
00203                 List<List<pointIndexHit> >&
00204             ) const;
00205 
00206             //- From a set of points and indices get the region
00207             virtual void getRegion
00208             (
00209                 const List<pointIndexHit>&,
00210                 labelList& region
00211             ) const;
00212 
00213             //- From a set of points and indices get the normal
00214             virtual void getNormal
00215             (
00216                 const List<pointIndexHit>&,
00217                 vectorField& normal
00218             ) const;
00219 
00220             //- Determine type (inside/outside/mixed) for point. unknown if
00221             //  cannot be determined (e.g. non-manifold surface)
00222             virtual void getVolumeType
00223             (
00224                 const pointField&,
00225                 List<volumeType>&
00226             ) const;
00227 
00228             //- Set bounds of surface. Bounds currently set as list of
00229             //  bounding boxes. The bounds are hints to the surface as for
00230             //  the range of queries it can expect. faceMap/pointMap can be
00231             //  set if the surface has done any redistribution.
00232             virtual void distribute
00233             (
00234                 const List<treeBoundBox>&,
00235                 const bool keepNonLocal,
00236                 autoPtr<mapDistribute>& faceMap,
00237                 autoPtr<mapDistribute>& pointMap
00238             )
00239             {}
00240 
00241         // Other
00242 
00243             //- Specific to triSurfaceMesh: from a set of hits (points and
00244             //  indices) get the specified field. Misses do not get set.
00245             virtual void getField
00246             (
00247                 const word& fieldName,
00248                 const List<pointIndexHit>&,
00249                 labelList& values
00250             ) const;
00251 
00252 
00253         // regIOobject implementation
00254 
00255             bool writeData(Ostream&) const
00256             {
00257                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
00258                 return false;
00259             }
00260 
00261             //- Write using given format, version and compression
00262             virtual bool writeObject
00263             (
00264                 IOstream::streamFormat fmt,
00265                 IOstream::versionNumber ver,
00266                 IOstream::compressionType cmp
00267             ) const;
00268 
00269 };
00270 
00271 
00272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00273 
00274 } // End namespace Foam
00275 
00276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00277 
00278 #endif
00279 
00280 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd