Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/meshing/adfront3.hpp
3206 views
1
#ifndef FILE_ADFRONT3
2
#define FILE_ADFRONT3
3
4
/**************************************************************************/
5
/* File: adfront3.hh */
6
/* Author: Joachim Schoeberl */
7
/* Date: 01. Okt. 95 */
8
/**************************************************************************/
9
10
/*
11
Advancing front class for volume meshing
12
*/
13
14
15
16
/// Point in advancing front
17
class FrontPoint3
18
{
19
/// coordinates
20
Point<3> p;
21
/// global node index
22
PointIndex globalindex;
23
/// number of faces connected to point
24
int nfacetopoint;
25
/// distance to original boundary
26
int frontnr;
27
///
28
int cluster;
29
public:
30
///
31
FrontPoint3 ();
32
///
33
FrontPoint3 (const Point<3> & ap, PointIndex agi);
34
35
///
36
const Point<3> & P () const
37
{ return p; }
38
///
39
PointIndex GlobalIndex () const
40
{ return globalindex; }
41
42
///
43
void AddFace ()
44
{ nfacetopoint++; }
45
46
///
47
void RemoveFace()
48
{
49
nfacetopoint--;
50
if (nfacetopoint == 0) nfacetopoint = -1;
51
}
52
53
///
54
int Valid () const
55
{ return nfacetopoint >= 0; }
56
57
///
58
void DecFrontNr (int afrontnr)
59
{
60
if (frontnr > afrontnr) frontnr = afrontnr;
61
}
62
63
///
64
int FrontNr () const
65
{ return frontnr; }
66
67
///
68
friend class AdFront3;
69
};
70
71
72
73
class MiniElement2d
74
{
75
protected:
76
int np;
77
PointIndex pnum[4];
78
bool deleted;
79
public:
80
MiniElement2d ()
81
{ np = 3; deleted = 0; }
82
MiniElement2d (int anp)
83
{ np = anp; deleted = 0; }
84
85
int GetNP() const { return np; }
86
PointIndex & operator[] (int i) { return pnum[i]; }
87
const PointIndex operator[] (int i) const { return pnum[i]; }
88
89
const PointIndex PNum (int i) const { return pnum[i-1]; }
90
PointIndex & PNum (int i) { return pnum[i-1]; }
91
const PointIndex PNumMod (int i) const { return pnum[(i-1)%np]; }
92
93
void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }
94
bool IsDeleted () const { return deleted; }
95
};
96
97
98
inline ostream & operator<<(ostream & s, const MiniElement2d & el)
99
{
100
s << "np = " << el.GetNP();
101
for (int j = 0; j < el.GetNP(); j++)
102
s << " " << el[j];
103
return s;
104
}
105
106
107
108
109
/// Face in advancing front
110
class FrontFace
111
{
112
private:
113
///
114
MiniElement2d f;
115
///
116
int qualclass;
117
///
118
char oldfront;
119
///
120
int hashvalue;
121
///
122
int cluster;
123
124
public:
125
///
126
FrontFace ();
127
///
128
FrontFace (const MiniElement2d & af);
129
///
130
const MiniElement2d & Face () const
131
{ return f; }
132
133
///
134
int QualClass () const
135
{ return qualclass; }
136
137
///
138
void IncrementQualClass ()
139
{ qualclass++; }
140
141
///
142
void ResetQualClass ()
143
{
144
if (qualclass > 1)
145
{
146
qualclass = 1;
147
oldfront = 0;
148
}
149
}
150
151
///
152
bool Valid () const
153
{ return !f.IsDeleted(); }
154
155
///
156
void Invalidate ();
157
158
///
159
int HashValue() const
160
{ return hashvalue; }
161
162
///
163
void SetHashValue(int hv)
164
{ hashvalue = hv; }
165
166
///
167
friend class AdFront3;
168
169
int Cluster () const { return cluster; }
170
};
171
172
173
174
175
/// Advancing front, 3D.
176
class AdFront3
177
{
178
///
179
ARRAY<FrontPoint3, PointIndex::BASE> points;
180
///
181
ARRAY<FrontFace> faces;
182
///
183
ARRAY<PointIndex> delpointl;
184
185
/// which points are connected to pi ?
186
TABLE<int, PointIndex::BASE> * connectedpairs;
187
188
/// number of total front faces;
189
int nff;
190
/// number of quads in front
191
int nff4;
192
193
///
194
double vol;
195
196
///
197
GeomSearch3d hashtable;
198
199
///
200
int hashon;
201
202
///
203
int hashcreated;
204
205
/// counter for rebuilding internal tables
206
int rebuildcounter;
207
/// last base element
208
int lasti;
209
/// minimal selection-value of baseelements
210
int minval;
211
212
///
213
class Box3dTree * facetree;
214
public:
215
216
///
217
AdFront3 ();
218
///
219
~AdFront3 ();
220
///
221
void GetPoints (ARRAY<Point<3> > & apoints) const;
222
///
223
int GetNP() const
224
{ return points.Size(); }
225
///
226
const Point<3> & GetPoint (PointIndex pi) const
227
{ return points[pi].P(); }
228
///
229
int GetNF() const
230
{ return nff; }
231
///
232
const MiniElement2d & GetFace (int i) const
233
{ return faces.Get(i).Face(); }
234
///
235
void Print () const;
236
///
237
bool Empty () const
238
{ return nff == 0; }
239
///
240
bool Empty (int elnp) const
241
{
242
if (elnp == 4)
243
return (nff4 == 0);
244
return (nff - nff4 == 0);
245
}
246
///
247
int SelectBaseElement ();
248
249
///
250
void CreateTrees ();
251
252
///
253
void GetIntersectingFaces (const Point<3> & pmin, const Point<3> & pmax,
254
ARRAY<int> & ifaces) const;
255
256
///
257
void GetFaceBoundingBox (int i, Box3d & box) const;
258
259
///
260
int GetLocals (int baseelement,
261
ARRAY<Point3d > & locpoints,
262
ARRAY<MiniElement2d> & locfaces, // local index
263
ARRAY<PointIndex> & pindex,
264
ARRAY<INDEX> & findex,
265
INDEX_2_HASHTABLE<int> & connectedpairs,
266
float xh,
267
float relh,
268
INDEX& facesplit);
269
270
///
271
void GetGroup (int fi,
272
ARRAY<MeshPoint> & grouppoints,
273
ARRAY<MiniElement2d> & groupelements,
274
ARRAY<PointIndex> & pindex,
275
ARRAY<INDEX> & findex
276
) const;
277
278
///
279
void DeleteFace (INDEX fi);
280
///
281
PointIndex AddPoint (const Point<3> & p, PointIndex globind);
282
///
283
INDEX AddFace (const MiniElement2d & e);
284
///
285
INDEX AddConnectedPair (const INDEX_2 & pair);
286
///
287
void IncrementClass (INDEX fi)
288
{ faces.Elem(fi).IncrementQualClass(); }
289
290
///
291
void ResetClass (INDEX fi)
292
{ faces.Elem(fi).ResetQualClass(); }
293
294
///
295
void SetStartFront (int baseelnp = 0);
296
297
/// is Point p inside Surface ?
298
bool Inside (const Point<3> & p) const;
299
/// both points on same side ?
300
int SameSide (const Point<3> & lp1, const Point<3> & lp2,
301
const ARRAY<int> * testfaces = NULL) const;
302
303
304
///
305
PointIndex GetGlobalIndex (PointIndex pi) const
306
{ return points[pi].GlobalIndex(); }
307
///
308
double Volume () const
309
{ return vol; }
310
311
312
private:
313
void RebuildInternalTables();
314
};
315
316
317
318
319
#endif
320
321