OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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