Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
dynamicMesh
polyTopoChange
polyTopoChange
refinementHistory.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::refinementHistory
26
27
Description
28
All refinement history. Used in unrefinement.
29
30
- visibleCells: valid for the current mesh and contains per cell -1
31
(cell unrefined) or an index into splitCells_.
32
- splitCells: for every split contains the parent (also index into
33
splitCells) and optionally a subsplit as 8 indices into splitCells.
34
Note that the numbers in splitCells are not cell labels, they are purely
35
indices into splitCells.
36
37
E.g. 2 cells, cell 1 gets refined so end up with 9 cells:
38
@verbatim
39
// splitCells
40
9
41
(
42
-1 (1 2 3 4 5 6 7 8)
43
0 0()
44
0 0()
45
0 0()
46
0 0()
47
0 0()
48
0 0()
49
0 0()
50
0 0()
51
)
52
53
// visibleCells
54
9(-1 1 2 3 4 5 6 7 8)
55
@endverbatim
56
57
58
So cell0 (visibleCells=-1) is unrefined.
59
Cells 1-8 have all valid splitCells entries which are:
60
- parent:0
61
- subsplits:0()
62
63
The parent 0 refers back to the splitcell entries.
64
65
66
SourceFiles
67
refinementHistory.C
68
69
\*---------------------------------------------------------------------------*/
70
71
#ifndef refinementHistory_H
72
#define refinementHistory_H
73
74
#include <
OpenFOAM/DynamicList.H
>
75
#include <
OpenFOAM/labelList.H
>
76
#include <
OpenFOAM/FixedList.H
>
77
#include <
OpenFOAM/SLList.H
>
78
#include <
OpenFOAM/autoPtr.H
>
79
#include <
OpenFOAM/regIOobject.H
>
80
81
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82
83
namespace
Foam
84
{
85
86
// Forward declaration of classes
87
class
mapPolyMesh;
88
class
mapDistributePolyMesh;
89
90
/*---------------------------------------------------------------------------*\
91
Class refinementHistory Declaration
92
\*---------------------------------------------------------------------------*/
93
94
class
refinementHistory
95
:
96
public
regIOobject
97
{
98
public
:
99
100
class
splitCell8
101
{
102
public
:
103
104
// Index to original splitCell this cell was refined off from
105
// -1: top level cell
106
// -2: free splitCell (so should also be in freeSplitCells_)
107
label
parent_
;
108
109
//- cells this cell was refined into
110
autoPtr<FixedList<label, 8>
>
addedCellsPtr_
;
111
112
//- Construct null (parent = -1)
113
splitCell8
();
114
115
//- Construct from parent
116
splitCell8
(
const
label parent);
117
118
//- Construct from Istream
119
splitCell8
(
Istream
& is);
120
121
//- Construct as deep copy
122
splitCell8
(
const
splitCell8
&);
123
124
//- Copy operator since autoPtr otherwise 'steals' storage.
125
void
operator=
(
const
splitCell8
& s)
126
{
127
// Check for assignment to self
128
if
(
this
== &s)
129
{
130
FatalErrorIn
(
"splitCell8::operator=(const Foam::splitCell8&)"
)
131
<<
"Attempted assignment to self"
132
<<
abort
(
FatalError
);
133
}
134
135
parent_
= s.
parent_
;
136
137
addedCellsPtr_
.
reset
138
(
139
s.
addedCellsPtr_
.
valid
()
140
?
new
FixedList<label, 8>
(s.
addedCellsPtr_
())
141
: NULL
142
);
143
}
144
145
bool
operator==
(
const
splitCell8
& s)
const
146
{
147
if
(
addedCellsPtr_
.
valid
() != s.
addedCellsPtr_
.
valid
())
148
{
149
return
false
;
150
}
151
else
if
(
parent_
!= s.
parent_
)
152
{
153
return
false
;
154
}
155
else
if
(
addedCellsPtr_
.
valid
())
156
{
157
return
addedCellsPtr_
() == s.
addedCellsPtr_
();
158
}
159
else
160
{
161
return
true
;
162
}
163
}
164
165
bool
operator!=
(
const
splitCell8
& s)
const
166
{
167
return
!
operator==
(s);
168
}
169
170
friend
Istream
&
operator>>
(
Istream
&,
splitCell8
&);
171
friend
Ostream
&
operator<<
(
Ostream
&,
const
splitCell8
&);
172
};
173
174
175
private
:
176
177
TypeName(
"refinementHistory"
);
178
179
// Private data
180
181
//- Storage for splitCells
182
DynamicList<splitCell8>
splitCells_;
183
184
//- Unused indices in splitCells
185
DynamicList<label>
freeSplitCells_;
186
187
//- Currently visible cells. Indices into splitCells.
188
labelList
visibleCells_;
189
190
191
// Private member functions
192
193
//- Debug write
194
static
void
writeEntry
195
(
196
const
List<splitCell8>
&,
197
const
splitCell8&
198
);
199
//- Debug write
200
static
void
writeDebug
201
(
202
const
labelList
&,
203
const
List<splitCell8>
&
204
);
205
206
//- Check consistency of structure, i.e. indices into splitCells_.
207
void
checkIndices()
const
;
208
209
//- Allocate a splitCell. Return index in splitCells_.
210
label allocateSplitCell(
const
label parent,
const
label i);
211
212
//- Free a splitCell.
213
void
freeSplitCell(
const
label index);
214
215
//- Mark entry in splitCells. Recursively mark its parent and subs.
216
void
markSplit
217
(
218
const
label,
219
labelList
& oldToNew,
220
DynamicList<splitCell8>
&
221
)
const
;
222
223
void
countProc
224
(
225
const
label index,
226
const
label newProcNo,
227
labelList
& splitCellProc,
228
labelList
& splitCellNum
229
)
const
;
230
231
public
:
232
233
// Constructors
234
235
//- Construct (read) given an IOobject
236
refinementHistory
(
const
IOobject
&);
237
238
//- Construct (read) or construct null
239
refinementHistory
240
(
241
const
IOobject
&,
242
const
List<splitCell8>
&
splitCells
,
243
const
labelList
&
visibleCells
244
);
245
246
//- Construct (read) or construct from initial number of cells
247
// (all visible)
248
refinementHistory
(
const
IOobject
&,
const
label nCells);
249
250
//- Construct as copy
251
refinementHistory
(
const
IOobject
&,
const
refinementHistory
&);
252
253
//- Construct from Istream
254
refinementHistory
(
const
IOobject
&,
Istream
&);
255
256
257
// Member Functions
258
259
260
//- Per cell in the current mesh (i.e. visible) either -1 (unrefined)
261
// or an index into splitCells.
262
const
labelList
&
visibleCells
()
const
263
{
264
return
visibleCells_;
265
}
266
267
//- Storage for splitCell8s.
268
const
DynamicList<splitCell8>
&
splitCells
()
const
269
{
270
return
splitCells_;
271
}
272
273
//- Cache of unused indices in splitCells
274
const
DynamicList<label>
&
freeSplitCells
()
const
275
{
276
return
freeSplitCells_;
277
}
278
279
//- Is there unrefinement history. Note that this will fall over if
280
// there are 0 cells in the mesh. But this gives problems with
281
// lots of other programs anyway.
282
bool
active
()
const
283
{
284
return
visibleCells_.
size
() > 0;
285
}
286
287
//- Get parent of cell
288
label
parentIndex
(
const
label cellI)
const
289
{
290
label index = visibleCells_[cellI];
291
292
if
(index < 0)
293
{
294
FatalErrorIn
(
"refinementHistory::parentIndex(const label)"
)
295
<<
"Cell "
<< cellI <<
" is not visible"
296
<<
abort
(
FatalError
);
297
}
298
return
splitCells_[index].parent_;
299
}
300
301
//- Store splitting of cell into 8
302
void
storeSplit
303
(
304
const
label cellI,
305
const
labelList
& addedCells
306
);
307
308
//- Store combining 8 cells into master
309
void
combineCells
310
(
311
const
label masterCellI,
312
const
labelList
& combinedCells
313
);
314
315
316
//- Update numbering for mesh changes
317
void
updateMesh
(
const
mapPolyMesh
&);
318
319
//- Update numbering for subsetting
320
void
subset
321
(
322
const
labelList
& pointMap,
323
const
labelList
& faceMap,
324
const
labelList
& cellMap
325
);
326
327
//- Update local numbering for mesh redistribution.
328
// Can only distribute clusters sent across in one go; cannot
329
// handle parts recombined in multiple passes.
330
void
distribute
(
const
mapDistributePolyMesh
&);
331
332
333
//- Compact splitCells_. Removes all freeSplitCells_ elements.
334
void
compact
();
335
336
//- Extend/shrink storage. additional visibleCells_ elements get
337
// set to -1.
338
void
resize
(
const
label nCells);
339
340
//- Debug write
341
void
writeDebug
()
const
;
342
343
344
//- ReadData function required for regIOobject read operation
345
virtual
bool
readData
(
Istream
&);
346
347
//- WriteData function required for regIOobject write operation
348
virtual
bool
writeData
(
Ostream
&)
const
;
349
350
351
// Friend Functions
352
353
// Friend Operators
354
355
// IOstream Operators
356
357
friend
Istream
&
operator>>
(
Istream
&,
refinementHistory
&);
358
friend
Ostream
&
operator<<
(
Ostream
&,
const
refinementHistory
&);
359
};
360
361
362
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363
364
}
// End namespace Foam
365
366
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367
368
#endif
369
370
// ************************ vim: set sw=4 sts=4 et: ************************ //