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
lagrangian
basic
Cloud
Cloud.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::Cloud
26
27
Description
28
29
SourceFiles
30
Cloud.C
31
CloudIO.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef Cloud_H
36
#define Cloud_H
37
38
#include <
OpenFOAM/cloud.H
>
39
#include <
OpenFOAM/IDLList.H
>
40
#include <
OpenFOAM/IOField.H
>
41
#include <
OpenFOAM/polyMesh.H
>
42
43
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45
namespace
Foam
46
{
47
48
// Forward declaration of functions
49
template
<
class
ParticleType>
50
class
Cloud;
51
52
template
<
class
ParticleType>
53
class
IOPosition;
54
55
template
<
class
ParticleType>
56
Ostream&
operator
<<
57
(
58
Ostream&,
59
const
Cloud<ParticleType>&
60
);
61
62
63
/*---------------------------------------------------------------------------*\
64
Class Cloud Declaration
65
\*---------------------------------------------------------------------------*/
66
67
template
<
class
ParticleType>
68
class
Cloud
69
:
70
public
cloud
,
71
public
IDLList
<ParticleType>
72
{
73
// Private data
74
75
const
polyMesh
& polyMesh_;
76
77
//- Overall count of particles ever created. Never decreases.
78
mutable
label particleCount_;
79
80
//- Temporary storage for addressing. Used in findFaces.
81
mutable
DynamicList<label>
labels_;
82
83
84
// Private member functions
85
86
//- Initialise cloud on IO constructor
87
void
initCloud(
const
bool
checkClass);
88
89
//- Read cloud properties dictionary
90
void
readCloudUniformProperties();
91
92
//- Write cloud properties dictionary
93
void
writeCloudUniformProperties()
const
;
94
95
96
public
:
97
98
template
<
class
ParticleT>
99
friend
class
Particle
;
100
template
<
class
ParticleT>
101
friend
class
IOPosition
;
102
103
typedef
ParticleType
particleType
;
104
105
typedef
typename
IDLList<ParticleType>::iterator
iterator
;
106
typedef
typename
IDLList<ParticleType>::const_iterator
const_iterator
;
107
108
//-Runtime type information
109
TypeName
(
"Cloud"
);
110
111
112
// Static data
113
114
//- Name of cloud properties dictionary
115
static
word
cloudPropertiesName
;
116
117
118
// Constructors
119
120
//- Construct from mesh and a list of particles
121
Cloud
122
(
123
const
polyMesh
&
mesh
,
124
const
IDLList<ParticleType>
& particles
125
);
126
127
//- Construct from mesh, cloud name, and a list of particles
128
Cloud
129
(
130
const
polyMesh
&
mesh
,
131
const
word
&
cloudName
,
132
const
IDLList<ParticleType>
& particles
133
);
134
135
//- Construct from mesh by reading from file
136
// Optionally disable checking of class name for post-processing
137
Cloud
138
(
139
const
polyMesh
&
mesh
,
140
const
bool
checkClass =
true
141
);
142
143
144
//- Construct from mesh by reading from file with given cloud instance
145
// Optionally disable checking of class name for post-processing
146
Cloud
147
(
148
const
polyMesh
&
pMesh
,
149
const
word
&
cloudName
,
150
const
bool
checkClass =
true
151
);
152
153
154
// Member Functions
155
156
// Access
157
158
//- Return the polyMesh reference
159
const
polyMesh
&
pMesh
()
const
160
{
161
return
polyMesh_;
162
}
163
164
//- Is this global face an internal face?
165
bool
internalFace
(
const
label facei)
const
166
{
167
return
polyMesh_.
isInternalFace
(facei);
168
}
169
170
//- Is this global face a boundary face?
171
bool
boundaryFace
(
const
label facei)
const
172
{
173
return
!
internalFace
(facei);
174
}
175
176
//- Which patch is this global face on
177
label
facePatch
(
const
label facei)
const
178
{
179
return
polyMesh_.
boundaryMesh
().
whichPatch
(facei);
180
}
181
182
//- Which face of this patch is this global face
183
label
patchFace
(
const
label
patchi
,
const
label facei)
const
184
{
185
return
polyMesh_.
boundaryMesh
()[
patchi
].whichFace(facei);
186
}
187
188
label
size
()
const
189
{
190
return
IDLList<ParticleType>::size
();
191
};
192
193
194
// Iterators
195
196
const
const_iterator
begin
()
const
197
{
198
return
IDLList<ParticleType>::begin
();
199
};
200
201
const
const_iterator
cbegin
()
const
202
{
203
return
IDLList<ParticleType>::cbegin
();
204
};
205
206
const
const_iterator
end
()
const
207
{
208
return
IDLList<ParticleType>::end
();
209
};
210
211
const
const_iterator
cend
()
const
212
{
213
return
IDLList<ParticleType>::cend
();
214
};
215
216
iterator
begin
()
217
{
218
return
IDLList<ParticleType>::begin
();
219
};
220
221
iterator
end
()
222
{
223
return
IDLList<ParticleType>::end
();
224
};
225
226
227
// Edit
228
229
void
clear
()
230
{
231
return
IDLList<ParticleType>::clear
();
232
};
233
234
//- Get unique particle creation id
235
label
getNewParticleID
()
const
;
236
237
//- Transfer particle to cloud
238
void
addParticle
(ParticleType* pPtr);
239
240
//- Remove particle from cloud and delete
241
void
deleteParticle
(ParticleType&);
242
243
//- Move the particles
244
// passing the TrackingData to the track function
245
template
<
class
TrackingData>
246
void
move
(TrackingData& td);
247
248
//- Remap the cells of particles corresponding to the
249
// mesh topology change
250
virtual
void
autoMap
(
const
mapPolyMesh
&);
251
252
253
// Read
254
255
//- Helper to construct IOobject for field and current time.
256
IOobject
fieldIOobject
257
(
258
const
word
& fieldName,
259
const
IOobject::readOption
r
260
)
const
;
261
262
//- Check lagrangian data field
263
template
<
class
DataType>
264
void
checkFieldIOobject
265
(
266
const
Cloud<ParticleType>
& c,
267
const
IOField<DataType>
& data
268
)
const
;
269
270
//- Read the field data for the cloud of particles. Dummy at
271
// this level.
272
virtual
void
readFields
();
273
274
275
// Write
276
277
//- Write the field data for the cloud of particles Dummy at
278
// this level.
279
virtual
void
writeFields
()
const
;
280
281
//- Write using given format, version and compression.
282
// Only writes the cloud file if the Cloud isn't empty
283
virtual
bool
writeObject
284
(
285
IOstream::streamFormat
fmt,
286
IOstream::versionNumber
ver,
287
IOstream::compressionType
cmp
288
)
const
;
289
290
//- Write positions to <cloudName>_positions.obj file
291
void
writePositions
()
const
;
292
293
294
// Ostream Operator
295
296
friend
Ostream
& operator<< <ParticleType>
297
(
298
Ostream
&,
299
const
Cloud<ParticleType>
&
300
);
301
};
302
303
304
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305
306
}
// End namespace Foam
307
308
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309
310
#ifdef NoRepository
311
# include "
Cloud.C
"
312
#endif
313
314
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315
316
#endif
317
318
// ************************ vim: set sw=4 sts=4 et: ************************ //