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

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-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::faceZone
00026 
00027 Description
00028     A subset of mesh faces organised as a primitive patch.
00029 
00030     For quick check whether a face belongs to the zone use the lookup
00031     mechanism in faceZoneMesh, where all the zoned faces are registered
00032     with their zone number.
00033 
00034 SourceFiles
00035     faceZone.C
00036     newFaceZone.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef faceZone_H
00041 #define faceZone_H
00042 
00043 #include <OpenFOAM/typeInfo.H>
00044 #include <OpenFOAM/dictionary.H>
00045 #include <OpenFOAM/labelList.H>
00046 #include <OpenFOAM/faceZoneMeshFwd.H>
00047 #include <OpenFOAM/boolList.H>
00048 #include <OpenFOAM/primitiveFacePatch.H>
00049 #include <OpenFOAM/Map.H>
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 class mapPolyMesh;
00057 
00058 // Forward declaration of friend functions and operators
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 components, transferring contents
00166         faceZone
00167         (
00168             const word& name,
00169             const Xfer<labelList>& addr,
00170             const Xfer<boolList>& fm,
00171             const label index,
00172             const faceZoneMesh&
00173         );
00174 
00175         //- Construct from dictionary
00176         faceZone
00177         (
00178             const word& name,
00179             const dictionary&,
00180             const label index,
00181             const faceZoneMesh&
00182         );
00183 
00184         //- Construct given the original zone and resetting the
00185         //  face list and zone mesh information
00186         faceZone
00187         (
00188             const faceZone&,
00189             const labelList& addr,
00190             const boolList& fm,
00191             const label index,
00192             const faceZoneMesh&
00193         );
00194 
00195         //- Construct given the original zone, resetting the
00196         //  face list and zone mesh information
00197         faceZone
00198         (
00199             const faceZone&,
00200             const Xfer<labelList>& addr,
00201             const Xfer<boolList>& fm,
00202             const label index,
00203             const faceZoneMesh&
00204         );
00205 
00206         //- Construct and return a clone, resetting the zone mesh
00207         virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
00208         {
00209             return autoPtr<faceZone>
00210             (
00211                 new faceZone(*this, *this, flipMap(), index(), zm)
00212             );
00213         }
00214 
00215         //- Construct and return a clone, resetting the face list
00216         //  and zone mesh
00217         virtual autoPtr<faceZone> clone
00218         (
00219             const labelList& addr,
00220             const boolList& fm,
00221             const label index,
00222             const faceZoneMesh& zm
00223         ) const
00224         {
00225             return autoPtr<faceZone>
00226             (
00227                 new faceZone(*this, addr, fm, index, zm)
00228             );
00229         }
00230 
00231 
00232     // Selectors
00233 
00234         //- Return a pointer to a new face zone
00235         //  created on freestore from dictionary
00236         static autoPtr<faceZone> New
00237         (
00238             const word& name,
00239             const dictionary&,
00240             const label index,
00241             const faceZoneMesh&
00242         );
00243 
00244 
00245     //- Destructor
00246 
00247         virtual ~faceZone();
00248 
00249 
00250     // Member Functions
00251 
00252         //- Return name
00253         const word& name() const
00254         {
00255             return name_;
00256         }
00257 
00258         //- Return face flip map
00259         const boolList& flipMap() const
00260         {
00261             return flipMap_;
00262         }
00263 
00264         //- Map storing the local face index for every global face index.
00265         //  Used to find out the index of face in the zone from the known global
00266         //  face index.  If the face is not in the zone, returns -1
00267         label whichFace(const label globalFaceID) const;
00268 
00269         //- Return reference to primitive patch
00270         const primitiveFacePatch& operator()() const;
00271 
00272         //- Return the index of this zone in zone list
00273         label index() const
00274         {
00275             return index_;
00276         }
00277 
00278         //- Return zoneMesh reference
00279         const faceZoneMesh& zoneMesh() const;
00280 
00281 
00282         // Addressing into mesh
00283 
00284             //- Return labels of master cells (cells next to the master face
00285             //  zone in the prescribed direction)
00286             const labelList& masterCells() const;
00287 
00288             //- Return labels of slave cells
00289             const labelList& slaveCells() const;
00290 
00291             //- Return global edge index for local edges
00292             const labelList& meshEdges() const;
00293 
00294 
00295         //- Clear addressing
00296         void clearAddressing();
00297 
00298         //- Reset addressing and flip map (clearing demand-driven data)
00299         void resetAddressing(const labelList&, const boolList&);
00300 
00301         //- Check zone definition. Return true if in error.
00302         bool checkDefinition(const bool report = false) const;
00303 
00304         //- Check whether all procs have faces synchronised. Return
00305         //  true if in error.
00306         bool checkParallelSync(const bool report = false) const;
00307 
00308         //- Correct patch after moving points
00309         virtual void movePoints(const pointField&);
00310 
00311         //- Update for changes in topology
00312         void updateMesh(const mapPolyMesh& mpm);
00313 
00314         //- Write
00315         virtual void write(Ostream&) const;
00316 
00317         //- Write dictionary
00318         virtual void writeDict(Ostream&) const;
00319 
00320 
00321     // Ostream Operator
00322 
00323         friend Ostream& operator<<(Ostream&, const faceZone&);
00324 };
00325 
00326 
00327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00328 
00329 } // End namespace Foam
00330 
00331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00332 
00333 #endif
00334 
00335 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines