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

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