polyAddFace.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::polyAddFace
26 
27 Description
28  A face addition data class. A face can be inflated either from a
29  point or from another face and can either be in internal or a
30  boundary face.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef polyAddFace_H
35 #define polyAddFace_H
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 #include "label.H"
40 #include "face.H"
41 #include "topoAction.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class polyAddFace Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class polyAddFace
53 :
54  public topoAction
55 {
56  // Private data
57 
58  //- Face identifier
59  face face_;
60 
61  //- Face owner
62  label owner_;
63 
64  //- Face neighbour
65  label neighbour_;
66 
67  //- Master point ID for faces blown up from points
68  label masterPointID_;
69 
70  //- Master edge ID for faces blown up from edges
71  label masterEdgeID_;
72 
73  //- Master face ID for faces blown up from faces
74  label masterFaceID_;
75 
76  //- Does the face flux need to be flipped
77  bool flipFaceFlux_;
78 
79  //- Boundary patch ID
80  label patchID_;
81 
82  //- Face zone ID
83  label zoneID_;
84 
85  //- Face zone flip
86  bool zoneFlip_;
87 
88 
89 public:
90 
91  // Static data members
92 
93  //- Runtime type information
94  TypeName("addFace");
95 
96 
97  // Constructors
98 
99  //- Construct null. Used for constructing lists
100  polyAddFace()
101  :
102  face_(0),
103  owner_(-1),
104  neighbour_(-1),
105  masterPointID_(-1),
106  masterEdgeID_(-1),
107  masterFaceID_(-1),
108  flipFaceFlux_(false),
109  patchID_(-1),
110  zoneID_(-1),
111  zoneFlip_(false)
112  {}
113 
114 
115  //- Construct from components
117  (
118  const face& f,
119  const label owner,
120  const label neighbour,
121  const label masterPointID,
122  const label masterEdgeID,
123  const label masterFaceID,
124  const bool flipFaceFlux,
125  const label patchID,
126  const label zoneID,
127  const bool zoneFlip
128  )
129  :
130  face_(f),
131  owner_(owner),
132  neighbour_(neighbour),
133  masterPointID_(masterPointID),
134  masterEdgeID_(masterEdgeID),
135  masterFaceID_(masterFaceID),
136  flipFaceFlux_(flipFaceFlux),
137  patchID_(patchID),
138  zoneID_(zoneID),
139  zoneFlip_(zoneFlip)
140  {
141  if (face_.size() < 3)
142  {
144  (
145  "polyAddFace\n"
146  "(\n"
147  " const face& f,\n"
148  " const label owner,"
149  " const label neighbour,\n"
150  " const label masterPointID,\n"
151  " const label masterEdgeID,\n"
152  " const label masterFaceID,\n"
153  " const bool flipFaceFlux,\n"
154  " const label patchID,\n"
155  " const label zoneID,\n"
156  " const bool zoneFlip\n"
157  ")"
158  ) << "Invalid face: less than 3 points. "
159  << "This is not allowed.\n"
160  << "Face: " << face_
161  << " masterPointID:" << masterPointID_
162  << " masterEdgeID:" << masterEdgeID_
163  << " masterFaceID:" << masterFaceID_
164  << " patchID:" << patchID_
165  << " owner:" << owner_
166  << " neighbour:" << neighbour_
167  << abort(FatalError);
168  }
169 
170  if (min(face_) < 0)
171  {
173  (
174  "polyAddFace\n"
175  "(\n"
176  " const face& f,\n"
177  " const label owner,"
178  " const label neighbour,\n"
179  " const label masterPointID,\n"
180  " const label masterEdgeID,\n"
181  " const label masterFaceID,\n"
182  " const bool flipFaceFlux,\n"
183  " const label patchID,\n"
184  " const label zoneID,\n"
185  " const bool zoneFlip\n"
186  ")"
187  ) << "Face contains invalid vertex ID: " << face_ << ". "
188  << "This is not allowed.\n"
189  << "Face: " << face_
190  << " masterPointID:" << masterPointID_
191  << " masterEdgeID:" << masterEdgeID_
192  << " masterFaceID:" << masterFaceID_
193  << " patchID:" << patchID_
194  << " owner:" << owner_
195  << " neighbour:" << neighbour_
196  << abort(FatalError);
197  }
198 
199  if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
200  {
202  (
203  "polyAddFace\n"
204  "(\n"
205  " const face& f,\n"
206  " const label owner,"
207  " const label neighbour,\n"
208  " const label masterPointID,\n"
209  " const label masterEdgeID,\n"
210  " const label masterFaceID,\n"
211  " const bool flipFaceFlux,\n"
212  " const label patchID,\n"
213  " const label zoneID,\n"
214  " const bool zoneFlip\n"
215  ")"
216  ) << "Face owner and neighbour are identical. "
217  << "This is not allowed.\n"
218  << "Face: " << face_
219  << " masterPointID:" << masterPointID_
220  << " masterEdgeID:" << masterEdgeID_
221  << " masterFaceID:" << masterFaceID_
222  << " patchID:" << patchID_
223  << " owner:" << owner_
224  << " neighbour:" << neighbour_
225  << abort(FatalError);
226  }
227 
228  if (neighbour_ >= 0 && patchID >= 0)
229  {
231  (
232  "polyAddFace\n"
233  "(\n"
234  " const face& f,\n"
235  " const label owner,"
236  " const label neighbour,\n"
237  " const label masterPointID,\n"
238  " const label masterEdgeID,\n"
239  " const label masterFaceID,\n"
240  " const bool flipFaceFlux,\n"
241  " const label patchID,\n"
242  " const label zoneID,\n"
243  " const bool zoneFlip\n"
244  ")"
245  ) << "Patch face has got a neighbour. Patch ID: " << patchID
246  << ". This is not allowed.\n"
247  << "Face: " << face_
248  << " masterPointID:" << masterPointID_
249  << " masterEdgeID:" << masterEdgeID_
250  << " masterFaceID:" << masterFaceID_
251  << " patchID:" << patchID_
252  << " owner:" << owner_
253  << " neighbour:" << neighbour_
254  << abort(FatalError);
255  }
256 
257  if (owner_ < 0 && zoneID < 0)
258  {
260  (
261  "polyAddFace\n"
262  "(\n"
263  " const face& f,\n"
264  " const label owner,"
265  " const label neighbour,\n"
266  " const label masterPointID,\n"
267  " const label masterEdgeID,\n"
268  " const label masterFaceID,\n"
269  " const bool flipFaceFlux,\n"
270  " const label patchID,\n"
271  " const label zoneID"
272  ")"
273  ) << "Face has no owner and is not in a zone. "
274  << "This is not allowed.\n"
275  << "Face: " << face_
276  << "Face: " << face_
277  << " masterPointID:" << masterPointID_
278  << " masterEdgeID:" << masterEdgeID_
279  << " masterFaceID:" << masterFaceID_
280  << " patchID:" << patchID_
281  << " owner:" << owner_
282  << " neighbour:" << neighbour_
283  << abort(FatalError);
284  }
285 
286  if (zoneID_ == -1 && zoneFlip)
287  {
289  (
290  "polyAddFace\n"
291  "(\n"
292  " const face& f,\n"
293  " const label owner,"
294  " const label neighbour,\n"
295  " const label masterPointID,\n"
296  " const label masterEdgeID,\n"
297  " const label masterFaceID,\n"
298  " const bool flipFaceFlux,\n"
299  " const label patchID,\n"
300  " const label zoneID,\n"
301  " const bool zoneFlip\n"
302  ")"
303  ) << "Specified zone flip for a face that does not "
304  << "belong to zone. This is not allowed.\n"
305  << "Face: " << face_
306  << " masterPointID:" << masterPointID_
307  << " masterEdgeID:" << masterEdgeID_
308  << " masterFaceID:" << masterFaceID_
309  << " patchID:" << patchID_
310  << " owner:" << owner_
311  << " neighbour:" << neighbour_
312  << abort(FatalError);
313  }
314  }
315 
316  //- Construct and return a clone
317  virtual autoPtr<topoAction> clone() const
318  {
319  return autoPtr<topoAction>(new polyAddFace(*this));
320  }
321 
322 
323  // Default Destructor
324 
325  // Member Functions
326 
327  //- Return face
328  const face& newFace() const
329  {
330  return face_;
331  }
332 
333  //- Return owner cell
334  label owner() const
335  {
336  return owner_;
337  }
338 
339  //- Return neighour cell
340  label neighbour() const
341  {
342  return neighbour_;
343  }
344 
345  //- Is the face mastered by a point
346  bool isPointMaster() const
347  {
348  return masterPointID_ >= 0;
349  }
350 
351  //- Is the face mastered by an edge
352  bool isEdgeMaster() const
353  {
354  return masterEdgeID_ >= 0;
355  }
356 
357  //- Is the face mastered by another face
358  bool isFaceMaster() const
359  {
360  return masterFaceID_ >= 0;
361  }
362 
363  //- Is the face appended with no master
364  bool appended() const
365  {
366  return !isPointMaster() && !isEdgeMaster() && !isFaceMaster();
367  }
368 
369  //- Return master point ID
370  label masterPointID() const
371  {
372  return masterPointID_;
373  }
374 
375  //- Return master edge ID
376  label masterEdgeID() const
377  {
378  return masterEdgeID_;
379  }
380 
381  //- Return master face ID
382  label masterFaceID() const
383  {
384  return masterFaceID_;
385  }
386 
387  //- Does the face flux need to be flipped
388  bool flipFaceFlux() const
389  {
390  return flipFaceFlux_;
391  }
392 
393  //- Does the face belong to a boundary patch?
394  bool isInPatch() const
395  {
396  return patchID_ >= 0;
397  }
398 
399  //- Boundary patch ID
400  label patchID() const
401  {
402  return patchID_;
403  }
404 
405  //- Does the face belong to a zone?
406  bool isInZone() const
407  {
408  return zoneID_ >= 0;
409  }
410 
411  //- Is the face only a zone face (i.e. not belonging to a cell)
412  bool onlyInZone() const
413  {
414  return zoneID_ >= 0 && owner_ < 0 && neighbour_ < 0;
415  }
416 
417  //- Face zone ID
418  label zoneID() const
419  {
420  return zoneID_;
421  }
422 
423  //- Face zone flip
424  label zoneFlip() const
425  {
426  return zoneFlip_;
427  }
428 };
429 
430 
431 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
432 
433 } // End namespace Foam
434 
435 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
436 
437 #endif
438 
439 // ************************************************************************* //
TypeName("addFace")
Runtime type information.
bool isFaceMaster() const
Is the face mastered by another face.
Definition: polyAddFace.H:357
bool appended() const
Is the face appended with no master.
Definition: polyAddFace.H:363
A face addition data class. A face can be inflated either from a point or from another face and can e...
Definition: polyAddFace.H:51
A virtual base class for topological actions.
Definition: topoAction.H:48
labelList f(nPoints)
label zoneFlip() const
Face zone flip.
Definition: polyAddFace.H:423
label patchID() const
Boundary patch ID.
Definition: polyAddFace.H:399
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
label masterPointID() const
Return master point ID.
Definition: polyAddFace.H:369
const face & newFace() const
Return face.
Definition: polyAddFace.H:327
Namespace for OpenFOAM.
label owner() const
Return owner cell.
Definition: polyAddFace.H:333
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
bool isPointMaster() const
Is the face mastered by a point.
Definition: polyAddFace.H:345
label masterEdgeID() const
Return master edge ID.
Definition: polyAddFace.H:375
label neighbour() const
Return neighour cell.
Definition: polyAddFace.H:339
bool isInPatch() const
Does the face belong to a boundary patch?
Definition: polyAddFace.H:393
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
bool flipFaceFlux() const
Does the face flux need to be flipped.
Definition: polyAddFace.H:387
bool onlyInZone() const
Is the face only a zone face (i.e. not belonging to a cell)
Definition: polyAddFace.H:411
bool isEdgeMaster() const
Is the face mastered by an edge.
Definition: polyAddFace.H:351
error FatalError
polyAddFace()
Construct null. Used for constructing lists.
Definition: polyAddFace.H:99
label zoneID() const
Face zone ID.
Definition: polyAddFace.H:417
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
bool isInZone() const
Does the face belong to a zone?
Definition: polyAddFace.H:405
label masterFaceID() const
Return master face ID.
Definition: polyAddFace.H:381
virtual autoPtr< topoAction > clone() const
Construct and return a clone.
Definition: polyAddFace.H:316
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117