FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/label.H>
40 #include <OpenFOAM/face.H>
41 #include <dynamicMesh/topoAction.H>
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class polyAddFace Declaration
50 \*---------------------------------------------------------------------------*/
51 
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
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 patchID,\n"
267  " const label zoneID"
268  ")"
269  ) << "Face has no owner and is not in a zone. "
270  << "This is not allowed.\n"
271  << "Face: " << face_
272  << "Face: " << face_
273  << " masterPointID:" << masterPointID_
274  << " masterEdgeID:" << masterEdgeID_
275  << " masterFaceID:" << masterFaceID_
276  << " patchID:" << patchID_
277  << " owner:" << owner_
278  << " neighbour:" << neighbour_
279  << abort(FatalError);
280  }
281 
282  if (zoneID_ == -1 && zoneFlip)
283  {
285  (
286  "polyAddFace\n"
287  "(\n"
288  " const face& f,\n"
289  " const label owner,"
290  " const label neighbour,\n"
291  " const label masterPointID,\n"
292  " const label masterEdgeID,\n"
293  " const label masterFaceID,\n"
294  " const label patchID,\n"
295  " const label zoneID,\n"
296  " const bool zoneFlip\n"
297  ")"
298  ) << "Specified zone flip for a face that does not "
299  << "belong to zone. This is not allowed.\n"
300  << "Face: " << face_
301  << " masterPointID:" << masterPointID_
302  << " masterEdgeID:" << masterEdgeID_
303  << " masterFaceID:" << masterFaceID_
304  << " patchID:" << patchID_
305  << " owner:" << owner_
306  << " neighbour:" << neighbour_
307  << abort(FatalError);
308  }
309  }
310 
311  //- Construct and return a clone
312  virtual autoPtr<topoAction> clone() const
313  {
314  return autoPtr<topoAction>(new polyAddFace(*this));
315  }
316 
317 
318  // Default Destructor
319 
320  // Member Functions
321 
322  //- Return face
323  const face& newFace() const
324  {
325  return face_;
326  }
327 
328  //- Return owner cell
329  label owner() const
330  {
331  return owner_;
332  }
333 
334  //- Return neighour cell
335  label neighbour() const
336  {
337  return neighbour_;
338  }
339 
340  //- Is the face mastered by a point
341  bool isPointMaster() const
342  {
343  return masterPointID_ >= 0;
344  }
345 
346  //- Is the face mastered by an edge
347  bool isEdgeMaster() const
348  {
349  return masterEdgeID_ >= 0;
350  }
351 
352  //- Is the face mastered by another face
353  bool isFaceMaster() const
354  {
355  return masterFaceID_ >= 0;
356  }
357 
358  //- Is the face appended with no master
359  bool appended() const
360  {
361  return !isPointMaster() && !isEdgeMaster() && !isFaceMaster();
362  }
363 
364  //- Return master point ID
365  label masterPointID() const
366  {
367  return masterPointID_;
368  }
369 
370  //- Return master edge ID
371  label masterEdgeID() const
372  {
373  return masterEdgeID_;
374  }
375 
376  //- Return master face ID
377  label masterFaceID() const
378  {
379  return masterFaceID_;
380  }
381 
382  //- Does the face flux need to be flipped
383  bool flipFaceFlux() const
384  {
385  return flipFaceFlux_;
386  }
387 
388  //- Does the face belong to a boundary patch?
389  bool isInPatch() const
390  {
391  return patchID_ >= 0;
392  }
393 
394  //- Boundary patch ID
395  label patchID() const
396  {
397  return patchID_;
398  }
399 
400  //- Does the face belong to a zone?
401  bool isInZone() const
402  {
403  return zoneID_ >= 0;
404  }
405 
406  //- Is the face only a zone face (i.e. not belonging to a cell)
407  bool onlyInZone() const
408  {
409  return zoneID_ >= 0 && owner_ < 0 && neighbour_ < 0;
410  }
411 
412  //- Face zone ID
413  label zoneID() const
414  {
415  return zoneID_;
416  }
417 
418  //- Face zone flip
419  label zoneFlip() const
420  {
421  return zoneFlip_;
422  }
423 };
424 
425 
426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
427 
428 } // End namespace Foam
429 
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
431 
432 #endif
433 
434 // ************************ vim: set sw=4 sts=4 et: ************************ //