initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / addObject / polyAddFace.H
blob944e645fe01176da8c79ce3f430813aef9a73144
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::polyAddFace
28 Description
29     A face addition data class. A face can be inflated either from a
30     point or from another face and can either be in internal or a
31     boundary face.
33 \*---------------------------------------------------------------------------*/
35 #ifndef polyAddFace_H
36 #define polyAddFace_H
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 #include "label.H"
41 #include "face.H"
42 #include "topoAction.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                            Class polyAddFace Declaration
51 \*---------------------------------------------------------------------------*/
53 class polyAddFace
55     public topoAction
57     // Private data
59         //- Face identifier
60         face face_;
62         //- Face owner
63         label owner_;
65         //- Face neighbour
66         label neighbour_;
68         //- Master point ID for faces blown up from points
69         label masterPointID_;
71         //- Master edge ID for faces blown up from edges
72         label masterEdgeID_;
74         //- Master face ID for faces blown up from faces
75         label masterFaceID_;
77         //- Does the face flux need to be flipped
78         bool flipFaceFlux_;
80         //- Boundary patch ID
81         label patchID_;
83         //- Face zone ID
84         label zoneID_;
86         //- Face zone flip
87         bool zoneFlip_;
90 public:
92     // Static data members
94         //- Runtime type information
95         TypeName("addFace");
98     // Constructors
100         //- Construct null.  Used for constructing lists
101         polyAddFace()
102         :
103             face_(0),
104             owner_(-1),
105             neighbour_(-1),
106             masterPointID_(-1),
107             masterEdgeID_(-1),
108             masterFaceID_(-1),
109             flipFaceFlux_(false),
110             patchID_(-1),
111             zoneID_(-1),
112             zoneFlip_(false)
113         {}
116         //- Construct from components
117         polyAddFace
118         (
119             const face& f,
120             const label owner,
121             const label neighbour,
122             const label masterPointID,
123             const label masterEdgeID,
124             const label masterFaceID,
125             const bool flipFaceFlux,
126             const label patchID,
127             const label zoneID,
128             const bool zoneFlip
129         )
130         :
131             face_(f),
132             owner_(owner),
133             neighbour_(neighbour),
134             masterPointID_(masterPointID),
135             masterEdgeID_(masterEdgeID),
136             masterFaceID_(masterFaceID),
137             flipFaceFlux_(flipFaceFlux),
138             patchID_(patchID),
139             zoneID_(zoneID),
140             zoneFlip_(zoneFlip)
141         {
142             if (face_.size() < 3)
143             {
144                 FatalErrorIn
145                 (
146                     "polyAddFace\n"
147                     "(\n"
148                     "    const face& f,\n"
149                     "    const label owner,"
150                     "    const label neighbour,\n"
151                     "    const label masterPointID,\n"
152                     "    const label masterEdgeID,\n"
153                     "    const label masterFaceID,\n"
154                     "    const bool flipFaceFlux,\n"
155                     "    const label patchID,\n"
156                     "    const label zoneID,\n"
157                     "    const bool zoneFlip\n"
158                     ")"
159                 )   << "Invalid face: less than 3 points.  "
160                     << "This is not allowed.\n"
161                     << "Face: " << face_
162                     << " masterPointID:" << masterPointID_
163                     << " masterEdgeID:" << masterEdgeID_
164                     << " masterFaceID:" << masterFaceID_
165                     << " patchID:" << patchID_
166                     << " owner:" << owner_
167                     << " neighbour:" << neighbour_
168                     << abort(FatalError);
169             }
171             if (min(face_) < 0)
172             {
173                 FatalErrorIn
174                 (
175                     "polyAddFace\n"
176                     "(\n"
177                     "    const face& f,\n"
178                     "    const label owner,"
179                     "    const label neighbour,\n"
180                     "    const label masterPointID,\n"
181                     "    const label masterEdgeID,\n"
182                     "    const label masterFaceID,\n"
183                     "    const bool flipFaceFlux,\n"
184                     "    const label patchID,\n"
185                     "    const label zoneID,\n"
186                     "    const bool zoneFlip\n"
187                     ")"
188                 )   << "Face contains invalid vertex ID: " << face_ << ".  "
189                     << "This is not allowed.\n"
190                     << "Face: " << face_
191                     << " masterPointID:" << masterPointID_
192                     << " masterEdgeID:" << masterEdgeID_
193                     << " masterFaceID:" << masterFaceID_
194                     << " patchID:" << patchID_
195                     << " owner:" << owner_
196                     << " neighbour:" << neighbour_
197                     << abort(FatalError);
198             }
200             if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
201             {
202                 FatalErrorIn
203                 (
204                     "polyAddFace\n"
205                     "(\n"
206                     "    const face& f,\n"
207                     "    const label owner,"
208                     "    const label neighbour,\n"
209                     "    const label masterPointID,\n"
210                     "    const label masterEdgeID,\n"
211                     "    const label masterFaceID,\n"
212                     "    const bool flipFaceFlux,\n"
213                     "    const label patchID,\n"
214                     "    const label zoneID,\n"
215                     "    const bool zoneFlip\n"
216                     ")"
217                 )   << "Face owner and neighbour are identical.  "
218                     << "This is not allowed.\n"
219                     << "Face: " << face_
220                     << " masterPointID:" << masterPointID_
221                     << " masterEdgeID:" << masterEdgeID_
222                     << " masterFaceID:" << masterFaceID_
223                     << " patchID:" << patchID_
224                     << " owner:" << owner_
225                     << " neighbour:" << neighbour_
226                     << abort(FatalError);
227             }
229             if (neighbour_ >= 0 && patchID >= 0)
230             {
231                 FatalErrorIn
232                 (
233                     "polyAddFace\n"
234                     "(\n"
235                     "    const face& f,\n"
236                     "    const label owner,"
237                     "    const label neighbour,\n"
238                     "    const label masterPointID,\n"
239                     "    const label masterEdgeID,\n"
240                     "    const label masterFaceID,\n"
241                     "    const bool flipFaceFlux,\n"
242                     "    const label patchID,\n"
243                     "    const label zoneID,\n"
244                     "    const bool zoneFlip\n"
245                     ")"
246                 )   << "Patch face has got a neighbour.  Patch ID: " << patchID
247                     << ".  This is not allowed.\n"
248                     << "Face: " << face_
249                     << " masterPointID:" << masterPointID_
250                     << " masterEdgeID:" << masterEdgeID_
251                     << " masterFaceID:" << masterFaceID_
252                     << " patchID:" << patchID_
253                     << " owner:" << owner_
254                     << " neighbour:" << neighbour_
255                     << abort(FatalError);
256             }
258             if (owner_ < 0 && zoneID < 0)
259             {
260                 FatalErrorIn
261                 (
262                     "polyAddFace\n"
263                     "(\n"
264                     "    const face& f,\n"
265                     "    const label owner,"
266                     "    const label neighbour,\n"
267                     "    const label patchID,\n"
268                     "    const label zoneID"
269                     ")"
270                 )   << "Face has no owner and is not in a zone.  "
271                     << "This is not allowed.\n"
272                     << "Face: " << face_
273                     << "Face: " << face_
274                     << " masterPointID:" << masterPointID_
275                     << " masterEdgeID:" << masterEdgeID_
276                     << " masterFaceID:" << masterFaceID_
277                     << " patchID:" << patchID_
278                     << " owner:" << owner_
279                     << " neighbour:" << neighbour_
280                     << abort(FatalError);
281             }
283             if (zoneID_ == -1 && zoneFlip)
284             {
285                 FatalErrorIn
286                 (
287                     "polyAddFace\n"
288                     "(\n"
289                     "    const face& f,\n"
290                     "    const label owner,"
291                     "    const label neighbour,\n"
292                     "    const label masterPointID,\n"
293                     "    const label masterEdgeID,\n"
294                     "    const label masterFaceID,\n"
295                     "    const label patchID,\n"
296                     "    const label zoneID,\n"
297                     "    const bool zoneFlip\n"
298                     ")"
299                 )   << "Specified zone flip for a face that does not  "
300                     << "belong to zone.  This is not allowed.\n"
301                     << "Face: " << face_
302                     << " masterPointID:" << masterPointID_
303                     << " masterEdgeID:" << masterEdgeID_
304                     << " masterFaceID:" << masterFaceID_
305                     << " patchID:" << patchID_
306                     << " owner:" << owner_
307                     << " neighbour:" << neighbour_
308                     << abort(FatalError);
309             }
310         }
312         //- Construct and return a clone
313         virtual autoPtr<topoAction> clone() const
314         {
315             return autoPtr<topoAction>(new polyAddFace(*this));
316         }
319     // Default Destructor
321     // Member Functions
323         //- Return face
324         const face& newFace() const
325         {
326             return face_;
327         }
329         //- Return owner cell
330         label owner() const
331         {
332             return owner_;
333         }
335         //- Return neighour cell
336         label neighbour() const
337         {
338             return neighbour_;
339         }
341         //- Is the face mastered by a point
342         bool isPointMaster() const
343         {
344             return masterPointID_ >= 0;
345         }
347         //- Is the face mastered by an edge
348         bool isEdgeMaster() const
349         {
350             return masterEdgeID_ >= 0;
351         }
353         //- Is the face mastered by another face
354         bool isFaceMaster() const
355         {
356             return masterFaceID_ >= 0;
357         }
359         //- Is the face appended with no master
360         bool appended() const
361         {
362             return !isPointMaster() && !isEdgeMaster() && !isFaceMaster();
363         }
365         //- Return master point ID
366         label masterPointID() const
367         {
368             return masterPointID_;
369         }
371         //- Return master edge ID
372         label masterEdgeID() const
373         {
374             return masterEdgeID_;
375         }
377         //- Return master face ID
378         label masterFaceID() const
379         {
380             return masterFaceID_;
381         }
383         //- Does the face flux need to be flipped
384         bool flipFaceFlux() const
385         {
386             return flipFaceFlux_;
387         }
389         //- Does the face belong to a boundary patch?
390         bool isInPatch() const
391         {
392             return patchID_ >= 0;
393         }
395         //- Boundary patch ID
396         label patchID() const
397         {
398             return patchID_;
399         }
401         //- Does the face belong to a zone?
402         bool isInZone() const
403         {
404             return zoneID_ >= 0;
405         }
407         //- Is the face only a zone face (i.e. not belonging to a cell)
408         bool onlyInZone() const
409         {
410             return zoneID_ >= 0 && owner_ < 0 && neighbour_ < 0;
411         }
413         //- Face zone ID
414         label zoneID() const
415         {
416             return zoneID_;
417         }
419         //- Face zone flip
420         label zoneFlip() const
421         {
422             return zoneFlip_;
423         }
427 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
429 } // End namespace Foam
431 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
433 #endif
435 // ************************************************************************* //