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

PrimitivePatch.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::PrimitivePatch
00027 
00028 Description
00029     A list of faces which address into the list of points.
00030 
00031     The class is templated on the face type (e.g. triangle, polygon etc.)
00032     and on the list type of faces and points so that it can refer to
00033     existing lists using UList and const pointField& or hold the storage
00034     using List and pointField.
00035 
00036 SourceFiles
00037     PrimitivePatchAddressing.C
00038     PrimitivePatchBdryPoints.C
00039     PrimitivePatch.C
00040     PrimitivePatchCheck.C
00041     PrimitivePatchClear.C
00042     PrimitivePatchEdgeLoops.C
00043     PrimitivePatchLocalPointOrder.C
00044     PrimitivePatchMeshData.C
00045     PrimitivePatchMeshEdges.C
00046     PrimitivePatchName.C
00047     PrimitivePatchPointAddressing.C
00048     PrimitivePatchProjectPoints.C
00049 
00050 \*---------------------------------------------------------------------------*/
00051 
00052 #ifndef PrimitivePatch_H
00053 #define PrimitivePatch_H
00054 
00055 #include "boolList.H"
00056 #include "labelList.H"
00057 #include "edgeList.H"
00058 #include "point.H"
00059 #include "intersection.H"
00060 #include "HashSet.H"
00061 
00062 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00063 
00064 namespace Foam
00065 {
00066 
00067 class face;
00068 class objectHit;
00069 template<class T> class Map;
00070 
00071 /*---------------------------------------------------------------------------*\
00072                         Class PrimitivePatchName Declaration
00073 \*---------------------------------------------------------------------------*/
00074 
00075 TemplateName(PrimitivePatch);
00076 
00077 
00078 /*---------------------------------------------------------------------------*\
00079                            Class PrimitivePatch Declaration
00080 \*---------------------------------------------------------------------------*/
00081 
00082 template
00083 <
00084     class Face,
00085     template<class> class FaceList,
00086     class PointField,
00087     class PointType=point
00088 >
00089 class PrimitivePatch
00090 :
00091     public PrimitivePatchName,
00092     public FaceList<Face>
00093 {
00094 
00095 public:
00096 
00097     // Public typedefs
00098 
00099         typedef Face FaceType;
00100         typedef FaceList<Face> FaceListType;
00101         typedef PointField PointFieldType;
00102 
00103 
00104     // Public data types
00105 
00106         //- Enumeration defining the surface type. Used in check routines.
00107         enum surfaceTopo
00108         {
00109             MANIFOLD,
00110             OPEN,
00111             ILLEGAL
00112         };
00113 
00114 private:
00115 
00116     // Private data
00117 
00118         //- Reference to global list of points
00119         PointField points_;
00120 
00121 
00122     // Demand driven private data
00123 
00124         //- Edges of the patch; address into local point list;
00125         //  sorted with internal edges first in upper-triangular order
00126         //  and external edges last.
00127         mutable edgeList* edgesPtr_;
00128 
00129         //- Which part of edgesPtr_ is internal edges.
00130         mutable label nInternalEdges_;
00131 
00132         //- Boundary point labels, addressing into local point list
00133         mutable labelList* boundaryPointsPtr_;
00134 
00135         //- Face-face addressing
00136         mutable labelListList* faceFacesPtr_;
00137 
00138         //- Edge-face addressing
00139         mutable labelListList* edgeFacesPtr_;
00140 
00141         //- Face-edge addressing
00142         mutable labelListList* faceEdgesPtr_;
00143 
00144         //- Point-edge addressing
00145         mutable labelListList* pointEdgesPtr_;
00146 
00147         //- Point-face addressing
00148         mutable labelListList* pointFacesPtr_;
00149 
00150         //- Faces addressing into local point list
00151         mutable List<Face>* localFacesPtr_;
00152 
00153         //- Labels of mesh points
00154         mutable labelList* meshPointsPtr_;
00155 
00156         //- Mesh point map.  Given the global point index find its
00157         //location in the patch
00158         mutable Map<label>* meshPointMapPtr_;
00159 
00160         //- Outside edge loops
00161         mutable labelListList* edgeLoopsPtr_;
00162 
00163         //- Points local to patch
00164         mutable Field<PointType>* localPointsPtr_;
00165 
00166         //- Local point order for most efficient search
00167         mutable labelList* localPointOrderPtr_;
00168 
00169         //- Face unit normals
00170         mutable Field<PointType>* faceNormalsPtr_;
00171 
00172         //- Point unit normals
00173         mutable Field<PointType>* pointNormalsPtr_;
00174 
00175 
00176     // Private Member Functions
00177 
00178         //- Calculate edges of the patch
00179         void calcIntBdryEdges() const;
00180 
00181         //- Calculated boundary points on a patch
00182         void calcBdryPoints() const;
00183 
00184         //- Calculate addressing
00185         void calcAddressing() const;
00186 
00187         //- Calculate point-edge addressing
00188         void calcPointEdges() const;
00189 
00190         //- Calculate point-face addressing
00191         void calcPointFaces() const;
00192 
00193         //- Calculate mesh addressing
00194         void calcMeshData() const;
00195 
00196         //- Calculate mesh point map
00197         void calcMeshPointMap() const;
00198 
00199         //- Calculate outside edge loops
00200         void calcEdgeLoops() const;
00201 
00202         //- Calculate local points
00203         void calcLocalPoints() const;
00204 
00205         //- Calculate local point order
00206         void calcLocalPointOrder() const;
00207 
00208         //- Calculate unit face normals
00209         void calcFaceNormals() const;
00210 
00211         //- Calculate unit point normals
00212         void calcPointNormals() const;
00213 
00214         //- Calculate edge owner
00215         void calcEdgeOwner() const;
00216 
00217 
00218         //- Face-edge-face walk while remaining on a patch point.
00219         //  Used to determine if surface multiply connected through point.
00220         void visitPointRegion
00221         (
00222             const label pointI,
00223             const labelList& pFaces,
00224             const label startFaceI,
00225             const label startEdgeI,
00226             boolList& pFacesHad
00227         ) const;
00228 
00229 
00230 public:
00231 
00232     // Constructors
00233 
00234         //- Construct from components
00235         PrimitivePatch
00236         (
00237             const FaceList<Face>& faces,
00238             const Field<PointType>& points
00239         );
00240 
00241         //- Construct from components, reuse storage
00242         PrimitivePatch
00243         (
00244             FaceList<Face>& faces,
00245             Field<PointType>& points,
00246             const bool reUse
00247         );
00248 
00249         //- Construct as copy
00250         PrimitivePatch
00251         (
00252             const PrimitivePatch<Face, FaceList, PointField, PointType>&
00253         );
00254 
00255 
00256     // Destructor
00257 
00258         virtual ~PrimitivePatch();
00259 
00260         void clearOut();
00261 
00262         void clearGeom();
00263 
00264         void clearTopology();
00265 
00266         void clearPatchMeshAddr();
00267 
00268 
00269     // Member Functions
00270 
00271     // Access
00272 
00273         //- Return reference to global points
00274         const Field<PointType>& points() const
00275         {
00276             return points_;
00277         }
00278 
00279 
00280     // Access functions for demand driven data
00281 
00282         // Topological data; no mesh required.
00283 
00284             //- Return number of points supporting patch faces
00285             label nPoints() const
00286             {
00287                 return meshPoints().size();
00288             }
00289 
00290             //- Return number of edges in patch
00291             label nEdges() const
00292             {
00293                 return edges().size();
00294             }
00295 
00296             //- Return list of edges, address into LOCAL point list
00297             const edgeList& edges() const;
00298 
00299             //- Number of internal edges
00300             label nInternalEdges() const;
00301 
00302             //- Is internal edge?
00303             bool isInternalEdge(const label edgeI) const
00304             {
00305                 return edgeI < nInternalEdges();
00306             }
00307 
00308             //- Return list of boundary points,
00309             //  address into LOCAL point list
00310             const labelList& boundaryPoints() const;
00311 
00312             //- Return face-face addressing
00313             const labelListList& faceFaces() const;
00314 
00315             //- Return edge-face addressing
00316             const labelListList& edgeFaces() const;
00317 
00318             //- Return face-edge addressing
00319             const labelListList& faceEdges() const;
00320 
00321             //- Return point-edge addressing
00322             const labelListList& pointEdges() const;
00323 
00324             //- Return point-face addressing
00325             const labelListList& pointFaces() const;
00326 
00327             //- Return patch faces addressing into local point list
00328             const List<Face>& localFaces() const;
00329 
00330 
00331         // Addressing into mesh
00332 
00333             //- Return labelList of mesh points in patch. They are constructed
00334             //  walking through the faces in incremental order and not sorted
00335             //  anymore.
00336             const labelList& meshPoints() const;
00337 
00338             //- Mesh point map.  Given the global point index find its
00339             //  location in the patch
00340             const Map<label>& meshPointMap() const;
00341 
00342             //- Return pointField of points in patch
00343             const Field<PointType>& localPoints() const;
00344 
00345             //- Return orders the local points for most efficient search
00346             const labelList& localPointOrder() const;
00347 
00348             //- Given a global point index, return the local point index.
00349             //  If the point is not found, return -1
00350             label whichPoint(const label gp) const;
00351 
00352             //- Given an edge in local point labels, return its
00353             //  index in the edge list.  If the edge is not found, return -1
00354             label whichEdge(const edge&) const;
00355 
00356             //- Return labels of patch edges in the global edge list using
00357             //  cell addressing
00358             labelList meshEdges
00359             (
00360                 const edgeList& allEdges,
00361                 const labelListList& cellEdges,
00362                 const labelList& faceCells
00363             ) const;
00364 
00365             //- Return labels of patch edges in the global edge list using
00366             //  basic edge addressing.
00367             labelList meshEdges
00368             (
00369                 const edgeList& allEdges,
00370                 const labelListList& pointEdges
00371             ) const;
00372 
00373             //- Return face normals for patch
00374             const Field<PointType>& faceNormals() const;
00375 
00376             //- Return point normals for patch
00377             const Field<PointType>& pointNormals() const;
00378 
00379 
00380         // Other patch operations
00381 
00382             //- Project vertices of patch onto another patch
00383             template <class ToPatch>
00384             List<objectHit> projectPoints
00385             (
00386                 const ToPatch& targetPatch,
00387                 const Field<PointType>& projectionDirection,
00388                 const intersection::algorithm = intersection::FULL_RAY,
00389                 const intersection::direction = intersection::VECTOR
00390             ) const;
00391 
00392             //- Project vertices of patch onto another patch
00393             template <class ToPatch>
00394             List<objectHit> projectFaceCentres
00395             (
00396                 const ToPatch& targetPatch,
00397                 const Field<PointType>& projectionDirection,
00398                 const intersection::algorithm = intersection::FULL_RAY,
00399                 const intersection::direction = intersection::VECTOR
00400             ) const;
00401 
00402             //- Return list of closed loops of boundary vertices.
00403             //  Edge loops are given as ordered lists of vertices
00404             //  in local addressing
00405             const labelListList& edgeLoops() const;
00406 
00407 
00408     // Check
00409 
00410         //- Calculate surface type formed by patch.
00411         //  - all edges have two neighbours (manifold)
00412         //  - some edges have more than two neighbours (illegal)
00413         //  - other (open)
00414         surfaceTopo surfaceType() const;
00415 
00416         //- Check surface formed by patch for manifoldness (see above).
00417         //  Return true if any incorrect edges are found.
00418         //  Insert vertices of incorrect edges into set.
00419         bool checkTopology
00420         (
00421             const bool report = false,
00422             labelHashSet* setPtr = NULL
00423         ) const;
00424 
00425         //- Checks primitivePatch for faces sharing point but not edge.
00426         //  This denotes a surface that is pinched at a single point
00427         //  (test for pinched at single edge is already in PrimitivePatch)
00428         //  Returns true if this situation found and puts conflicting
00429         //  (mesh)point in set. Based on all the checking routines in
00430         //  primitiveMesh.
00431         bool checkPointManifold
00432         (
00433             const bool report = false,
00434             labelHashSet* setPtr = NULL
00435         ) const;
00436 
00437 
00438     // Edit
00439 
00440         //- Correct patch after moving points
00441         virtual void movePoints(const Field<PointType>&);
00442 
00443 
00444     // Member operators
00445 
00446         //- Assignment
00447         void operator=
00448         (
00449             const PrimitivePatch<Face, FaceList, PointField, PointType>&
00450         );
00451 };
00452 
00453 
00454 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00455 
00456 } // End namespace Foam
00457 
00458 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00459 
00460 #ifdef NoRepository
00461 #   include "PrimitivePatch.C"
00462 #endif
00463 
00464 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00465 
00466 #endif
00467 
00468 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd