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
fvMeshDistribute
fvMeshDistribute.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::fvMeshDistribute
26
27
Description
28
Sends/receives parts of mesh+fvfields to neighbouring processors.
29
Used in load balancing.
30
31
Input is per local cell the processor it should move to. Moves meshes
32
and volFields/surfaceFields and returns map which can be used to
33
distribute other.
34
35
Notes:
36
- does not handle cyclics. Will probably handle separated proc patches.
37
- if all cells move off processor also all its processor patches will
38
get deleted so comms might be screwed up (since e.g. globalMeshData
39
expects procPatches on all)
40
- initial mesh has to have procPatches last and all normal patches common
41
to all processors and in the same order. This is checked.
42
- faces are matched topologically but points on the faces are not. So
43
expect problems -on separated patches (cyclics?) -on zero sized processor
44
edges.
45
46
SourceFiles
47
fvMeshDistribute.C
48
fvMeshDistributeTemplates.C
49
50
\*---------------------------------------------------------------------------*/
51
52
#ifndef fvMeshDistribute_H
53
#define fvMeshDistribute_H
54
55
#include <
OpenFOAM/Field.H
>
56
//#include <OpenFOAM/uLabel.H>
57
#include <
finiteVolume/fvMeshSubset.H
>
58
59
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61
namespace
Foam
62
{
63
64
// Forward declaration of classes
65
class
mapAddedPolyMesh;
66
class
mapDistributePolyMesh;
67
68
/*---------------------------------------------------------------------------*\
69
Class fvMeshDistribute Declaration
70
\*---------------------------------------------------------------------------*/
71
72
class
fvMeshDistribute
73
{
74
// Private data
75
76
//- Underlying fvMesh
77
fvMesh
& mesh_;
78
79
//- Absolute merging tolerance (constructing meshes gets done using
80
// geometric matching)
81
const
scalar mergeTol_;
82
83
84
// Private Member Functions
85
86
//- Find indices with value
87
static
labelList
select
88
(
89
const
bool
selectEqual,
90
const
labelList
& values,
91
const
label value
92
);
93
94
//- Check all procs have same names and in exactly same order.
95
static
void
checkEqualWordList(
const
string
&,
const
wordList
&);
96
97
//- Merge wordlists over all processors
98
static
wordList
mergeWordList(
const
wordList
&);
99
100
101
// Patch handling
102
103
//- Find patch to put exposed faces into.
104
label findNonEmptyPatch()
const
;
105
106
//- Appends processorPolyPatch. Returns patchID.
107
label addProcPatch(
const
word
& patchName,
const
label nbrProc);
108
109
//- Add patch field
110
template
<
class
GeoField>
111
void
addPatchFields(
const
word
& patchFieldType);
112
113
//- Deletes last patch.
114
void
deleteTrailingPatch();
115
116
// Delete trailing patch fields
117
template
<
class
GeoField>
118
void
deleteTrailingPatchFields();
119
120
//- Save boundary fields
121
template
<
class
T,
class
Mesh>
122
void
saveBoundaryFields
123
(
124
PtrList
<
FieldField<fvsPatchField, T>
>& bflds
125
)
const
;
126
127
//- Map boundary fields
128
template
<
class
T,
class
Mesh>
129
void
mapBoundaryFields
130
(
131
const
mapPolyMesh
& map,
132
const
PtrList
<
FieldField<fvsPatchField, T>
>& oldBflds
133
);
134
135
//- Init patch fields of certain type
136
template
<
class
GeoField,
class
PatchFieldType>
137
void
initPatchFields
138
(
139
const
typename
GeoField::value_type& initVal
140
);
141
142
//- Delete all processor patches. Move any processor faces into
143
// patchI.
144
autoPtr<mapPolyMesh>
deleteProcPatches(
const
label patchI);
145
146
//- Repatch the mesh. This is only nessecary for the proc
147
// boundary faces. newPatchID is over all boundary faces: -1 or
148
// new patchID. constructFaceMap is being adapted for the
149
// possible new face position (since proc faces get automatically
150
// matched)
151
autoPtr<mapPolyMesh>
repatch
152
(
153
const
labelList
& newPatchID,
154
labelListList
& constructFaceMap
155
);
156
157
//- Merge any shared points that are geometrically shared. Needs
158
// parallel valid mesh - uses globalMeshData.
159
// constructPointMap is adapted for the new point labels.
160
autoPtr<mapPolyMesh>
mergeSharedPoints
161
(
162
labelListList
& constructPointMap
163
);
164
165
// Coupling information
166
167
//- Construct the local environment of all boundary faces.
168
void
getNeighbourData
169
(
170
const
labelList
&
distribution
,
171
labelList
& sourceFace,
172
labelList
& sourceProc,
173
labelList
& sourceNewProc
174
)
const
;
175
176
// Subset the neighbourCell/neighbourProc fields
177
static
void
subsetBoundaryData
178
(
179
const
fvMesh
&
mesh
,
180
const
labelList
& faceMap,
181
const
labelList
& cellMap,
182
183
const
labelList
& oldDistribution,
184
const
labelList
& oldFaceOwner,
185
const
labelList
& oldFaceNeighbour,
186
const
label oldInternalFaces,
187
188
const
labelList
& sourceFace,
189
const
labelList
& sourceProc,
190
const
labelList
& sourceNewProc,
191
192
labelList
& subFace,
193
labelList
& subProc,
194
labelList
& subNewProc
195
);
196
197
//- Find cells on mesh whose faceID/procID match the neighbour
198
// cell/proc of domainMesh. Store the matching face.
199
static
void
findCouples
200
(
201
const
primitiveMesh
&,
202
const
labelList
& sourceFace,
203
const
labelList
& sourceProc,
204
205
const
label domain,
206
const
primitiveMesh
& domainMesh,
207
const
labelList
& domainFace,
208
const
labelList
& domainProc,
209
210
labelList
& masterCoupledFaces,
211
labelList
& slaveCoupledFaces
212
);
213
214
//- Map data on boundary faces to new mesh (resulting from adding
215
// two meshes)
216
static
labelList
mapBoundaryData
217
(
218
const
primitiveMesh
& mesh,
// mesh after adding
219
const
mapAddedPolyMesh
& map,
220
const
labelList
& boundaryData0,
// mesh before adding
221
const
label nInternalFaces1,
222
const
labelList
& boundaryData1
// added mesh
223
);
224
225
226
// Other
227
228
//- Remove cells. Add all exposed faces to patch oldInternalPatchI
229
autoPtr<mapPolyMesh>
doRemoveCells
230
(
231
const
labelList
& cellsToRemove,
232
const
label oldInternalPatchI
233
);
234
235
//- Add processor patches. Changes mesh and returns per neighbour
236
// proc the processor patchID.
237
void
addProcPatches
238
(
239
const
labelList
&,
// processor that neighbour is on
240
labelList
& procPatchID
241
);
242
243
//- Get boundary faces to be repatched. Is -1 or new patchID
244
static
labelList
getProcBoundaryPatch
245
(
246
const
labelList
& neighbourNewProc,
// new processor per b. face
247
const
labelList
& procPatchID
// patchID
248
);
249
250
//- Send mesh and coupling data.
251
static
void
sendMesh
252
(
253
const
label domain,
254
const
fvMesh
& mesh,
255
const
wordList
& pointZoneNames,
256
const
wordList
& facesZoneNames,
257
const
wordList
& cellZoneNames,
258
const
labelList
& sourceFace,
259
const
labelList
& sourceProc,
260
const
labelList
& sourceNewProc,
261
OSstream
& toDomain
262
);
263
//- Send subset of fields
264
template
<
class
GeoField>
265
static
void
sendFields
266
(
267
const
label domain,
268
const
wordList
&
fieldNames
,
269
const
fvMeshSubset
&,
270
OSstream
& toNbr
271
);
272
273
//- Receive mesh. Opposite of sendMesh
274
static
autoPtr<fvMesh>
receiveMesh
275
(
276
const
label domain,
277
const
wordList
& pointZoneNames,
278
const
wordList
& facesZoneNames,
279
const
wordList
& cellZoneNames,
280
const
Time
& runTime,
281
labelList
& domainSourceFace,
282
labelList
& domainSourceProc,
283
labelList
& domainSourceNewProc,
284
ISstream
& fromNbr
285
);
286
287
//- Receive fields. Opposite of sendFields
288
template
<
class
GeoField>
289
static
void
receiveFields
290
(
291
const
label domain,
292
const
wordList
& fieldNames,
293
fvMesh
&,
294
PtrList<GeoField>
&,
295
const
dictionary
& fieldDicts
296
);
297
298
//- Do parallel exchange
299
template
<
class
Container,
class
T>
300
static
void
exchange
301
(
302
const
List<Container >
& sendBufs,
303
List<Container >
& recvBufs,
304
labelListList
& sizes
305
);
306
307
//- Disallow default bitwise copy construct
308
fvMeshDistribute
(
const
fvMeshDistribute
&);
309
310
//- Disallow default bitwise assignment
311
void
operator=(
const
fvMeshDistribute
&);
312
313
public
:
314
315
ClassName
(
"fvMeshDistribute"
);
316
317
318
// Constructors
319
320
//- Construct from mesh and absolute merge tolerance
321
fvMeshDistribute
(
fvMesh
& mesh,
const
scalar mergeTol);
322
323
324
// Member Functions
325
326
//- Helper function: count cells per processor in wanted distribution
327
static
labelList
countCells
(
const
labelList
&);
328
329
//- Send cells to neighbours according to distribution
330
// (for every cell the new proc)
331
autoPtr<mapDistributePolyMesh>
distribute
(
const
labelList
&
dist
);
332
333
// Debugging
334
335
//- Print some info on coupling data
336
static
void
printCoupleInfo
337
(
338
const
primitiveMesh
&,
339
const
labelList
&,
340
const
labelList
&,
341
const
labelList
&
342
);
343
344
//- Print some field info
345
template
<
class
GeoField>
346
static
void
printFieldInfo
(
const
fvMesh
&);
347
348
//- Print some info on mesh.
349
static
void
printMeshInfo
(
const
fvMesh
&);
350
};
351
352
353
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354
355
}
// End namespace Foam
356
357
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358
359
#ifdef NoRepository
360
# include <
dynamicMesh/fvMeshDistributeTemplates.C
>
361
#endif
362
363
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364
365
#endif
366
367
// ************************ vim: set sw=4 sts=4 et: ************************ //