partTetMeshSimplex.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "Map.H"
29 #include "partTetMeshSimplex.H"
30 
31 //#define DEBUGSmooth
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
41 (
42  const partTetMesh& tm,
43  const label pI
44 )
45 :
46  pts_(),
47  tets_()
48 {
49  const LongList<point>& points = tm.points();
50  const LongList<partTet>& tets = tm.tets();
51  const VRWGraph& pt = tm.pointTets();
52 
53  tets_.setSize(pt.sizeOfRow(pI));
54  label counter(0);
55 
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  }
70 
71  # ifdef DEBUGSmooth
72  Info << "Tet " << tetI << " is " << tet << endl;
73  # endif
74 
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  {
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  }
133 }
134 
136 (
137  const DynList<parPartTet>& pt,
138  const label gpI
139 )
140 :
141  pts_(),
142  tets_()
143 {
144  tets_.setSize(pt.size());
145  label pI(0);
146 
147  Map<label> addr;
148  forAll(pt, tetI)
149  {
150  const parPartTet& tet = pt[tetI];
151 
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  }
161 
162  if( tet[i].pointLabel() == gpI )
163  pos = i;
164  }
165 
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  {
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  }
223 }
224 
226 (
227  const DynList<point, 128>& pts,
228  const DynList<partTet, 128>& tets,
229  const label pointI
230 )
231 :
232  pts_(pts),
233  tets_(tets.size())
234 {
235  forAll(tets, tetI)
236  {
237  const partTet& tet = tets[tetI];
238 
239  const label pos = tet.whichPosition(pointI);
240 
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  {
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  }
299 }
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
304 {}
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 } // End namespace Foam
309 
310 // ************************************************************************* //
Foam::parPartTet
Definition: parPartTet.H:49
Foam::partTet::d
label d() const
Definition: partTetI.H:78
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::partTet::b
label b() const
Definition: partTetI.H:68
Foam::partTet
Definition: partTet.H:53
Foam::Map< label >
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::partTetMesh::pointTets
const VRWGraph & pointTets() const
Definition: partTetMesh.H:184
Foam::LongList
Definition: LongList.H:55
Map.H
Foam::label
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
Foam::Info
messageStream Info
partTetMeshSimplex.H
Foam::partTetMesh::tets
const LongList< partTet > & tets() const
Definition: partTetMesh.H:179
Foam::VRWGraph::setSize
void setSize(const label)
Reset the number of rows.
Definition: VRWGraphI.H:132
forAllRow
#define forAllRow(graph, rowI, index)
Definition: VRWGraph.H:277
Foam::partTetMeshSimplex::partTetMeshSimplex
partTetMeshSimplex(const partTetMesh &tm, const label pI)
Construct from partTetMeshSimplex and point label.
Definition: partTetMeshSimplex.C:41
coordinates
PtrList< coordinateSystem > coordinates(solidRegions.size())
Foam::VRWGraph::sizeOfRow
label sizeOfRow(const label rowI) const
Returns the number of elements in the given row.
Definition: VRWGraphI.H:127
Foam::partTet::c
label c() const
Definition: partTetI.H:73
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::DynList
Definition: DynList.H:53
Foam::partTetMesh
Definition: partTetMesh.H:59
Foam::partTetMeshSimplex::~partTetMeshSimplex
~partTetMeshSimplex()
Definition: partTetMeshSimplex.C:303
Foam::partTet::whichPosition
label whichPosition(const label) const
find position of the node in the partTet
Definition: partTetI.H:88
points
const pointField & points
Definition: gmvOutputHeader.H:1
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::DynList::size
label size() const
Definition: DynListI.H:235
Foam::partTetMesh::points
const LongList< point > & points() const
access to points, tets and other data
Definition: partTetMesh.H:174
Foam::partTet::a
label a() const
Return vertices.
Definition: partTetI.H:63
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190