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

ZoneMesh.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::ZoneMesh
00027 
00028 Description
00029     List of mesh zones
00030 
00031 SourceFiles
00032     ZoneMesh.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef ZoneMesh_H
00037 #define ZoneMesh_H
00038 
00039 #include "List.H"
00040 #include "regIOobject.H"
00041 #include "HashSet.H"
00042 #include "pointFieldsFwd.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 // Forward declaration of friend functions and operators
00052 
00053 template<class ZoneType, class MeshType> class ZoneMesh;
00054 
00055 template<class ZoneType, class MeshType>
00056 Ostream& operator<<(Ostream&, const ZoneMesh<ZoneType, MeshType>&);
00057 
00058 /*---------------------------------------------------------------------------*\
00059                            Class ZoneMesh Declaration
00060 \*---------------------------------------------------------------------------*/
00061 
00062 template<class ZoneType, class MeshType>
00063 class ZoneMesh
00064 :
00065     public PtrList<ZoneType>,
00066     public regIOobject
00067 {
00068     // Private data
00069 
00070         //- Reference to mesh
00071         const MeshType& mesh_;
00072 
00073         //- Map of zone labels for given element
00074         mutable Map<label>* zoneMapPtr_;
00075 
00076 
00077     // Private member functions
00078 
00079         //- Disallow construct as copy
00080         ZoneMesh(const ZoneMesh&);
00081 
00082         //- Disallow assignment
00083         void operator=(const ZoneMesh<ZoneType, MeshType>&);
00084 
00085 
00086         //- Create zone map
00087         void calcZoneMap() const;
00088 
00089 
00090 public:
00091 
00092     // Constructors
00093 
00094         //- Read constructor given IOobject and a MeshType reference
00095         ZoneMesh
00096         (
00097             const IOobject&,
00098             const MeshType&
00099         );
00100 
00101         //- Construct given size
00102         ZoneMesh
00103         (
00104             const IOobject&,
00105             const MeshType&,
00106             const label size
00107         );
00108 
00109     // Destructor
00110 
00111         ~ZoneMesh();
00112 
00113 
00114     // Member functions
00115 
00116         //- Return the mesh reference
00117         const MeshType& mesh() const
00118         {
00119             return mesh_;
00120         }
00121 
00122         //- Map of zones containing zone index for all zoned elements
00123         //  Return -1 if the object is not in the zone
00124         const Map<label>& zoneMap() const;
00125 
00126         //- Given a global object index, return the zone it is in.  If
00127         //object does not belong to any zones, return -1
00128         label whichZone(const label objectIndex) const;
00129 
00130         //- Return a list of zone types
00131         wordList types() const;
00132 
00133         //- Return a list of zone names
00134         wordList names() const;
00135 
00136         //- Find zone index given a name
00137         label findZoneID(const word& zoneName) const;
00138 
00139         //- Clear addressing
00140         void clearAddressing();
00141 
00142         //- Clear the zones
00143         void clear();
00144 
00145         //- Check zone definition. Return true if in error.
00146         bool checkDefinition(const bool report = false) const;
00147 
00148         //- Correct zone mesh after moving points
00149         void movePoints(const pointField&);
00150 
00151         //- writeData member function required by regIOobject
00152         bool writeData(Ostream&) const;
00153 
00154 
00155     // Ostream operator
00156 
00157         friend Ostream& operator<< <ZoneType, MeshType>
00158         (
00159             Ostream&,
00160             const ZoneMesh<ZoneType, MeshType>&
00161         );
00162 };
00163 
00164 
00165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00166 
00167 } // End namespace Foam
00168 
00169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00170 
00171 #ifdef NoRepository
00172 #   include "ZoneMesh.C"
00173 #endif
00174 
00175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00176 
00177 #endif
00178 
00179 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd