FreeFOAM The Cross-Platform CFD Toolkit
faceZone.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::faceZone
26 
27 Description
28  A subset of mesh faces organised as a primitive patch.
29 
30  For quick check whether a face belongs to the zone use the lookup
31  mechanism in faceZoneMesh, where all the zoned faces are registered
32  with their zone number.
33 
34 SourceFiles
35  faceZone.C
36  newFaceZone.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef faceZone_H
41 #define faceZone_H
42 
43 #include <OpenFOAM/typeInfo.H>
44 #include <OpenFOAM/dictionary.H>
45 #include <OpenFOAM/labelList.H>
47 #include <OpenFOAM/boolList.H>
49 #include <OpenFOAM/Map.H>
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class mapPolyMesh;
57 
58 // Forward declaration of friend functions and operators
59 
60 class faceZone;
61 Ostream& operator<<(Ostream&, const faceZone&);
62 
63 
64 /*---------------------------------------------------------------------------*\
65  Class faceZone Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class faceZone
69 :
70  public labelList
71 {
72  // Private data
73 
74  //- Name of zone
75  word name_;
76 
77  //- Flip map for all faces in the zone. Set to true if the
78  // face needs to be flipped to achieve the correct orientation.
79  boolList flipMap_;
80 
81  //- Index of zone
82  label index_;
83 
84  //- Reference to zone list
85  const faceZoneMesh& zoneMesh_;
86 
87 
88  // Demand-driven private data
89 
90  //- Primitive patch made out of correctly flipped faces
91  mutable primitiveFacePatch* patchPtr_;
92 
93  //- Master cell layer
94  mutable labelList* masterCellsPtr_;
95 
96  //- Slave cell layer
97  mutable labelList* slaveCellsPtr_;
98 
99  //- Global edge addressing
100  mutable labelList* mePtr_;
101 
102  //- Map of face labels in zone for fast location lookup
103  mutable Map<label>* faceLookupMapPtr_;
104 
105 
106  // Private Member Functions
107 
108  //- Disallow default bitwise copy construct
109  faceZone(const faceZone&);
110 
111  //- Disallow default bitwise assignment
112  void operator=(const faceZone&);
113 
114  //- Build primitive patch
115  void calcFaceZonePatch() const;
116 
117  //- Return map of local face indices
118  const Map<label>& faceLookupMap() const;
119 
120  //- Build map of local face indices
121  void calcFaceLookupMap() const;
122 
123  //- Calculate master and slave face layer
124  void calcCellLayers() const;
125 
126  //- Check addressing
127  void checkAddressing() const;
128 
129 
130 public:
131 
132  //- Runtime type information
133  TypeName("faceZone");
134 
135 
136  // Declare run-time constructor selection tables
137 
139  (
140  autoPtr,
141  faceZone,
142  dictionary,
143  (
144  const word& name,
145  const dictionary& dict,
146  const label index,
147  const faceZoneMesh& zm
148  ),
149  (name, dict, index, zm)
150  );
151 
152 
153  // Constructors
154 
155  //- Construct from components
156  faceZone
157  (
158  const word& name,
159  const labelList& addr,
160  const boolList& fm,
161  const label index,
162  const faceZoneMesh& zm
163  );
164 
165  //- Construct from components, transferring contents
166  faceZone
167  (
168  const word& name,
169  const Xfer<labelList>& addr,
170  const Xfer<boolList>& fm,
171  const label index,
172  const faceZoneMesh&
173  );
174 
175  //- Construct from dictionary
176  faceZone
177  (
178  const word& name,
179  const dictionary&,
180  const label index,
181  const faceZoneMesh&
182  );
183 
184  //- Construct given the original zone and resetting the
185  // face list and zone mesh information
186  faceZone
187  (
188  const faceZone&,
189  const labelList& addr,
190  const boolList& fm,
191  const label index,
192  const faceZoneMesh&
193  );
194 
195  //- Construct given the original zone, resetting the
196  // face list and zone mesh information
197  faceZone
198  (
199  const faceZone&,
200  const Xfer<labelList>& addr,
201  const Xfer<boolList>& fm,
202  const label index,
203  const faceZoneMesh&
204  );
205 
206  //- Construct and return a clone, resetting the zone mesh
207  virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
208  {
209  return autoPtr<faceZone>
210  (
211  new faceZone(*this, *this, flipMap(), index(), zm)
212  );
213  }
214 
215  //- Construct and return a clone, resetting the face list
216  // and zone mesh
217  virtual autoPtr<faceZone> clone
218  (
219  const labelList& addr,
220  const boolList& fm,
221  const label index,
222  const faceZoneMesh& zm
223  ) const
224  {
225  return autoPtr<faceZone>
226  (
227  new faceZone(*this, addr, fm, index, zm)
228  );
229  }
230 
231 
232  // Selectors
233 
234  //- Return a pointer to a new face zone
235  // created on freestore from dictionary
236  static autoPtr<faceZone> New
237  (
238  const word& name,
239  const dictionary&,
240  const label index,
241  const faceZoneMesh&
242  );
243 
244 
245  //- Destructor
246 
247  virtual ~faceZone();
248 
249 
250  // Member Functions
251 
252  //- Return name
253  const word& name() const
254  {
255  return name_;
256  }
257 
258  //- Return face flip map
259  const boolList& flipMap() const
260  {
261  return flipMap_;
262  }
263 
264  //- Map storing the local face index for every global face index.
265  // Used to find out the index of face in the zone from the known global
266  // face index. If the face is not in the zone, returns -1
267  label whichFace(const label globalFaceID) const;
268 
269  //- Return reference to primitive patch
270  const primitiveFacePatch& operator()() const;
271 
272  //- Return the index of this zone in zone list
273  label index() const
274  {
275  return index_;
276  }
277 
278  //- Return zoneMesh reference
279  const faceZoneMesh& zoneMesh() const;
280 
281 
282  // Addressing into mesh
283 
284  //- Return labels of master cells (cells next to the master face
285  // zone in the prescribed direction)
286  const labelList& masterCells() const;
287 
288  //- Return labels of slave cells
289  const labelList& slaveCells() const;
290 
291  //- Return global edge index for local edges
292  const labelList& meshEdges() const;
293 
294 
295  //- Clear addressing
296  void clearAddressing();
297 
298  //- Reset addressing and flip map (clearing demand-driven data)
299  void resetAddressing(const labelList&, const boolList&);
300 
301  //- Check zone definition. Return true if in error.
302  bool checkDefinition(const bool report = false) const;
303 
304  //- Check whether all procs have faces synchronised. Return
305  // true if in error.
306  bool checkParallelSync(const bool report = false) const;
307 
308  //- Correct patch after moving points
309  virtual void movePoints(const pointField&);
310 
311  //- Update for changes in topology
312  void updateMesh(const mapPolyMesh& mpm);
313 
314  //- Write
315  virtual void write(Ostream&) const;
316 
317  //- Write dictionary
318  virtual void writeDict(Ostream&) const;
319 
320 
321  // Ostream Operator
322 
323  friend Ostream& operator<<(Ostream&, const faceZone&);
324 };
325 
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 } // End namespace Foam
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 #endif
334 
335 // ************************ vim: set sw=4 sts=4 et: ************************ //