OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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