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

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