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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::Cloud
29
30Description
31 Base cloud calls templated on particle type
32
33SourceFiles
34 Cloud.C
35 CloudIO.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_Cloud_H
40#define Foam_Cloud_H
41
42#include "cloud.H"
43#include "IDLList.H"
44#include "IOField.H"
45#include "CompactIOField.H"
46#include "polyMesh.H"
47#include "bitSet.H"
48#include "wordRes.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56template<class ParticleType> class Cloud;
57template<class ParticleType> class IOPosition;
58
59
60/*---------------------------------------------------------------------------*\
61 Class Cloud Declaration
62\*---------------------------------------------------------------------------*/
63
64template<class ParticleType>
65class Cloud
66:
67 public cloud,
68 public IDLList<ParticleType>
69{
70 // Private data
71
72 //- Reference to the mesh database
73 const polyMesh& polyMesh_;
74
75 //- Temporary storage for addressing. Used in findTris.
76 mutable DynamicList<label> labels_;
77
78 //- Does the cell have wall faces
79 mutable autoPtr<bitSet> cellWallFacesPtr_;
80
81 //- Temporary storage for the global particle positions
82 mutable autoPtr<vectorField> globalPositionsPtr_;
83
84
85 // Private Member Functions
86
87 //- Check patches
88 void checkPatches() const;
89
90 //- Initialise cloud on IO constructor
91 void initCloud(const bool checkClass);
92
93 //- Find all cells which have wall faces
94 void calcCellWallFaces() const;
95
96 //- Read cloud properties dictionary
97 void readCloudUniformProperties();
98
99 //- Write cloud properties dictionary
100 void writeCloudUniformProperties() const;
101
102
103protected:
104
105 //- Geometry type
107
108
109public:
111 friend class particle;
112 template<class ParticleT>
113 friend class IOPosition;
115 typedef ParticleType particleType;
116
117 //- Parcels are just particles
118 typedef ParticleType parcelType;
119
120
121 //- Runtime type information
122 TypeName("Cloud");
123
124
125 // Static Data
126
127 //- Name of cloud properties dictionary
129
130
131 // Constructors
132
133 //- Construct from mesh and a list of particles
134 Cloud
135 (
136 const polyMesh& mesh,
137 const word& cloudName,
138 const IDLList<ParticleType>& particles
139 );
140
141 //- Construct from mesh by reading from file with given cloud instance
142 // Optionally disable checking of class name for post-processing
143 Cloud
144 (
145 const polyMesh& pMesh,
146 const word& cloudName,
147 const bool checkClass = true
148 );
149
150
151 // Member Functions
152
153 // Access
154
155 //- Return the polyMesh reference
156 const polyMesh& pMesh() const
157 {
158 return polyMesh_;
159 }
160
161 //- Return the number of particles in the cloud
162 using IDLList<ParticleType>::size;
163
164 //- Return the number of particles in the cloud
165 virtual label nParcels() const
166 {
168 };
169
170 //- Return temporary addressing
172 {
173 return labels_;
174 }
175
176
177 // Iterators
178
179 using typename IDLList<ParticleType>::iterator;
181
182 using IDLList<ParticleType>::begin;
183 using IDLList<ParticleType>::cbegin;
184 using IDLList<ParticleType>::end;
185 using IDLList<ParticleType>::cend;
186
187
188 // Edit
189
190 //- Clear the particle list
191 using IDLList<ParticleType>::clear;
192
193 //- Transfer particle to cloud
194 void addParticle(ParticleType* pPtr);
195
196 //- Remove particle from cloud and delete
197 void deleteParticle(ParticleType& p);
198
199 //- Remove lost particles from cloud and delete
200 void deleteLostParticles();
201
202 //- Reset the particles
203 void cloudReset(const Cloud<ParticleType>& c);
204
205 //- Move the particles
206 template<class TrackCloudType>
207 void move
208 (
209 TrackCloudType& cloud,
210 typename ParticleType::trackingData& td,
211 const scalar trackTime
212 );
213
214 //- Remap the cells of particles corresponding to the
215 // mesh topology change
216 void autoMap(const mapPolyMesh&);
217
218
219 // Read
220
221 //- Helper to construct IOobject for field and current time.
223 (
224 const word& fieldName,
226 ) const;
227
228 //- Check lagrangian data field
229 template<class DataType>
231 (
232 const Cloud<ParticleType>& c,
234 ) const;
235
236 //- Check lagrangian data fieldfield
237 template<class DataType>
239 (
240 const Cloud<ParticleType>& c,
241 const CompactIOField<Field<DataType>, DataType>& data
242 ) const;
243
244 //- Helper function to store a cloud field on its registry
245 template<class Type>
246 bool readStoreFile
247 (
248 const IOobject& io,
249 const IOobject& ioNew
250 ) const;
251
252 //- Read from files into objectRegistry
253 void readFromFiles
254 (
255 objectRegistry& obr,
256 const wordRes& selectFields,
258 ) const;
259
260
261 // Write
262
263 //- Write the field data for the cloud of particles Dummy at
264 // this level.
265 virtual void writeFields() const;
266
267 //- Write using stream options.
268 // Only writes the cloud file if the Cloud isn't empty
269 virtual bool writeObject
270 (
271 IOstreamOption streamOpt,
272 const bool valid
273 ) const;
274
275 //- Write positions to <cloudName>_positions.obj file
276 void writePositions() const;
277
278 //- Call this before a topology change.
279 // Stores the particles global positions in the database
280 // for use during mapping.
281 void storeGlobalPositions() const;
282};
283
284
285// Ostream Operator
286
287template<class ParticleType>
289
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293} // End namespace Foam
294
295// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296
297#ifdef NoRepository
298 #include "Cloud.C"
299#endif
300
301// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302
303#endif
304
305// ************************************************************************* //
Intrusive doubly-linked list.
Base cloud calls templated on particle type.
Definition: Cloud.H:68
bool readStoreFile(const IOobject &io, const IOobject &ioNew) const
Helper function to store a cloud field on its registry.
Definition: CloudIO.C:249
virtual label nParcels() const
Return the number of particles in the cloud.
Definition: Cloud.H:164
static word cloudPropertiesName
Name of cloud properties dictionary.
Definition: Cloud.H:127
void readFromFiles(objectRegistry &obr, const wordRes &selectFields, const wordRes &excludeFields=wordRes::null()) const
Read from files into objectRegistry.
Definition: CloudIO.C:267
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
Definition: CloudIO.C:211
void writePositions() const
Write positions to <cloudName>_positions.obj file.
Definition: Cloud.C:340
void deleteParticle(ParticleType &p)
Remove particle from cloud and delete.
Definition: Cloud.C:111
void deleteLostParticles()
Remove lost particles from cloud and delete.
Definition: Cloud.C:118
DynamicList< label > & labels() const
Return temporary addressing.
Definition: Cloud.H:170
TypeName("Cloud")
Runtime type information.
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
Definition: CloudIO.C:325
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
Definition: Cloud.C:147
void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition: Cloud.C:308
const polyMesh & pMesh() const
Return the polyMesh reference.
Definition: Cloud.H:155
IOobject fieldIOobject(const word &fieldName, const IOobject::readOption r) const
Helper to construct IOobject for field and current time.
Definition: CloudIO.C:191
ParticleType parcelType
Parcels are just particles.
Definition: Cloud.H:117
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
Definition: CloudIO.C:333
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
Definition: Cloud.C:135
cloud::geometryType geometryType_
Geometry type.
Definition: Cloud.H:105
void storeGlobalPositions() const
Call this before a topology change.
Definition: Cloud.C:359
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition: Cloud.C:104
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType >, DataType > &data) const
Check lagrangian data fieldfield.
Definition: CloudIO.C:230
ParticleType particleType
Definition: Cloud.H:114
A Field of objects of type <T> with automated input and output using a compact storage....
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Generic templated field type.
Definition: Field.H:82
Forward iterator with non-const access.
Definition: HashTable.H:720
label size() const noexcept
The number of elements in table.
Definition: HashTableI.H:52
Template class for intrusive linked lists.
Definition: ILList.H:69
void clear()
Clear the contents of the list.
Definition: ILList.C:101
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
Helper IO class to read and write particle coordinates (positions).
Definition: IOPosition.H:56
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
readOption
Enumeration defining the read options.
Definition: IOobject.H:177
The IOstreamOption is a simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
const iterator & end()
End of list for forward iterators.
Definition: UILList.H:414
const_iterator cbegin() const
Iterator to first item in list with const access.
Definition: UILList.H:383
const const_iterator & cend() const
End of list for forward iterators.
Definition: UILList.H:420
iterator begin()
Iterator to first item in list with non-const access.
Definition: UILList.H:377
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A const_iterator for iterating across on values.
Definition: bitSet.H:505
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:60
geometryType
Cloud geometry type (internal or IO representations)
Definition: cloud.H:75
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Registry of regIOobjects.
Base particle class.
Definition: particle.H:79
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
wordRes excludeFields
const word cloudName(propsDict.get< word >("cloud"))