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

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