OpenFOAM logo
Open Source CFD Toolkit

polyPatch.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-2005 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     polyPatch
00027 
00028 Description
00029     A patch is a list of labels, which address the faces in the global face
00030     list. Based on the global faces, the patch can calculate its own edge.
00031     Patch also contains all addressing between the faces.
00032 
00033 SourceFiles
00034     polyPatch.C
00035     calcPolyPatchAddressing.C
00036     calcPolyPatchFaceCells.C
00037     calcPolyPatchIntBdryEdges.C
00038     calcPolyPatchMeshEdges.C
00039     calcPolyPatchMeshData.C
00040     calcPolyPatchPointAddressing.C
00041     clearPolyPatch.C
00042     newPolyPatch.C
00043     polyPatchTools.C
00044 
00045 \*---------------------------------------------------------------------------*/
00046 
00047 #ifndef polyPatch_H
00048 #define polyPatch_H
00049 
00050 #include "patchIdentifier.H"
00051 #include "primitivePatch.H"
00052 #include "typeInfo.H"
00053 #include "runTimeSelectionTables.H"
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00061 
00062 class polyBoundaryMesh;
00063 
00064 /*---------------------------------------------------------------------------*\
00065                            Class polyPatch Declaration
00066 \*---------------------------------------------------------------------------*/
00067 
00068 class polyPatch
00069 :
00070     public patchIdentifier,
00071     public primitivePatch
00072 {
00073     // Private data
00074 
00075         //- Start label of this patch in the polyMesh face list
00076         label start_;
00077 
00078         //- Reference to boundary mesh
00079         const polyBoundaryMesh& boundaryMesh_;
00080 
00081 
00082         // Demand-driven private data
00083 
00084             //- Global edge addressing
00085             mutable labelList* mePtr_;
00086 
00087 
00088     // Private Member Functions
00089 
00090         //- Calculate labels of mesh edges
00091         void calcMeshEdges() const;
00092 
00093 
00094 protected:
00095 
00096     // Protected Member Functions
00097 
00098         //- Return the polyMesh allPoints
00099         const pointField& allPoints() const;
00100 
00101         // The polyPatch geometry initialisation is called by polyBoundaryMesh
00102         friend class polyBoundaryMesh;
00103 
00104         //- Initialise the calculation of the patch geometry
00105         virtual void initGeometry()
00106         {}
00107 
00108         //- Calculate the patch geometry
00109         virtual void calcGeometry()
00110         {}
00111 
00112         //- Initialise the patches for moving points
00113         virtual void initMovePoints(const pointField&)
00114         {}
00115 
00116         //- Correct patches after moving points
00117         virtual void movePoints(const pointField& p);
00118 
00119         //- Initialise the update of the patch topology
00120         virtual void initUpdateTopology()
00121         {}
00122 
00123         //- Update of the patch topology
00124         virtual void updateMesh();
00125 
00126 
00127 public:
00128 
00129     //- Runtime type information
00130     TypeName("patch");
00131 
00132 
00133     // Declare run-time constructor selection tables
00134 
00135         declareRunTimeSelectionTable
00136         (
00137             autoPtr,
00138             polyPatch,
00139             word,
00140             (
00141                 const word& name,
00142                 const label size,
00143                 const label start,
00144                 const label index,
00145                 const polyBoundaryMesh& bm
00146             ),
00147             (name, size, start, index, bm)
00148         );
00149 
00150         declareRunTimeSelectionTable
00151         (
00152             autoPtr,
00153             polyPatch,
00154             Istream,
00155             (Istream& is, const label index, const polyBoundaryMesh& bm),
00156             (is, index, bm)
00157         );
00158 
00159         declareRunTimeSelectionTable
00160         (
00161             autoPtr,
00162             polyPatch,
00163             dictionary,
00164             (
00165                 const word& name,
00166                 const dictionary& dict,
00167                 const label index,
00168                 const polyBoundaryMesh& bm
00169             ),
00170             (name, dict, index, bm)
00171         );
00172 
00173 
00174     // Constructors
00175 
00176         //- Construct from components
00177         polyPatch
00178         (
00179             const word& name,
00180             const label size,
00181             const label start,
00182             const label index,
00183             const polyBoundaryMesh& bm
00184         );
00185 
00186         //- Construct from Istream
00187         polyPatch(Istream&, const label index, const polyBoundaryMesh&);
00188 
00189         //- Construct from dictionary
00190         polyPatch
00191         (
00192             const word& name,
00193             const dictionary& dict,
00194             const label index,
00195             const polyBoundaryMesh& bm
00196         );
00197 
00198         //- Construct as copy, resetting the boundary mesh
00199         polyPatch(const polyPatch&, const polyBoundaryMesh&);
00200 
00201         //- Construct given the original patch and resetting the
00202         //  face list and boundary mesh information
00203         polyPatch
00204         (
00205             const polyPatch& pp,
00206             const polyBoundaryMesh& bm,
00207             const label index,
00208             const label newSize,
00209             const label newStart
00210         );
00211 
00212         //- Construct as copy
00213         polyPatch(const polyPatch&);
00214 
00215         //- Construct and return a clone, resetting the boundary mesh
00216         virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
00217         {
00218             return autoPtr<polyPatch>(new polyPatch(*this, bm));
00219         }
00220 
00221         //- Construct and return a clone, resetting the face list
00222         //  and boundary mesh
00223         virtual autoPtr<polyPatch> clone
00224         (
00225             const polyBoundaryMesh& bm,
00226             const label index,
00227             const label newSize,
00228             const label newStart
00229         ) const
00230         {
00231             return autoPtr<polyPatch>
00232             (
00233                 new polyPatch(*this, bm, index, newSize, newStart)
00234             );
00235         }
00236 
00237 
00238     // Selectors
00239 
00240         //- Return a pointer to a new patch created on freestore from
00241         //  components
00242         static autoPtr<polyPatch> New
00243         (
00244             const word& patchType,
00245             const word& name,
00246             const label size,
00247             const label start,
00248             const label index,
00249             const polyBoundaryMesh& bm
00250         );
00251 
00252         //- Return a pointer to a new patch created on freestore from input
00253         static autoPtr<polyPatch> New
00254         (
00255             Istream&,
00256             const label index,
00257             const polyBoundaryMesh& bm
00258         );
00259 
00260         //- Return a pointer to a new patch created on freestore from
00261         //  dictionary
00262         static autoPtr<polyPatch> New
00263         (
00264             const word& name,
00265             const dictionary& dict,
00266             const label index,
00267             const polyBoundaryMesh& bm
00268         );
00269 
00270 
00271     // Destructor
00272 
00273         virtual ~polyPatch();
00274 
00275 
00276     // Member Functions
00277 
00278         //- Return start label of this patch in the polyMesh face list
00279         label start() const
00280         {
00281             return start_;
00282         }
00283 
00284         //- Return boundaryMesh reference
00285         const polyBoundaryMesh& boundaryMesh() const;
00286 
00287         //- Return true if this patch field is coupled
00288         virtual bool coupled() const
00289         {
00290             return false;
00291         }
00292 
00293         //- Return true if the given type is a constraint type
00294         static bool constraintType(const word& pt);
00295 
00296         //- Return a list of all the constraint patch types
00297         static wordList constraintTypes();
00298 
00299         //- Slice list to patch
00300         template<class T>
00301         const typename List<T>::subList patchSlice(const List<T>& l) const
00302         {
00303             return typename List<T>::subList(l, this->size(), start_);
00304         }
00305 
00306         //- Slice Field to patch
00307         template<class T>
00308         const typename Field<T>::subField patchSlice(const Field<T>& l) const
00309         {
00310             return typename Field<T>::subField(l, this->size(), start_);
00311         }
00312 
00313 
00314         //- Write
00315         virtual void write(Ostream&) const;
00316 
00317         //- Write dictionary
00318         virtual void writeDict(Ostream&) const;
00319 
00320 
00321         // Geometric data; point list required
00322 
00323             //- Return face centres
00324             const vectorField::subField faceCentres() const;
00325 
00326             //- Return face normals
00327             const vectorField::subField faceAreas() const;
00328 
00329             //- Return face neighbour cell centres
00330             tmp<vectorField> faceCellCentres() const;
00331 
00332 
00333         // Addressing into mesh
00334 
00335             //- Return face-cell addressing
00336             const labelList::subList faceCells() const;
00337 
00338             //- Return global edge index for local edges
00339             const labelList& meshEdges() const;
00340 
00341             //- Clear addressing
00342             void clearAddressing();
00343 
00344 
00345         // Other patch operations
00346 
00347             //- Return label of face in patch from global face label
00348             inline label whichFace(const label l) const
00349             {
00350                 return l - start_;
00351             }
00352 
00353 
00354         //- Initialize ordering for primitivePatch. Does not
00355         //  refer to *this (except for name() and type() etc.)
00356         virtual void initOrder(const primitivePatch&) const;
00357 
00358         //- Return new ordering for primitivePatch.
00359         //  Ordering is -faceMap: for every face
00360         //  index of the new face -rotation:for every new face the clockwise
00361         //  shift of the original face. Return false if nothing changes
00362         //  (faceMap is identity, rotation is 0), true otherwise.
00363         virtual bool order
00364         (
00365             const primitivePatch&,
00366             labelList& faceMap,
00367             labelList& rotation
00368         ) const;
00369 
00370 
00371     // Member operators
00372 
00373         //- Assignment
00374         void operator=(const polyPatch&);
00375 
00376 
00377     // Ostream Operator
00378 
00379         friend Ostream& operator<<(Ostream&, const polyPatch&);
00380 };
00381 
00382 
00383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00384 
00385 } // End namespace Foam
00386 
00387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00388 
00389 #endif
00390 
00391 // ************************************************************************* //
For further information go to www.openfoam.org