Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / meshes / partTetMesh / partTetMeshSimplex.C
blob5987653acf42fea6e55fad834c709fdbe5cdac4e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9     This file is part of cfMesh.
11     cfMesh 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 3 of the License, or (at your
14     option) any later version.
16     cfMesh 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 cfMesh.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "Map.H"
29 #include "partTetMeshSimplex.H"
31 //#define DEBUGSmooth
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 partTetMeshSimplex::partTetMeshSimplex
42     const partTetMesh& tm,
43     const label pI
46     pts_(),
47     tets_()
49     const LongList<point>& points = tm.points();
50     const LongList<partTet>& tets = tm.tets();
51     const VRWGraph& pt = tm.pointTets();
53     tets_.setSize(pt.sizeOfRow(pI));
54     label counter(0);
56     Map<label> addr(2*pt.sizeOfRow(pI));
57     forAllRow(pt, pI, tetI)
58     {
59         const partTet& tet = tets[pt(pI, tetI)];
60         for(label i=0;i<4;++i)
61         {
62             const label tpI = tet[i];
63             if( !addr.found(tpI) )
64             {
65                 addr.insert(tpI, counter);
66                 pts_.append(points[tpI]);
67                 ++counter;
68             }
69         }
71         # ifdef DEBUGSmooth
72         Info << "Tet " << tetI << " is " << tet << endl;
73         # endif
75         const label pos = tet.whichPosition(pI);
76         switch( pos )
77         {
78             case 0:
79             {
80                 tets_[tetI] =
81                     partTet
82                     (
83                         addr[tet.b()],
84                         addr[tet.d()],
85                         addr[tet.c()],
86                         addr[tet.a()]
87                     );
88             } break;
89             case 1:
90             {
91                 tets_[tetI] =
92                     partTet
93                     (
94                         addr[tet.a()],
95                         addr[tet.c()],
96                         addr[tet.d()],
97                         addr[tet.b()]
98                     );
99             } break;
100             case 2:
101             {
102                 tets_[tetI] =
103                     partTet
104                     (
105                         addr[tet.a()],
106                         addr[tet.d()],
107                         addr[tet.b()],
108                         addr[tet.c()]
109                     );
110             } break;
111             case 3:
112             {
113                 tets_[tetI] =
114                     partTet
115                     (
116                         addr[tet.a()],
117                         addr[tet.b()],
118                         addr[tet.c()],
119                         addr[tet.d()]
120                     );
121             } break;
122             default:
123             {
124                 FatalErrorIn
125                 (
126                     "partTetMeshSimplex::partTetMeshSimplex("
127                     "(const partTetMesh& tm, const label pI)"
128                 ) << "Point " << pI << " is not present in tet" << tet
129                     << abort(FatalError);
130             }
131         }
132     }
135 partTetMeshSimplex::partTetMeshSimplex
137     const DynList<parPartTet>& pt,
138     const label gpI
141     pts_(),
142     tets_()
144     tets_.setSize(pt.size());
145     label pI(0);
147     Map<label> addr;
148     forAll(pt, tetI)
149     {
150         const parPartTet& tet = pt[tetI];
152         label pos(-1);
153         for(label i=0;i<4;++i)
154         {
155             if( !addr.found(tet[i].pointLabel()) )
156             {
157                 addr.insert(tet[i].pointLabel(), pI);
158                 pts_.append(tet[i].coordinates());
159                 ++pI;
160             }
162             if( tet[i].pointLabel() == gpI )
163                 pos = i;
164         }
166         switch( pos )
167         {
168             case 0:
169             {
170                 tets_[tetI] =
171                     partTet
172                     (
173                         addr[tet[1].pointLabel()],
174                         addr[tet[3].pointLabel()],
175                         addr[tet[2].pointLabel()],
176                         addr[tet[0].pointLabel()]
177                     );
178             } break;
179             case 1:
180             {
181                 tets_[tetI] =
182                     partTet
183                     (
184                         addr[tet[0].pointLabel()],
185                         addr[tet[2].pointLabel()],
186                         addr[tet[3].pointLabel()],
187                         addr[tet[1].pointLabel()]
188                     );
189             } break;
190             case 2:
191             {
192                 tets_[tetI] =
193                     partTet
194                     (
195                         addr[tet[0].pointLabel()],
196                         addr[tet[3].pointLabel()],
197                         addr[tet[1].pointLabel()],
198                         addr[tet[2].pointLabel()]
199                     );
200             } break;
201             case 3:
202             {
203                 tets_[tetI] =
204                     partTet
205                     (
206                         addr[tet[0].pointLabel()],
207                         addr[tet[1].pointLabel()],
208                         addr[tet[2].pointLabel()],
209                         addr[tet[3].pointLabel()]
210                     );
211             } break;
212             default:
213             {
214                 FatalErrorIn
215                 (
216                     "partTetMeshSimplex::partTetMeshSimplex("
217                     "(const partTetMesh& tm, const label pI)"
218                 ) << "Point " << gpI << " is not present in tet" << tet
219                     << abort(FatalError);
220             }
221         }
222     }
225 partTetMeshSimplex::partTetMeshSimplex
227     const DynList<point, 128>& pts,
228     const DynList<partTet, 128>& tets,
229     const label pointI
232     pts_(pts),
233     tets_(tets.size())
235     forAll(tets, tetI)
236     {
237         const partTet& tet = tets[tetI];
239         const label pos = tet.whichPosition(pointI);
241         switch( pos )
242         {
243             case 0:
244             {
245                 tets_[tetI] =
246                     partTet
247                     (
248                         tet.b(),
249                         tet.d(),
250                         tet.c(),
251                         tet.a()
252                     );
253             } break;
254             case 1:
255             {
256                 tets_[tetI] =
257                     partTet
258                     (
259                         tet.a(),
260                         tet.c(),
261                         tet.d(),
262                         tet.b()
263                     );
264             } break;
265             case 2:
266             {
267                 tets_[tetI] =
268                     partTet
269                     (
270                         tet.a(),
271                         tet.d(),
272                         tet.b(),
273                         tet.c()
274                     );
275             } break;
276             case 3:
277             {
278                 tets_[tetI] =
279                     partTet
280                     (
281                         tet.a(),
282                         tet.b(),
283                         tet.c(),
284                         tet.d()
285                     );
286             } break;
287             default:
288             {
289                 FatalErrorIn
290                 (
291                     "partTetMeshSimplex::partTetMeshSimplex"
292                     "(const DynList<point, 128>& pts,"
293                     "const DynList<partTet, 128>& tets, const label pointI)"
294                 ) << "Point " << pointI << " is not present in tet" << tet
295                     << abort(FatalError);
296             }
297         }
298     }
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 partTetMeshSimplex::~partTetMeshSimplex()
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 } // End namespace Foam
310 // ************************************************************************* //