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
OpenFOAM
algorithms
MeshWave
FaceCellWave.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::FaceCellWave
26
27
Description
28
Wave propagation of information through grid. Every iteration
29
information goes through one layer of cells. Templated on information
30
that is transferred.
31
32
Handles parallel and cyclics and non-parallel cyclics.
33
34
Note: whether to propagate depends on the return value of Type::update
35
which returns true (i.e. propagate) if the value changes by more than a
36
certain tolerance.
37
This tolerance can be very strict for normal face-cell and parallel
38
cyclics (we use a value of 0.01 just to limit propagation of small changes)
39
but for non-parallel cyclics this tolerance can be critical and if chosen
40
too small can lead to non-convergence.
41
42
SourceFiles
43
FaceCellWave.C
44
45
\*---------------------------------------------------------------------------*/
46
47
#ifndef FaceCellWave_H
48
#define FaceCellWave_H
49
50
#include <
OpenFOAM/boolList.H
>
51
#include <
OpenFOAM/labelList.H
>
52
#include <
OpenFOAM/primitiveFieldsFwd.H
>
53
54
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56
namespace
Foam
57
{
58
59
// Forward declaration of classes
60
class
polyMesh;
61
class
polyPatch;
62
63
/*---------------------------------------------------------------------------*\
64
Class FaceCellWaveName Declaration
65
\*---------------------------------------------------------------------------*/
66
67
TemplateName
(FaceCellWave);
68
69
70
/*---------------------------------------------------------------------------*\
71
Class FaceCellWave Declaration
72
\*---------------------------------------------------------------------------*/
73
74
template
<
class
Type>
75
class
FaceCellWave
76
:
77
public
FaceCellWaveName
78
{
79
// Private data
80
81
//- Reference to mesh
82
const
polyMesh
& mesh_;
83
84
//- Information for all faces
85
UList<Type>
& allFaceInfo_;
86
87
//- Information for all cells
88
UList<Type>
& allCellInfo_;
89
90
//- Has face changed
91
boolList
changedFace_;
92
93
//- List of changed faces
94
labelList
changedFaces_;
95
96
//- Number of changed faces
97
label nChangedFaces_;
98
99
// Cells that have changed
100
boolList
changedCell_;
101
labelList
changedCells_;
102
label nChangedCells_;
103
104
//- Contains cyclics
105
bool
hasCyclicPatches_;
106
107
//- Number of evaluations
108
label nEvals_;
109
110
//- Number of unvisited cells/faces
111
label nUnvisitedCells_;
112
label nUnvisitedFaces_;
113
114
//- Iteration counter
115
label iter_;
116
117
118
// Static Functions
119
120
//- Write faces info
121
static
Ostream
& writeFaces
122
(
123
const
label nFaces,
124
const
labelList
& faceLabels,
125
const
List<Type>
& faceInfo,
126
Ostream
& os
127
);
128
129
//- Read faces info
130
static
Istream
& readFaces
131
(
132
label& nFaces,
133
labelList
& faceLabels,
134
List<Type>
& faceInfo,
135
Istream
& is
136
);
137
138
139
// Private Member Functions
140
141
//- Disallow default bitwise copy construct
142
FaceCellWave
(
const
FaceCellWave
&);
143
144
//- Disallow default bitwise assignment
145
void
operator=(
const
FaceCellWave
&);
146
147
148
//- Updates cellInfo with information from neighbour. Updates all
149
// statistics.
150
bool
updateCell
151
(
152
const
label cellI,
153
const
label neighbourFaceI,
154
const
Type& neighbourInfo,
155
const
scalar tol,
156
Type&
cellInfo
157
);
158
159
//- Updates faceInfo with information from neighbour. Updates all
160
// statistics.
161
bool
updateFace
162
(
163
const
label faceI,
164
const
label neighbourCellI,
165
const
Type& neighbourInfo,
166
const
scalar tol,
167
Type& faceInfo
168
);
169
170
//- Updates faceInfo with information from same face. Updates all
171
// statistics.
172
bool
updateFace
173
(
174
const
label faceI,
175
const
Type& neighbourInfo,
176
const
scalar tol,
177
Type& faceInfo
178
);
179
180
181
// Parallel, cyclic
182
183
//- Debugging: check info on both sides of cyclic
184
void
checkCyclic(
const
polyPatch
& pPatch)
const
;
185
186
//- Has cyclic patch?
187
bool
hasCyclicPatch()
const
;
188
189
//- Merge received patch data into global data
190
void
mergeFaceInfo
191
(
192
const
polyPatch
& patch,
193
const
label nFaces,
194
const
labelList
&,
195
const
List<Type>
&,
196
const
bool
isParallel
197
);
198
199
//- Extract info for single patch only
200
label getChangedPatchFaces
201
(
202
const
polyPatch
& patch,
203
const
label startFaceI,
204
const
label nFaces,
205
labelList
& changedPatchFaces,
206
List<Type>
& changedPatchFacesInfo
207
)
const
;
208
209
//- Handle leaving domain. Implementation referred to Type
210
void
leaveDomain
211
(
212
const
polyPatch
& patch,
213
const
label nFaces,
214
const
labelList
& faceLabels,
215
List<Type>
& faceInfo
216
)
const
;
217
218
//- Handle leaving domain. Implementation referred to Type
219
void
enterDomain
220
(
221
const
polyPatch
& patch,
222
const
label nFaces,
223
const
labelList
& faceLabels,
224
List<Type>
& faceInfo
225
)
const
;
226
227
//- Send info to neighbour
228
void
sendPatchInfo
229
(
230
const
label neighbour,
231
const
label nFaces,
232
const
labelList
&,
233
const
List<Type>
&
234
)
const
;
235
236
//- Receive info from neighbour. Returns number of faces received.
237
label receivePatchInfo
238
(
239
const
label neighbour,
240
labelList
&,
241
List<Type>
&
242
)
const
;
243
244
//- Offset face labels by constant value
245
static
void
offset
246
(
247
const
polyPatch
& patch,
248
const
label off,
249
const
label nFaces,
250
labelList
& faces
251
);
252
253
//- Apply transformation to Type
254
void
transform
255
(
256
const
tensorField
& rotTensor,
257
const
label nFaces,
258
List<Type>
& faceInfo
259
);
260
261
//- Merge data from across processor boundaries
262
void
handleProcPatches();
263
264
//- Merge data from across cyclics
265
void
handleCyclicPatches();
266
267
268
// Private static data
269
270
static
const
scalar geomTol_;
271
static
scalar propagationTol_;
272
273
public
:
274
275
// Static Functions
276
277
//- Access to tolerance
278
static
scalar
propagationTol
()
279
{
280
return
propagationTol_;
281
}
282
283
//- Change tolerance
284
static
void
setPropagationTol
(
const
scalar tol)
285
{
286
propagationTol_ = tol;
287
}
288
289
290
// Constructors
291
292
// Construct from mesh. Use setFaceInfo and iterate() to do actual
293
// calculation.
294
FaceCellWave
295
(
296
const
polyMesh
&,
297
UList<Type>
&
allFaceInfo
,
298
UList<Type>
&
allCellInfo
299
);
300
301
//- Construct from mesh and list of changed faces with the Type
302
// for these faces. Iterates until nothing changes or maxIter reached.
303
// (maxIter can be 0)
304
FaceCellWave
305
(
306
const
polyMesh
&,
307
const
labelList
& initialChangedFaces,
308
const
List<Type>
& changedFacesInfo,
309
UList<Type>
&
allFaceInfo
,
310
UList<Type>
&
allCellInfo
,
311
const
label maxIter
312
);
313
314
315
// Member Functions
316
317
// Access
318
319
//- Access allFaceInfo
320
UList<Type>
&
allFaceInfo
()
321
{
322
return
allFaceInfo_;
323
}
324
325
//- Access allCellInfo
326
UList<Type>
&
allCellInfo
()
327
{
328
return
allCellInfo_;
329
}
330
331
//- Access mesh
332
const
polyMesh
&
mesh
()
const
333
{
334
return
mesh_;
335
}
336
337
//- Get number of unvisited cells, i.e. cells that were not (yet)
338
// reached from walking across mesh. This can happen from
339
// - not enough iterations done
340
// - a disconnected mesh
341
// - a mesh without walls in it
342
label
getUnsetCells
()
const
;
343
344
//- Get number of unvisited faces
345
label
getUnsetFaces
()
const
;
346
347
348
// Edit
349
350
//- Set initial changed faces
351
void
setFaceInfo
352
(
353
const
labelList
& changedFaces,
354
const
List<Type>
& changedFacesInfo
355
);
356
357
//- Propagate from face to cell. Returns total number of cells
358
// (over all processors) changed.
359
label
faceToCell
();
360
361
//- Propagate from cell to face. Returns total number of faces
362
// (over all processors) changed. (Faces on processorpatches are
363
// counted double)
364
label
cellToFace
();
365
366
//- Iterate until no changes or maxIter reached. Returns number of
367
// unset cells (see getUnsetCells)
368
label
iterate
(
const
label maxIter);
369
370
};
371
372
373
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374
375
}
// End namespace Foam
376
377
378
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379
380
#ifdef NoRepository
381
# include <
OpenFOAM/FaceCellWave.C
>
382
#endif
383
384
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385
386
#endif
387
388
// ************************ vim: set sw=4 sts=4 et: ************************ //