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) 2011-2016 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::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  faceZoneNew.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef faceZone_H
41 #define faceZone_H
42 
43 #include "zone.H"
44 #include "faceZoneMeshFwd.H"
45 #include "boolList.H"
46 #include "primitiveFacePatch.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class mapPolyMesh;
54 
55 // Forward declaration of friend functions and operators
56 
57 class faceZone;
58 Ostream& operator<<(Ostream&, const faceZone&);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class faceZone Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class faceZone
66 :
67  public zone
68 {
69  // Private data
70 
71  //- The name associated with the zone-labels dictionary entry
72  static const word labelsName_;
73 
74 
75  // Private Member Functions
76 
77  //- Disallow default bitwise copy construct
78  faceZone(const faceZone&);
79 
80  //- Disallow default bitwise assignment
81  void operator=(const faceZone&);
82 
83 
84 protected:
85 
86  // Protected data
87 
88  //- Flip map for all faces in the zone. Set to true if the
89  // face needs to be flipped to achieve the correct orientation.
91 
92  //- Reference to zone list
93  const faceZoneMesh& zoneMesh_;
94 
95 
96  // Demand-driven private data
97 
98  //- Primitive patch made out of correctly flipped faces
100 
101  //- Master cell layer
102  mutable labelList* masterCellsPtr_;
103 
104  //- Slave cell layer
105  mutable labelList* slaveCellsPtr_;
106 
107  //- Global edge addressing
108  mutable labelList* mePtr_;
109 
110 
111  // Protected Member Functions
112 
113  //- Build primitive patch
114  void calcFaceZonePatch() const;
115 
116  //- Return map of local face indices
117  const Map<label>& faceLookupMap() const;
118 
119  //- Calculate master and slave face layer
120  void calcCellLayers() const;
121 
122  //- Check addressing
123  void checkAddressing() const;
124 
125 
126 public:
127 
128  // Static data members
129 
130  //- The name associated with the zone-labels dictionary entry
131  static const char * const labelsName;
132 
133 
134  //- Runtime type information
135  TypeName("faceZone");
136 
137 
138  // Declare run-time constructor selection tables
139 
141  (
142  autoPtr,
143  faceZone,
144  dictionary,
145  (
146  const word& name,
147  const dictionary& dict,
148  const label index,
149  const faceZoneMesh& zm
150  ),
151  (name, dict, index, zm)
152  );
153 
154 
155  // Constructors
156 
157  //- Construct from components
158  faceZone
159  (
160  const word& name,
161  const labelUList& addr,
162  const boolList& fm,
163  const label index,
164  const faceZoneMesh& zm
165  );
166 
167  //- Construct from components, transferring contents
168  faceZone
169  (
170  const word& name,
171  const Xfer<labelList>& addr,
172  const Xfer<boolList>& fm,
173  const label index,
174  const faceZoneMesh&
175  );
176 
177  //- Construct from dictionary
178  faceZone
179  (
180  const word& name,
181  const dictionary&,
182  const label index,
183  const faceZoneMesh&
184  );
185 
186  //- Construct given the original zone and resetting the
187  // face list and zone mesh information
188  faceZone
189  (
190  const faceZone&,
191  const labelUList& addr,
192  const boolList& fm,
193  const label index,
194  const faceZoneMesh&
195  );
196 
197  //- Construct given the original zone, resetting the
198  // face list and zone mesh information
199  faceZone
200  (
201  const faceZone&,
202  const Xfer<labelList>& addr,
203  const Xfer<boolList>& fm,
204  const label index,
205  const faceZoneMesh&
206  );
207 
208  //- Construct and return a clone, resetting the zone mesh
209  virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
210  {
211  return autoPtr<faceZone>
212  (
213  new faceZone(*this, *this, flipMap(), index(), zm)
214  );
215  }
216 
217  //- Construct and return a clone, resetting the face list
218  // and zone mesh
220  (
221  const labelUList& addr,
222  const boolList& fm,
223  const label index,
224  const faceZoneMesh& zm
225  ) const
226  {
227  return autoPtr<faceZone>
228  (
229  new faceZone(*this, addr, fm, index, zm)
230  );
231  }
232 
233 
234  // Selectors
235 
236  //- Return a pointer to a new face zone
237  // created on freestore from dictionary
238  static autoPtr<faceZone> New
239  (
240  const word& name,
241  const dictionary&,
242  const label index,
243  const faceZoneMesh&
244  );
245 
246 
247  //- Destructor
248  virtual ~faceZone();
249 
250 
251  // Member Functions
252 
253  //- Return face flip map
254  const boolList& flipMap() const
255  {
256  return flipMap_;
257  }
258 
259  //- Helper function to re-direct to zone::localID(...)
260  label whichFace(const label globalCellID) const;
261 
262  //- Return reference to primitive patch
263  const primitiveFacePatch& operator()() const;
264 
265  //- Return zoneMesh reference
266  const faceZoneMesh& zoneMesh() const;
267 
268 
269  // Addressing into mesh
270 
271  //- Return labels of master cells (cells next to the master face
272  // zone in the prescribed direction)
273  const labelList& masterCells() const;
274 
275  //- Return labels of slave cells
276  const labelList& slaveCells() const;
277 
278  //- Return global edge index for local edges
279  const labelList& meshEdges() const;
280 
281 
282  //- Clear addressing
283  virtual void clearAddressing();
284 
285  //- Reset addressing and flip map (clearing demand-driven data)
286  virtual void resetAddressing(const labelUList&, const boolList&);
287 
288  //- Check zone definition. Return true if in error.
289  virtual bool checkDefinition(const bool report = false) const;
290 
291  //- Check whether all procs have faces synchronised. Return
292  // true if in error.
293  virtual bool checkParallelSync(const bool report = false) const;
294 
295  //- Correct patch after moving points
296  virtual void movePoints(const pointField&);
297 
298  //- Update for changes in topology
299  virtual void updateMesh(const mapPolyMesh&);
300 
301  //- Write
302  virtual void write(Ostream&) const;
303 
304  //- Write dictionary
305  virtual void writeDict(Ostream&) const;
306 
307  // I-O
308 
309  //- Ostream Operator
310  friend Ostream& operator<<(Ostream&, const faceZone&);
311 };
312 
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 } // End namespace Foam
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 #endif
321 
322 // ************************************************************************* //
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
dictionary dict
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:333
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
virtual void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
Definition: faceZone.C:377
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:344
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:253
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
virtual ~faceZone()
Destructor.
Definition: faceZone.C:291
void checkAddressing() const
Check addressing.
Definition: faceZone.C:154
virtual void write(Ostream &) const
Write.
Definition: faceZone.C:521
static autoPtr< faceZone > New(const word &name, const dictionary &, const label index, const faceZoneMesh &)
Return a pointer to a new face zone.
Definition: faceZoneNew.C:32
labelList * mePtr_
Global edge addressing.
Definition: faceZone.H:107
labelList * slaveCellsPtr_
Slave cell layer.
Definition: faceZone.H:104
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: faceZone.C:513
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: faceZone.C:305
const word & name() const
Return name.
Definition: zone.H:150
A list of faces which address into the list of points.
const Map< label > & faceLookupMap() const
Return map of local face indices.
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
primitiveFacePatch * patchPtr_
Primitive patch made out of correctly flipped faces.
Definition: faceZone.H:98
void calcFaceZonePatch() const
Build primitive patch.
Definition: faceZone.C:48
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised. Return.
Definition: faceZone.C:424
const faceZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: faceZone.C:299
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 writeDict(Ostream &) const
Write dictionary.
Definition: faceZone.C:529
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const faceZoneMesh & zoneMesh_
Reference to zone list.
Definition: faceZone.H:92
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:418
virtual void clearAddressing()
Clear addressing.
Definition: faceZone.C:363
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:130
labelList * masterCellsPtr_
Master cell layer.
Definition: faceZone.H:101
boolList flipMap_
Flip map for all faces in the zone. Set to true if the.
Definition: faceZone.H:89
virtual void updateMesh(const mapPolyMesh &)
Update for changes in topology.
Definition: faceZone.C:388
Ostream & operator<<(Ostream &, const ensightPart &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
declareRunTimeSelectionTable(autoPtr, faceZone, dictionary,(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm),(name, dict, index, zm))
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:64
void calcCellLayers() const
Calculate master and slave face layer.
Definition: faceZone.C:95
autoPtr< List< label > > clone() const
Clone.
friend Ostream & operator<<(Ostream &, const faceZone &)
Ostream Operator.
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
Definition: faceZone.C:322
const primitiveFacePatch & operator()() const
Return reference to primitive patch.
Definition: faceZone.C:311
TypeName("faceZone")
Runtime type information.
Namespace for OpenFOAM.