zone.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) 2011 OpenFOAM Foundation
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::zone
26 
27 Description
28  Base class for zones
29 
30 SourceFiles
31  zone.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef zone_H
36 #define zone_H
37 
38 #include "labelList.H"
39 #include "typeInfo.H"
40 #include "dictionary.H"
41 #include "Map.H"
42 #include "pointFieldFwd.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 class zone;
52 Ostream& operator<<(Ostream&, const zone&);
53 
54 /*---------------------------------------------------------------------------*\
55  Class zone Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class zone
59 :
60  public labelList
61 {
62 
63 protected:
64 
65  // Protected data
66 
67  //- Name of zone
68  word name_;
69 
70  //- Index of zone
71  label index_;
72 
73 
74  // Demand-driven private data
75 
76  //- Map of labels in zone for fast location lookup
77  mutable Map<label>* lookupMapPtr_;
78 
79 
80  // Protected Member Functions
81 
82  //- Return a reference to the look-up map
83  const Map<label>& lookupMap() const;
84 
85  //- Construct the look-up map
86  void calcLookupMap() const;
87 
88  //- Disallow default bitwise copy construct
89  zone(const zone&);
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("zone");
96 
97 
98  // Constructors
99 
100  //- Construct from components
101  zone
102  (
103  const word& name,
104  const labelUList& addr,
105  const label index
106  );
107 
108  //- Construct from components, transferring contents
109  zone
110  (
111  const word& name,
112  const Xfer<labelList>& addr,
113  const label index
114  );
115 
116  //- Construct from dictionary
117  zone
118  (
119  const word& name,
120  const dictionary&,
121  const word& labelsName,
122  const label index
123  );
124 
125  //- Construct given the original zone and resetting the
126  // cell list and zone mesh information
127  zone
128  (
129  const zone&,
130  const labelUList& addr,
131  const label index
132  );
133 
134  //- Construct given the original zone, resetting the
135  // cell list and zone mesh information
136  zone
137  (
138  const zone&,
139  const Xfer<labelList>& addr,
140  const label index
141  );
142 
143 
144  //- Destructor
145  virtual ~zone();
146 
147 
148  // Member Functions
149 
150  //- Return name
151  const word& name() const
152  {
153  return name_;
154  }
155 
156  //- Map storing the local index for every global index. Used to find
157  // the index of the item in the zone from the known global index. If
158  // the item is not in the zone, returns -1
159  label localID(const label globalID) const;
160 
161  //- Return the index of this zone in zone list
162  label index() const
163  {
164  return index_;
165  }
166 
167  //- Clear addressing
168  virtual void clearAddressing();
169 
170  //- Check zone definition. Return true if in error.
171  virtual bool checkDefinition(const bool report = false) const = 0;
172 
173  //- Check zone definition with max size given. Return true if in error.
174  virtual bool checkDefinition
175  (
176  const label maxSize,
177  const bool report = false
178  ) const;
179 
180  //- Correct patch after moving points
181  virtual void movePoints(const pointField&)
182  {}
183 
184  //- Write
185  virtual void write(Ostream&) const;
186 
187  //- Write dictionary
188  virtual void writeDict(Ostream&) const = 0;
189 
190 
191  // I-O
192 
193  //- Ostream Operator
194  friend Ostream& operator<<(Ostream&, const zone&);
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
virtual void clearAddressing()
Clear addressing.
Definition: zone.C:183
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
zone(const zone &)
Disallow default bitwise copy construct.
label index() const
Return the index of this zone in zone list.
Definition: zone.H:161
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
void calcLookupMap() const
Construct the look-up map.
Definition: zone.C:52
virtual void write(Ostream &) const
Write.
Definition: zone.C:233
TypeName("zone")
Runtime type information.
virtual ~zone()
Destructor.
Definition: zone.C:158
const word & name() const
Return name.
Definition: zone.H:150
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
word name_
Name of zone.
Definition: zone.H:67
label localID(const label globalID) const
Map storing the local index for every global index. Used to find.
Definition: zone.C:166
label index_
Index of zone.
Definition: zone.H:70
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: zone.H:180
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
friend Ostream & operator<<(Ostream &, const zone &)
Ostream Operator.
Ostream & operator<<(Ostream &, const ensightPart &)
virtual void writeDict(Ostream &) const =0
Write dictionary.
const Map< label > & lookupMap() const
Return a reference to the look-up map.
Definition: zone.C:41
Namespace for OpenFOAM.
Map< label > * lookupMapPtr_
Map of labels in zone for fast location lookup.
Definition: zone.H:76