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