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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::faceZone
29 
30 Description
31  A subset of mesh faces organised as a primitive patch.
32 
33  For quick check whether a face belongs to the zone use the lookup
34  mechanism in faceZoneMesh, where all the zoned faces are registered
35  with their zone number.
36 
37 SourceFiles
38  faceZone.C
39  faceZoneNew.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef faceZone_H
44 #define faceZone_H
45 
46 #include "zone.H"
47 #include "faceZoneMeshFwd.H"
48 #include "boolList.H"
49 #include "primitiveFacePatch.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declarations
57 class mapPolyMesh;
58 class faceZone;
59 Ostream& operator<<(Ostream& os, const faceZone& zn);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class faceZone Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class faceZone
67 :
68  public zone
69 {
70  // Private Member Functions
71 
72  //- Set flip-map to uniform value
73  void setFlipMap(const bool val);
74 
75  //- No copy construct
76  faceZone(const faceZone&) = delete;
77 
78  //- No copy assignment
79  void operator=(const faceZone&) = delete;
80 
81 
82 protected:
83 
84  // Protected Data
85 
86  //- Flip map for all faces in the zone.
87  // Use true if the face needs flipping for the correct orientation.
89 
90  //- Reference to zone list
91  const faceZoneMesh& zoneMesh_;
92 
93 
94  // Demand-driven data
95 
96  //- Primitive patch made out of correctly flipped faces
98 
99  //- Master cell layer
100  mutable labelList* masterCellsPtr_;
101 
102  //- Slave cell layer
103  mutable labelList* slaveCellsPtr_;
104 
105  //- Global edge addressing
106  mutable labelList* mePtr_;
107 
108 
109  // Protected Member Functions
110 
111  //- Build primitive patch
112  void calcFaceZonePatch() const;
113 
114  //- Calculate master and slave face layer
115  void calcCellLayers() const;
116 
117  //- Check addressing
118  void checkAddressing() const;
119 
120 
121 public:
122 
123  // Static Data Members
124 
125  //- The name associated with the zone-labels dictionary entry
126  static const char * const labelsName;
127 
128 
129  //- Runtime type information
130  TypeName("faceZone");
131 
132 
133  // Declare run-time constructor selection tables
134 
136  (
137  autoPtr,
138  faceZone,
139  dictionary,
140  (
141  const word& name,
142  const dictionary& dict,
143  const label index,
144  const faceZoneMesh& zm
145  ),
146  (name, dict, index, zm)
147  );
148 
149 
150  // Constructors
151 
152  //- Construct an empty zone
153  faceZone(const word& name, const label index, const faceZoneMesh& zm);
154 
155  //- Construct from components with uniform flip map value
156  faceZone
157  (
158  const word& name,
159  const labelUList& addr,
160  const bool flipMapValue,
161  const label index,
162  const faceZoneMesh& zm
163  );
164 
165  //- Construct from components with uniform flip map value,
166  //- transferring addressing.
167  faceZone
168  (
169  const word& name,
170  labelList&& addr,
171  const bool flipMapValue,
172  const label index,
173  const faceZoneMesh& zm
174  );
175 
176  //- Construct from components
177  faceZone
178  (
179  const word& name,
180  const labelUList& addr,
181  const boolUList& fm,
182  const label index,
183  const faceZoneMesh& zm
184  );
185 
186  //- Construct from components, transferring addressing
187  faceZone
188  (
189  const word& name,
190  labelList&& addr,
191  boolList&& fm,
192  const label index,
193  const faceZoneMesh& zm
194  );
195 
196  //- Construct from dictionary
197  faceZone
198  (
199  const word& name,
200  const dictionary& dict,
201  const label index,
202  const faceZoneMesh& zm
203  );
204 
205  //- Construct with a new index and zone mesh information, the name
206  //- of the original zone, resetting the face addressing
207  //- and flip-map.
208  faceZone
209  (
210  const faceZone& origZone,
211  const labelUList& addr,
212  const boolUList& fm,
213  const label index,
214  const faceZoneMesh& zm
215  );
216 
217  //- Construct with a new index and zone mesh information, the name
218  //- of the original zone, (move) resetting the face addressing
219  //- and flip-map.
220  faceZone
221  (
222  const faceZone& origZone,
223  labelList&& addr,
224  boolList&& fm,
225  const label index,
226  const faceZoneMesh& zm
227  );
228 
229  //- Construct and return a clone, resetting the zone mesh
230  virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
231  {
232  return autoPtr<faceZone>::New(*this, *this, flipMap(), index(), zm);
233  }
234 
235  //- Construct and return a clone,
236  //- resetting the face list and zone mesh
238  (
239  const labelUList& addr,
240  const boolUList& fm,
241  const label index,
242  const faceZoneMesh& zm
243  ) const
244  {
245  return autoPtr<faceZone>::New(*this, addr, fm, index, zm);
246  }
247 
248 
249  // Selectors
250 
251  //- Return a pointer to a new face zone
252  //- created on freestore from dictionary
253  static autoPtr<faceZone> New
254  (
255  const word& name,
256  const dictionary& dict,
257  const label index,
258  const faceZoneMesh& zm
259  );
260 
261 
262  //- Destructor
263  virtual ~faceZone();
264 
265 
266  // Member Functions
267 
268  //- Return zoneMesh reference
269  const faceZoneMesh& zoneMesh() const;
270 
271  //- Return face flip map
272  const boolList& flipMap() const
273  {
274  return flipMap_;
275  }
276 
277  //- Helper function to re-direct to zone::localID(...)
278  label whichFace(const label globalCellID) const;
279 
280  //- Return reference to primitive patch
281  const primitiveFacePatch& operator()() const;
282 
283 
284  // Addressing into mesh
285 
286  //- Return labels of master cells (cells next to the master face
287  //- zone in the prescribed direction)
288  const labelList& masterCells() const;
289 
290  //- Return labels of slave cells
291  const labelList& slaveCells() const;
292 
293  //- Return global edge index for local edges
294  const labelList& meshEdges() const;
295 
296 
297  //- Clear addressing
298  virtual void clearAddressing();
299 
300  //- Reset addressing - use uniform flip map value
301  // Clears demand-driven data.
302  virtual void resetAddressing
303  (
304  const labelUList& addr,
305  const bool flipMapValue
306  );
307 
308  //- Reset addressing and flip map.
309  // Clears demand-driven data.
310  virtual void resetAddressing
311  (
312  const labelUList& addr,
313  const boolUList& flipMap
314  );
315 
316  //- Move reset addressing - use uniform flip map value
317  // Clears demand-driven data.
318  virtual void resetAddressing
319  (
320  labelList&& addr,
321  const bool flipMapValue
322  );
323 
324  //- Check zone definition. Return true if in error.
325  virtual bool checkDefinition(const bool report = false) const;
326 
327  //- Check whether all procs have faces synchronised.
328  // \return True if any errors.
329  virtual bool checkParallelSync(const bool report = false) const;
330 
331  //- Correct patch after moving points
332  virtual void movePoints(const pointField& pts);
333 
334  //- Update for changes in topology
335  virtual void updateMesh(const mapPolyMesh& mpm);
336 
337  //- Write
338  virtual void write(Ostream& os) const;
339 
340  //- Write dictionary
341  virtual void writeDict(Ostream& os) const;
342 
343 
344  // I-O
345 
346  //- Ostream Operator
347  friend Ostream& operator<<(Ostream& os, const faceZone& zn);
348 };
349 
350 
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352 
353 } // End namespace Foam
354 
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 
357 #endif
358 
359 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::faceZone::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: faceZone.C:437
Foam::faceZone::labelsName
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:125
boolList.H
Foam::faceZone::operator<<
friend Ostream & operator<<(Ostream &os, const faceZone &zn)
Ostream Operator.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::faceZone::checkAddressing
void checkAddressing() const
Check addressing.
Definition: faceZone.C:167
Foam::faceZone::meshEdges
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:418
Foam::faceZone::zoneMesh_
const faceZoneMesh & zoneMesh_
Reference to zone list.
Definition: faceZone.H:90
zone.H
faceZoneMeshFwd.H
Foam::faceZone::resetAddressing
virtual void resetAddressing(const labelUList &addr, const bool flipMapValue)
Reset addressing - use uniform flip map value.
Definition: faceZone.C:451
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
primitiveFacePatch.H
Foam::faceZone::TypeName
TypeName("faceZone")
Runtime type information.
Foam::faceZone::~faceZone
virtual ~faceZone()
Destructor.
Definition: faceZone.C:365
Foam::faceZone::masterCellsPtr_
labelList * masterCellsPtr_
Master cell layer.
Definition: faceZone.H:99
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::faceZone::patchPtr_
primitiveFacePatch * patchPtr_
Primitive patch made out of correctly flipped faces.
Definition: faceZone.H:96
Foam::Field< vector >
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:65
Foam::faceZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:516
Foam::faceZone::flipMap_
boolList flipMap_
Flip map for all faces in the zone.
Definition: faceZone.H:87
Foam::faceZone::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, faceZone, dictionary,(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm),(name, dict, index, zm))
Foam::faceZone::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes in topology.
Definition: faceZone.C:486
Foam::faceZone::slaveCells
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:407
Foam::ZoneMesh< faceZone, polyMesh >
Foam::faceZone::zoneMesh
const faceZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: faceZone.C:373
Foam::faceZone::slaveCellsPtr_
labelList * slaveCellsPtr_
Slave cell layer.
Definition: faceZone.H:102
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::faceZone::movePoints
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition: faceZone.C:611
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faceZone::whichFace
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: faceZone.C:379
Foam::zone::name
const word & name() const
Return name.
Definition: zone.H:158
Foam::faceZone::mePtr_
labelList * mePtr_
Global edge addressing.
Definition: faceZone.H:105
Foam::faceZone::checkParallelSync
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised.
Definition: faceZone.C:522
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::faceZone::masterCells
const labelList & masterCells() const
Definition: faceZone.C:396
Foam::faceZone::operator()
const primitiveFacePatch & operator()() const
Return reference to primitive patch.
Definition: faceZone.C:385
Foam::faceZone::calcCellLayers
void calcCellLayers() const
Calculate master and slave face layer.
Definition: faceZone.C:111
Foam::faceZone::calcFaceZonePatch
void calcFaceZonePatch() const
Build primitive patch.
Definition: faceZone.C:70
Foam::faceZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: faceZone.C:627
Foam::List< bool >
Foam::UList< label >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::faceZone::write
virtual void write(Ostream &os) const
Write.
Definition: faceZone.C:619
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::faceZone::New
static autoPtr< faceZone > New(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm)
Definition: faceZoneNew.C:35
Foam::List::clone
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:99
Foam::faceZone::flipMap
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:271
Foam::zone::index
label index() const
Return the index of this zone in zone list.
Definition: zone.H:169
Foam::faceZone::clone
virtual autoPtr< faceZone > clone(const faceZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: faceZone.H:229
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85