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

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