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