OpenFOAM logo
Open Source CFD Toolkit

pointZone.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     pointZone
00027 
00028 Description
00029     A subset of mesh points.
00030     The labels of points in the zone can be obtained from the addressing() list.
00031     For quick check whether a point belongs to the zone use the lookup mechanism
00032     in pointZoneMesh, where all the zoned points are registered with their zone
00033     number.
00034 
00035 SourceFiles
00036     pointZone.C
00037     newPointZone.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef pointZone_H
00042 #define pointZone_H
00043 
00044 #include "labelList.H"
00045 #include "typeInfo.H"
00046 #include "dictionary.H"
00047 #include "pointZoneMeshFwd.H"
00048 #include "Map.H"
00049 #include "pointField.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 // * * * * * * * * Forward declaration of friend functions * * * * * * * * * //
00057 
00058 class pointZone;
00059 Ostream& operator<<(Ostream&, const pointZone&);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class pointZone Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class pointZone
00067 :
00068     public labelList
00069 {
00070     // Private data
00071 
00072         //- Name of zone
00073         word name_;
00074 
00075         //- Index of zone
00076         label index_;
00077 
00078         //- Reference to zone list
00079         const pointZoneMesh& zoneMesh_;
00080 
00081 
00082         // Demand-driven private data
00083 
00084             //- Map of point labels in zone for fast location lookup
00085             mutable Map<label>* pointLookupMapPtr_;
00086 
00087 
00088     // Private Member Functions
00089 
00090         //- Disallow default bitwise copy construct
00091         pointZone(const pointZone&);
00092 
00093         //- Return map of local point indices
00094         const Map<label>& pointLookupMap() const;
00095 
00096         //- Build map of local point indices
00097         void calcPointLookupMap() const;
00098 
00099 
00100 public:
00101 
00102     //- Runtime type information
00103     TypeName("pointZone");
00104 
00105 
00106     // Declare run-time constructor selection tables
00107 
00108         declareRunTimeSelectionTable
00109         (
00110             autoPtr,
00111             pointZone,
00112             dictionary,
00113             (
00114                 const word& name,
00115                 const dictionary& dict,
00116                 const label index,
00117                 const pointZoneMesh& zm
00118             ),
00119             (name, dict, index, zm)
00120         );
00121 
00122 
00123     // Constructors
00124 
00125         //- Construct from components
00126         pointZone
00127         (
00128             const word& name,
00129             const labelList& addr,
00130             const label index,
00131             const pointZoneMesh& zm
00132         );
00133 
00134         //- Construct from dictionary
00135         pointZone
00136         (
00137             const word& name,
00138             const dictionary& dict,
00139             const label index,
00140             const pointZoneMesh& zm
00141         );
00142 
00143         //- Construct given the original zone and resetting the
00144         //  point list and zone mesh information
00145         pointZone
00146         (
00147             const pointZone& pz,
00148             const labelList& addr,
00149             const label index,
00150             const pointZoneMesh& zm
00151         );
00152 
00153         //- Construct and return a clone, resetting the zone mesh
00154         virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
00155         {
00156             return autoPtr<pointZone>
00157             (
00158                 new pointZone(*this, *this, index(), zm)
00159             );
00160         }
00161 
00162         //- Construct and return a clone, resetting the point list
00163         //  and zone mesh
00164         virtual autoPtr<pointZone> clone
00165         (
00166             const pointZoneMesh& zm,
00167             const label index,
00168             const labelList& addr
00169         ) const
00170         {
00171             return autoPtr<pointZone>
00172             (
00173                 new pointZone(*this, addr, index, zm)
00174             );
00175         }
00176 
00177 
00178     // Selectors
00179 
00180         //- Return a pointer to a new point zone
00181         //  created on freestore from dictionary
00182         static autoPtr<pointZone> New
00183         (
00184             const word& name,
00185             const dictionary& dict,
00186             const label index,
00187             const pointZoneMesh&
00188         );
00189 
00190 
00191     //- Destructor
00192 
00193         virtual ~pointZone();
00194 
00195 
00196     // Member Functions
00197 
00198         //- Return name
00199         const word& name() const
00200         {
00201             return name_;
00202         }
00203 
00204         //- Map storing the local point index for every global point
00205         //  index.  Used to find out the index of point in the zone from
00206         //  the known global point index.  If the point is not in the
00207         //  zone, returns -1
00208         label whichPoint(const label globalPointID) const;
00209 
00210         //- Return the index of this zone in zone list
00211         label index() const
00212         {
00213             return index_;
00214         }
00215 
00216         //- Return zoneMesh reference
00217         const pointZoneMesh& zoneMesh() const;
00218 
00219         //- Clear addressing
00220         void clearAddressing();
00221 
00222         //- Correct patch after moving points
00223         virtual void movePoints(const pointField&)
00224         {}
00225 
00226         //- Write
00227         virtual void write(Ostream&) const;
00228 
00229         //- Write dictionary
00230         virtual void writeDict(Ostream&) const;
00231 
00232 
00233     // Member Operators
00234 
00235         //- Assign to zone clearing demand-driven data
00236         void operator=(const pointZone&);
00237 
00238         //- Assign addressing clearing demand-driven data
00239         void operator=(const labelList&);
00240 
00241 
00242     // Ostream Operator
00243 
00244         friend Ostream& operator<<(Ostream&, const pointZone&);
00245 };
00246 
00247 
00248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00249 
00250 } // End namespace Foam
00251 
00252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00253 
00254 #endif
00255 
00256 // ************************************************************************* //
For further information go to www.openfoam.org