FreeFOAM The Cross-Platform CFD Toolkit
ZoneMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ZoneMesh
26 
27 Description
28  List of mesh zones
29 
30 SourceFiles
31  ZoneMesh.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef ZoneMesh_H
36 #define ZoneMesh_H
37 
38 #include <OpenFOAM/List.H>
39 #include <OpenFOAM/regIOobject.H>
40 #include <OpenFOAM/HashSet.H>
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 // Forward declaration of friend functions and operators
51 
52 template<class ZoneType, class MeshType> class ZoneMesh;
53 
54 template<class ZoneType, class MeshType>
55 Ostream& operator<<(Ostream&, const ZoneMesh<ZoneType, MeshType>&);
56 
57 /*---------------------------------------------------------------------------*\
58  Class ZoneMesh Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template<class ZoneType, class MeshType>
62 class ZoneMesh
63 :
64  public PtrList<ZoneType>,
65  public regIOobject
66 {
67  // Private data
68 
69  //- Reference to mesh
70  const MeshType& mesh_;
71 
72  //- Map of zone labels for given element
73  mutable Map<label>* zoneMapPtr_;
74 
75 
76  // Private member functions
77 
78  //- Disallow construct as copy
79  ZoneMesh(const ZoneMesh&);
80 
81  //- Disallow assignment
82  void operator=(const ZoneMesh<ZoneType, MeshType>&);
83 
84 
85  //- Create zone map
86  void calcZoneMap() const;
87 
88 
89 public:
90 
91  // Constructors
92 
93  //- Read constructor given IOobject and a MeshType reference
94  ZoneMesh
95  (
96  const IOobject&,
97  const MeshType&
98  );
99 
100  //- Construct given size
101  ZoneMesh
102  (
103  const IOobject&,
104  const MeshType&,
105  const label size
106  );
107 
108  // Destructor
109 
110  ~ZoneMesh();
111 
112 
113  // Member functions
114 
115  //- Return the mesh reference
116  const MeshType& mesh() const
117  {
118  return mesh_;
119  }
120 
121  //- Map of zones containing zone index for all zoned elements
122  // Return -1 if the object is not in the zone
123  const Map<label>& zoneMap() const;
124 
125  //- Given a global object index, return the zone it is in. If
126  //object does not belong to any zones, return -1
127  label whichZone(const label objectIndex) const;
128 
129  //- Return a list of zone types
130  wordList types() const;
131 
132  //- Return a list of zone names
133  wordList names() const;
134 
135  //- Find zone index given a name
136  label findZoneID(const word& zoneName) const;
137 
138  //- Clear addressing
139  void clearAddressing();
140 
141  //- Clear the zones
142  void clear();
143 
144  //- Check zone definition. Return true if in error.
145  bool checkDefinition(const bool report = false) const;
146 
147  //- Correct zone mesh after moving points
148  void movePoints(const pointField&);
149 
150  //- writeData member function required by regIOobject
151  bool writeData(Ostream&) const;
152 
153 
154  // Ostream operator
155 
156  friend Ostream& operator<< <ZoneType, MeshType>
157  (
158  Ostream&,
160  );
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #ifdef NoRepository
171 # include "ZoneMesh.C"
172 #endif
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************ vim: set sw=4 sts=4 et: ************************ //