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