OpenFOAM logo
Open Source CFD Toolkit

faceZone.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     faceZone
00027 
00028 Description
00029     A subset of mesh faces organised as a primitive patch.
00030     For quick check whether a face belongs to the zone use the lookup mechanism
00031     in faceZoneMesh, where all the zoned faces are registered with their zone
00032     number.
00033 
00034 SourceFiles
00035     faceZone.C
00036     newFaceZone.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef faceZone_H
00041 #define faceZone_H
00042 
00043 #include "typeInfo.H"
00044 #include "dictionary.H"
00045 #include "labelList.H"
00046 #include "faceZoneMeshFwd.H"
00047 #include "boolList.H"
00048 #include "primitiveFacePatch.H"
00049 #include "Map.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 class mapPolyMesh;
00057 
00058 // * * * * * * * * Forward declaration of friend functions * * * * * * * * * //
00059 
00060 class faceZone;
00061 Ostream& operator<<(Ostream&, const faceZone&);
00062 
00063 
00064 /*---------------------------------------------------------------------------*\
00065                            Class faceZone Declaration
00066 \*---------------------------------------------------------------------------*/
00067 
00068 class faceZone
00069 :
00070     public labelList
00071 {
00072     // Private data
00073 
00074         //- Name of zone
00075         word name_;
00076 
00077         //- Flip map for all faces in the zone.  Set to true if the
00078         //  face needs to be flipped to achieve the correct orientation.
00079         boolList flipMap_;
00080 
00081         //- Index of zone
00082         label index_;
00083 
00084         //- Reference to zone list
00085         const faceZoneMesh& zoneMesh_;
00086 
00087 
00088         // Demand-driven private data
00089 
00090             //- Primitive patch made out of correctly flipped faces
00091             mutable primitiveFacePatch* patchPtr_;
00092 
00093             //- Master cell layer
00094             mutable labelList* masterCellsPtr_;
00095 
00096             //- Slave cell layer
00097             mutable labelList* slaveCellsPtr_;
00098 
00099             //- Global edge addressing
00100             mutable labelList* mePtr_;
00101 
00102             //- Map of face labels in zone for fast location lookup
00103             mutable Map<label>* faceLookupMapPtr_;
00104 
00105 
00106     // Private Member Functions
00107 
00108         //- Disallow default bitwise copy construct
00109         faceZone(const faceZone&);
00110 
00111         //- Disallow default bitwise assignment
00112         void operator=(const faceZone&);
00113 
00114         //- Build primitive patch
00115         void calcFaceZonePatch() const;
00116 
00117         //- Return map of local face indices
00118         const Map<label>& faceLookupMap() const;
00119 
00120         //- Build map of local face indices
00121         void calcFaceLookupMap() const;
00122 
00123         //- Calculate master and slave face layer
00124         void calcCellLayers() const;
00125 
00126         //- Check addressing
00127         void checkAddressing() const;
00128 
00129 
00130 public:
00131 
00132     //- Runtime type information
00133     TypeName("faceZone");
00134 
00135 
00136     // Declare run-time constructor selection tables
00137 
00138         declareRunTimeSelectionTable
00139         (
00140             autoPtr,
00141             faceZone,
00142             dictionary,
00143             (
00144                 const word& name,
00145                 const dictionary& dict,
00146                 const label index,
00147                 const faceZoneMesh& zm
00148             ),
00149             (name, dict, index, zm)
00150         );
00151 
00152 
00153     // Constructors
00154 
00155         //- Construct from components
00156         faceZone
00157         (
00158             const word& name,
00159             const labelList& addr,
00160             const boolList& fm,
00161             const label index,
00162             const faceZoneMesh& zm
00163         );
00164 
00165         //- Construct from dictionary
00166         faceZone
00167         (
00168             const word& name,
00169             const dictionary& dict,
00170             const label index,
00171             const faceZoneMesh& zm
00172         );
00173 
00174         //- Construct given the original zone and resetting the
00175         //  face list and zone mesh information
00176         faceZone
00177         (
00178             const faceZone& fz,
00179             const labelList& addr,
00180             const boolList& fm,
00181             const label index,
00182             const faceZoneMesh& zm
00183         );
00184 
00185         //- Construct and return a clone, resetting the zone mesh
00186         virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
00187         {
00188             return autoPtr<faceZone>
00189             (
00190                 new faceZone(*this, *this, flipMap(), index(), zm)
00191             );
00192         }
00193 
00194         //- Construct and return a clone, resetting the face list
00195         //  and zone mesh
00196         virtual autoPtr<faceZone> clone
00197         (
00198             const labelList& addr,
00199             const boolList& fm,
00200             const label index,
00201             const faceZoneMesh& zm
00202         ) const
00203         {
00204             return autoPtr<faceZone>
00205             (
00206                 new faceZone(*this, addr, fm, index, zm)
00207             );
00208         }
00209 
00210 
00211     // Selectors
00212 
00213         //- Return a pointer to a new face zone
00214         //  created on freestore from dictionary
00215         static autoPtr<faceZone> New
00216         (
00217             const word& name,
00218             const dictionary& dict,
00219             const label index,
00220             const faceZoneMesh& zm
00221         );
00222 
00223 
00224     //- Destructor
00225 
00226         virtual ~faceZone();
00227 
00228 
00229     // Member Functions
00230 
00231         //- Return name
00232         const word& name() const
00233         {
00234             return name_;
00235         }
00236 
00237         //- Return face flip map
00238         const boolList& flipMap() const
00239         {
00240             return flipMap_;
00241         }
00242 
00243         //- Map storing the local face index for every global face index.
00244         //  Used to find out the index of face in the zone from the known global
00245         //  face index.  If the face is not in the zone, returns -1
00246         label whichFace(const label globalFaceID) const;
00247 
00248         //- Return reference to primitive patch
00249         const primitiveFacePatch& operator()() const;
00250 
00251         //- Return the index of this zone in zone list
00252         label index() const
00253         {
00254             return index_;
00255         }
00256 
00257         //- Return zoneMesh reference
00258         const faceZoneMesh& zoneMesh() const;
00259 
00260 
00261         // Addressing into mesh
00262 
00263             //- Return labels of master cells (cells next to the master face
00264             //  zone in the prescribed direction)
00265             const labelList& masterCells() const;
00266 
00267             //- Return labels of slave cells
00268             const labelList& slaveCells() const;
00269 
00270             //- Return global edge index for local edges
00271             const labelList& meshEdges() const;
00272 
00273 
00274         //- Clear addressing
00275         void clearAddressing();
00276 
00277         //- Reset addressing and flip map (clearing demand-driven data)
00278         void resetAddressing(const labelList&, const boolList&);
00279 
00280         //- Correct patch after moving points
00281         virtual void movePoints(const pointField&);
00282 
00283         //- Update for changes in topology
00284         void updateMesh(const mapPolyMesh& mpm);
00285 
00286         //- Write
00287         virtual void write(Ostream&) const;
00288 
00289         //- Write dictionary
00290         virtual void writeDict(Ostream&) const;
00291 
00292 
00293     // Ostream Operator
00294 
00295         friend Ostream& operator<<(Ostream&, const faceZone&);
00296 };
00297 
00298 
00299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00300 
00301 } // End namespace Foam
00302 
00303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00304 
00305 #endif
00306 
00307 // ************************************************************************* //
For further information go to www.openfoam.org