initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / modifyObject / polyModifyFace.H
blob53e8990a7d2051402bb43aa31fa74ba5fde27c2f
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::polyModifyFace
28 Description
29     Class describing modification of a face.
32 \*---------------------------------------------------------------------------*/
34 #ifndef polyModifyFace_H
35 #define polyModifyFace_H
37 #include "label.H"
38 #include "face.H"
39 #include "topoAction.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                            Class polyModifyFace Declaration
48 \*---------------------------------------------------------------------------*/
50 class polyModifyFace
52     public topoAction
54     // Private data
56         //- Face 
57         face face_;
59         //- Master face ID
60         label faceID_;
62         //- Face owner
63         label owner_;
65         //- Face neighbour
66         label neighbour_;
68         //- Does the face flux need to be flipped
69         bool flipFaceFlux_;
71         //- Boundary patch ID
72         label patchID_;
74         //- Remove from current zone
75         bool removeFromZone_;
77         //- Face zone ID
78         label zoneID_;
80         //- Face zone flip
81         bool zoneFlip_;
84 public:
86     // Static data members
88         //- Runtime type information
89         TypeName("modifyFace");
92     // Constructors
94         //- Construct null.  Used in constructing lists
95         polyModifyFace()
96         :
97             face_(0),
98             faceID_(-1),
99             owner_(-1),
100             neighbour_(-1),
101             flipFaceFlux_(false),
102             patchID_(-1),
103             removeFromZone_(false),
104             zoneID_(-1),
105             zoneFlip_(false)
106         {}
108         //- Construct from components
109         polyModifyFace
110         (
111             const face& f,
112             const label faceID,
113             const label owner,
114             const label neighbour,
115             const bool flipFaceFlux,
116             const label patchID,
117             const bool removeFromZone,
118             const label zoneID,
119             const bool zoneFlip
120         )
121         :
122             face_(f),
123             faceID_(faceID),
124             owner_(owner),
125             neighbour_(neighbour),
126             flipFaceFlux_(flipFaceFlux),
127             patchID_(patchID),
128             removeFromZone_(removeFromZone),
129             zoneID_(zoneID),
130             zoneFlip_(zoneFlip)
131         {
132             if (face_.size() < 3)
133             {
134                 FatalErrorIn
135                 (
136                     "polyModifyFace::polyModifyFace\n"
137                     "(\n"
138                     "    const face& f,\n"
139                     "    const label faceID,\n"
140                     "    const label owner,\n"
141                     "    const label neighbour,\n"
142                     "    const bool flipFaceFlux,\n"
143                     "    const label patchID,\n"
144                     "    const bool removeFromZone,\n"
145                     "    const label zoneID,\n"
146                     "    const bool zoneFlip\n"
147                     ")"
148                 )   << "Invalid face: less than 3 points. This is not allowed\n"
149                     << "Face: " << face_
150                     << " faceID:" << faceID_
151                     << " owner:" << owner_
152                     << " neighbour:" << neighbour_
153                     << abort(FatalError);
154             }
156             if (min(face_) < 0)
157             {
158                 FatalErrorIn
159                 (
160                     "polyModifyFace::polyModifyFace\n"
161                     "(\n"
162                     "    const face& f,\n"
163                     "    const label faceID,\n"
164                     "    const label owner,\n"
165                     "    const label neighbour,\n"
166                     "    const bool flipFaceFlux,\n"
167                     "    const label patchID,\n"
168                     "    const bool removeFromZone,\n"
169                     "    const label zoneID,\n"
170                     "    const bool zoneFlip\n"
171                     ")"
172                 )   << "Face contains invalid vertex ID: " << face_ << ".  "
173                     << "This is not allowed.\n"
174                     << " faceID:" << faceID_
175                     << " owner:" << owner_
176                     << " neighbour:" << neighbour_
177                     << abort(FatalError);
178             }
180             if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_)
181             {
182                 FatalErrorIn
183                 (
184                     "polyModifyFace::polyModifyFace\n"
185                     "(\n"
186                     "    const face& f,\n"
187                     "    const label faceID,\n"
188                     "    const label owner,\n"
189                     "    const label neighbour,\n"
190                     "    const bool flipFaceFlux,\n"
191                     "    const label patchID,\n"
192                     "    const bool removeFromZone,\n"
193                     "    const label zoneID,\n"
194                     "    const bool zoneFlip\n"
195                     ")"
196                 )   << "Face owner and neighbour are identical.  "
197                     << "This is not allowed.\n"
198                     << "Face: " << face_
199                     << " faceID:" << faceID_
200                     << " owner:" << owner_
201                     << " neighbour:" << neighbour_
202                     << abort(FatalError);
203             }
205             if (neighbour_ >= 0 && patchID_ >= 0)
206             {
207                 FatalErrorIn
208                 (
209                     "polyModifyFace::polyModifyFace\n"
210                     "(\n"
211                     "    const face& f,\n"
212                     "    const label faceID,\n"
213                     "    const label owner,\n"
214                     "    const label neighbour,\n"
215                     "    const bool flipFaceFlux,\n"
216                     "    const label patchID,\n"
217                     "    const bool removeFromZone,\n"
218                     "    const label zoneID,\n"
219                     "    const bool zoneFlip\n"
220                     ")"
221                 )   << "Patch face has got a neighbour  "
222                     << "This is not allowed.\n"
223                     << "Face: " << face_
224                     << " faceID:" << faceID_
225                     << " owner:" << owner_
226                     << " neighbour:" << neighbour_
227                     << " patchID:" << patchID_
228                     << abort(FatalError);
229             }
231             if (zoneID_ < 0 && zoneFlip )
232             {
233                 FatalErrorIn
234                 (
235                     "polyModifyFace::polyModifyFace\n"
236                     "(\n"
237                     "    const face& f,\n"
238                     "    const label faceID,\n"
239                     "    const label owner,\n"
240                     "    const label neighbour,\n"
241                     "    const bool flipFaceFlux,\n"
242                     "    const label patchID,\n"
243                     "    const bool removeFromZone,\n"
244                     "    const label zoneID,\n"
245                     "    const bool zoneFlip\n"
246                     ")"
247                 )   << "Specified zone flip for a face that does not  "
248                     << "belong to zone.  This is not allowed.\n"
249                     << "Face: " << face_
250                     << " faceID:" << faceID_
251                     << " owner:" << owner_
252                     << " neighbour:" << neighbour_
253                     << abort(FatalError);
254             }
255         }
257         //- Construct and return a clone
258         virtual autoPtr<topoAction> clone() const
259         {
260             return autoPtr<topoAction>(new polyModifyFace(*this));
261         }
264     // Default Destructor
266     // Member Functions
268         //- Return face
269         const face& newFace() const
270         {
271             return face_;
272         }
274         //- Return master face ID
275         label faceID() const
276         {
277             return faceID_;
278         }
280         //- Return owner cell ID
281         label owner() const
282         {
283             return owner_;
284         }
286         //- Return owner cell ID
287         label neighbour() const
288         {
289             return neighbour_;
290         }
292         //- Does the face flux need to be flipped
293         bool flipFaceFlux() const
294         {
295             return flipFaceFlux_;
296         }
298         //- Does the face belong to a boundary patch?
299         bool isInPatch() const
300         {
301             return patchID_ >= 0;
302         }
304         //- Boundary patch ID
305         label patchID() const
306         {
307             return patchID_;
308         }
310         //- Does the face belong to a zone?
311         bool isInZone() const
312         {
313             return zoneID_ >= 0;
314         }
316         //- Is the face only a zone face (i.e. not belonging to a cell)
317         bool onlyInZone() const
318         {
319             return zoneID_ >= 0 && owner_ < 0 && neighbour_ < 0;
320         }
322         bool removeFromZone() const
323         {
324             return removeFromZone_;
325         }
327         //- Face zone ID
328         label zoneID() const
329         {
330             return zoneID_;
331         }
333         //- Face zone flip
334         label zoneFlip() const
335         {
336             return zoneFlip_;
337         }
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 } // End namespace Foam
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347 #endif
349 // ************************************************************************* //