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