polyModifyFace.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::polyModifyFace
26 
27 Description
28  Class describing modification of a face.
29 
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef polyModifyFace_H
34 #define polyModifyFace_H
35 
36 #include "label.H"
37 #include "face.H"
38 #include "topoAction.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class polyModifyFace Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class polyModifyFace
50 :
51  public topoAction
52 {
53  // Private data
54 
55  //- Face
56  face face_;
57 
58  //- Master face ID
59  label faceID_;
60 
61  //- Face owner
62  label owner_;
63 
64  //- Face neighbour
65  label neighbour_;
66 
67  //- Does the face flux need to be flipped
68  bool flipFaceFlux_;
69 
70  //- Boundary patch ID
71  label patchID_;
72 
73  //- Remove from current zone
74  bool removeFromZone_;
75 
76  //- Face zone ID
77  label zoneID_;
78 
79  //- Face zone flip
80  bool zoneFlip_;
81 
82 
83 public:
84 
85  // Static data members
86 
87  //- Runtime type information
88  TypeName("modifyFace");
89 
90 
91  // Constructors
92 
93  //- Construct null. Used in constructing lists
95  :
96  face_(0),
97  faceID_(-1),
98  owner_(-1),
99  neighbour_(-1),
100  flipFaceFlux_(false),
101  patchID_(-1),
102  removeFromZone_(false),
103  zoneID_(-1),
104  zoneFlip_(false)
105  {}
106 
107  //- Construct from components
109  (
110  const face& f,
111  const label faceID,
112  const label owner,
113  const label neighbour,
114  const bool flipFaceFlux,
115  const label patchID,
116  const bool removeFromZone,
117  const label zoneID,
118  const bool zoneFlip
119  )
120  :
121  face_(f),
122  faceID_(faceID),
123  owner_(owner),
124  neighbour_(neighbour),
125  flipFaceFlux_(flipFaceFlux),
126  patchID_(patchID),
127  removeFromZone_(removeFromZone),
128  zoneID_(zoneID),
129  zoneFlip_(zoneFlip)
130  {
131  if (face_.size() < 3)
132  {
134  (
135  "polyModifyFace::polyModifyFace\n"
136  "(\n"
137  " const face& f,\n"
138  " const label faceID,\n"
139  " const label owner,\n"
140  " const label neighbour,\n"
141  " const bool flipFaceFlux,\n"
142  " const label patchID,\n"
143  " const bool removeFromZone,\n"
144  " const label zoneID,\n"
145  " const bool zoneFlip\n"
146  ")"
147  ) << "Invalid face: less than 3 points. This is not allowed\n"
148  << "Face: " << face_
149  << " faceID:" << faceID_
150  << " owner:" << owner_
151  << " neighbour:" << neighbour_
152  << abort(FatalError);
153  }
154 
155  if (min(face_) < 0)
156  {
158  (
159  "polyModifyFace::polyModifyFace\n"
160  "(\n"
161  " const face& f,\n"
162  " const label faceID,\n"
163  " const label owner,\n"
164  " const label neighbour,\n"
165  " const bool flipFaceFlux,\n"
166  " const label patchID,\n"
167  " const bool removeFromZone,\n"
168  " const label zoneID,\n"
169  " const bool zoneFlip\n"
170  ")"
171  ) << "Face contains invalid vertex ID: " << face_ << ". "
172  << "This is not allowed.\n"
173  << " faceID:" << faceID_
174  << " owner:" << owner_
175  << " neighbour:" << neighbour_
176  << abort(FatalError);
177  }
178 
179  if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
180  {
182  (
183  "polyModifyFace::polyModifyFace\n"
184  "(\n"
185  " const face& f,\n"
186  " const label faceID,\n"
187  " const label owner,\n"
188  " const label neighbour,\n"
189  " const bool flipFaceFlux,\n"
190  " const label patchID,\n"
191  " const bool removeFromZone,\n"
192  " const label zoneID,\n"
193  " const bool zoneFlip\n"
194  ")"
195  ) << "Face owner and neighbour are identical. "
196  << "This is not allowed.\n"
197  << "Face: " << face_
198  << " faceID:" << faceID_
199  << " owner:" << owner_
200  << " neighbour:" << neighbour_
201  << abort(FatalError);
202  }
203 
204  if (neighbour_ >= 0 && patchID_ >= 0)
205  {
207  (
208  "polyModifyFace::polyModifyFace\n"
209  "(\n"
210  " const face& f,\n"
211  " const label faceID,\n"
212  " const label owner,\n"
213  " const label neighbour,\n"
214  " const bool flipFaceFlux,\n"
215  " const label patchID,\n"
216  " const bool removeFromZone,\n"
217  " const label zoneID,\n"
218  " const bool zoneFlip\n"
219  ")"
220  ) << "Patch face has got a neighbour "
221  << "This is not allowed.\n"
222  << "Face: " << face_
223  << " faceID:" << faceID_
224  << " owner:" << owner_
225  << " neighbour:" << neighbour_
226  << " patchID:" << patchID_
227  << abort(FatalError);
228  }
229 
230  if (zoneID_ < 0 && zoneFlip )
231  {
233  (
234  "polyModifyFace::polyModifyFace\n"
235  "(\n"
236  " const face& f,\n"
237  " const label faceID,\n"
238  " const label owner,\n"
239  " const label neighbour,\n"
240  " const bool flipFaceFlux,\n"
241  " const label patchID,\n"
242  " const bool removeFromZone,\n"
243  " const label zoneID,\n"
244  " const bool zoneFlip\n"
245  ")"
246  ) << "Specified zone flip for a face that does not "
247  << "belong to zone. This is not allowed.\n"
248  << "Face: " << face_
249  << " faceID:" << faceID_
250  << " owner:" << owner_
251  << " neighbour:" << neighbour_
252  << abort(FatalError);
253  }
254  }
255 
256  //- Construct and return a clone
257  virtual autoPtr<topoAction> clone() const
258  {
259  return autoPtr<topoAction>(new polyModifyFace(*this));
260  }
261 
262 
263  // Default Destructor
264 
265  // Member Functions
266 
267  //- Return face
268  const face& newFace() const
269  {
270  return face_;
271  }
272 
273  //- Return master face ID
274  label faceID() const
275  {
276  return faceID_;
277  }
278 
279  //- Return owner cell ID
280  label owner() const
281  {
282  return owner_;
283  }
284 
285  //- Return owner cell ID
286  label neighbour() const
287  {
288  return neighbour_;
289  }
290 
291  //- Does the face flux need to be flipped
292  bool flipFaceFlux() const
293  {
294  return flipFaceFlux_;
295  }
296 
297  //- Does the face belong to a boundary patch?
298  bool isInPatch() const
299  {
300  return patchID_ >= 0;
301  }
302 
303  //- Boundary patch ID
304  label patchID() const
305  {
306  return patchID_;
307  }
308 
309  //- Does the face belong to a zone?
310  bool isInZone() const
311  {
312  return zoneID_ >= 0;
313  }
314 
315  //- Is the face only a zone face (i.e. not belonging to a cell)
316  bool onlyInZone() const
317  {
318  return zoneID_ >= 0 && owner_ < 0 && neighbour_ < 0;
319  }
321  bool removeFromZone() const
322  {
323  return removeFromZone_;
324  }
325 
326  //- Face zone ID
327  label zoneID() const
328  {
329  return zoneID_;
330  }
331 
332  //- Face zone flip
333  label zoneFlip() const
334  {
335  return zoneFlip_;
336  }
337 };
338 
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 } // End namespace Foam
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 #endif
347 
348 // ************************************************************************* //
bool flipFaceFlux() const
Does the face flux need to be flipped.
A virtual base class for topological actions.
Definition: topoAction.H:48
labelList f(nPoints)
label zoneFlip() const
Face zone flip.
label patchID() const
Boundary patch ID.
virtual autoPtr< topoAction > clone() const
Construct and return a clone.
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
const face & newFace() const
Return face.
Namespace for OpenFOAM.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
label faceID() const
Return master face ID.
label owner() const
Return owner cell ID.
Class describing modification of a face.
polyModifyFace()
Construct null. Used in constructing lists.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
bool isInZone() const
Does the face belong to a zone?
label neighbour() const
Return owner cell ID.
bool onlyInZone() const
Is the face only a zone face (i.e. not belonging to a cell)
bool removeFromZone() const
error FatalError
label zoneID() const
Face zone ID.
bool isInPatch() const
Does the face belong to a boundary patch?
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
TypeName("modifyFace")
Runtime type information.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117